From 11e3839c21831fa11d5508b05a57320e02f12330 Mon Sep 17 00:00:00 2001 From: michaelh Date: Sat, 6 Oct 2001 16:59:25 +0000 Subject: [PATCH] * support/makebin/makebin.c (usage): Removed getopt as mingw32 doesn't have it. Sigh. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1361 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- support/makebin/makebin.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/support/makebin/makebin.c b/support/makebin/makebin.c index c44c6c07..deb4e78f 100644 --- a/support/makebin/makebin.c +++ b/support/makebin/makebin.c @@ -22,30 +22,51 @@ int getbyte(char **p) return (getnibble(p) << 4) | getnibble(p); } +void usage(void) +{ + fprintf(stderr, + "makebin: convert a Intel IHX file to binary.\n" + "Usage: makebin [-p] [-s romsize] [-h]\n"); +} + int main(int argc, char **argv) { - int opt; int size = 32768, pack = 0, real_size = 0; BYTE *rom; char line[256]; char *p; - while ((opt = getopt(argc, argv, "ps:h"))!=-1) { - switch (opt) { + argc--; + argv++; + + while (argc--) { + if (**argv != '-') { + usage(); + return -1; + } + switch (argv[0][1]) { case 's': - size = atoi(optarg); + if (argc < 1) { + usage(); + return -1; + } + argc--; + argv++; + size = atoi(*argv); break; case 'h': - printf("makebin: convert a Intel IHX file to binary.\n" - "Usage: %s [-p] [-s romsize] [-h]\n", argv[0]); + usage(); return 0; case 'p': pack = 1; break; default: - return 1; + usage(); + return -1; } + argv++; } + rom = malloc(size); if (rom == NULL) { fprintf(stderr, "error: couldn't allocate room for the image.\n"); -- 2.30.2