FreeCalypso > hg > ueda-linux
annotate netdiff/match/rdpass.c @ 145:5e91200bf609
netdiff: donl-pinreport utility written, compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 15 Nov 2020 01:17:10 +0000 |
parents | d3eb3790386d |
children |
rev | line source |
---|---|
140
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 #include <ctype.h> |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 #include <string.h> |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 #include <strings.h> |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 #include <stdio.h> |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <stdlib.h> |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include "struct.h" |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 extern char *infnames[2]; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 extern struct pin_info *database; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #define MAX_FIELDS 2 |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 static int pass; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 static FILE *inf; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 static char linebuf[512]; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 static int lineno; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 static char *fields[MAX_FIELDS]; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 static unsigned nfields; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 static void |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 parse_into_fields() |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 { |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 char *cp; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 nfields = 0; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 for (cp = linebuf; ; ) { |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 while (isspace(*cp)) |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 cp++; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 if (*cp == '\0' || *cp == '#') |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 break; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 if (nfields >= MAX_FIELDS) { |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 fprintf(stderr, "%s line %d: too many fields\n", |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 infnames[pass], lineno); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 exit(1); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 } |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 fields[nfields++] = cp; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 while (*cp && !isspace(*cp)) |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 cp++; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 if (*cp) |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 *cp++ = '\0'; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 } |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 } |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 static void |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 existing_pin(p, netname) |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 struct pin_info *p; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 char *netname; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 { |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 char *dp; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 if (p->netnames[pass]) { |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 fprintf(stderr, "%s line %d: multiple nets to pin %s\n", |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 infnames[pass], lineno, p->pin_name); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 exit(1); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 } |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 dp = malloc(strlen(netname) + 1); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 if (!dp) { |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 perror("malloc"); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 exit(1); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 } |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 strcpy(dp, netname); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 p->netnames[pass] = dp; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 } |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 static void |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 process_connect(netname, pinname) |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 char *netname, *pinname; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 { |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 struct pin_info *p, **pp; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 char *dp; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 for (pp = &database; p = *pp; pp = &p->next) { |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 if (!strcmp(p->pin_name, pinname)) { |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 existing_pin(p, netname); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 return; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 } |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 } |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 p = malloc(sizeof(struct pin_info) + strlen(netname) + strlen(pinname) |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 + 2); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 if (!p) { |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 perror("malloc"); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 exit(1); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 } |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 bzero(p, sizeof(struct pin_info)); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 dp = (char *)(p + 1); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 p->pin_name = dp; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 strcpy(dp, pinname); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 dp += strlen(pinname) + 1; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 p->netnames[pass] = dp; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 strcpy(dp, netname); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 *pp = p; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 } |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 static void |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 process_line() |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 { |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 parse_into_fields(); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 if (!nfields) |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 return; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 if (nfields != 2) { |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 fprintf(stderr, "%s line %d: expected 2 fields\n", |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 infnames[pass], lineno); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 exit(1); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 } |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 process_connect(fields[0], fields[1]); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 } |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 read_pass(pass_no) |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 { |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 pass = pass_no; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 inf = fopen(infnames[pass], "r"); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 if (!inf) { |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 perror(infnames[pass]); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 exit(1); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 } |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 lineno = 0; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 while (fgets(linebuf, sizeof linebuf, inf)) { |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 lineno++; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 process_line(); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 } |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 fclose(inf); |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 return 0; |
d3eb3790386d
netdiff: donl-netmatch put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 } |