-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcom_equate.c
141 lines (129 loc) · 3.45 KB
/
com_equate.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include "db.h"
#include "xwin.h"
#include "token.h"
#include "rlgetc.h"
#include "equate.h"
#define UNUSED(x) (void)(x)
#define MAXBUF 128
int com_equate(LEXER* lp, char *arg) /* define properties of each layer */
{
UNUSED(arg);
TOKEN token;
int done=0;
char *word;
char buf[MAXBUF] = "";
int color = -1;
int line_type = -1;
int mask_type = -1;
int layer = -1;
int pen = -1;
int fill = 0;
int debug=0;
if (lp->mode != PRO) {
printf("Can only enter EQUate commands in the PROCESS subsystem!\n");
token_flush_EOL(lp);
return(1);
}
while(!done && (token=token_get(lp, &word)) != EOF) {
switch(token) {
case OPT: /* option */
if (word[0] != ':') {
printf("EQUATE: unrecognized option: %s\n", word);
done++;
token_flush_EOL(lp);
}
switch(toupper((unsigned char)word[1])) {
case 'C': /* color */
if ((color = color2equate(word[2])) == -1) {
printf("EQUATE: bad color spec: %c\n", word[2]);
done++;
token_flush_EOL(lp);
}
if (debug) printf("got color %s %d\n", word+2, color);
break;
case 'P': /* pen */
pen = atoi(word+2);
if (pen < 0 || pen > 7) {
printf("EQUATE: bad pen: %c\n", word[2]);
done++;
token_flush_EOL(lp);
}
if (debug) printf("got pen %s\n", word+2);
break;
case 'M': /* mask linetype */
if ((line_type = linetype2equate(word[2])) == -1) {
printf("EQUATE: bad mask line type: %c\n", word[2]);
done++;
token_flush_EOL(lp);
}
if (debug) printf("got mask %s\n", word+2);
break;
case 'F': /* fill flag */
fill = atoi(word+2);
if (fill < 0 || fill > 7) {
printf("EQUATE: bad fill: %c\n", word[2]);
done++;
token_flush_EOL(lp);
}
if (debug) printf("got fill %s\n", word+2);
break;
case 'B': /* boundary */
case 'D': /* detail */
case 'S': /* symbolic */
case 'I': /* interconnect */
if ((mask_type = masktype2equate(word[1])) == -1) {
printf("EQUATE: bad mask type: %c\n", word[1]);
done++;
token_flush_EOL(lp);
}
break;
default:
printf("EQUATE: unrecognized option: %s\n", word);
done++;
token_flush_EOL(lp);
break;
}
break;
case NUMBER: /* number */
if (((layer = atoi(word)) < 0) || layer > MAX_LAYER ) {
printf("EQUATE: bad layer: %d\n", layer);
done++;
token_flush_EOL(lp);
}
if (debug) printf("got layer %d\n", layer);
break;
case IDENT: /* identifier */
strncpy(buf, word,MAXBUF);
if (debug) printf("got name %s\n", buf);
break;
case CMD: /* command */
token_unget(lp, token, word);
done++;
break;
case EOC: /* end of command */
done++;
break;
case EOL: /* newline or carriage return */
break;
default:
printf("EQUATE: expected OPT, got %s %s\n", tok2str(token), word);
done++;
break;
}
}
if (layer == -1) {
printf("EQUATE: no layer specified\n");
} else {
if (color != -1) equate_set_color(layer, color);
if (line_type != -1) equate_set_linetype(layer, line_type);
if (pen != -1) equate_set_pen(layer, pen);
if (mask_type != -1) equate_set_masktype(layer, mask_type);
if (buf[0] != '\0') equate_set_label(layer, buf);
equate_set_fill(layer, fill);
}
/* equate_print(); */
return (0);
}