Line 37... |
Line 37... |
#include <unistd.h>
|
#include <unistd.h>
|
#include <ctype.h>
|
#include <ctype.h>
|
|
|
#include "zopcodes.h"
|
#include "zopcodes.h"
|
|
|
void dump_file(const char *fn) {
|
void dump_file(const bool bigend, const char *fn) {
|
const int NZIP = 4096;
|
const int NZIP = 4096;
|
char ln[NZIP], lb[NZIP];
|
char ln[NZIP], lb[NZIP];
|
ZIPI ibuf[NZIP];
|
ZIPI ibuf[NZIP];
|
FILE *fp;
|
FILE *fp;
|
int nr;
|
int nr;
|
Line 51... |
Line 51... |
if (!fp)
|
if (!fp)
|
return;
|
return;
|
printf("%s:\n", fn);
|
printf("%s:\n", fn);
|
while((nr=fread(ibuf, sizeof(ZIPI), NZIP, fp))>0) {
|
while((nr=fread(ibuf, sizeof(ZIPI), NZIP, fp))>0) {
|
for(int i=0; i<nr; i++) {
|
for(int i=0; i<nr; i++) {
|
|
if (bigend) {
|
|
ZIPI bei, lei = ibuf[i];
|
|
bei = lei&0x0ff; bei<<=8; lei>>= 8;
|
|
bei |= lei&0x0ff; bei<<=8; lei>>= 8;
|
|
bei |= lei&0x0ff; bei<<=8; lei>>= 8;
|
|
bei |= lei&0x0ff;
|
|
ibuf[i] = bei;
|
|
}
|
zipi_to_string(ibuf[i], ln, lb);
|
zipi_to_string(ibuf[i], ln, lb);
|
// printf("%s\n", ln);
|
// printf("%s\n", ln);
|
printf("%08x: (0x%08x %c%c%c%c) %s\n", addr++,
|
printf("%08x: (0x%08x %c%c%c%c) %s\n", addr++,
|
ibuf[i],
|
ibuf[i],
|
isgraph((ibuf[i]>>24)&0x0ff)?((ibuf[i]>>24)&0x0ff) : '.',
|
isgraph((ibuf[i]>>24)&0x0ff)?((ibuf[i]>>24)&0x0ff) : '.',
|
Line 67... |
Line 75... |
}
|
}
|
} fclose(fp);
|
} fclose(fp);
|
}
|
}
|
|
|
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
|
bool bigend = false;
|
for(int argn=1; argn<argc; argn++) {
|
for(int argn=1; argn<argc; argn++) {
|
if(access(argv[argn], R_OK)==0)
|
if (argv[argn][0] == '-') {
|
dump_file(argv[argn]);
|
if (argv[argn][1] == 'B')
|
|
bigend = true;
|
|
else if (argv[argn][1] == 'L')
|
|
bigend = false;
|
|
} else if(access(argv[argn], R_OK)==0)
|
|
dump_file(bigend, argv[argn]);
|
}
|
}
|
|
|
return 0;
|
return 0;
|
}
|
}
|
|
|