7 static void usage(const char *progname
);
9 static unsigned char header_magic
[] =
11 0x0F, 0xAC, 0xE0, 0xFF, 0xDE, 0xAD, 0xBA, 0xBE
17 int main(int argc
, char **argv
)
21 unsigned char buf
[4096];
27 in
= fopen(argv
[1], "r");
30 fprintf(stderr
, "couldn't open file '%s'\n", argv
[1]);
34 out
= fopen(argv
[2], "w");
37 fprintf(stderr
, "couldn't open file '%s'\n", argv
[2]);
42 n
= fwrite(header_magic
, 1, sizeof(header_magic
), out
);
43 if (n
!= sizeof(header_magic
))
45 fprintf(stderr
, "fwrite failed\n");
51 n
= fwrite(&size
, 1, sizeof(size
), out
);
52 if (n
!= sizeof(size
))
54 fprintf(stderr
, "fwrite failed\n");
58 n
= fseek(in
, 0, SEEK_END
);
61 fprintf(stderr
, "fseek failed\n");
67 n
= fseek(in
, 0, SEEK_SET
);
70 fprintf(stderr
, "fseek failed\n");
76 n
= fwrite(&size
, 1, sizeof(size
), out
);
77 if (n
!= sizeof(size
))
79 fprintf(stderr
, "fwrite failed\n");
83 n
= fseek(out
, 0x400, SEEK_SET
);
86 fprintf(stderr
, "fseek failed\n");
90 while ((nread
= fread(buf
, 1, sizeof(buf
), in
)) > 0)
92 n
= fwrite(buf
, 1, nread
, out
);
95 fprintf(stderr
, "fwrite failed\n");
109 static void usage(const char *progname
)
111 fprintf(stderr
, "usage: %s <input file> <output file>\n", progname
);