FreeCalypso > hg > themwi-system-sw
comparison utils/themwi-short-dial.c @ 239:19d1c39ae4e7
themwi-short-dial: convert to libnumdb2
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 14 Aug 2023 15:35:04 -0800 |
parents | aea422af79dd |
children | c7a3ba56c636 |
comparison
equal
deleted
inserted
replaced
238:697fe2c87fec | 239:19d1c39ae4e7 |
---|---|
3 * in ThemWi number database and reports its status: not defined, | 3 * in ThemWi number database and reports its status: not defined, |
4 * ITN or mapping to NANP. | 4 * ITN or mapping to NANP. |
5 */ | 5 */ |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <stdint.h> | |
8 #include <stdlib.h> | 9 #include <stdlib.h> |
9 #include <syslog.h> | 10 #include <syslog.h> |
11 #include "../include/number_db_v2.h" | |
12 #include "../libnumdb2/lookup_func.h" | |
10 | 13 |
11 main(argc, argv) | 14 main(argc, argv) |
12 char **argv; | 15 char **argv; |
13 { | 16 { |
14 char nanp[11]; | 17 struct short_number_rec *rec; |
15 int res; | |
16 | 18 |
17 if (argc != 2) { | 19 if (argc != 2) { |
18 usage: fprintf(stderr, "usage: %s 4-digit-number\n", argv[0]); | 20 usage: fprintf(stderr, "usage: %s 4-digit-number\n", argv[0]); |
19 exit(1); | 21 exit(1); |
20 } | 22 } |
23 openlog("themwi-short-dial", 0, LOG_LOCAL5); | 25 openlog("themwi-short-dial", 0, LOG_LOCAL5); |
24 if (read_number_db() < 0) { | 26 if (read_number_db() < 0) { |
25 fprintf(stderr, "error reading number database\n"); | 27 fprintf(stderr, "error reading number database\n"); |
26 exit(1); | 28 exit(1); |
27 } | 29 } |
28 res = lookup_short_dial_number(argv[1], nanp); | 30 rec = numdb_lookup_short(argv[1]); |
29 if (!res) | 31 if (!rec) { |
30 printf("Short number %s is not defined\n", argv[1]); | 32 printf("Short number %s is not defined\n", argv[1]); |
31 else if (nanp[0]) | 33 exit(0); |
32 printf("Short number %s maps to +1-%.3s-%.3s-%s\n", argv[1], | 34 } |
33 nanp, nanp+3, nanp+6); | 35 switch (rec->short_num_type) { |
34 else | 36 case SHORT_NUM_TYPE_ABBREV: |
37 printf("Short number %s is abbrev for +1-%03u-%03u-%04u\n", | |
38 rec->fullnum_prefix[0], rec->fullnum_prefix[1], | |
39 rec->short_num); | |
40 break; | |
41 case SHORT_NUM_TYPE_ITN: | |
35 printf("Short number %s is an ITN\n", argv[1]); | 42 printf("Short number %s is an ITN\n", argv[1]); |
43 break; | |
44 case SHORT_NUM_TYPE_TEST_SINK: | |
45 printf("Short number %s is a test sink\n", argv[1]); | |
46 break; | |
47 default: | |
48 printf("Short number %s has unknown type 0x%02X\n", argv[1], | |
49 rec->short_num_type); | |
50 } | |
36 exit(0); | 51 exit(0); |
37 } | 52 } |