FreeCalypso > hg > ueda-linux
annotate ueda/mclutils/getfps.c @ 12:51893347bc42
unet-bind implementation started
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Sat, 01 Aug 2015 23:33:05 +0000 |
parents | d098f8548b44 |
children |
rev | line source |
---|---|
0
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * This program "gets" all footprints for the board. The footprint attributes |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * are extracted from the MCL and a set of M4 macro calls is emitted on stdout |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 * which when run through M4 will produce all footprints for the board with the |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 * refdes and value filled in. |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 */ |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <stdio.h> |
3
d098f8548b44
ueda/mclutils Linuxified
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
0
diff
changeset
|
9 #include <stdlib.h> |
d098f8548b44
ueda/mclutils Linuxified
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
0
diff
changeset
|
10 #include <string.h> |
0
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include <strings.h> |
3
d098f8548b44
ueda/mclutils Linuxified
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
0
diff
changeset
|
12 #include <unistd.h> |
0
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 #include "../libueda/mcl.h" |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 extern char *MCLfile; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 extern struct component components[]; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 extern int ncomponents; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 extern char *get_comp_attr(); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 int check_completeness; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 main(argc, argv) |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 char **argv; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 { |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 register int c; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 register struct component *comp; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 register char *footprint, *value; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 while ((c = getopt(argc, argv, "chM:")) != EOF) |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 switch (c) { |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 case 'c': |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 check_completeness++; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 break; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 case 'h': |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 puts("include(template.pcb)"); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 break; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 case 'M': |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 MCLfile = optarg; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 break; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 default: |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 /* getopt prints the error message */ |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 exit(1); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 } |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 read_MCL(); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 for (comp = components, c = 0; c < ncomponents; comp++, c++) { |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 footprint = get_comp_attr(comp, "footprint"); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 if (!footprint) { |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 if (check_completeness) |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 fprintf(stderr, "%s has no footprint\n", |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 comp->name); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 continue; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 } |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 if (!strcmp(footprint, "none")) |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 continue; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 if (!strcmp(footprint, "TBD")) { |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 if (check_completeness) |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 fprintf(stderr, "%s: footprint=TBD\n", |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 comp->name); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 continue; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 } |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 value = get_comp_attr(comp, "pcbvalue"); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 if (!value) |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 value = get_comp_attr(comp, "value"); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 if (!value) |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 value = get_comp_attr(comp, "device"); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 if (!value) |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 value = get_comp_attr(comp, "manufacturer_part_number"); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 if (!value) |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 value = ""; |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 if (strncmp(footprint, "file:", 5)) |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 printf("make_footprint(`%s',`%s',`%s')\n", footprint, |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 comp->name, value); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 else |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 printf("make_footprint_file(`%s',`%s',`%s')\n", |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 footprint + 5, comp->name, value); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 } |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 exit(0); |
cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 } |