FreeCalypso > hg > themwi-system-sw
comparison utils/themwi-check-own.c @ 13:26b98505684e
themwi-check-own utility written, compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 26 Jun 2022 14:17:26 -0800 |
parents | |
children | 697fe2c87fec |
comparison
equal
deleted
inserted
replaced
12:6560915b0d27 | 13:26b98505684e |
---|---|
1 /* | |
2 * This utility performs a lookup in ThemWi number database to see | |
3 * if a given NANP number is owned by us. | |
4 */ | |
5 | |
6 #include <stdio.h> | |
7 #include <stdlib.h> | |
8 #include <syslog.h> | |
9 | |
10 main(argc, argv) | |
11 char **argv; | |
12 { | |
13 char nanp[11]; | |
14 | |
15 if (argc != 2) { | |
16 usage: fprintf(stderr, "usage: %s 10-digit-number\n", argv[0]); | |
17 exit(1); | |
18 } | |
19 if (grok_number_string(argv[1], 1) != 10) | |
20 goto usage; | |
21 dehyphen_number_string(argv[1], nanp); | |
22 if (!is_nanp_valid_prefix(nanp)) { | |
23 fprintf(stderr, "error: number violates NANP rules\n"); | |
24 exit(1); | |
25 } | |
26 openlog("themwi-check-own", 0, LOG_LOCAL5); | |
27 if (read_number_db() < 0) { | |
28 fprintf(stderr, "error reading number database\n"); | |
29 exit(1); | |
30 } | |
31 printf("+1-%.3s-%.3s-%s is %s\n", nanp, nanp+3, nanp+6, | |
32 is_nanp_locally_owned(nanp) ? "locally owned" | |
33 : "NOT owned by us"); | |
34 exit(0); | |
35 } |