annotate sip-in/readconf.c @ 48:8117d8ee44a5

sip-in: beginning of INVITE handling
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 06 Sep 2022 22:07:51 -0800
parents 62f39c7cee15
children 709b78a4ebf0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we implement the reading of /var/gsm/themwi-sip-in.cfg:
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * the main settings are bind-ip and bind-port, but we also have some
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * optional config settings.
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/types.h>
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <sys/socket.h>
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <netinet/in.h>
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <arpa/inet.h>
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <ctype.h>
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <stdio.h>
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <stdlib.h>
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include <string.h>
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include <strings.h>
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 struct in_addr sip_bind_ip;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 unsigned sip_bind_port;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 int cfg_use_100rel;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 static char config_file_pathname[] = "/var/gsm/themwi-sip-in.cfg";
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 struct parse_state {
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 int lineno;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 int set_mask;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 };
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 static void
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 handle_ip(st, kw, var, arg)
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 struct parse_state *st;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 char *kw, *arg;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 struct in_addr *var;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 {
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 var->s_addr = inet_addr(arg);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 if (var->s_addr == INADDR_NONE) {
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 fprintf(stderr,
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 "%s line %d: invalid IP address argument \"%s\"\n",
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 config_file_pathname, st->lineno, arg);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 exit(1);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 }
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 }
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 static void
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 handle_num(st, kw, var, arg)
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 struct parse_state *st;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 char *kw, *arg;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 unsigned *var;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 {
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 char *endp;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 *var = strtoul(arg, &endp, 10);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 if (*endp) {
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 fprintf(stderr, "%s line %d: invalid numeric argument \"%s\"\n",
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 config_file_pathname, st->lineno, arg);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 exit(1);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 }
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 }
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 static void
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 handle_bool(st, kw, var, arg)
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 struct parse_state *st;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 char *kw, *arg;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 int *var;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 {
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 if (!strcmp(arg, "true") || !strcmp(arg, "on") || !strcmp(arg, "yes")
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 || !strcmp(arg, "1")) {
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 *var = 1;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 return;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 }
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 if (!strcmp(arg, "false") || !strcmp(arg, "off") || !strcmp(arg, "no")
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 || !strcmp(arg, "0")) {
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 *var = 0;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 return;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 }
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 fprintf(stderr, "%s line %d: invalid boolean argument \"%s\"\n",
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 config_file_pathname, st->lineno, arg);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 exit(1);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 }
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 static void
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 process_line(st, line)
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 struct parse_state *st;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 char *line;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 {
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 char *cp, *np, *arg;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 void (*handler)(), *var;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 int set_id;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 if (!index(line, '\n')) {
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 fprintf(stderr, "%s line %d: too long or missing newline\n",
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 config_file_pathname, st->lineno);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 exit(1);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 }
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 for (cp = line; isspace(*cp); cp++)
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 ;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 if (*cp == '\0' || *cp == '#')
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 return;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 for (np = cp; *cp && !isspace(*cp); cp++)
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 ;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 if (*cp)
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 *cp++ = '\0';
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 if (!strcmp(np, "bind-ip")) {
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 handler = handle_ip;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 var = &sip_bind_ip;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 set_id = 1;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 } else if (!strcmp(np, "bind-port")) {
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 handler = handle_num;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 var = &sip_bind_port;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 set_id = 2;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 } else if (!strcmp(np, "use-100rel")) {
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 handler = handle_bool;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 var = &cfg_use_100rel;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 set_id = 0;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 } else {
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 fprintf(stderr, "%s line %d: non-understood keyword \"%s\"\n",
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 config_file_pathname, st->lineno, np);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 exit(1);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 }
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 if (st->set_mask & set_id) {
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 fprintf(stderr, "%s line %d: duplicate %s setting\n",
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 config_file_pathname, st->lineno, np);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 exit(1);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 }
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 while (isspace(*cp))
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 cp++;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 if (*cp == '\0' || *cp == '#') {
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 inv_syntax: fprintf(stderr,
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 "%s line %d: %s setting requires one argument\n",
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 config_file_pathname, st->lineno, np);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 exit(1);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 }
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 for (arg = cp; *cp && !isspace(*cp); cp++)
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 ;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 if (*cp)
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 *cp++ = '\0';
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 while (isspace(*cp))
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 cp++;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 if (*cp != '\0' && *cp != '#')
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 goto inv_syntax;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 handler(st, np, var, arg);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 st->set_mask |= set_id;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 }
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 read_config_file()
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 {
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 FILE *inf;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 struct parse_state pst;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 char linebuf[256];
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 inf = fopen(config_file_pathname, "r");
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 if (!inf) {
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 perror(config_file_pathname);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 exit(1);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 }
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 pst.set_mask = 0;
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 for (pst.lineno = 1; fgets(linebuf, sizeof linebuf, inf); pst.lineno++)
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 process_line(&pst, linebuf);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 fclose(inf);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 if (pst.set_mask != 3) {
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 fprintf(stderr, "error: %s did not set all required settings\n",
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 config_file_pathname);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 exit(1);
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 }
62f39c7cee15 themwi-sip-in skeleton started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 }