FreeCalypso > hg > themwi-system-sw
annotate utils/themwi-update-outrt.c @ 269:ff1ed366c84d
doc/Number-database: first draft written
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 26 Nov 2023 14:51:22 -0800 |
parents | b997de027717 |
children |
rev | line source |
---|---|
130
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This program reads (parses) ThemWi config file /var/gsm/out-routes, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * generates the compiled binary form of this database, and then makes |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * it live via atomic rename. |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 */ |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <sys/types.h> |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <sys/socket.h> |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <netinet/in.h> |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <arpa/inet.h> |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <ctype.h> |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <stdio.h> |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <stdint.h> |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <stdlib.h> |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include <string.h> |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include <strings.h> |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include <unistd.h> |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 #include "../include/out_routes.h" |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #define MAX_DEST_ENTRIES 16 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 #define MAX_INN_ENTRIES 64 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 #define MAX_SPC_NUM_ENTRIES 64 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 static struct sip_out_dest dest_records[MAX_DEST_ENTRIES]; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 static char *dest_names[MAX_DEST_ENTRIES]; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 static struct inn_route inn_records[MAX_INN_ENTRIES]; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 static struct special_num_route special_num_records[MAX_SPC_NUM_ENTRIES]; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 static unsigned dest_rec_count, inn_rec_count, special_num_count; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 static char *system_dir; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 static FILE *inf; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 static int lineno; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 static char linebuf[256]; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 static int |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 find_dest_by_name(sought_name) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 char *sought_name; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 unsigned n; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 for (n = 0; n < dest_rec_count; n++) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 if (!strcmp(dest_names[n], sought_name)) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 return n; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 return -1; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 static int |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 find_dest_by_number(target_num) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 char *target_num; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 unsigned inn_index; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 struct inn_route *rec; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 char *pp, *tp; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 for (inn_index = 0; inn_index < inn_rec_count; inn_index++) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 rec = inn_records + inn_index; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 pp = rec->prefix; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 tp = target_num; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 while (*pp && *pp == *tp) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 pp++; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 tp++; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 if (*pp) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 continue; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 return rec->sip_dest_id; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 return -1; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 static void |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 handle_dest_line(cp) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 char *cp; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 char *name, *name_copy, *domain, *ip_str, *port_str; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 struct sip_out_dest *rec; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 unsigned portnum; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 int rc; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 for (name = cp; *cp && !isspace(*cp); cp++) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 ; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 if (*cp) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 *cp++ = '\0'; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 while (isspace(*cp)) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 cp++; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 if (*cp == '\0' || *cp == '#') { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 inv_syntax: fprintf(stderr, "out-routes line %d: invalid syntax for dest\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 lineno); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 for (domain = cp; *cp && !isspace(*cp); cp++) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 ; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 if (*cp) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 *cp++ = '\0'; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 while (isspace(*cp)) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 cp++; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 if (*cp == '\0' || *cp == '#') |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 goto inv_syntax; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 for (ip_str = cp; *cp && !isspace(*cp); cp++) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 ; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 if (*cp) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 *cp++ = '\0'; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 while (isspace(*cp)) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 cp++; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 if (*cp == '\0' || *cp == '#') |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 port_str = 0; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 else { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 for (port_str = cp; *cp && !isspace(*cp); cp++) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 ; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 if (*cp) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 *cp++ = '\0'; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 while (isspace(*cp)) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 cp++; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 if (*cp != '\0' && *cp != '#') |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 goto inv_syntax; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 rc = find_dest_by_name(name); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 if (rc >= 0) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 "out-routes line %d: duplicate destination name \"%s\"\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 lineno, name); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 if (dest_rec_count >= MAX_DEST_ENTRIES) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 "out-routes line %d: MAX_DEST_ENTRIES exceeded\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 lineno); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 name_copy = strdup(name); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 if (!name_copy) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 perror("strdup"); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 dest_names[dest_rec_count] = name_copy; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 rec = dest_records + dest_rec_count; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 if (strlen(domain) > MAX_SIP_DEST_DOMAIN) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 "out-routes line %d: dest domain string is too long\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 lineno); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 strcpy(rec->domain, domain); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 rec->sin.sin_family = AF_INET; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 rec->sin.sin_addr.s_addr = inet_addr(ip_str); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 if (rec->sin.sin_addr.s_addr == INADDR_NONE) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 "out-routes line %d: dest IP address is invalid\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 lineno); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 if (port_str) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 portnum = strtoul(port_str, &cp, 10); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 if (*cp) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 goto inv_syntax; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 } else |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 portnum = 5060; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 rec->sin.sin_port = htons(portnum); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 dest_rec_count++; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 static void |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 handle_inn_route(cp) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 char *cp; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 char *prefix, *dest_name; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 struct inn_route *rec; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 int rc, dest_id; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 for (prefix = cp; *cp && !isspace(*cp); cp++) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 ; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 if (*cp) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 *cp++ = '\0'; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 while (isspace(*cp)) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 cp++; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 if (*cp == '\0' || *cp == '#') { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 inv_syntax: fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 "out-routes line %d: invalid syntax for inn-route\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 lineno); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 for (dest_name = cp; *cp && !isspace(*cp); cp++) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 ; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 if (*cp) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 *cp++ = '\0'; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 while (isspace(*cp)) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 cp++; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 if (*cp != '\0' && *cp != '#') |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 goto inv_syntax; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 rc = grok_number_string(prefix, 1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 if (rc < 1) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 goto inv_syntax; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 if (rc > MAX_INN_PREFIX) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 "out-routes line %d: inn-route prefix is too long\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 lineno); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 dest_id = find_dest_by_name(dest_name); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 if (dest_id < 0) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 "out-routes line %d: SIP destination \"%s\" not defined\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 lineno, dest_name); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 if (inn_rec_count >= MAX_INN_ENTRIES) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 "out-routes line %d: MAX_INN_ENTRIES exceeded\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 lineno); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 rec = inn_records + inn_rec_count; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 dehyphen_number_string(prefix, rec->prefix); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 rec->sip_dest_id = dest_id; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 inn_rec_count++; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 static void |
204
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
218 handle_default_rt(cp) |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
219 char *cp; |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
220 { |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
221 char *dest_name; |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
222 struct inn_route *rec; |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
223 int dest_id; |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
224 |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
225 for (dest_name = cp; *cp && !isspace(*cp); cp++) |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
226 ; |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
227 if (*cp) |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
228 *cp++ = '\0'; |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
229 while (isspace(*cp)) |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
230 cp++; |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
231 if (*cp != '\0' && *cp != '#') { |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
232 fprintf(stderr, |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
233 "out-routes line %d: invalid syntax for inn-default-rt\n", |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
234 lineno); |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
235 exit(1); |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
236 } |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
237 dest_id = find_dest_by_name(dest_name); |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
238 if (dest_id < 0) { |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
239 fprintf(stderr, |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
240 "out-routes line %d: SIP destination \"%s\" not defined\n", |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
241 lineno, dest_name); |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
242 exit(1); |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
243 } |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
244 if (inn_rec_count >= MAX_INN_ENTRIES) { |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
245 fprintf(stderr, |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
246 "out-routes line %d: MAX_INN_ENTRIES exceeded\n", |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
247 lineno); |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
248 exit(1); |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
249 } |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
250 rec = inn_records + inn_rec_count; |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
251 rec->prefix[0] = '\0'; |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
252 rec->sip_dest_id = dest_id; |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
253 inn_rec_count++; |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
254 } |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
255 |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
256 static void |
130
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 preen_special_num_code(num_code) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 char *num_code; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 char *cp; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 int c; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 unsigned n; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 n = 0; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 for (cp = num_code; *cp; ) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 c = *cp++; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 if (is_valid_ext_digit(c)) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 n++; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 else { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 "out-routes line %d: special-num string \"%s\" is invalid\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 lineno, num_code); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 if (n > MAX_SPECIAL_NUM) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 "out-routes line %d: special-num string \"%s\" is too long\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 lineno, num_code); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 static void |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 handle_special_num_map_to(num_code, cp) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 char *num_code, *cp; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 struct special_num_route *rec; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 char *tgt_num_src; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 int rc, dest_id; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 while (isspace(*cp)) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 cp++; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 if (*cp++ != '+') { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 inv_syntax: fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 "out-routes line %d: invalid syntax for special-num map-to\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 lineno); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 if (!isdigit(*cp)) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 goto inv_syntax; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 for (tgt_num_src = cp; *cp && !isspace(*cp); cp++) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 ; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 if (*cp) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 *cp++ = '\0'; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 while (isspace(*cp)) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 cp++; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 if (*cp != '\0' && *cp != '#') |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 goto inv_syntax; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 rc = grok_number_string(tgt_num_src, 1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 if (rc < 1) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 goto inv_syntax; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 if (rc > MAX_E164_NUMBER) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 "out-routes line %d: map-to number is too long for E.164\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 lineno); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 rec = special_num_records + special_num_count; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 strcpy(rec->special_num, num_code); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 rec->sip_user[0] = '+'; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 dehyphen_number_string(tgt_num_src, rec->sip_user+1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 dest_id = find_dest_by_number(rec->sip_user+1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 if (dest_id < 0) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 "out-routes line %d: no inn-route for map-to number\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 lineno); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 rec->sip_dest_id = dest_id; |
255
b0bf167bb846
themwi-update-outrt: add route-to-e911 option
Mychaela Falconia <falcon@freecalypso.org>
parents:
204
diff
changeset
|
331 rec->flags = 0; |
130
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 special_num_count++; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
334 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
335 static void |
255
b0bf167bb846
themwi-update-outrt: add route-to-e911 option
Mychaela Falconia <falcon@freecalypso.org>
parents:
204
diff
changeset
|
336 handle_special_num_route_to(num_code, cp, is_e911) |
130
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
337 char *num_code, *cp; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
338 { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
339 struct special_num_route *rec; |
260
b997de027717
themwi-update-outrt: special-num route-to: add support for
Mychaela Falconia <falcon@freecalypso.org>
parents:
255
diff
changeset
|
340 char *dest_name, *new_sip_user; |
130
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
341 int dest_id; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 while (isspace(*cp)) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
344 cp++; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
345 if (*cp == '\0' || *cp == '#') { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
346 inv_syntax: fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 "out-routes line %d: invalid syntax for special-num route-to\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
348 lineno); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
349 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
350 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
351 for (dest_name = cp; *cp && !isspace(*cp); cp++) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
352 ; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
353 if (*cp) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
354 *cp++ = '\0'; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
355 while (isspace(*cp)) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
356 cp++; |
260
b997de027717
themwi-update-outrt: special-num route-to: add support for
Mychaela Falconia <falcon@freecalypso.org>
parents:
255
diff
changeset
|
357 if (*cp != '\0' && *cp != '#') { |
b997de027717
themwi-update-outrt: special-num route-to: add support for
Mychaela Falconia <falcon@freecalypso.org>
parents:
255
diff
changeset
|
358 for (new_sip_user = cp; *cp && !isspace(*cp); cp++) |
b997de027717
themwi-update-outrt: special-num route-to: add support for
Mychaela Falconia <falcon@freecalypso.org>
parents:
255
diff
changeset
|
359 ; |
b997de027717
themwi-update-outrt: special-num route-to: add support for
Mychaela Falconia <falcon@freecalypso.org>
parents:
255
diff
changeset
|
360 if (*cp) |
b997de027717
themwi-update-outrt: special-num route-to: add support for
Mychaela Falconia <falcon@freecalypso.org>
parents:
255
diff
changeset
|
361 *cp++ = '\0'; |
b997de027717
themwi-update-outrt: special-num route-to: add support for
Mychaela Falconia <falcon@freecalypso.org>
parents:
255
diff
changeset
|
362 while (isspace(*cp)) |
b997de027717
themwi-update-outrt: special-num route-to: add support for
Mychaela Falconia <falcon@freecalypso.org>
parents:
255
diff
changeset
|
363 cp++; |
b997de027717
themwi-update-outrt: special-num route-to: add support for
Mychaela Falconia <falcon@freecalypso.org>
parents:
255
diff
changeset
|
364 if (*cp != '\0' && *cp != '#') |
b997de027717
themwi-update-outrt: special-num route-to: add support for
Mychaela Falconia <falcon@freecalypso.org>
parents:
255
diff
changeset
|
365 goto inv_syntax; |
b997de027717
themwi-update-outrt: special-num route-to: add support for
Mychaela Falconia <falcon@freecalypso.org>
parents:
255
diff
changeset
|
366 if (strlen(new_sip_user) > MAX_SIP_USER_PART) { |
b997de027717
themwi-update-outrt: special-num route-to: add support for
Mychaela Falconia <falcon@freecalypso.org>
parents:
255
diff
changeset
|
367 fprintf(stderr, |
b997de027717
themwi-update-outrt: special-num route-to: add support for
Mychaela Falconia <falcon@freecalypso.org>
parents:
255
diff
changeset
|
368 "out-routes line %d: new SIP user part is too long\n", |
b997de027717
themwi-update-outrt: special-num route-to: add support for
Mychaela Falconia <falcon@freecalypso.org>
parents:
255
diff
changeset
|
369 lineno); |
b997de027717
themwi-update-outrt: special-num route-to: add support for
Mychaela Falconia <falcon@freecalypso.org>
parents:
255
diff
changeset
|
370 exit(1); |
b997de027717
themwi-update-outrt: special-num route-to: add support for
Mychaela Falconia <falcon@freecalypso.org>
parents:
255
diff
changeset
|
371 } |
b997de027717
themwi-update-outrt: special-num route-to: add support for
Mychaela Falconia <falcon@freecalypso.org>
parents:
255
diff
changeset
|
372 } else |
b997de027717
themwi-update-outrt: special-num route-to: add support for
Mychaela Falconia <falcon@freecalypso.org>
parents:
255
diff
changeset
|
373 new_sip_user = 0; |
130
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
374 dest_id = find_dest_by_name(dest_name); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
375 if (dest_id < 0) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
376 fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
377 "out-routes line %d: SIP destination \"%s\" not defined\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
378 lineno, dest_name); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
379 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
380 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
381 rec = special_num_records + special_num_count; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
382 strcpy(rec->special_num, num_code); |
260
b997de027717
themwi-update-outrt: special-num route-to: add support for
Mychaela Falconia <falcon@freecalypso.org>
parents:
255
diff
changeset
|
383 strcpy(rec->sip_user, new_sip_user ? new_sip_user : num_code); |
130
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
384 rec->sip_dest_id = dest_id; |
255
b0bf167bb846
themwi-update-outrt: add route-to-e911 option
Mychaela Falconia <falcon@freecalypso.org>
parents:
204
diff
changeset
|
385 rec->flags = is_e911 ? SPECIAL_NUM_FLAG_E911 : 0; |
130
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
386 special_num_count++; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
387 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
388 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
389 static void |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
390 handle_special_num(cp) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
391 char *cp; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
392 { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
393 char *num_code, *handling_kw; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
394 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
395 for (num_code = cp; *cp && !isspace(*cp); cp++) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
396 ; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
397 if (*cp) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
398 *cp++ = '\0'; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
399 preen_special_num_code(num_code); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
400 if (special_num_count >= MAX_SPC_NUM_ENTRIES) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
401 fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
402 "out-routes line %d: MAX_SPC_NUM_ENTRIES exceeded\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
403 lineno); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
404 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
405 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
406 while (isspace(*cp)) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
407 cp++; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
408 if (*cp == '\0' || *cp == '#') { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
409 inv_syntax: fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
410 "out-routes line %d: invalid syntax for special-num\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
411 lineno); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
412 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
413 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
414 for (handling_kw = cp; *cp && !isspace(*cp); cp++) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
415 ; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
416 if (*cp) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
417 *cp++ = '\0'; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
418 if (!strcmp(handling_kw, "map-to")) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
419 handle_special_num_map_to(num_code, cp); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
420 else if (!strcmp(handling_kw, "route-to")) |
255
b0bf167bb846
themwi-update-outrt: add route-to-e911 option
Mychaela Falconia <falcon@freecalypso.org>
parents:
204
diff
changeset
|
421 handle_special_num_route_to(num_code, cp, 0); |
b0bf167bb846
themwi-update-outrt: add route-to-e911 option
Mychaela Falconia <falcon@freecalypso.org>
parents:
204
diff
changeset
|
422 else if (!strcmp(handling_kw, "route-to-e911")) |
b0bf167bb846
themwi-update-outrt: add route-to-e911 option
Mychaela Falconia <falcon@freecalypso.org>
parents:
204
diff
changeset
|
423 handle_special_num_route_to(num_code, cp, 1); |
130
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
424 else |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
425 goto inv_syntax; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
426 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
427 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
428 static void |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
429 process_line() |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
430 { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
431 char *cp, *np; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
432 void (*handler)(); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
433 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
434 if (!index(linebuf, '\n')) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
435 fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
436 "out-routes line %d: too long or missing newline\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
437 lineno); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
438 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
439 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
440 for (cp = linebuf; isspace(*cp); cp++) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
441 ; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
442 if (*cp == '\0' || *cp == '#') |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
443 return; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
444 for (np = cp; *cp && !isspace(*cp); cp++) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
445 ; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
446 if (*cp) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
447 *cp++ = '\0'; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
448 if (!strcmp(np, "dest")) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
449 handler = handle_dest_line; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
450 else if (!strcmp(np, "inn-route")) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
451 handler = handle_inn_route; |
204
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
452 else if (!strcmp(np, "inn-default-rt")) |
de7c64c4d6fd
themwi-update-outrt: add inn-default-rt possibility
Mychaela Falconia <falcon@freecalypso.org>
parents:
132
diff
changeset
|
453 handler = handle_default_rt; |
130
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
454 else if (!strcmp(np, "special-num")) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
455 handler = handle_special_num; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
456 else { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
457 fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
458 "out-routes line %d: non-understood keyword \"%s\"\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
459 lineno, np); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
460 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
461 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
462 while (isspace(*cp)) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
463 cp++; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
464 if (*cp == '\0' || *cp == '#') { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
465 fprintf(stderr, |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
466 "out-routes line %d: missing argument after \"%s\" keyword\n", |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
467 lineno, np); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
468 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
469 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
470 handler(cp); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
471 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
472 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
473 static void |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
474 emit_output() |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
475 { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
476 FILE *outf; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
477 struct out_routes_header hdr; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
478 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
479 outf = fopen("out-routes.newbin", "w"); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
480 if (!outf) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
481 perror("creating out-routes.newbin"); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
482 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
483 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
484 hdr.num_dest = dest_rec_count; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
485 hdr.num_inn = inn_rec_count; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
486 hdr.num_special = special_num_count; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
487 if (fwrite(&hdr, sizeof hdr, 1, outf) != 1) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
488 write_err: fprintf(stderr, "error writing to new binary file\n"); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
489 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
490 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
491 if (fwrite(dest_records, sizeof(dest_records[0]), dest_rec_count, outf) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
492 != dest_rec_count) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
493 goto write_err; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
494 if (fwrite(inn_records, sizeof(inn_records[0]), inn_rec_count, outf) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
495 != inn_rec_count) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
496 goto write_err; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
497 if (fwrite(special_num_records, sizeof(special_num_records[0]), |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
498 special_num_count, outf) != special_num_count) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
499 goto write_err; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
500 fclose(outf); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
501 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
502 |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
503 main(argc, argv) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
504 char **argv; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
505 { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
506 if (argc > 2) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
507 fprintf(stderr, "usage: %s [directory]\n", argv[0]); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
508 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
509 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
510 if (argv[1]) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
511 system_dir = argv[1]; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
512 else |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
513 system_dir = "/var/gsm"; |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
514 if (chdir(system_dir) < 0) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
515 perror(system_dir); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
516 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
517 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
518 inf = fopen("out-routes", "r"); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
519 if (!inf) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
520 perror("opening out-routes"); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
521 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
522 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
523 for (lineno = 1; fgets(linebuf, sizeof linebuf, inf); lineno++) |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
524 process_line(); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
525 fclose(inf); |
132
aa278d75d757
themwi-update-outrt: catch and reject empty tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
131
diff
changeset
|
526 if (!dest_rec_count) { |
aa278d75d757
themwi-update-outrt: catch and reject empty tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
131
diff
changeset
|
527 fprintf(stderr, "error: no SIP destinations defined\n"); |
aa278d75d757
themwi-update-outrt: catch and reject empty tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
131
diff
changeset
|
528 exit(1); |
aa278d75d757
themwi-update-outrt: catch and reject empty tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
131
diff
changeset
|
529 } |
aa278d75d757
themwi-update-outrt: catch and reject empty tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
131
diff
changeset
|
530 if (!inn_rec_count && !special_num_count) { |
aa278d75d757
themwi-update-outrt: catch and reject empty tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
131
diff
changeset
|
531 fprintf(stderr, "error: no routes defined\n"); |
aa278d75d757
themwi-update-outrt: catch and reject empty tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
131
diff
changeset
|
532 exit(1); |
aa278d75d757
themwi-update-outrt: catch and reject empty tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
131
diff
changeset
|
533 } |
130
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
534 emit_output(); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
535 /* make it live */ |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
536 if (rename("out-routes.newbin", "out-routes.bin") < 0) { |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
537 perror("rename"); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
538 exit(1); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
539 } |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
540 exit(0); |
44dc809ffec0
themwi-update-out-routes utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
541 } |