1 /*****************************************************************************/
2 /* */
3 /* ACTEST.C */
4 /* */
5 /* Test an areacode data file */
6 /* */
7 /* */
8 /* */
9 /* (C) 1996,97 Ullrich von Bassewitz */
10 /* Wacholderweg 14 */
11 /* D-70597 Stuttgart */
12 /* EMail: uz@musoftware.com */
13 /* */
14 /* */
15 /* This software is provided 'as-is', without any express or implied */
16 /* warranty. In no event will the authors be held liable for any damages */
17 /* arising from the use of this software. */
18 /* */
19 /* Permission is granted to anyone to use this software for any purpose, */
20 /* including commercial applications, and to alter it and redistribute it */
21 /* freely, subject to the following restrictions: */
22 /* */
23 /* 1. The origin of this software must not be misrepresented; you must not */
24 /* claim that you wrote the original software. If you use this software */
25 /* in a product, an acknowledgment in the product documentation would be */
26 /* appreciated but is not required. */
27 /* 2. Altered source versions must be plainly marked as such, and must not */
28 /* be misrepresented as being the original software. */
29 /* 3. This notice may not be removed or altered from any source */
30 /* distribution. */
31 /* */
32 /*****************************************************************************/
33
34
35
36 #include <stdio.h>
37 #include <string.h>
38 #include <stdlib.h>
39
40 #include "areacode.h"
41
42
43
main(int argc,char * argv[])44 int main (int argc, char* argv [])
45 {
46 acInfo AC;
47 char Buf [256];
48 unsigned RC;
49 acMaxMem = 0;
50
51 /* See if there is an argument given. If so, use it as name and path of
52 * the database.
53 */
54 if (argc >= 2) {
55 acFileName = argv [1];
56 }
57
58 /* Test loop */
59 while (1) {
60
61 printf ("Enter phone number: ");
62 fflush (stdout);
63 fgets (Buf, sizeof(Buf), stdin);
64 Buf[strcspn (Buf, "\n")] = '\0';
65 if (strlen (Buf) == 0) {
66 break;
67 }
68
69 switch ((RC = GetAreaCodeInfo (&AC, Buf))) {
70
71 case acOk:
72 printf ("acOK:\n"
73 " PrefixLen = %d\n"
74 " Info = %s\n",
75 AC.AreaCodeLen, AC.Info);
76 break;
77
78 case acFileError:
79 printf ("acFileError\n");
80 break;
81
82 case acInvalidFile:
83 printf ("acInvalidFile\n");
84 break;
85
86 case acWrongVersion:
87 printf ("acWrongVersion\n");
88 break;
89
90 default:
91 printf ("Unknown return: %u\n", RC);
92 break;
93
94 }
95 printf ("\n");
96
97 }
98
99 return 0;
100 }
101
102