summaryrefslogtreecommitdiff
path: root/cfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'cfile.c')
-rw-r--r--cfile.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/cfile.c b/cfile.c
index c9a22f5..b06c1d8 100644
--- a/cfile.c
+++ b/cfile.c
@@ -5,19 +5,14 @@
#include <stdio.h>
#include <errno.h>
-#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);