FreeCalypso > hg > themwi-nanp
comparison utils/themwi-short-dial.c @ 8:db3c657efafa
themwi-short-dial: old source as starting point
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Wed, 13 Dec 2023 03:39:48 +0000 |
| parents | |
| children | 0b4d54289ef3 |
comparison
equal
deleted
inserted
replaced
| 7:dc1554b7dfb8 | 8:db3c657efafa |
|---|---|
| 1 /* | |
| 2 * This command line utility looks up a 4-digit short dialing code | |
| 3 * in ThemWi number database and reports its status: not defined, | |
| 4 * ITN or mapping to NANP. | |
| 5 */ | |
| 6 | |
| 7 #include <stdio.h> | |
| 8 #include <stdint.h> | |
| 9 #include <stdlib.h> | |
| 10 #include <syslog.h> | |
| 11 #include "../include/number_db_v2.h" | |
| 12 #include "../libnumdb2/lookup_func.h" | |
| 13 | |
| 14 main(argc, argv) | |
| 15 char **argv; | |
| 16 { | |
| 17 struct short_number_rec *rec; | |
| 18 | |
| 19 if (argc != 2) { | |
| 20 usage: fprintf(stderr, "usage: %s 4-digit-number\n", argv[0]); | |
| 21 exit(1); | |
| 22 } | |
| 23 if (grok_number_string(argv[1], 0) != 4) | |
| 24 goto usage; | |
| 25 openlog("themwi-short-dial", 0, LOG_LOCAL5); | |
| 26 if (read_number_db() < 0) { | |
| 27 fprintf(stderr, "error reading number database\n"); | |
| 28 exit(1); | |
| 29 } | |
| 30 rec = numdb_lookup_short(argv[1]); | |
| 31 if (!rec) { | |
| 32 printf("Short number %s is not defined\n", argv[1]); | |
| 33 exit(0); | |
| 34 } | |
| 35 switch (rec->short_num_type) { | |
| 36 case SHORT_NUM_TYPE_ABBREV: | |
| 37 printf("Short number %s is abbrev for +1-%03u-%03u-%04u\n", | |
| 38 argv[1], rec->fullnum_prefix[0], rec->fullnum_prefix[1], | |
| 39 rec->short_num); | |
| 40 break; | |
| 41 case SHORT_NUM_TYPE_ITN: | |
| 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 } | |
| 51 exit(0); | |
| 52 } |
