comparison utils/themwi-short-dial.c @ 14:aea422af79dd

themwi-short-dial utility written, compiles
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 26 Jun 2022 14:42:33 -0800
parents
children 19d1c39ae4e7
comparison
equal deleted inserted replaced
13:26b98505684e 14:aea422af79dd
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 <stdlib.h>
9 #include <syslog.h>
10
11 main(argc, argv)
12 char **argv;
13 {
14 char nanp[11];
15 int res;
16
17 if (argc != 2) {
18 usage: fprintf(stderr, "usage: %s 4-digit-number\n", argv[0]);
19 exit(1);
20 }
21 if (grok_number_string(argv[1], 0) != 4)
22 goto usage;
23 openlog("themwi-short-dial", 0, LOG_LOCAL5);
24 if (read_number_db() < 0) {
25 fprintf(stderr, "error reading number database\n");
26 exit(1);
27 }
28 res = lookup_short_dial_number(argv[1], nanp);
29 if (!res)
30 printf("Short number %s is not defined\n", argv[1]);
31 else if (nanp[0])
32 printf("Short number %s maps to +1-%.3s-%.3s-%s\n", argv[1],
33 nanp, nanp+3, nanp+6);
34 else
35 printf("Short number %s is an ITN\n", argv[1]);
36 exit(0);
37 }