1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                AREACODE.H                                 */
4 /*                                                                           */
5 /*     Portable library module to search for an area code in a database.     */
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 /*
37  * The code assumes
38  *      - 8 bit bytes
39  *      - unsigned long is 32 bit. This may be changed by #defining u32 to
40  *        a data type that is an 32 bit unsigned when compiling this module.
41  *      - ascii character set
42  *
43  * The code does *not* assume
44  *      - a specific byte order. Currently the code autoadjusts to big or
45  *        little endian data. If you have something more weird than that,
46  *        you have to add conversion code.
47  *
48  */
49 
50 
51 
52 #ifndef _AREACODE_H
53 #define _AREACODE_H
54 
55 
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 
62 
63 /*****************************************************************************/
64 /*                        Data, structs and constants                        */
65 /*****************************************************************************/
66 
67 
68 
69 /* The name of the areacode data file. The default is what is #defined as
70  * DATA_FILENAME. If this is not #defined, the default is "areacode.dat",
71  * which is probably not what you want. In the latter case set this to
72  * the correct filename *before* your first call to GetAreaCodeInfo.
73  */
74 extern char* acFileName;
75 
76 /* How much dynamic memory is GetAreaCodeInfo allowed to consume? Having less
77  * memory means more disk access and vice versa. The function does even work
78  * if you set this value to zero. For maximum performance, the function needs
79  * 4 byte per area code stored in the data file. The default is 32KB.
80  */
81 extern unsigned long acMaxMem;
82 
83 /* Result codes of GetAreaCodeInfo */
84 #define acOk            0       /* Done */
85 #define acFileError     1       /* Cannot open/read file */
86 #define acInvalidFile   2       /* The file exists but is no area code data file */
87 #define acWrongVersion  3       /* Wrong version of data file */
88 
89 /* The result of an area code search */
90 typedef struct {
91     unsigned    AreaCodeLen;    /* The length of the area code found */
92     char        Info [256];     /* An info string */
93 } acInfo;
94 
95 
96 
97 /*****************************************************************************/
98 /*                                   Code                                    */
99 /*****************************************************************************/
100 
101 
102 
103 unsigned GetAreaCodeInfo (acInfo* /*AC*/ , const char* /*PhoneNumber*/);
104 /* Return - if possible - an information for the area code of the given number.
105  * The function returns one of the error codes defined in areacode.h. If the
106  * returned value is acOk, the AC struct is filled with the data of the
107  * area code found. If we did not have an error, but there is no area code
108  * that corresponds to the given number, the function returns acOk, but the
109  * AC struct is filled with an empty Info field and a AreaCodeLen of zero.
110  */
111 
112 
113 
114 #ifdef __cplusplus
115 }
116 #endif
117 
118 
119 
120 /* End of AREACODE.H */
121 
122 #endif
123 
124