FreeCalypso > hg > ueda-linux
comparison 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 |
comparison
equal
deleted
inserted
replaced
46:c81aba92cb5e | 47:8fa304e2b7e1 |
---|---|
1 #include <stdio.h> | 1 #include <stdio.h> |
2 #include <stdlib.h> | 2 #include <stdlib.h> |
3 #include <unistd.h> | |
3 #include <ctype.h> | 4 #include <ctype.h> |
4 #include <string.h> | 5 #include <string.h> |
5 #include <strings.h> | 6 #include <strings.h> |
6 #include "globals.h" | 7 #include "globals.h" |
7 | 8 |
26 else | 27 else |
27 return(-1); | 28 return(-1); |
28 return(0); | 29 return(0); |
29 } | 30 } |
30 | 31 |
32 static void | |
33 process_write_option() | |
34 { | |
35 extern char *optarg; | |
36 | |
37 if (strlen(optarg) != 1) { | |
38 inv: fprintf(stderr, "usage error: invalid -w option\n"); | |
39 exit(1); | |
40 } | |
41 switch (optarg[0]) { | |
42 case 'd': | |
43 write_decal_files = 1; | |
44 return; | |
45 case 'p': | |
46 write_parttype_files = 1; | |
47 return; | |
48 case 'e': | |
49 write_final_elements = 1; | |
50 return; | |
51 default: | |
52 goto inv; | |
53 } | |
54 } | |
55 | |
31 main(argc, argv) | 56 main(argc, argv) |
32 char **argv; | 57 char **argv; |
33 { | 58 { |
34 if (argc != 2) { | 59 int c; |
35 fprintf(stderr, "usage: %s pads-file.asc\n", argv[0]); | 60 extern int optind; |
36 exit(1); | 61 |
37 } | 62 while ((c = getopt(argc, argv, "w:")) != EOF) |
38 input_filename = argv[1]; | 63 switch (c) { |
64 case 'w': | |
65 process_write_option(); | |
66 continue; | |
67 default: | |
68 usage: | |
69 fprintf(stderr, "usage: %s [options] pads-file.asc\n", | |
70 argv[0]); | |
71 exit(1); | |
72 } | |
73 if (argc != optind + 1) | |
74 goto usage; | |
75 input_filename = argv[optind]; | |
39 open_input_file(); | 76 open_input_file(); |
40 | 77 |
41 /* parse the header line with the units specification */ | 78 /* parse the header line with the units specification */ |
42 if (!get_input_line()) { | 79 if (!get_input_line()) { |
43 invheader: fprintf(stderr, | 80 invheader: fprintf(stderr, |