diff options
Diffstat (limited to 'msdos/bin2c.c')
-rw-r--r-- | msdos/bin2c.c | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/msdos/bin2c.c b/msdos/bin2c.c index d82056e..26d9008 100644 --- a/msdos/bin2c.c +++ b/msdos/bin2c.c @@ -1,43 +1,43 @@ -#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <time.h>
-
-static void Abort (char *fmt,...)
-{
- va_list args;
- va_start (args, fmt);
- vfprintf (stderr, fmt, args);
- va_end (args);
- exit (1);
-}
-
-int main (int argc, char **argv)
-{
- FILE *inFile;
- FILE *outFile = stdout;
- time_t now = time (NULL);
- int ch, i;
-
- if (argc != 2)
- Abort ("Usage: %s bin-file [> result]", argv[0]);
-
- if ((inFile = fopen(argv[1],"rb")) == NULL)
- Abort ("Cannot open %s\n", argv[1]);
-
- fprintf (outFile,
- "/* data statements for file %s at %.24s */\n"
- "/* Generated by BIN2C, G.Vanem 1995 */\n",
- argv[1], ctime(&now));
-
- i = 0;
- while ((ch = fgetc(inFile)) != EOF)
- {
- if (i++ % 12 == 0)
- fputs ("\n ", outFile);
- fprintf (outFile, "0x%02X,", ch);
- }
- fputc ('\n', outFile);
- fclose (inFile);
- return (0);
-}
+#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include <time.h> + +static void Abort (const char *fmt,...) +{ + va_list args; + va_start (args, fmt); + vfprintf (stderr, fmt, args); + va_end (args); + exit (1); +} + +int main (int argc, char **argv) +{ + FILE *inFile; + FILE *outFile = stdout; + time_t now = time (NULL); + int ch, i; + + if (argc != 2) + Abort ("Usage: %s bin-file [> result]", argv[0]); + + if ((inFile = fopen(argv[1],"rb")) == NULL) + Abort ("Cannot open %s\n", argv[1]); + + fprintf (outFile, + "/* data statements for file %s at %.24s */\n" + "/* Generated by BIN2C, G. Vanem 1995 */\n", + argv[1], ctime(&now)); + + i = 0; + while ((ch = fgetc(inFile)) != EOF) + { + if (i++ % 12 == 0) + fputs ("\n ", outFile); + fprintf (outFile, "0x%02X,", ch); + } + fputc ('\n', outFile); + fclose (inFile); + return (0); +} |