FreeCalypso > hg > themwi-system-sw
annotate utils/themwi-short-dial.c @ 101:ca21fbf9d2ea
mgw: implement G.711 encoding
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 26 Sep 2022 15:21:05 -0800 |
parents | aea422af79dd |
children | 19d1c39ae4e7 |
rev | line source |
---|---|
14
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This command line utility looks up a 4-digit short dialing code |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * in ThemWi number database and reports its status: not defined, |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * ITN or mapping to NANP. |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 */ |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdio.h> |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdlib.h> |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <syslog.h> |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 main(argc, argv) |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 char **argv; |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 { |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 char nanp[11]; |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 int res; |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 if (argc != 2) { |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 usage: fprintf(stderr, "usage: %s 4-digit-number\n", argv[0]); |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 exit(1); |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 } |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 if (grok_number_string(argv[1], 0) != 4) |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 goto usage; |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 openlog("themwi-short-dial", 0, LOG_LOCAL5); |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 if (read_number_db() < 0) { |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 fprintf(stderr, "error reading number database\n"); |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 exit(1); |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 } |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 res = lookup_short_dial_number(argv[1], nanp); |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 if (!res) |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 printf("Short number %s is not defined\n", argv[1]); |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 else if (nanp[0]) |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 printf("Short number %s maps to +1-%.3s-%.3s-%s\n", argv[1], |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 nanp, nanp+3, nanp+6); |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 else |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 printf("Short number %s is an ITN\n", argv[1]); |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 exit(0); |
aea422af79dd
themwi-short-dial utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 } |