# HG changeset patch # User Mychaela Falconia # Date 1692056104 28800 # Node ID 19d1c39ae4e79dc641b4c188a79fd9f43a35a2de # Parent 697fe2c87fec33e3a81f2d5c136b7edada5fdf4d themwi-short-dial: convert to libnumdb2 diff -r 697fe2c87fec -r 19d1c39ae4e7 utils/Makefile --- a/utils/Makefile Mon Aug 14 14:42:59 2023 -0800 +++ b/utils/Makefile Mon Aug 14 15:35:04 2023 -0800 @@ -43,8 +43,8 @@ themwi-dump-numdb2: themwi-dump-numdb2.c ${CC} ${CFLAGS} -o $@ $@.c -themwi-short-dial: themwi-short-dial.o ${LIBNUMDB} ${LIBUTIL} - ${CC} ${CFLAGS} -o $@ $@.o ${LIBNUMDB} ${LIBUTIL} +themwi-short-dial: themwi-short-dial.o ${LIBNUMDB2} ${LIBUTIL} + ${CC} ${CFLAGS} -o $@ $@.o ${LIBNUMDB2} ${LIBUTIL} themwi-update-numdb: themwi-update-numdb.o ${LIBUTIL} ${CC} ${CFLAGS} -o $@ $@.o ${LIBUTIL} diff -r 697fe2c87fec -r 19d1c39ae4e7 utils/themwi-short-dial.c --- a/utils/themwi-short-dial.c Mon Aug 14 14:42:59 2023 -0800 +++ b/utils/themwi-short-dial.c Mon Aug 14 15:35:04 2023 -0800 @@ -5,14 +5,16 @@ */ #include +#include #include #include +#include "../include/number_db_v2.h" +#include "../libnumdb2/lookup_func.h" main(argc, argv) char **argv; { - char nanp[11]; - int res; + struct short_number_rec *rec; if (argc != 2) { usage: fprintf(stderr, "usage: %s 4-digit-number\n", argv[0]); @@ -25,13 +27,26 @@ fprintf(stderr, "error reading number database\n"); exit(1); } - res = lookup_short_dial_number(argv[1], nanp); - if (!res) + rec = numdb_lookup_short(argv[1]); + if (!rec) { printf("Short number %s is not defined\n", argv[1]); - else if (nanp[0]) - printf("Short number %s maps to +1-%.3s-%.3s-%s\n", argv[1], - nanp, nanp+3, nanp+6); - else + exit(0); + } + switch (rec->short_num_type) { + case SHORT_NUM_TYPE_ABBREV: + printf("Short number %s is abbrev for +1-%03u-%03u-%04u\n", + 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); }