summaryrefslogtreecommitdiff
path: root/src/qcommon/IpToCountryResolver.h
blob: cf97cf8193cee77460225cf4b338d3fc98205c8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef IPTOCOUNTRYRESOLVER_H_INCLUDED
#define IPTOCOUNTRYRESOLVER_H_INCLUDED

#define FULL_NAME_LENGTH 64

typedef struct {
        unsigned int ipFrom;
        unsigned int ipTo;
        char name2[2+1]; //1 for zero character (line end)
        char name3[3+1];
        char nameFull[FULL_NAME_LENGTH];
} IpToCountryInfo;

typedef struct {
    unsigned int size;
    IpToCountryInfo *infoArray;
} IpToCountryList;

unsigned int ipstr_to_int (const char *cp_arg);
unsigned int ipbyte_to_int(unsigned int parts[4], unsigned int length);
unsigned int LoadIp2CountryInfo(const char *fileName, IpToCountryList *infoList, int camelCaseNames);
IpToCountryInfo *FindCountryInfoS(const char *ip_addr, IpToCountryList *infoList);
IpToCountryInfo *FindCountryInfoB(unsigned int parts[4], unsigned int length, IpToCountryList *infoList);
IpToCountryInfo *FindCountryInfoUI(unsigned int ip, IpToCountryList *infoList);

#endif // IPTOCOUNTRYRESOLVER_H_INCLUDED