annotate pads2gpcb/main.c @ 41:a2d304ec3817

pads2gpcb: decal processing code compiles
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Mon, 11 Jan 2016 18:31:44 +0000
parents 242f73e61ef0
children 43ba91b137e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
1 #include <stdio.h>
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
2 #include <stdlib.h>
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
3 #include <ctype.h>
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
4 #include <string.h>
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <strings.h>
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
6 #include "globals.h"
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
7
39
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
8 static
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
9 parse_header_line()
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
10 {
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
11 char *cp;
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
12
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
13 if (strncmp(input_line_buf, "!PADS-POWERPCB-", 15))
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
14 return(-1);
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
15 cp = input_line_buf + 15;
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
16 while (isalnum(*cp) || *cp == '.')
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
17 cp++;
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
18 if (*cp++ != '-')
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
19 return(-1);
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
20 if (!strncmp(cp, "BASIC", 5))
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
21 input_units_global = 'B';
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
22 else if (!strncmp(cp, "MILS", 4))
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
23 input_units_global = 'I';
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
24 else if (!strncmp(cp, "METRIC", 6))
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
25 input_units_global = 'M';
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
26 else
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
27 return(-1);
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
28 return(0);
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
29 }
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
30
38
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
31 main(argc, argv)
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
32 char **argv;
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
33 {
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
34 if (argc != 2) {
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
35 fprintf(stderr, "usage: %s pads-file.asc\n", argv[0]);
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
36 exit(1);
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
37 }
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
38 input_filename = argv[1];
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
39 open_input_file();
39
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
40
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
41 /* parse the header line with the units specification */
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
42 if (!get_input_line()) {
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
43 invheader: fprintf(stderr,
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
44 "error: %s does not begin with a recognized header line\n",
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
45 input_filename);
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
46 exit(1);
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
47 }
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
48 if (parse_header_line() < 0)
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
49 goto invheader;
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
50
242f73e61ef0 pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents: 38
diff changeset
51 /* process the body of the monster! */
38
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
52 while (get_input_line()) {
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
53 if (input_line_buf[0] != '*')
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
54 continue;
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
55 parse_starline();
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
56 #if 0
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
57 loop: if (!strcmp(input_line_starkw, "PARTDECAL")) {
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
58 process_partdecal_section();
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
59 goto loop;
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
60 }
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
61 if (!strcmp(input_line_starkw, "PARTTYPE")) {
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
62 process_parttype_section();
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
63 goto loop;
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
64 }
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
65 if (!strcmp(input_line_starkw, "PART")) {
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
66 process_part_section();
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
67 goto loop;
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
68 }
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
69 #endif
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
70 }
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
71 exit(0);
aa0539cc3d41 pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff changeset
72 }