comparison ueda/libuschem/pinref.c @ 0:cd92449fdb51

initial import of ueda and ifctf-part-lib from ifctfvax CVS
author Space Falcon <falcon@ivan.Harhan.ORG>
date Mon, 20 Jul 2015 00:24:37 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:cd92449fdb51
1 /*
2 * pin name reference parsing
3 */
4
5 #include <sys/types.h>
6 #include <stdio.h>
7 #include <ctype.h>
8 #include "schemstruct.h"
9
10 extern struct schemobj *find_component_instance();
11
12 parse_pin_nameref(schem, lineno, nameref, compp, soughtpin, bynum)
13 struct schem *schem;
14 int lineno;
15 char *nameref;
16 struct schemobj **compp;
17 char **soughtpin;
18 int *bynum;
19 {
20 register char *cp;
21 char chsave;
22 register struct schemobj *comp;
23
24 cp = nameref;
25 if (!isalnum(*cp)) {
26 inv: fprintf(stderr,
27 "%s: line %d: \"%s\" is not a valid pin name reference\n",
28 schem->orig_filename, lineno, nameref);
29 return(-1);
30 }
31 while (isalnum(*cp))
32 cp++;
33 chsave = *cp;
34 switch (*cp) {
35 case '.':
36 *bynum = 0;
37 break;
38 case '-':
39 *bynum = 1;
40 break;
41 default:
42 goto inv;
43 }
44 *cp = '\0';
45 comp = find_component_instance(schem, nameref);
46 if (!comp)
47 fprintf(stderr,
48 "%s: line %d: component instance %s not found\n",
49 schem->orig_filename, lineno, nameref);
50 *cp++ = chsave;
51 *compp = comp;
52 if (!isgraph(*cp))
53 goto inv;
54 *soughtpin = cp;
55 return(comp ? 0 : -1);
56 }