FreeCalypso > hg > ueda-linux
diff pads2gpcb/main.c @ 47:8fa304e2b7e1
pads2gpcb: parsing of -w options implemented
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Sat, 30 Jan 2016 08:23:35 +0000 |
parents | 43ba91b137e2 |
children | f2bcf69fce63 |
line wrap: on
line diff
--- a/pads2gpcb/main.c Sat Jan 30 07:56:18 2016 +0000 +++ b/pads2gpcb/main.c Sat Jan 30 08:23:35 2016 +0000 @@ -1,5 +1,6 @@ #include <stdio.h> #include <stdlib.h> +#include <unistd.h> #include <ctype.h> #include <string.h> #include <strings.h> @@ -28,14 +29,50 @@ return(0); } +static void +process_write_option() +{ + extern char *optarg; + + if (strlen(optarg) != 1) { +inv: fprintf(stderr, "usage error: invalid -w option\n"); + exit(1); + } + switch (optarg[0]) { + case 'd': + write_decal_files = 1; + return; + case 'p': + write_parttype_files = 1; + return; + case 'e': + write_final_elements = 1; + return; + default: + goto inv; + } +} + main(argc, argv) char **argv; { - if (argc != 2) { - fprintf(stderr, "usage: %s pads-file.asc\n", argv[0]); - exit(1); - } - input_filename = argv[1]; + int c; + extern int optind; + + while ((c = getopt(argc, argv, "w:")) != EOF) + switch (c) { + case 'w': + process_write_option(); + continue; + default: + usage: + fprintf(stderr, "usage: %s [options] pads-file.asc\n", + argv[0]); + exit(1); + } + if (argc != optind + 1) + goto usage; + input_filename = argv[optind]; open_input_file(); /* parse the header line with the units specification */