FreeCalypso > hg > themwi-nanp
annotate utils/themwi-update-numdb.c @ 14:78319ed870dc
convert to new ThemWi configure and build system
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 21 May 2024 00:15:24 +0000 |
parents | 5bf2648e5413 |
children |
rev | line source |
---|---|
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This program reads (parses) ThemWi config file /var/gsm/number-db2, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * generates the compiled binary form of this database, and then makes |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * it live via atomic rename. |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 */ |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <ctype.h> |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdio.h> |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdint.h> |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdlib.h> |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <string.h> |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <strings.h> |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <unistd.h> |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
14 |
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
15 #include <themwi/nanp/number_db_v2.h> |
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
16 #include <themwi/nanp/number_utils.h> |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 #define MAX_OWNED_NUMBERS 1000 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 #define MAX_SHORT_NUMBERS 1000 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 static struct owned_number_rec owned_number_buf[MAX_OWNED_NUMBERS]; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 static struct short_number_rec short_number_buf[MAX_SHORT_NUMBERS]; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 static unsigned owned_number_count, short_number_count; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 static char *system_dir; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 static FILE *inf; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 static int lineno; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 static char linebuf[256]; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 static int prefix_set, prefix_allows_abbrev; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 static uint16_t prefix_buf[2]; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
32 static void enter_owned_number(const struct owned_number_rec *rec) |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 if (owned_number_count >= MAX_OWNED_NUMBERS) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 fprintf(stderr, "error: MAX_OWNED_NUMBERS exceeded\n"); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 bcopy(rec, owned_number_buf + owned_number_count, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 sizeof(struct owned_number_rec)); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 owned_number_count++; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
43 static void enter_short_number(const struct short_number_rec *rec) |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 if (short_number_count >= MAX_SHORT_NUMBERS) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 fprintf(stderr, "error: MAX_SHORT_NUMBERS exceeded\n"); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 bcopy(rec, short_number_buf + short_number_count, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 sizeof(struct short_number_rec)); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 short_number_count++; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
54 static void handle_prefix_line(char *cp) |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 char *np, prefix[7]; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 for (np = cp; *cp && !isspace(*cp); cp++) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 ; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 if (*cp) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 *cp++ = '\0'; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 if (grok_number_string(np, 1) != 6) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 "number-db2 line %d: prefix requires 6-digit argument\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 lineno); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 dehyphen_number_string(np, prefix); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 if (!is_nanp_valid_prefix(prefix)) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 "number-db2 line %d: prefix violates NANP rules\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 lineno); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 prefix_buf[0] = digits3_to_uint16(prefix); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 prefix_buf[1] = digits3_to_uint16(prefix + 3); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 prefix_set = 1; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 while (isspace(*cp)) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 cp++; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 if (*cp == '\0' || *cp == '#') { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 prefix_allows_abbrev = 0; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 return; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 for (np = cp; *cp && !isspace(*cp); cp++) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 ; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 if (*cp) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 *cp++ = '\0'; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 if (!strcmp(np, "allow-abbrev")) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 prefix_allows_abbrev = 1; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 return; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 "number-db2 line %d: non-understood notation \"%s\" after prefix\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 lineno, np); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
98 static int parse_extra_number(struct owned_number_rec *rec, const char *numstr) |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 char buf[11]; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 int rc; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 rc = grok_number_string(numstr, 1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 switch (rc) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 case 4: |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 if (!prefix_set) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 return(-1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 dehyphen_number_string(numstr, buf); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 rec->remap[0] = prefix_buf[0]; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 rec->remap[1] = prefix_buf[1]; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 rec->remap[2] = digits4_to_uint16(buf); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 return(0); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 case 10: |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 dehyphen_number_string(numstr, buf); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 rec->remap[0] = digits3_to_uint16(buf); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 rec->remap[1] = digits3_to_uint16(buf + 3); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 rec->remap[2] = digits4_to_uint16(buf + 6); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 return(0); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 default: |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 return(-1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
124 static void handle_number_attr(struct owned_number_rec *rec, char *tail) |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 char *cp, *np; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 int rc; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 for (cp = tail; ; ) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 while (isspace(*cp)) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 cp++; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 if (*cp == '\0' || *cp == '#') |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 return; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 for (np = cp; *cp && !isspace(*cp); cp++) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 ; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 if (*cp) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 *cp++ = '\0'; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 if (!strcmp(np, "sms")) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 rec->number_flags |= NUMBER_FLAG_SMSPROV; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 else if (!strcmp(np, "e911")) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 rec->number_flags |= NUMBER_FLAG_E911PROV; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 else if (!strcmp(np, "gsm-sub")) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 rec->usage = NUMBER_USAGE_TYPE_GSM_SUB; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 else if (!strcmp(np, "map-to")) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 rec->usage = NUMBER_USAGE_TYPE_ALIAS; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 while (isspace(*cp)) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 cp++; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 if (*cp == '\0' || *cp == '#') { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 "number-db2 line %d: map-to requires an argument\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 lineno); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 for (np = cp; *cp && !isspace(*cp); cp++) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 ; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 if (*cp) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 *cp++ = '\0'; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 rc = parse_extra_number(rec, np); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 if (rc < 0) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 "number-db2 line %d: map-to argument is invalid\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 lineno); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 } else if (!strcmp(np, "e911-via")) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 if (rec->usage != NUMBER_USAGE_TYPE_GSM_SUB) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 "number-db2 line %d: invalid usage of e911-via\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 lineno); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 rec->usage |= NUMBER_USAGE_FLAG_E911_VIA; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 while (isspace(*cp)) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 cp++; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 if (*cp == '\0' || *cp == '#') { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 "number-db2 line %d: e911-via requires an argument\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 lineno); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 for (np = cp; *cp && !isspace(*cp); cp++) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 ; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 if (*cp) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 *cp++ = '\0'; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 rc = parse_extra_number(rec, np); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 if (rc < 0) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 "number-db2 line %d: e911-via argument is invalid\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 lineno); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 } else { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 "number-db2 line %d: invalid attribute \"%s\"\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 lineno, np); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
201 static void handle_suffix_line(char *cp) |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 char *np; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 uint16_t suffix; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 struct owned_number_rec own_rec; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 struct short_number_rec short_rec; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 if (!prefix_set) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 "number-db2 line %d: suffix not valid without preceding prefix\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 lineno); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 for (np = cp; *cp && !isspace(*cp); cp++) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 ; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 if (*cp) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 *cp++ = '\0'; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 if (grok_number_string(np, 0) != 4) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 "number-db2 line %d: suffix requires 4-digit argument\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 lineno); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 suffix = digits4_to_uint16(np); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 bzero(&own_rec, sizeof own_rec); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 own_rec.number[0] = prefix_buf[0]; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 own_rec.number[1] = prefix_buf[1]; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 own_rec.number[2] = suffix; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 handle_number_attr(&own_rec, cp); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 enter_owned_number(&own_rec); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 if (!prefix_allows_abbrev) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 return; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 if ((own_rec.usage & NUMBER_USAGE_MASK) != NUMBER_USAGE_TYPE_GSM_SUB) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 return; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 bzero(&short_rec, sizeof short_rec); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 short_rec.short_num = suffix; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 short_rec.short_num_type = SHORT_NUM_TYPE_ABBREV; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 short_rec.fullnum_flags = own_rec.number_flags; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 short_rec.fullnum_prefix[0] = prefix_buf[0]; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 short_rec.fullnum_prefix[1] = prefix_buf[1]; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 enter_short_number(&short_rec); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
244 static void handle_full10_line(char *cp) |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 char *np, full10[11]; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 struct owned_number_rec own_rec; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 prefix_set = 0; /* cancel any previous prefix line */ |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 for (np = cp; *cp && !isspace(*cp); cp++) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 ; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 if (*cp) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 *cp++ = '\0'; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 if (grok_number_string(np, 1) != 10) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 "number-db2 line %d: full10 requires 10-digit argument\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 lineno); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 dehyphen_number_string(np, full10); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 if (!is_nanp_valid_prefix(full10)) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 "number-db2 line %d: number violates NANP rules\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 lineno); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 bzero(&own_rec, sizeof own_rec); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 own_rec.number[0] = digits3_to_uint16(full10); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 own_rec.number[1] = digits3_to_uint16(full10 + 3); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 own_rec.number[2] = digits4_to_uint16(full10 + 6); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 handle_number_attr(&own_rec, cp); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 enter_owned_number(&own_rec); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
275 static void handle_itn_line(char *cp) |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 char *np; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 struct short_number_rec short_rec; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 prefix_set = 0; /* cancel any previous prefix line */ |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 for (np = cp; *cp && !isspace(*cp); cp++) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 ; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 if (*cp) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 *cp++ = '\0'; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 if (grok_number_string(np, 0) != 4) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 "number-db2 line %d: itn requires 4-digit argument\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 lineno); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 bzero(&short_rec, sizeof short_rec); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 short_rec.short_num = digits4_to_uint16(np); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 short_rec.short_num_type = SHORT_NUM_TYPE_ITN; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 enter_short_number(&short_rec); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
297 static void handle_test_sink_line(char *cp) |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 char *np; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 struct short_number_rec short_rec; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 prefix_set = 0; /* cancel any previous prefix line */ |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 for (np = cp; *cp && !isspace(*cp); cp++) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 ; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 if (*cp) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 *cp++ = '\0'; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 if (grok_number_string(np, 0) != 4) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 "number-db2 line %d: test-sink requires 4-digit argument\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 lineno); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 bzero(&short_rec, sizeof short_rec); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 short_rec.short_num = digits4_to_uint16(np); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 short_rec.short_num_type = SHORT_NUM_TYPE_TEST_SINK; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 enter_short_number(&short_rec); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
319 static void process_line(void) |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 char *cp, *np; |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
322 void (*handler)(char *); |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 if (!index(linebuf, '\n')) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 "number-db2 line %d: too long or missing newline\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 lineno); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 for (cp = linebuf; isspace(*cp); cp++) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 ; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 if (*cp == '\0' || *cp == '#') |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 return; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
334 for (np = cp; *cp && !isspace(*cp); cp++) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
335 ; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
336 if (*cp) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
337 *cp++ = '\0'; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
338 if (!strcmp(np, "prefix")) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
339 handler = handle_prefix_line; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
340 else if (!strcmp(np, "suffix")) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
341 handler = handle_suffix_line; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 else if (!strcmp(np, "full10")) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 handler = handle_full10_line; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
344 else if (!strcmp(np, "itn")) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
345 handler = handle_itn_line; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
346 else if (!strcmp(np, "test-sink")) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 handler = handle_test_sink_line; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
348 else { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
349 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
350 "number-db2 line %d: non-understood keyword \"%s\"\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
351 lineno, np); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
352 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
353 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
354 while (isspace(*cp)) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
355 cp++; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
356 if (*cp == '\0' || *cp == '#') { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
357 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
358 "number-db2 line %d: missing argument after \"%s\" keyword\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
359 lineno, np); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
360 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
361 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
362 handler(cp); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
363 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
364 |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
365 static int compare_owned_num(const void *p1v, const void *p2v) |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
366 { |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
367 const uint16_t *p1 = p1v, *p2 = p2v; |
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
368 |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
369 if (p1[0] < p2[0]) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
370 return(-1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
371 if (p1[0] > p2[0]) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
372 return(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
373 if (p1[1] < p2[1]) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
374 return(-1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
375 if (p1[1] > p2[1]) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
376 return(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
377 if (p1[2] < p2[2]) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
378 return(-1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
379 if (p1[2] > p2[2]) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
380 return(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
381 return(0); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
382 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
383 |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
384 static int compare_short_num(const void *p1v, const void *p2v) |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
385 { |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
386 const uint16_t *p1 = p1v, *p2 = p2v; |
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
387 |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
388 if (*p1 < *p2) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
389 return(-1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
390 if (*p1 > *p2) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
391 return(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
392 return(0); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
393 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
394 |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
395 static void owned_num_check_dup(void) |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
396 { |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
397 const struct owned_number_rec *p, *endp; |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
398 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
399 endp = owned_number_buf + owned_number_count - 1; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
400 for (p = owned_number_buf; p < endp; p++) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
401 if (p[0].number[0] == p[1].number[0] && |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
402 p[0].number[1] == p[1].number[1] && |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
403 p[0].number[2] == p[1].number[2]) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
404 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
405 "error: NANP number %03u-%03u-%04u appears more than once\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
406 p[0].number[0], p[0].number[1], p[0].number[2]); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
407 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
408 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
409 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
410 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
411 |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
412 static void short_num_check_dup(void) |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
413 { |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
414 const struct short_number_rec *p, *endp; |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
415 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
416 endp = short_number_buf + short_number_count - 1; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
417 for (p = short_number_buf; p < endp; p++) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
418 if (p[0].short_num == p[1].short_num) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
419 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
420 "error: short number %04u appears more than once\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
421 (unsigned) p->short_num); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
422 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
423 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
424 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
425 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
426 |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
427 static void check_secondnum_mapto(const struct owned_number_rec *src) |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
428 { |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
429 const struct owned_number_rec *dest; |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
430 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
431 dest = bsearch(src->remap, owned_number_buf, owned_number_count, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
432 sizeof(struct owned_number_rec), compare_owned_num); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
433 if (!dest) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
434 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
435 "error: NANP %03u-%03u-%04u map-to target is not in the database\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
436 src->number[0], src->number[1], src->number[2]); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
437 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
438 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
439 if ((dest->usage & NUMBER_USAGE_MASK) != NUMBER_USAGE_TYPE_GSM_SUB) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
440 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
441 "error: NANP %03u-%03u-%04u map-to target is not a gsm-sub number\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
442 src->number[0], src->number[1], src->number[2]); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
443 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
444 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
445 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
446 |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
447 static void check_secondnum_e911via(const struct owned_number_rec *src) |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
448 { |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
449 const struct owned_number_rec *dest; |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
450 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
451 dest = bsearch(src->remap, owned_number_buf, owned_number_count, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
452 sizeof(struct owned_number_rec), compare_owned_num); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
453 if (!dest) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
454 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
455 "error: NANP %03u-%03u-%04u e911-via target is not in the database\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
456 src->number[0], src->number[1], src->number[2]); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
457 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
458 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
459 if (!(dest->number_flags & NUMBER_FLAG_E911PROV)) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
460 fprintf(stderr, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
461 "error: NANP %03u-%03u-%04u e911-via target is not an E911 number\n", |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
462 src->number[0], src->number[1], src->number[2]); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
463 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
464 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
465 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
466 |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
467 static void check_secondary_numbers(void) |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
468 { |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
469 const struct owned_number_rec *p, *endp; |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
470 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
471 endp = owned_number_buf + owned_number_count; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
472 for (p = owned_number_buf; p < endp; p++) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
473 if ((p->usage & NUMBER_USAGE_MASK) == NUMBER_USAGE_TYPE_ALIAS) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
474 check_secondnum_mapto(p); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
475 if (p->usage & NUMBER_USAGE_FLAG_E911_VIA) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
476 check_secondnum_e911via(p); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
477 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
478 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
479 |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
480 static void emit_output(void) |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
481 { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
482 FILE *outf; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
483 struct numdb_file_hdr hdr; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
484 |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
485 outf = fopen("number-db2.newbin", "w"); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
486 if (!outf) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
487 perror("creating number-db2.newbin"); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
488 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
489 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
490 hdr.owned_number_count = owned_number_count; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
491 hdr.short_number_count = short_number_count; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
492 if (fwrite(&hdr, sizeof hdr, 1, outf) != 1) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
493 write_err: fprintf(stderr, "error writing to new binary file\n"); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
494 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
495 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
496 if (fwrite(owned_number_buf, sizeof(owned_number_buf[0]), |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
497 owned_number_count, outf) != owned_number_count) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
498 goto write_err; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
499 if (fwrite(short_number_buf, sizeof(short_number_buf[0]), |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
500 short_number_count, outf) != short_number_count) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
501 goto write_err; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
502 fclose(outf); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
503 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
504 |
3
5bf2648e5413
themwi-update-numdb compiles in the new model
Mychaela Falconia <falcon@freecalypso.org>
parents:
2
diff
changeset
|
505 int main(int argc, char **argv) |
2
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
506 { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
507 if (argc > 2) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
508 fprintf(stderr, "usage: %s [directory]\n", argv[0]); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
509 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
510 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
511 if (argv[1]) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
512 system_dir = argv[1]; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
513 else |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
514 system_dir = "/var/gsm"; |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
515 if (chdir(system_dir) < 0) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
516 perror(system_dir); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
517 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
518 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
519 inf = fopen("number-db2", "r"); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
520 if (!inf) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
521 perror("opening number-db2"); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
522 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
523 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
524 for (lineno = 1; fgets(linebuf, sizeof linebuf, inf); lineno++) |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
525 process_line(); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
526 fclose(inf); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
527 if (owned_number_count >= 2) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
528 qsort(owned_number_buf, owned_number_count, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
529 sizeof(owned_number_buf[0]), compare_owned_num); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
530 owned_num_check_dup(); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
531 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
532 check_secondary_numbers(); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
533 if (short_number_count >= 2) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
534 qsort(short_number_buf, short_number_count, |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
535 sizeof(short_number_buf[0]), compare_short_num); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
536 short_num_check_dup(); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
537 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
538 emit_output(); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
539 /* make it live */ |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
540 if (rename("number-db2.newbin", "number-db2.bin") < 0) { |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
541 perror("rename"); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
542 exit(1); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
543 } |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
544 exit(0); |
1773886ef54e
themwi-update-numdb: old source as starting point
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
545 } |