URL
https://opencores.org/ocsvn/socgen/socgen/trunk
Subversion Repositories socgen
Compare Revisions
- This comparison shows the changes necessary to convert path
/socgen/trunk/tools/utils
- from Rev 106 to Rev 116
- ↔ Reverse comparison
Rev 106 → Rev 116
/bin2abs.c
60,12 → 60,15
FILE *fd; |
int c; |
int i = 0; |
int j = 1; |
int line = 0; |
int filename_index=1; |
int bytes_per_line=1; |
int bytes_per_line_index=2; |
int min_num_bytes = 0; |
int min_num_bytes_index=3; |
int min_num_bytes = 0; |
int byte_lane=0; |
int byte_lane_index=4; |
|
|
if(argc < 3) { |
77,27 → 80,19
} |
|
fd = fopen( argv[filename_index], "r" ); |
|
|
|
|
|
|
|
|
bytes_per_line = atoi(argv[bytes_per_line_index]); |
|
|
|
|
if(argc > 3) { |
min_num_bytes = atoi(argv[min_num_bytes_index]); |
} |
|
|
if(argc > 4) { |
byte_lane = atoi(argv[byte_lane_index]); |
} |
|
|
if ((bytes_per_line == 0) || (bytes_per_line > 8)) |
if ((bytes_per_line == 0) || (bytes_per_line > 8) || (byte_lane > bytes_per_line ) ) |
{ |
fprintf(stderr,"bytes per line incorrect or missing: %s\n",argv[bytes_per_line_index]); |
exit(1); |
104,12 → 99,6
} |
|
|
|
|
|
|
|
|
|
if (fd == NULL) { |
fprintf(stderr,"failed to open input file: %s\n",argv[1]); |
119,8 → 108,51
i=0; |
line=0; |
|
if(byte_lane) |
{ |
// Now write out the binary data to hex format |
while ((c = fgetc(fd)) != EOF) { |
j=i+1; |
if(byte_lane == j) |
{ printf("%.2x", (unsigned int) c); |
|
} |
if (++i == bytes_per_line) { |
printf("\n"); |
line++; |
i = 0; |
} |
} |
|
|
while (i) { |
j=i+1; |
if(byte_lane == j) |
{ printf("00"); |
|
} |
|
|
if (++i == bytes_per_line) { |
printf("\n"); |
line++; |
i = 0; |
} |
} |
|
|
|
while (line < min_num_bytes) { |
printf("00\n"); |
line++; |
} |
} |
else |
|
{ |
// no byte lane |
// Now write out the binary data to hex format |
while ((c = fgetc(fd)) != EOF) { |
printf("%.2x", (unsigned int) c); |
if (++i == bytes_per_line) { |
printf("\n"); |
145,10 → 177,10
printf("00000000\n"); |
line++; |
} |
} |
|
|
|
|
|
return 0; |
} |