# HG changeset patch # User Mychaela Falconia # Date 1702438788 0 # Node ID db3c657efafa6097d2480e4e361482f8443b82b4 # Parent dc1554b7dfb828eccb423811111a5d4db1fdfcdf themwi-short-dial: old source as starting point diff -r dc1554b7dfb8 -r db3c657efafa utils/themwi-short-dial.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utils/themwi-short-dial.c Wed Dec 13 03:39:48 2023 +0000 @@ -0,0 +1,52 @@ +/* + * This command line utility looks up a 4-digit short dialing code + * in ThemWi number database and reports its status: not defined, + * ITN or mapping to NANP. + */ + +#include +#include +#include +#include +#include "../include/number_db_v2.h" +#include "../libnumdb2/lookup_func.h" + +main(argc, argv) + char **argv; +{ + struct short_number_rec *rec; + + if (argc != 2) { +usage: fprintf(stderr, "usage: %s 4-digit-number\n", argv[0]); + exit(1); + } + if (grok_number_string(argv[1], 0) != 4) + goto usage; + openlog("themwi-short-dial", 0, LOG_LOCAL5); + if (read_number_db() < 0) { + fprintf(stderr, "error reading number database\n"); + exit(1); + } + rec = numdb_lookup_short(argv[1]); + if (!rec) { + printf("Short number %s is not defined\n", argv[1]); + exit(0); + } + switch (rec->short_num_type) { + case SHORT_NUM_TYPE_ABBREV: + printf("Short number %s is abbrev for +1-%03u-%03u-%04u\n", + argv[1], rec->fullnum_prefix[0], rec->fullnum_prefix[1], + rec->short_num); + break; + case SHORT_NUM_TYPE_ITN: + printf("Short number %s is an ITN\n", argv[1]); + break; + case SHORT_NUM_TYPE_TEST_SINK: + printf("Short number %s is a test sink\n", argv[1]); + break; + default: + printf("Short number %s has unknown type 0x%02X\n", argv[1], + rec->short_num_type); + } + exit(0); +}