=================================================================== RCS file: /cvs/djgpp/djgpp/src/utils/bin2h.c,v retrieving revision 1.1 retrieving revision 1.2 diff -p -u -r1.1 -r1.2 --- djgpp/src/utils/bin2h.c 1995/08/27 03:14:30 1.1 +++ /cvs/djgpp/djgpp/src/utils/bin2h.c 1999/03/20 22:21:30 1.2 @@ -1,4 +1,6 @@ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ +/* 1998 -- Modified by Nils van den Heuvel (n.heuvel@wxs.nl) */ + #include #include #include @@ -7,16 +9,34 @@ int main(int argc, char **argv) { - int f = open(argv[1], O_RDONLY|O_BINARY); - FILE *of = fopen(argv[3], "w"); + int f; + FILE *of; unsigned char buf[4096]; int rbytes; int col=0, i; if (argc < 4) { - printf("usage: bin2byte infile symname outfile\n"); + printf("usage: %s infile symname outfile\n", basename(argv[0])); + exit(1); + } + f = open(argv[1], O_RDONLY|O_BINARY); + if (f < 1) + { + printf("%s: ",basename(argv[0])); + perror(argv[1]); exit(1); } + + of = fopen(argv[3], "w"); + + if (of == NULL) + { + printf("%s: ",basename(argv[0])); + perror(argv[3]); + exit(1); + } + + fprintf(of, "unsigned char %s[] = {\n", argv[2]); while ((rbytes = read(f, buf, 4096)) > 0) {