From 2eedbb0079a38f02af5423e9a071cec6ee4b8c3e Mon Sep 17 00:00:00 2001 From: Ian C Date: Wed, 6 Apr 2016 20:55:47 +0000 Subject: Restored other lost changes + files --- cfile.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'cfile.c') diff --git a/cfile.c b/cfile.c index c9a22f5..b06c1d8 100644 --- a/cfile.c +++ b/cfile.c @@ -5,19 +5,14 @@ #include #include -#define TYPE unsigned char -#define STR(x) #x -#define XSTR(x) STR(x) - int main(int argc, char *argv[]) { const char *name="bfile"; FILE *in,*out; - TYPE num; + unsigned long num; int col; int first; int len; - int fldsz; in=stdin; out=stdout; @@ -52,9 +47,7 @@ int main(int argc, char *argv[]) fprintf(out,"/* Auto-generated binary */\n\n"); } - fldsz = sizeof num * 2; - - fprintf(out,XSTR(TYPE) " %s[]=\n\t{",name); + fprintf(out,"unsigned long %s[]=\n\t\t\t{",name); col=0; num=0; @@ -63,33 +56,33 @@ int main(int argc, char *argv[]) while(!feof(in)) { - fread(&num,sizeof num,1,in); + fread(&num,sizeof(unsigned long),1,in); if (col==0) { if (first) { - fprintf(out,"\n\t\t"); + fprintf(out,"\n\t\t\t"); first=0; } else { - fprintf(out,",\n\t\t"); + fprintf(out,",\n\t\t\t"); } } else { - fprintf(out,", "); + fprintf(out,","); } - fprintf(out,"0x%.*x",fldsz, num); + fprintf(out,"0x%.8x",num); - col=(col+1) % (8 / sizeof num); + col=(col+1)%4; num=0; len++; } - fprintf(out,"\n\t};\n#define %s_LEN %d\n", name, len); + fprintf(out,"\n\t\t\t};\n#define %s_LEN %d\n", name, len); fclose(in); fclose(out); -- cgit v1.2.3