FreeCalypso > hg > ueda-linux
annotate ueda/unet-utils/unet2protel.c @ 149:d1a507d34e77
netdiff: donl-netmatch2 factored out
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 15 Nov 2020 04:18:47 +0000 |
parents | 7c0fd80782c8 |
children |
rev | line source |
---|---|
35
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 #include <stdio.h> |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 #include <stdlib.h> |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 #include <string.h> |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 #include <strings.h> |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include "../libunet/unetrd.h" |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include "../libunet/nethash.h" |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 extern struct net *enter_net_object(); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 extern struct net *find_net_by_name(); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 extern struct net *net_list_head; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 static char *input_filename, *output_filename; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 static struct unetrd_state rdstate; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 static struct unetrd_out rdout; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 static FILE *outFILE; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 struct netextra { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 struct netmember *head; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 struct netmember **tailp; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 }; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 struct netmember { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 char *name; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 struct netmember *next; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 }; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 static void |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 process_pin_connect(compname) |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 char *compname; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 register struct net *n; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 register struct netextra *nx; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 register struct netmember *nm; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 n = find_net_by_name(rdout.connect_to_net); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 nx = (struct netextra *)(n + 1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 nm = (struct netmember *) malloc(sizeof(struct netmember) + |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 strlen(compname) + |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 strlen(rdout.objname) + 2); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 if (!nm) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 perror("malloc"); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 exit(1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 nm->name = (char *)(nm + 1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 sprintf(nm->name, "%s-%s", compname, rdout.objname); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 nm->next = 0; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 *nx->tailp = nm; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 nx->tailp = &nm->next; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 static void |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 process_component() |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 char compname[64]; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 strcpy(compname, rdout.objname); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 for (;;) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 if (!read_unet_line(&rdstate, &rdout)) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 fprintf(stderr, "%s error: EOF in COMPONENT block\n", |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 input_filename); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 exit(1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 if (rdout.typecode == UNETOBJ_CLOSINGBRACE) |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 break; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 switch(rdout.typecode) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 case UNETOBJ_PRIMITIVE: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 case UNETOBJ_ALTNAME: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 case UNETOBJ_ATTR: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 continue; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 case UNETOBJ_PIN: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 if (rdout.connect_to_net) |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 process_pin_connect(compname); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 continue; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 case UNETOBJ_PINMAP: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 fprintf(stderr, |
143
7c0fd80782c8
unet2protel utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
76 "%s line %d: PINMAP objects not expected in unet2protel input\n", |
35
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 input_filename, rdstate.lineno); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 exit(1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 default: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 fprintf(stderr, |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 "%s line %d: object type %s unexpected in COMPONENT block\n", |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 input_filename, rdstate.lineno, rdout.keyword); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 exit(1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 static void |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 process_input_unet() |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 struct net *n; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 struct netextra *nx; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 open_unet_input_file(input_filename, &rdstate); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 while (read_unet_line(&rdstate, &rdout)) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 switch(rdout.typecode) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 case UNETOBJ_CLOSINGBRACE: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
98 fprintf(stderr, |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 "%s line %d: unexpected '}' outside of component block\n", |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 input_filename, rdstate.lineno); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
101 exit(1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
102 case UNETOBJ_NET: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 n = enter_net_object(rdout.objname, |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 sizeof(struct netextra)); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 nx = (struct netextra *)(n + 1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
106 nx->head = 0; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
107 nx->tailp = &nx->head; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
108 continue; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
109 case UNETOBJ_COMPONENT: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
110 process_component(); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
111 continue; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
112 case UNETOBJ_STARPOINT: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
113 fprintf(stderr, |
143
7c0fd80782c8
unet2protel utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
114 "error: STARPOINT objects not expected in unet2protel input (%s line %d)\n", |
35
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
115 input_filename, rdstate.lineno); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
116 exit(1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 default: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
118 fprintf(stderr, |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
119 "%s line %d: unexpected object type %s\n", |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
120 input_filename, rdstate.lineno, rdout.keyword); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 exit(1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
122 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
123 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
124 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
125 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
126 static |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 emit_net(net) |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 struct net *net; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
129 { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
130 struct netextra *nx; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
131 register struct netmember *nm; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
132 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
133 nx = (struct netextra *)(net + 1); |
143
7c0fd80782c8
unet2protel utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
134 fprintf(outFILE, "(\n%s\n", net->name); |
7c0fd80782c8
unet2protel utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
135 for (nm = nx->head; nm; nm = nm->next) |
7c0fd80782c8
unet2protel utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
136 fprintf(outFILE, "%s\n", nm->name); |
7c0fd80782c8
unet2protel utility added
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
137 fputs(")\n", outFILE); |
35
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
138 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
139 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
140 static void |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
141 generate_output() |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
142 { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
143 register struct net *n; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
144 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
145 if (output_filename) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
146 outFILE = fopen(output_filename, "w"); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
147 if (!outFILE) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
148 perror(output_filename); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
149 exit(1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
150 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
151 } else |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
152 outFILE = stdout; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
153 for (n = net_list_head; n; n = n->nextinlist) |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
154 emit_net(n); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
155 if (outFILE != stdout) |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
156 fclose(outFILE); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
157 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
158 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
159 main(argc, argv) |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
160 char **argv; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
161 { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
162 if (argc < 2 || argc > 3) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
163 fprintf(stderr, "usage: %s input.unet [output-file]\n", |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
164 argv[0]); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
165 exit(1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
166 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
167 input_filename = argv[1]; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
168 output_filename = argv[2]; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
169 process_input_unet(); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
170 generate_output(); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
171 exit(0); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
172 } |