FreeCalypso > hg > ueda-linux
annotate ueda/unet-utils/unet2pcb.c @ 55:e93375570f91
pads2gpcb/decals.c: saving of silk lines and arcs implemented
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Sun, 31 Jan 2016 02:14:57 +0000 |
parents | 47b5b8310cac |
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 <unistd.h> |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include "../libunet/unetrd.h" |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include "../libunet/nethash.h" |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 extern struct net *enter_net_object(); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 extern struct net *find_net_by_name(); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 extern struct net *net_list_head; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 static char *input_filename, *output_filename; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 static struct unetrd_state rdstate; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 static struct unetrd_out rdout; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 static FILE *outFILE; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 struct netextra { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 struct netmember *head; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 struct netmember **tailp; |
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 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 struct netmember { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 char *name; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 struct netmember *next; |
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 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 static void |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 process_pin_connect(compname) |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 char *compname; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 register struct net *n; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 register struct netextra *nx; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 register struct netmember *nm; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 n = find_net_by_name(rdout.connect_to_net); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 nx = (struct netextra *)(n + 1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 nm = (struct netmember *) malloc(sizeof(struct netmember) + |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 strlen(compname) + |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 strlen(rdout.objname) + 2); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 if (!nm) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 perror("malloc"); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 exit(1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 nm->name = (char *)(nm + 1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 sprintf(nm->name, "%s-%s", compname, rdout.objname); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 nm->next = 0; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 *nx->tailp = nm; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 nx->tailp = &nm->next; |
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 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 static void |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 process_component() |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 char compname[64]; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 strcpy(compname, rdout.objname); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 for (;;) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 if (!read_unet_line(&rdstate, &rdout)) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 fprintf(stderr, "%s error: EOF in COMPONENT block\n", |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 input_filename); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 exit(1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 if (rdout.typecode == UNETOBJ_CLOSINGBRACE) |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 break; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 switch(rdout.typecode) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 case UNETOBJ_PRIMITIVE: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 case UNETOBJ_ALTNAME: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 case UNETOBJ_ATTR: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 continue; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 case UNETOBJ_PIN: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 if (rdout.connect_to_net) |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 process_pin_connect(compname); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 continue; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 case UNETOBJ_PINMAP: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 fprintf(stderr, |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 "%s line %d: PINMAP objects not expected in unet2pcb input\n", |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 input_filename, rdstate.lineno); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 exit(1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 default: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 fprintf(stderr, |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 "%s line %d: object type %s unexpected in COMPONENT block\n", |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 input_filename, rdstate.lineno, rdout.keyword); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 exit(1); |
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 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 static void |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 process_input_unet() |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 struct net *n; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 struct netextra *nx; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 open_unet_input_file(input_filename, &rdstate); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 while (read_unet_line(&rdstate, &rdout)) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 switch(rdout.typecode) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
98 case UNETOBJ_CLOSINGBRACE: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 fprintf(stderr, |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 "%s line %d: unexpected '}' outside of component block\n", |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
101 input_filename, rdstate.lineno); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
102 exit(1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 case UNETOBJ_NET: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 n = enter_net_object(rdout.objname, |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 sizeof(struct netextra)); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
106 nx = (struct netextra *)(n + 1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
107 nx->head = 0; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
108 nx->tailp = &nx->head; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
109 continue; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
110 case UNETOBJ_COMPONENT: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
111 process_component(); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
112 continue; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
113 case UNETOBJ_STARPOINT: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
114 fprintf(stderr, |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
115 "error: STARPOINT objects not expected in unet2pcb input (%s line %d)\n", |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
116 input_filename, rdstate.lineno); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 exit(1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
118 default: |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
119 fprintf(stderr, |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
120 "%s line %d: unexpected object type %s\n", |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 input_filename, rdstate.lineno, rdout.keyword); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
122 exit(1); |
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 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 static |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 emit_net(net) |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
129 struct net *net; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
130 { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
131 struct netextra *nx; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
132 register struct netmember *nm; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
133 int linelen, linefresh; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
134 register int i; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
135 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
136 nx = (struct netextra *)(net + 1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
137 fprintf(outFILE, "%s\t", net->name); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
138 linelen = (strlen(net->name) + 8) & ~7; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
139 linefresh = 1; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
140 for (nm = nx->head; nm; nm = nm->next) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
141 i = strlen(nm->name) + 1; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
142 if (!linefresh && linelen + i > 78) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
143 fputs(" \\\n\t", outFILE); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
144 linelen = 8; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
145 linefresh = 1; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
146 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
147 if (linefresh) |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
148 i--; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
149 else |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
150 putc(' ', outFILE); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
151 fputs(nm->name, outFILE); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
152 linelen += i; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
153 linefresh = 0; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
154 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
155 putc('\n', outFILE); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
156 } |
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 static void |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
159 generate_output() |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
160 { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
161 register struct net *n; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
162 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
163 if (output_filename) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
164 outFILE = fopen(output_filename, "w"); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
165 if (!outFILE) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
166 perror(output_filename); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
167 exit(1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
168 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
169 } else |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
170 outFILE = stdout; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
171 for (n = net_list_head; n; n = n->nextinlist) |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
172 emit_net(n); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
173 if (outFILE != stdout) |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
174 fclose(outFILE); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
175 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
176 |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
177 main(argc, argv) |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
178 char **argv; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
179 { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
180 if (argc < 2 || argc > 3) { |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
181 fprintf(stderr, "usage: %s input.unet [output-file]\n", |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
182 argv[0]); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
183 exit(1); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
184 } |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
185 input_filename = argv[1]; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
186 output_filename = argv[2]; |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
187 process_input_unet(); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
188 generate_output(); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
189 exit(0); |
47b5b8310cac
unet2pcb written, compiles
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
190 } |