mirror of
https://github.com/preble/libpinproc
synced 2026-02-24 18:25:23 +01:00
Added .p-roc file format version check so that p.roc file format changes won't be misinterpreted.
This commit is contained in:
@@ -1930,11 +1930,13 @@ int checkPROCFile() {
|
|||||||
unsigned char data;
|
unsigned char data;
|
||||||
int i=0,file_i=0;
|
int i=0,file_i=0;
|
||||||
int min_board_rev, max_board_rev;
|
int min_board_rev, max_board_rev;
|
||||||
int temp, num_header_words;
|
int temp, num_header_words, proc_file_version;
|
||||||
|
|
||||||
if (!fscanf(in, "%x\n", &temp)) return 0;
|
if (!fscanf(in, "%x\n", &temp)) return 0;
|
||||||
num_header_words = (int)(0x012345678 - temp);
|
num_header_words = (int)(0x012345678 - temp);
|
||||||
if (!fscanf(in, "%x\n", &temp)) return 0;
|
if (!fscanf(in, "%x\n", &temp)) return 0;
|
||||||
|
proc_file_version = (int)(-1 - temp);
|
||||||
|
if (!fscanf(in, "%x\n", &temp)) return 0;
|
||||||
file_i = (int)(-1 - temp);
|
file_i = (int)(-1 - temp);
|
||||||
//fprintf(stderr, "\nbyte count: %d, %x", file_i, temp);
|
//fprintf(stderr, "\nbyte count: %d, %x", file_i, temp);
|
||||||
if (!fscanf(in, "%x\n", &temp)) return 0;
|
if (!fscanf(in, "%x\n", &temp)) return 0;
|
||||||
@@ -1962,6 +1964,11 @@ int checkPROCFile() {
|
|||||||
(board_rev & 0x20) >> 3 |
|
(board_rev & 0x20) >> 3 |
|
||||||
(board_rev & 0x10) >> 1;
|
(board_rev & 0x10) >> 1;
|
||||||
|
|
||||||
|
if (proc_file_version != 0) {
|
||||||
|
fprintf(stderr, "\nERROR: Invalid .p-roc file.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Check for valid board ID and rev
|
// Check for valid board ID and rev
|
||||||
if (board_id != file_board_id) {
|
if (board_id != file_board_id) {
|
||||||
fprintf(stderr, "\nERROR: This image is not compatible with the P-ROC board (ID: %x)", board_id);
|
fprintf(stderr, "\nERROR: This image is not compatible with the P-ROC board (ID: %x)", board_id);
|
||||||
@@ -2072,11 +2079,11 @@ int main( int argc, char** argv )
|
|||||||
// Check for .p-roc file
|
// Check for .p-roc file
|
||||||
if (strstr(pzXsvfFileName, ".p-roc")) {
|
if (strstr(pzXsvfFileName, ".p-roc")) {
|
||||||
|
|
||||||
fprintf(stderr, "\nP-ROC file format detected\n");
|
fprintf(stderr, "\nP-ROC file format detected\n.");
|
||||||
|
|
||||||
in = fopen( pzXsvfFileName, "rb" );
|
in = fopen( pzXsvfFileName, "rb" );
|
||||||
if ( !in ) {
|
if ( !in ) {
|
||||||
fprintf(stderr, "ERROR: Cannot open file %s\n", pzXsvfFileName );
|
fprintf(stderr, "ERROR: Cannot open file %s\n.", pzXsvfFileName );
|
||||||
iErrorCode = XSVF_ERRORCODE( XSVF_ERROR_UNKNOWN );
|
iErrorCode = XSVF_ERRORCODE( XSVF_ERROR_UNKNOWN );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -2096,10 +2103,10 @@ int main( int argc, char** argv )
|
|||||||
}
|
}
|
||||||
// Check for .p-roc file
|
// Check for .p-roc file
|
||||||
else if (strstr(pzXsvfFileName, ".xsvf")) {
|
else if (strstr(pzXsvfFileName, ".xsvf")) {
|
||||||
fprintf(stderr, "\nXSVF file format detected\n");
|
fprintf(stderr, "\nXSVF file format detected.\n");
|
||||||
in = fopen( pzXsvfFileName, "rb" );
|
in = fopen( pzXsvfFileName, "rb" );
|
||||||
if ( !in ) {
|
if ( !in ) {
|
||||||
fprintf(stderr, "ERROR: Cannot open file %s\n", pzXsvfFileName );
|
fprintf(stderr, "ERROR: Cannot open file %s\n.", pzXsvfFileName );
|
||||||
iErrorCode = XSVF_ERRORCODE( XSVF_ERROR_UNKNOWN );
|
iErrorCode = XSVF_ERRORCODE( XSVF_ERROR_UNKNOWN );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -2112,8 +2119,8 @@ int main( int argc, char** argv )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fprintf(stderr, "\nUnsupported file format.");
|
fprintf(stderr, "\nERROR: Unsupported file format.\n");
|
||||||
printUsage(argv[5]);
|
printUsage(argv[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user