FreeCalypso > hg > themwi-system-sw
changeset 238:697fe2c87fec
themwi-check-own: convert to libnumdb2
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 14 Aug 2023 14:42:59 -0800 |
parents | f78c097108a7 |
children | 19d1c39ae4e7 |
files | utils/Makefile utils/themwi-check-own.c |
diffstat | 2 files changed, 28 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/utils/Makefile Mon Aug 14 14:18:04 2023 -0800 +++ b/utils/Makefile Mon Aug 14 14:42:59 2023 -0800 @@ -5,6 +5,7 @@ themwi-update-numdb themwi-update-numdb2 themwi-update-outrt NOINST= rtp-alloc-test smpp-test1 smpp-test2 tcpserv-dump LIBNUMDB=../libnumdb/libnumdb.a +LIBNUMDB2=../libnumdb2/libnumdb.a LIBRTPA=../librtpalloc/librtpalloc.a LIBSIP= ../libsip/libsip.a LIBUTIL=../libutil/libutil.a @@ -33,8 +34,8 @@ tcpserv-dump: tcpserv-dump.c ${CC} ${CFLAGS} -o $@ $@.c -themwi-check-own: themwi-check-own.o ${LIBNUMDB} ${LIBUTIL} - ${CC} ${CFLAGS} -o $@ $@.o ${LIBNUMDB} ${LIBUTIL} +themwi-check-own: themwi-check-own.o ${LIBNUMDB2} ${LIBUTIL} + ${CC} ${CFLAGS} -o $@ $@.o ${LIBNUMDB2} ${LIBUTIL} themwi-dump-numdb: themwi-dump-numdb.c ${CC} ${CFLAGS} -o $@ $@.c
--- a/utils/themwi-check-own.c Mon Aug 14 14:18:04 2023 -0800 +++ b/utils/themwi-check-own.c Mon Aug 14 14:42:59 2023 -0800 @@ -4,13 +4,17 @@ */ #include <stdio.h> +#include <stdint.h> #include <stdlib.h> #include <syslog.h> +#include "../include/number_db_v2.h" +#include "../libnumdb2/lookup_func.h" main(argc, argv) char **argv; { char nanp[11]; + struct owned_number_rec *rec; if (argc != 2) { usage: fprintf(stderr, "usage: %s 10-digit-number\n", argv[0]); @@ -28,8 +32,26 @@ fprintf(stderr, "error reading number database\n"); exit(1); } - printf("+1-%.3s-%.3s-%s is %s\n", nanp, nanp+3, nanp+6, - is_nanp_locally_owned(nanp) ? "locally owned" - : "NOT owned by us"); + rec = numdb_lookup_nanp(nanp); + printf("+1-%.3s-%.3s-%s is ", nanp, nanp+3, nanp+6); + if (!rec) { + puts("NOT owned by us"); + exit(1); + } + fputs("locally owned, ", stdout); + switch (rec->usage & NUMBER_USAGE_MASK) { + case NUMBER_USAGE_TYPE_RSVD: + puts("reserved"); + break; + case NUMBER_USAGE_TYPE_GSM_SUB: + puts("assigned to a GSM subscriber"); + break; + case NUMBER_USAGE_TYPE_ALIAS: + printf("mapped to +1-%03u-%03u-%04u\n", rec->remap[0], + rec->remap[1], rec->remap[2]); + break; + default: + printf("unknown usage byte 0x%02X\n", rec->usage); + } exit(0); }