FreeCalypso > hg > ueda-linux
comparison pads2gpcb/main.c @ 39:242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
| author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
|---|---|
| date | Mon, 11 Jan 2016 05:09:25 +0000 |
| parents | aa0539cc3d41 |
| children | 43ba91b137e2 |
comparison
equal
deleted
inserted
replaced
| 38:aa0539cc3d41 | 39:242f73e61ef0 |
|---|---|
| 2 #include <stdlib.h> | 2 #include <stdlib.h> |
| 3 #include <ctype.h> | 3 #include <ctype.h> |
| 4 #include <string.h> | 4 #include <string.h> |
| 5 #include <strings.h> | 5 #include <strings.h> |
| 6 #include "globals.h" | 6 #include "globals.h" |
| 7 | |
| 8 static | |
| 9 parse_header_line() | |
| 10 { | |
| 11 char *cp; | |
| 12 | |
| 13 if (strncmp(input_line_buf, "!PADS-POWERPCB-", 15)) | |
| 14 return(-1); | |
| 15 cp = input_line_buf + 15; | |
| 16 while (isalnum(*cp) || *cp == '.') | |
| 17 cp++; | |
| 18 if (*cp++ != '-') | |
| 19 return(-1); | |
| 20 if (!strncmp(cp, "BASIC", 5)) | |
| 21 input_units_global = 'B'; | |
| 22 else if (!strncmp(cp, "MILS", 4)) | |
| 23 input_units_global = 'I'; | |
| 24 else if (!strncmp(cp, "METRIC", 6)) | |
| 25 input_units_global = 'M'; | |
| 26 else | |
| 27 return(-1); | |
| 28 return(0); | |
| 29 } | |
| 7 | 30 |
| 8 main(argc, argv) | 31 main(argc, argv) |
| 9 char **argv; | 32 char **argv; |
| 10 { | 33 { |
| 11 if (argc != 2) { | 34 if (argc != 2) { |
| 12 fprintf(stderr, "usage: %s pads-file.asc\n", argv[0]); | 35 fprintf(stderr, "usage: %s pads-file.asc\n", argv[0]); |
| 13 exit(1); | 36 exit(1); |
| 14 } | 37 } |
| 15 input_filename = argv[1]; | 38 input_filename = argv[1]; |
| 16 open_input_file(); | 39 open_input_file(); |
| 40 | |
| 41 /* parse the header line with the units specification */ | |
| 42 if (!get_input_line()) { | |
| 43 invheader: fprintf(stderr, | |
| 44 "error: %s does not begin with a recognized header line\n", | |
| 45 input_filename); | |
| 46 exit(1); | |
| 47 } | |
| 48 if (parse_header_line() < 0) | |
| 49 goto invheader; | |
| 50 | |
| 51 /* process the body of the monster! */ | |
| 17 while (get_input_line()) { | 52 while (get_input_line()) { |
| 18 if (input_line_buf[0] != '*') | 53 if (input_line_buf[0] != '*') |
| 19 continue; | 54 continue; |
| 20 parse_starline(); | 55 parse_starline(); |
| 21 #if 0 | 56 #if 0 |
