FreeCalypso > hg > ueda-linux
annotate pads2gpcb/main.c @ 98:bf0b17a3da26
SIM_Socket_473882001.fp: pads captured, no silk courtyard yet
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 26 Sep 2019 07:21:11 +0000 |
parents | be1fe110b6ab |
children |
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> |
47
8fa304e2b7e1
pads2gpcb: parsing of -w options implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
42
diff
changeset
|
3 #include <unistd.h> |
38
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 #include <ctype.h> |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <string.h> |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <strings.h> |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include "globals.h" |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 |
77
f640c8f005c5
pads2gpcb: soldermask and clearance adjustment options added
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
9 extern long cmdline_dim_arg(); |
f640c8f005c5
pads2gpcb: soldermask and clearance adjustment options added
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
10 |
39
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
11 static |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
12 parse_header_line() |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
13 { |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
14 char *cp; |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
15 |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
16 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
|
17 return(-1); |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
18 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
|
19 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
|
20 cp++; |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
21 if (*cp++ != '-') |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
22 return(-1); |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
23 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
|
24 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
|
25 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
|
26 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
|
27 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
|
28 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
|
29 else |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
30 return(-1); |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
31 return(0); |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
32 } |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
33 |
38
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 main(argc, argv) |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 char **argv; |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 { |
47
8fa304e2b7e1
pads2gpcb: parsing of -w options implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
42
diff
changeset
|
37 int c; |
73
bdfd0b802bb0
pads2gpcb/main.c: preparations for main output of named and placed elements
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
72
diff
changeset
|
38 char *main_output; |
47
8fa304e2b7e1
pads2gpcb: parsing of -w options implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
42
diff
changeset
|
39 extern int optind; |
62
9d7e2937883d
pads2gpcb: select specific drawing levels for silk with -s
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
51
diff
changeset
|
40 extern char *optarg; |
47
8fa304e2b7e1
pads2gpcb: parsing of -w options implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
42
diff
changeset
|
41 |
78
be1fe110b6ab
pads2gpcb: output offset implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
42 while ((c = getopt(argc, argv, "c:fm:s:x:y:")) != EOF) |
47
8fa304e2b7e1
pads2gpcb: parsing of -w options implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
42
diff
changeset
|
43 switch (c) { |
77
f640c8f005c5
pads2gpcb: soldermask and clearance adjustment options added
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
44 case 'c': |
f640c8f005c5
pads2gpcb: soldermask and clearance adjustment options added
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
45 clearance_setting = cmdline_dim_arg(optarg); |
f640c8f005c5
pads2gpcb: soldermask and clearance adjustment options added
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
46 continue; |
72
fab9fc646044
pads2gpcb: single -f option to write loose footprint files
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
47 case 'f': |
fab9fc646044
pads2gpcb: single -f option to write loose footprint files
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
48 write_footprint_files = 1; |
fab9fc646044
pads2gpcb: single -f option to write loose footprint files
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
49 continue; |
77
f640c8f005c5
pads2gpcb: soldermask and clearance adjustment options added
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
50 case 'm': |
f640c8f005c5
pads2gpcb: soldermask and clearance adjustment options added
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
51 soldermask_delta = cmdline_dim_arg(optarg); |
f640c8f005c5
pads2gpcb: soldermask and clearance adjustment options added
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
74
diff
changeset
|
52 continue; |
51
f2bcf69fce63
pads2gpcb: -s option to enable footprint silk processing
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
47
diff
changeset
|
53 case 's': |
f2bcf69fce63
pads2gpcb: -s option to enable footprint silk processing
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
47
diff
changeset
|
54 do_footprint_silk = 1; |
62
9d7e2937883d
pads2gpcb: select specific drawing levels for silk with -s
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
51
diff
changeset
|
55 select_drawlevel_for_silk(atoi(optarg)); |
51
f2bcf69fce63
pads2gpcb: -s option to enable footprint silk processing
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
47
diff
changeset
|
56 continue; |
78
be1fe110b6ab
pads2gpcb: output offset implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
57 case 'x': |
be1fe110b6ab
pads2gpcb: output offset implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
58 output_x_offset = cmdline_dim_arg(optarg); |
be1fe110b6ab
pads2gpcb: output offset implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
59 continue; |
be1fe110b6ab
pads2gpcb: output offset implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
60 case 'y': |
be1fe110b6ab
pads2gpcb: output offset implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
61 output_y_offset = cmdline_dim_arg(optarg); |
be1fe110b6ab
pads2gpcb: output offset implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
77
diff
changeset
|
62 continue; |
47
8fa304e2b7e1
pads2gpcb: parsing of -w options implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
42
diff
changeset
|
63 default: |
8fa304e2b7e1
pads2gpcb: parsing of -w options implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
42
diff
changeset
|
64 usage: |
73
bdfd0b802bb0
pads2gpcb/main.c: preparations for main output of named and placed elements
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
72
diff
changeset
|
65 fprintf(stderr, |
bdfd0b802bb0
pads2gpcb/main.c: preparations for main output of named and placed elements
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
72
diff
changeset
|
66 "usage: %s [options] pads-file.asc [output.pcb]\n", |
47
8fa304e2b7e1
pads2gpcb: parsing of -w options implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
42
diff
changeset
|
67 argv[0]); |
8fa304e2b7e1
pads2gpcb: parsing of -w options implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
42
diff
changeset
|
68 exit(1); |
8fa304e2b7e1
pads2gpcb: parsing of -w options implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
42
diff
changeset
|
69 } |
73
bdfd0b802bb0
pads2gpcb/main.c: preparations for main output of named and placed elements
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
72
diff
changeset
|
70 if (argc < optind + 1 || argc > optind + 2) |
47
8fa304e2b7e1
pads2gpcb: parsing of -w options implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
42
diff
changeset
|
71 goto usage; |
8fa304e2b7e1
pads2gpcb: parsing of -w options implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
42
diff
changeset
|
72 input_filename = argv[optind]; |
73
bdfd0b802bb0
pads2gpcb/main.c: preparations for main output of named and placed elements
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
72
diff
changeset
|
73 main_output = argv[optind+1]; |
38
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 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
|
75 |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
76 /* 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
|
77 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
|
78 invheader: fprintf(stderr, |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
79 "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
|
80 input_filename); |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
81 exit(1); |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
82 } |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
83 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
|
84 goto invheader; |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
85 |
242f73e61ef0
pads2gpcb: implemented parsing of the header line with units spec
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
38
diff
changeset
|
86 /* process the body of the monster! */ |
38
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 while (get_input_line()) { |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 if (input_line_buf[0] != '*') |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 continue; |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 parse_starline(); |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 loop: if (!strcmp(input_line_starkw, "PARTDECAL")) { |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 process_partdecal_section(); |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 goto loop; |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 } |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 if (!strcmp(input_line_starkw, "PARTTYPE")) { |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 process_parttype_section(); |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 goto loop; |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
98 } |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 if (!strcmp(input_line_starkw, "PART")) { |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 process_part_section(); |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
101 goto loop; |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
102 } |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 } |
74
58f11f06d831
pads2gpcb: main output implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
104 if (main_output) |
58f11f06d831
pads2gpcb: main output implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
73
diff
changeset
|
105 write_elements_pcb(main_output); |
38
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
106 exit(0); |
aa0539cc3d41
pads2gpcb project started, skeleton compiles
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
107 } |