annotate cmu200/cableconf.c @ 104:7ad0495991ed

autocal: use the new ERROR_RFFAIL exit code
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 09 Dec 2017 07:01:13 +0000
parents 3ec82dc1dbda
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
68
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * The code that reads and parses cable config files lives here.
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/param.h>
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <ctype.h>
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <string.h>
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <strings.h>
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "band.h"
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 char cableconf_directory[] = "/opt/freecalypso/rfcal/cableconf/";
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 extern struct band supported_bands[];
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 extern int cmu200_rf_port;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 static void
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 cable_loss_line(cp, filename_for_errs, lineno)
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 char *cp, *filename_for_errs;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 {
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 char *np;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 struct band *band;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 int dir;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 unsigned num;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 while (isspace(*cp))
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 cp++;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 if (!isdigit(*cp)) {
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 inv: fprintf(stderr, "%s line %d: invalid syntax for cable-loss\n",
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 filename_for_errs, lineno);
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 exit(1);
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 }
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 for (np = cp; isdigit(*cp); cp++)
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 ;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 if (cp[0] != 'd' && cp[0] != 'u' || cp[1] != 'l')
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 goto inv;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 dir = *cp;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 *cp = '\0';
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 cp += 2;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 for (band = supported_bands; band->name; band++)
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 if (!strcmp(band->name, np))
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 break;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 if (!band->name) {
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 fprintf(stderr, "%s line %d: frequency band \"%s\" not known\n",
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 filename_for_errs, lineno, np);
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 exit(1);
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 }
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 while (isspace(*cp))
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 cp++;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 if (!isdigit(*cp))
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 goto inv;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 for (np = cp; isdigit(*cp); cp++)
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 ;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 if (cp[0] != '.' || !isdigit(cp[1]))
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 goto inv;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 num = atoi(np) * 10 + (cp[1] - '0');
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 cp += 2;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 while (isspace(*cp))
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 cp++;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 if (*cp != '\0' && *cp != '#')
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 goto inv;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 switch (dir) {
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 case 'd':
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 band->dl_cable_loss = num;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 break;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 case 'u':
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 band->ul_cable_loss = num;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 break;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 }
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 }
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 static void
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 rf_port_line(cp, filename_for_errs, lineno)
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 char *cp, *filename_for_errs;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 {
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 while (isspace(*cp))
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 cp++;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 if (!isdigit(*cp)) {
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 inv: fprintf(stderr, "%s line %d: invalid syntax for rf-port\n",
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 filename_for_errs, lineno);
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 exit(1);
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 }
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 if (cp[0] != '1' && cp[0] != '2' || isdigit(cp[1])) {
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 fprintf(stderr, "%s line %d: invalid RF port number\n",
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 filename_for_errs, lineno);
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 exit(1);
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 }
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 cmu200_rf_port = *cp++ - '0';
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 while (isspace(*cp))
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 cp++;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 if (*cp != '\0' && *cp != '#')
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 goto inv;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 }
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 static void
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 process_line(linebuf, filename_for_errs, lineno)
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 char *linebuf, *filename_for_errs;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 {
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 char *cp, *np;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 for (cp = linebuf; isspace(*cp); cp++)
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 ;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 if (*cp == '\0' || *cp == '#')
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 return;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 for (np = cp; *cp && !isspace(*cp); cp++)
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 ;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 if (*cp)
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 *cp++ = '\0';
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 if (!strcmp(np, "cable-loss"))
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 cable_loss_line(cp, filename_for_errs, lineno);
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 else if (!strcmp(np, "rf-port"))
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 rf_port_line(cp, filename_for_errs, lineno);
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 else {
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 fprintf(stderr, "%s line %d: unknown keyword \"%s\"\n",
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 filename_for_errs, lineno, np);
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 exit(1);
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 }
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 }
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 read_cable_conf_file(cable_conf_name)
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 char *cable_conf_name;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 {
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 char pathname[MAXPATHLEN];
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 FILE *inf;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 int lineno;
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 char linebuf[512];
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 strcpy(pathname, cableconf_directory);
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 strcat(pathname, cable_conf_name);
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 inf = fopen(pathname, "r");
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 if (!inf) {
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 perror(pathname);
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 exit(1);
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 }
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 for (lineno = 1; fgets(linebuf, sizeof linebuf, inf); lineno++)
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 process_line(linebuf, pathname, lineno);
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 fclose(inf);
3ec82dc1dbda fc-cmu200d: implemented reading and parsing of cable config files (-c arg)
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 }