mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-24 13:55:36 +03:00
Initial import
This commit is contained in:
parent
9df4374195
commit
55b57ca0cb
686
dlls/geoip/GeoIP.c
Executable file
686
dlls/geoip/GeoIP.c
Executable file
@ -0,0 +1,686 @@
|
||||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
|
||||
/* GeoIP.c
|
||||
*
|
||||
* Copyright (C) 2003 MaxMind LLC All Rights Reserved.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "GeoIP.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifndef _WIN32
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h> /* For ntohl */
|
||||
#else
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
#include <sys/types.h> /* for fstat */
|
||||
#include <sys/stat.h> /* for fstat */
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h> /* For uint32_t */
|
||||
#endif
|
||||
|
||||
#define COUNTRY_BEGIN 16776960
|
||||
#define STATE_BEGIN_REV0 16700000
|
||||
#define STATE_BEGIN_REV1 16000000
|
||||
#define STRUCTURE_INFO_MAX_SIZE 20
|
||||
#define DATABASE_INFO_MAX_SIZE 100
|
||||
#define MAX_ORG_RECORD_LENGTH 300
|
||||
#define US_OFFSET 1
|
||||
#define CANADA_OFFSET 677
|
||||
#define WORLD_OFFSET 1353
|
||||
#define FIPS_RANGE 360
|
||||
|
||||
#define CHECK_ERR(err, msg) { \
|
||||
if (err != Z_OK) { \
|
||||
fprintf(stderr, "%s error: %d\n", msg, err); \
|
||||
exit(1); \
|
||||
} \
|
||||
}
|
||||
|
||||
const char GeoIP_country_code[247][3] = { "--","AP","EU","AD","AE","AF","AG","AI","AL","AM","AN","AO","AQ","AR","AS","AT","AU","AW","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BM","BN","BO","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","FX","GA","GB","GD","GE","GF","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IN","IO","IQ","IR","IS","IT","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA","RE","RO","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","ST","SV","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TM","TN","TO","TP","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","YE","YT","YU","ZA","ZM","ZR","ZW","A1","A2","O1"};
|
||||
|
||||
const char GeoIP_country_code3[247][4] = { "--","AP","EU","AND","ARE","AFG","ATG","AIA","ALB","ARM","ANT","AGO","AQ","ARG","ASM","AUT","AUS","ABW","AZE","BIH","BRB","BGD","BEL","BFA","BGR","BHR","BDI","BEN","BMU","BRN","BOL","BRA","BHS","BTN","BV","BWA","BLR","BLZ","CAN","CC","COD","CAF","COG","CHE","CIV","COK","CHL","CMR","CHN","COL","CRI","CUB","CPV","CX","CYP","CZE","DEU","DJI","DNK","DMA","DOM","DZA","ECU","EST","EGY","ESH","ERI","ESP","ETH","FIN","FJI","FLK","FSM","FRO","FRA","FX","GAB","GBR","GRD","GEO","GUF","GHA","GIB","GRL","GMB","GIN","GLP","GNQ","GRC","GS","GTM","GUM","GNB","GUY","HKG","HM","HND","HRV","HTI","HUN","IDN","IRL","ISR","IND","IO","IRQ","IRN","ISL","ITA","JAM","JOR","JPN","KEN","KGZ","KHM","KIR","COM","KNA","PRK","KOR","KWT","CYM","KAZ","LAO","LBN","LCA","LIE","LKA","LBR","LSO","LTU","LUX","LVA","LBY","MAR","MCO","MDA","MDG","MHL","MKD","MLI","MMR","MNG","MAC","MNP","MTQ","MRT","MSR","MLT","MUS","MDV","MWI","MEX","MYS","MOZ","NAM","NCL","NER","NFK","NGA","NIC","NLD","NOR","NPL","NRU","NIU","NZL","OMN","PAN","PER","PYF","PNG","PHL","PAK","POL","SPM","PCN","PRI","PSE","PRT","PLW","PRY","QAT","REU","ROU","RUS","RWA","SAU","SLB","SYC","SDN","SWE","SGP","SHN","SVN","SJM","SVK","SLE","SMR","SEN","SOM","SUR","STP","SLV","SYR","SWZ","TCA","TCD","TF","TGO","THA","TJK","TKL","TLS","TKM","TUN","TON","TUR","TTO","TUV","TWN","TZA","UKR","UGA","UM","USA","URY","UZB","VAT","VCT","VEN","VGB","VIR","VNM","VUT","WLF","WSM","YEM","YT","YUG","ZAF","ZMB","ZR","ZWE","A1","A2","O1"};
|
||||
|
||||
const char * GeoIP_country_name[247] = {"N/A","Asia/Pacific Region","Europe","Andorra","United Arab Emirates","Afghanistan","Antigua and Barbuda","Anguilla","Albania","Armenia","Netherlands Antilles","Angola","Antarctica","Argentina","American Samoa","Austria","Australia","Aruba","Azerbaijan","Bosnia and Herzegovina","Barbados","Bangladesh","Belgium","Burkina Faso","Bulgaria","Bahrain","Burundi","Benin","Bermuda","Brunei Darussalam","Bolivia","Brazil","Bahamas","Bhutan","Bouvet Island","Botswana","Belarus","Belize","Canada","Cocos (Keeling) Islands","Congo, The Democratic Republic of the","Central African Republic","Congo","Switzerland","Cote D'Ivoire","Cook Islands","Chile","Cameroon","China","Colombia","Costa Rica","Cuba","Cape Verde","Christmas Island","Cyprus","Czech Republic","Germany","Djibouti","Denmark","Dominica","Dominican Republic","Algeria","Ecuador","Estonia","Egypt","Western Sahara","Eritrea","Spain","Ethiopia","Finland","Fiji","Falkland Islands (Malvinas)","Micronesia, Federated States of","Faroe Islands","France","France, Metropolitan","Gabon","United Kingdom","Grenada","Georgia","French Guiana","Ghana","Gibraltar","Greenland","Gambia","Guinea","Guadeloupe","Equatorial Guinea","Greece","South Georgia and the South Sandwich Islands","Guatemala","Guam","Guinea-Bissau","Guyana","Hong Kong","Heard Island and McDonald Islands","Honduras","Croatia","Haiti","Hungary","Indonesia","Ireland","Israel","India","British Indian Ocean Territory","Iraq","Iran, Islamic Republic of","Iceland","Italy","Jamaica","Jordan","Japan","Kenya","Kyrgyzstan","Cambodia","Kiribati","Comoros","Saint Kitts and Nevis",
|
||||
"Korea, Democratic People's Republic of","Korea, Republic of","Kuwait","Cayman Islands","Kazakhstan","Lao People's Democratic Republic","Lebanon","Saint Lucia","Liechtenstein","Sri Lanka","Liberia","Lesotho","Lithuania","Luxembourg","Latvia","Libyan Arab Jamahiriya","Morocco","Monaco","Moldova, Republic of","Madagascar","Marshall Islands","Macedonia","Mali","Myanmar","Mongolia","Macau","Northern Mariana Islands","Martinique","Mauritania","Montserrat","Malta","Mauritius","Maldives","Malawi","Mexico","Malaysia","Mozambique","Namibia","New Caledonia","Niger","Norfolk Island","Nigeria","Nicaragua","Netherlands","Norway","Nepal","Nauru","Niue","New Zealand","Oman","Panama","Peru","French Polynesia","Papua New Guinea","Philippines","Pakistan","Poland","Saint Pierre and Miquelon","Pitcairn Islands","Puerto Rico","Palestinian Territory, Occupied","Portugal","Palau","Paraguay","Qatar","Reunion","Romania","Russian Federation","Rwanda","Saudi Arabia","Solomon Islands","Seychelles","Sudan","Sweden","Singapore","Saint Helena","Slovenia","Svalbard and Jan Mayen","Slovakia","Sierra Leone","San Marino","Senegal","Somalia","Suriname","Sao Tome and Principe","El Salvador","Syrian Arab Republic","Swaziland","Turks and Caicos Islands","Chad","French Southern Territories","Togo","Thailand","Tajikistan","Tokelau","Turkmenistan","Tunisia","Tonga","East Timor","Turkey","Trinidad and Tobago","Tuvalu","Taiwan","Tanzania, United Republic of","Ukraine","Uganda","United States Minor Outlying Islands","United States","Uruguay","Uzbekistan","Holy See (Vatican City State)","Saint Vincent and the Grenadines","Venezuela","Virgin Islands, British","Virgin Islands, U.S.","Vietnam","Vanuatu","Wallis and Futuna","Samoa","Yemen","Mayotte","Yugoslavia","South Africa","Zambia","Zaire","Zimbabwe",
|
||||
"Anonymous Proxy","Satellite Provider","Other"};
|
||||
|
||||
const char GeoIP_country_continent[247][3] = {"--","AS","EU","EU","AS","AS","SA","SA","EU","AS","SA","AF","AN","SA","OC","EU","OC","SA","AS","EU","SA","AS","EU","AF","EU","AS","AF","AF","SA","AS","SA","SA","SA","AS","AF","AF","EU","SA","NA","AS","AF","AF","AF","EU","AF","OC","SA","AF","AS","SA","SA","SA","AF","AS","AS","EU","EU","AF","EU","SA","SA","AF","SA","EU","AF","AF","AF","EU","AF","EU","OC","SA","OC","EU","EU","EU","AF","EU","SA","AS","SA","AF","EU","SA","AF","AF","SA","AF","EU","SA","SA","OC","AF","SA","AS","AF","SA","EU","SA","EU","AS","EU","AS","AS","AS","AS","AS","EU","EU","SA","AS","AS","AF","AS","AS","OC","AF","SA","AS","AS","AS","SA","AS","AS","AS","SA","EU","AS","AF","AF","EU","EU","EU","AF","AF","EU","EU","AF","OC","EU","AF","AS","AS","AS","OC","SA","AF","SA","EU","AF","AS","AF","NA","AS","AF","AF","OC","AF","OC","AF","SA","EU","EU","AS","OC","OC","OC","AS","SA","SA","OC","OC","AS","AS","EU","SA","OC","SA","AS","EU","OC","SA","AS","AF","EU","AS","AF","AS","OC","AF","AF","EU","AS","AF","EU","EU","EU","AF","EU","AF","AF","SA","AF","SA","AS","AF","SA","AF","AF","AF","AS","AS","OC","AS","AF","OC","AS","AS","SA","OC","AS","AF","EU","AF","OC","NA","SA","AS","EU","SA","SA","SA","SA","AS","OC","OC","OC","AS","AF","EU","AF","AF","AF","AF"};
|
||||
|
||||
const char * GeoIPDBDescription[NUM_DB_TYPES] = {NULL, "GeoIP Country Edition", "GeoIP City Edition, Rev 1", "GeoIP Region Edition, Rev 1", "GeoIP ISP Edition", "GeoIP Organization Edition", "GeoIP City Edition, Rev 0", "GeoIP Region Edition, Rev 0","GeoIP Proxy Edition","GeoIP Netspeed Edition"};
|
||||
|
||||
char *_full_path_to(const char *file_name) {
|
||||
char *path = malloc(sizeof(char) * 1024);
|
||||
|
||||
#ifndef _WIN32
|
||||
memset(path, 0, sizeof(char) * 1024);
|
||||
snprintf(path, sizeof(char) * 1024 - 1, "%s/%s", GEOIPDATADIR, file_name);
|
||||
#else
|
||||
char buf[MAX_PATH], *p, *q = NULL;
|
||||
int len;
|
||||
memset(buf, 0, sizeof(buf));
|
||||
len = GetModuleFileName(GetModuleHandle(NULL), buf, sizeof(buf) - 1);
|
||||
for (p = buf + len; p > buf; p--)
|
||||
if (*p == '\\')
|
||||
{
|
||||
if (!q)
|
||||
q = p;
|
||||
else
|
||||
*p = '/';
|
||||
}
|
||||
*q = 0;
|
||||
memset(path, 0, sizeof(char) * 1024);
|
||||
sprintf(path, "%s/%s", buf, file_name);
|
||||
#endif
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
char ** GeoIPDBFileName = NULL;
|
||||
|
||||
void _setup_dbfilename() {
|
||||
if (NULL == GeoIPDBFileName) {
|
||||
GeoIPDBFileName = malloc(sizeof(char *) * NUM_DB_TYPES);
|
||||
memset(GeoIPDBFileName, 0, sizeof(char *) * NUM_DB_TYPES);
|
||||
|
||||
GeoIPDBFileName[GEOIP_COUNTRY_EDITION] = _full_path_to("GeoIP.dat");
|
||||
GeoIPDBFileName[GEOIP_REGION_EDITION_REV0] = _full_path_to("GeoIPRegion.dat");
|
||||
GeoIPDBFileName[GEOIP_REGION_EDITION_REV1] = _full_path_to("GeoIPRegion.dat");
|
||||
GeoIPDBFileName[GEOIP_CITY_EDITION_REV0] = _full_path_to("GeoIPCity.dat");
|
||||
GeoIPDBFileName[GEOIP_CITY_EDITION_REV1] = _full_path_to("GeoIPCity.dat");
|
||||
GeoIPDBFileName[GEOIP_ISP_EDITION] = _full_path_to("GeoIPISP.dat");
|
||||
GeoIPDBFileName[GEOIP_ORG_EDITION] = _full_path_to("GeoIPOrg.dat");
|
||||
GeoIPDBFileName[GEOIP_PROXY_EDITION] = _full_path_to("GeoIPProxy.dat");
|
||||
GeoIPDBFileName[GEOIP_ASNUM_EDITION] = _full_path_to("GeoIPASNum.dat");
|
||||
GeoIPDBFileName[GEOIP_NETSPEED_EDITION] = _full_path_to("GeoIPNetSpeed.dat");
|
||||
}
|
||||
}
|
||||
|
||||
int _check_mtime(GeoIP *gi) {
|
||||
struct stat buf;
|
||||
|
||||
if (gi->flags & GEOIP_CHECK_CACHE) {
|
||||
if (fstat(fileno(gi->GeoIPDatabase), &buf) != -1) {
|
||||
if (buf.st_mtime > gi->mtime) {
|
||||
/* GeoIP Database file updated, reload database into memory cache */
|
||||
if (realloc(gi->cache, buf.st_size) != NULL) {
|
||||
if (fread(gi->cache, sizeof(unsigned char), buf.st_size, gi->GeoIPDatabase) != (size_t) buf.st_size) {
|
||||
fprintf(stderr,"Error reading file %s\n",gi->file_path);
|
||||
return -1;
|
||||
}
|
||||
gi->mtime = buf.st_mtime;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _file_exists(const char *file_name) {
|
||||
struct stat file_stat;
|
||||
return( (stat(file_name, &file_stat) == 0) ? 1:0);
|
||||
}
|
||||
|
||||
int GeoIP_db_avail(int type) {
|
||||
const char * filePath;
|
||||
if (type < 0 || type >= NUM_DB_TYPES) {
|
||||
return 0;
|
||||
}
|
||||
filePath = GeoIPDBFileName[type];
|
||||
if (NULL == filePath) {
|
||||
return 0;
|
||||
}
|
||||
return _file_exists(filePath);
|
||||
}
|
||||
|
||||
void _setup_segments(GeoIP * gi) {
|
||||
int i, j;
|
||||
unsigned char delim[3];
|
||||
unsigned char buf[SEGMENT_RECORD_LENGTH];
|
||||
|
||||
/* default to GeoIP Country Edition */
|
||||
gi->databaseType = GEOIP_COUNTRY_EDITION;
|
||||
gi->record_length = STANDARD_RECORD_LENGTH;
|
||||
fseek(gi->GeoIPDatabase, -3l, SEEK_END);
|
||||
for (i = 0; i < STRUCTURE_INFO_MAX_SIZE; i++) {
|
||||
fread(delim, 1, 3, gi->GeoIPDatabase);
|
||||
if (delim[0] == 255 && delim[1] == 255 && delim[2] == 255) {
|
||||
fread(&gi->databaseType, 1, 1, gi->GeoIPDatabase);
|
||||
if (gi->databaseType >= 106) {
|
||||
/* backwards compatibility with databases from April 2003 and earlier */
|
||||
gi->databaseType -= 105;
|
||||
}
|
||||
|
||||
if (gi->databaseType == GEOIP_REGION_EDITION_REV0) {
|
||||
/* Region Edition, pre June 2003 */
|
||||
gi->databaseSegments = malloc(sizeof(int));
|
||||
gi->databaseSegments[0] = STATE_BEGIN_REV0;
|
||||
} else if (gi->databaseType == GEOIP_REGION_EDITION_REV1) {
|
||||
/* Region Edition, post June 2003 */
|
||||
gi->databaseSegments = malloc(sizeof(int));
|
||||
gi->databaseSegments[0] = STATE_BEGIN_REV1;
|
||||
} else if (gi->databaseType == GEOIP_CITY_EDITION_REV0 ||
|
||||
gi->databaseType == GEOIP_CITY_EDITION_REV1 ||
|
||||
gi->databaseType == GEOIP_ORG_EDITION ||
|
||||
gi->databaseType == GEOIP_ISP_EDITION ||
|
||||
gi->databaseType == GEOIP_ASNUM_EDITION) {
|
||||
/* City/Org Editions have two segments, read offset of second segment */
|
||||
gi->databaseSegments = malloc(sizeof(int));
|
||||
gi->databaseSegments[0] = 0;
|
||||
fread(buf, SEGMENT_RECORD_LENGTH, 1, gi->GeoIPDatabase);
|
||||
for (j = 0; j < SEGMENT_RECORD_LENGTH; j++) {
|
||||
gi->databaseSegments[0] += (buf[j] << (j * 8));
|
||||
}
|
||||
if (gi->databaseType == GEOIP_ORG_EDITION ||
|
||||
gi->databaseType == GEOIP_ISP_EDITION)
|
||||
gi->record_length = ORG_RECORD_LENGTH;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
fseek(gi->GeoIPDatabase, -4l, SEEK_CUR);
|
||||
}
|
||||
}
|
||||
if (gi->databaseType == GEOIP_COUNTRY_EDITION ||
|
||||
gi->databaseType == GEOIP_PROXY_EDITION ||
|
||||
gi->databaseType == GEOIP_NETSPEED_EDITION) {
|
||||
gi->databaseSegments = malloc(sizeof(int));
|
||||
gi->databaseSegments[0] = COUNTRY_BEGIN;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int _seek_record (GeoIP *gi, unsigned long ipnum) {
|
||||
int depth;
|
||||
unsigned int x;
|
||||
unsigned char stack_buffer[2 * MAX_RECORD_LENGTH];
|
||||
const unsigned char *buf = (gi->cache == NULL) ? stack_buffer : NULL;
|
||||
unsigned int offset = 0;
|
||||
|
||||
const unsigned char * p;
|
||||
int j;
|
||||
|
||||
_check_mtime(gi);
|
||||
for (depth = 31; depth >= 0; depth--) {
|
||||
if (gi->cache == NULL) {
|
||||
/* read from disk */
|
||||
fseek(gi->GeoIPDatabase, (long)gi->record_length * 2 * offset, SEEK_SET);
|
||||
fread(stack_buffer,gi->record_length,2,gi->GeoIPDatabase);
|
||||
} else {
|
||||
/* simply point to record in memory */
|
||||
buf = gi->cache + (long)gi->record_length * 2 *offset;
|
||||
}
|
||||
|
||||
if (ipnum & (1 << depth)) {
|
||||
/* Take the right-hand branch */
|
||||
if ( gi->record_length == 3 ) {
|
||||
/* Most common case is completely unrolled and uses constants. */
|
||||
x = (buf[3*1 + 0] << (0*8))
|
||||
+ (buf[3*1 + 1] << (1*8))
|
||||
+ (buf[3*1 + 2] << (2*8));
|
||||
|
||||
} else {
|
||||
/* General case */
|
||||
j = gi->record_length;
|
||||
p = &buf[2*j];
|
||||
x = 0;
|
||||
do {
|
||||
x <<= 8;
|
||||
x += *(--p);
|
||||
} while ( --j );
|
||||
}
|
||||
|
||||
} else {
|
||||
/* Take the left-hand branch */
|
||||
if ( gi->record_length == 3 ) {
|
||||
/* Most common case is completely unrolled and uses constants. */
|
||||
x = (buf[3*0 + 0] << (0*8))
|
||||
+ (buf[3*0 + 1] << (1*8))
|
||||
+ (buf[3*0 + 2] << (2*8));
|
||||
} else {
|
||||
/* General case */
|
||||
j = gi->record_length;
|
||||
p = &buf[1*j];
|
||||
x = 0;
|
||||
do {
|
||||
x <<= 8;
|
||||
x += *(--p);
|
||||
} while ( --j );
|
||||
}
|
||||
}
|
||||
|
||||
if (x >= gi->databaseSegments[0]) {
|
||||
return x;
|
||||
}
|
||||
offset = x;
|
||||
}
|
||||
|
||||
/* shouldn't reach here */
|
||||
fprintf(stderr,"Error Traversing Database for ipnum = %lu - Perhaps database is corrupt?\n",ipnum);
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long _addr_to_num (const char *addr) {
|
||||
int i;
|
||||
char tok[4];
|
||||
int octet;
|
||||
int j = 0, k = 0;
|
||||
unsigned long ipnum = 0;
|
||||
char c = 0;
|
||||
|
||||
for (i=0; i<4; i++) {
|
||||
for (;;) {
|
||||
c = addr[k++];
|
||||
if (c == '.' || c == '\0') {
|
||||
tok[j] = '\0';
|
||||
octet = atoi(tok);
|
||||
if (octet > 255)
|
||||
return 0;
|
||||
ipnum += (octet << ((3-i)*8));
|
||||
j = 0;
|
||||
break;
|
||||
} else if (c >= '0' && c<= '9') {
|
||||
if (j > 2) {
|
||||
return 0;
|
||||
}
|
||||
tok[j++] = c;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if(c == '\0' && i<3) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return ipnum;
|
||||
}
|
||||
|
||||
GeoIP* GeoIP_open_type (int type, int flags) {
|
||||
GeoIP * gi;
|
||||
const char * filePath;
|
||||
if (type < 0 || type >= NUM_DB_TYPES) {
|
||||
printf("Invalid database type %d\n", type);
|
||||
return NULL;
|
||||
}
|
||||
_setup_dbfilename();
|
||||
filePath = GeoIPDBFileName[type];
|
||||
if (filePath == NULL) {
|
||||
printf("Invalid database type %d\n", type);
|
||||
return NULL;
|
||||
}
|
||||
gi = GeoIP_open (filePath, flags);
|
||||
return gi;
|
||||
}
|
||||
|
||||
GeoIP* GeoIP_new (int flags) {
|
||||
GeoIP * gi;
|
||||
_setup_dbfilename();
|
||||
gi = GeoIP_open (GeoIPDBFileName[GEOIP_COUNTRY_EDITION], flags);
|
||||
return gi;
|
||||
}
|
||||
|
||||
GeoIP* GeoIP_open (const char * filename, int flags) {
|
||||
struct stat buf;
|
||||
GeoIP *gi = (GeoIP *)malloc(sizeof(GeoIP));
|
||||
|
||||
#ifdef _WIN32
|
||||
WSADATA wsa;
|
||||
if (WSAStartup(MAKEWORD(1, 1), &wsa) != 0)
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
if (gi == NULL)
|
||||
return NULL;
|
||||
gi->file_path = malloc(sizeof(char) * (strlen(filename)+1));
|
||||
if (gi->file_path == NULL)
|
||||
return NULL;
|
||||
strcpy(gi->file_path, filename);
|
||||
gi->GeoIPDatabase = fopen(filename,"rb");
|
||||
if (gi->GeoIPDatabase == NULL) {
|
||||
fprintf(stderr,"Error Opening file %s\n",filename);
|
||||
free(gi->file_path);
|
||||
free(gi);
|
||||
return NULL;
|
||||
} else {
|
||||
if (flags & GEOIP_MEMORY_CACHE) {
|
||||
if (fstat(fileno(gi->GeoIPDatabase), &buf) == -1) {
|
||||
fprintf(stderr,"Error stating file %s\n",filename);
|
||||
free(gi);
|
||||
return NULL;
|
||||
}
|
||||
gi->mtime = buf.st_mtime;
|
||||
gi->cache = (unsigned char *) malloc(sizeof(unsigned char) * buf.st_size);
|
||||
if (gi->cache != NULL) {
|
||||
if (fread(gi->cache, sizeof(unsigned char), buf.st_size, gi->GeoIPDatabase) != (size_t) buf.st_size) {
|
||||
fprintf(stderr,"Error reading file %s\n",filename);
|
||||
free(gi->cache);
|
||||
free(gi);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
gi->cache = NULL;
|
||||
}
|
||||
gi->flags = flags;
|
||||
_setup_segments(gi);
|
||||
return gi;
|
||||
}
|
||||
}
|
||||
|
||||
void GeoIP_delete (GeoIP *gi) {
|
||||
if (gi->GeoIPDatabase != NULL)
|
||||
fclose(gi->GeoIPDatabase);
|
||||
if (gi->cache != NULL)
|
||||
free(gi->cache);
|
||||
if (gi->file_path != NULL)
|
||||
free(gi->file_path);
|
||||
if (gi->databaseSegments != NULL)
|
||||
free(gi->databaseSegments);
|
||||
free(gi);
|
||||
}
|
||||
|
||||
const char *GeoIP_country_code_by_name (GeoIP* gi, const char *name) {
|
||||
int country_id;
|
||||
country_id = GeoIP_id_by_name(gi, name);
|
||||
return (country_id > 0) ? GeoIP_country_code[country_id] : NULL;
|
||||
}
|
||||
|
||||
const char *GeoIP_country_code3_by_name (GeoIP* gi, const char *name) {
|
||||
int country_id;
|
||||
country_id = GeoIP_id_by_name(gi, name);
|
||||
return (country_id > 0) ? GeoIP_country_code3[country_id] : NULL;
|
||||
}
|
||||
|
||||
const char *GeoIP_country_name_by_name (GeoIP* gi, const char *name) {
|
||||
int country_id;
|
||||
country_id = GeoIP_id_by_name(gi, name);
|
||||
return (country_id > 0) ? GeoIP_country_name[country_id] : NULL;
|
||||
}
|
||||
|
||||
unsigned long lookupaddress (const char *host) {
|
||||
unsigned long addr = inet_addr(host);
|
||||
struct hostent * phe;
|
||||
if (addr == INADDR_NONE)
|
||||
{
|
||||
phe = gethostbyname(host);
|
||||
if (!phe)
|
||||
return 0;
|
||||
addr = *((unsigned long *) phe->h_addr_list[0]);
|
||||
}
|
||||
return ntohl(addr);
|
||||
}
|
||||
|
||||
int GeoIP_id_by_name (GeoIP* gi, const char *name) {
|
||||
unsigned long ipnum;
|
||||
int ret;
|
||||
if (name == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (gi->databaseType != GEOIP_COUNTRY_EDITION && gi->databaseType != GEOIP_PROXY_EDITION && gi->databaseType != GEOIP_NETSPEED_EDITION) {
|
||||
printf("Invalid database type %s, expected %s\n", GeoIPDBDescription[(int)gi->databaseType], GeoIPDBDescription[GEOIP_COUNTRY_EDITION]);
|
||||
return 0;
|
||||
}
|
||||
if (!(ipnum = lookupaddress(name)))
|
||||
return 0;
|
||||
ret = _seek_record(gi, ipnum) - COUNTRY_BEGIN;
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
const char *GeoIP_country_code_by_addr (GeoIP* gi, const char *addr) {
|
||||
int country_id;
|
||||
country_id = GeoIP_id_by_addr(gi, addr);
|
||||
return (country_id > 0) ? GeoIP_country_code[country_id] : NULL;
|
||||
}
|
||||
|
||||
const char *GeoIP_country_code3_by_addr (GeoIP* gi, const char *addr) {
|
||||
int country_id;
|
||||
country_id = GeoIP_id_by_addr(gi, addr);
|
||||
return (country_id > 0) ? GeoIP_country_code3[country_id] : NULL;
|
||||
return GeoIP_country_code3[country_id];
|
||||
}
|
||||
|
||||
const char *GeoIP_country_name_by_addr (GeoIP* gi, const char *addr) {
|
||||
int country_id;
|
||||
country_id = GeoIP_id_by_addr(gi, addr);
|
||||
return (country_id > 0) ? GeoIP_country_name[country_id] : NULL;
|
||||
return GeoIP_country_name[country_id];
|
||||
}
|
||||
|
||||
int GeoIP_country_id_by_addr (GeoIP* gi, const char *addr) {
|
||||
return GeoIP_id_by_addr(gi, addr);
|
||||
}
|
||||
|
||||
int GeoIP_country_id_by_name (GeoIP* gi, const char *host) {
|
||||
return GeoIP_id_by_name(gi, host);
|
||||
}
|
||||
|
||||
int GeoIP_id_by_addr (GeoIP* gi, const char *addr) {
|
||||
unsigned long ipnum;
|
||||
int ret;
|
||||
|
||||
if (addr == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (gi->databaseType != GEOIP_COUNTRY_EDITION && gi->databaseType != GEOIP_PROXY_EDITION && gi->databaseType != GEOIP_NETSPEED_EDITION) {
|
||||
printf("Invalid database type %s, expected %s\n", GeoIPDBDescription[(int)gi->databaseType], GeoIPDBDescription[GEOIP_COUNTRY_EDITION]);
|
||||
return 0;
|
||||
}
|
||||
ipnum = _addr_to_num(addr);
|
||||
ret = _seek_record(gi, ipnum) - COUNTRY_BEGIN;
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *GeoIP_database_info (GeoIP* gi) {
|
||||
int i;
|
||||
unsigned char buf[3];
|
||||
char *retval;
|
||||
int hasStructureInfo = 0;
|
||||
|
||||
if(gi == NULL)
|
||||
return NULL;
|
||||
|
||||
_check_mtime(gi);
|
||||
fseek(gi->GeoIPDatabase, -3l, SEEK_END);
|
||||
|
||||
/* first get past the database structure information */
|
||||
for (i = 0; i < STRUCTURE_INFO_MAX_SIZE; i++) {
|
||||
fread(buf, 1, 3, gi->GeoIPDatabase);
|
||||
if (buf[0] == 255 && buf[1] == 255 && buf[2] == 255) {
|
||||
hasStructureInfo = 1;
|
||||
break;
|
||||
}
|
||||
fseek(gi->GeoIPDatabase, -4l, SEEK_CUR);
|
||||
}
|
||||
if (hasStructureInfo == 1) {
|
||||
fseek(gi->GeoIPDatabase, -3l, SEEK_CUR);
|
||||
} else {
|
||||
/* no structure info, must be pre Sep 2002 database, go back to end */
|
||||
fseek(gi->GeoIPDatabase, -3l, SEEK_END);
|
||||
}
|
||||
|
||||
for (i = 0; i < DATABASE_INFO_MAX_SIZE; i++) {
|
||||
fread(buf, 1, 3, gi->GeoIPDatabase);
|
||||
if (buf[0] == 0 && buf[1] == 0 && buf[2] == 0) {
|
||||
retval = malloc(sizeof(char) * (i+1));
|
||||
if (retval == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
fread(retval, 1, i, gi->GeoIPDatabase);
|
||||
retval[i] = '\0';
|
||||
return retval;
|
||||
}
|
||||
fseek(gi->GeoIPDatabase, -4l, SEEK_CUR);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* GeoIP Region Edition functions */
|
||||
|
||||
void GeoIP_assign_region_by_inetaddr(GeoIP* gi, unsigned long inetaddr, GeoIPRegion *region) {
|
||||
unsigned int seek_region;
|
||||
|
||||
/* This also writes in the terminating NULs (if you decide to
|
||||
* keep them) and clear any fields that are not set. */
|
||||
memset(region, 0, sizeof(GeoIPRegion));
|
||||
|
||||
seek_region = _seek_record(gi, ntohl(inetaddr));
|
||||
|
||||
if (gi->databaseType == GEOIP_REGION_EDITION_REV0) {
|
||||
/* Region Edition, pre June 2003 */
|
||||
seek_region -= STATE_BEGIN_REV0;
|
||||
if (seek_region >= 1000) {
|
||||
region->country_code[0] = 'U';
|
||||
region->country_code[1] = 'S';
|
||||
region->region[0] = (char) ((seek_region - 1000)/26 + 65);
|
||||
region->region[1] = (char) ((seek_region - 1000)%26 + 65);
|
||||
} else {
|
||||
memcpy(region->country_code, GeoIP_country_code[seek_region], 2);
|
||||
}
|
||||
} else if (gi->databaseType == GEOIP_REGION_EDITION_REV1) {
|
||||
/* Region Edition, post June 2003 */
|
||||
seek_region -= STATE_BEGIN_REV1;
|
||||
if (seek_region < US_OFFSET) {
|
||||
/* Unknown */
|
||||
/* we don't need to do anything here b/c we memset region to 0 */
|
||||
} else if (seek_region < CANADA_OFFSET) {
|
||||
/* USA State */
|
||||
region->country_code[0] = 'U';
|
||||
region->country_code[1] = 'S';
|
||||
region->region[0] = (char) ((seek_region - US_OFFSET)/26 + 65);
|
||||
region->region[1] = (char) ((seek_region - US_OFFSET)%26 + 65);
|
||||
} else if (seek_region < WORLD_OFFSET) {
|
||||
/* Canada Province */
|
||||
region->country_code[0] = 'C';
|
||||
region->country_code[1] = 'A';
|
||||
region->region[0] = (char) ((seek_region - CANADA_OFFSET)/26 + 65);
|
||||
region->region[1] = (char) ((seek_region - CANADA_OFFSET)%26 + 65);
|
||||
} else {
|
||||
/* Not US or Canada */
|
||||
memcpy(region->country_code, GeoIP_country_code[(seek_region - WORLD_OFFSET) / FIPS_RANGE], 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GeoIPRegion * _get_region(GeoIP* gi, unsigned long ipnum) {
|
||||
GeoIPRegion * region;
|
||||
|
||||
region = malloc(sizeof(GeoIPRegion));
|
||||
if (region) {
|
||||
GeoIP_assign_region_by_inetaddr(gi, htonl(ipnum), region);
|
||||
}
|
||||
return region;
|
||||
}
|
||||
|
||||
GeoIPRegion * GeoIP_region_by_addr (GeoIP* gi, const char *addr) {
|
||||
unsigned long ipnum;
|
||||
if (addr == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (gi->databaseType != GEOIP_REGION_EDITION_REV0 &&
|
||||
gi->databaseType != GEOIP_REGION_EDITION_REV1) {
|
||||
printf("Invalid database type %s, expected %s\n", GeoIPDBDescription[(int)gi->databaseType], GeoIPDBDescription[GEOIP_REGION_EDITION_REV1]);
|
||||
return 0;
|
||||
}
|
||||
ipnum = _addr_to_num(addr);
|
||||
return _get_region(gi, ipnum);
|
||||
}
|
||||
|
||||
GeoIPRegion * GeoIP_region_by_name (GeoIP* gi, const char *name) {
|
||||
unsigned long ipnum;
|
||||
if (name == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (gi->databaseType != GEOIP_REGION_EDITION_REV0 &&
|
||||
gi->databaseType != GEOIP_REGION_EDITION_REV1) {
|
||||
printf("Invalid database type %s, expected %s\n", GeoIPDBDescription[(int)gi->databaseType], GeoIPDBDescription[GEOIP_REGION_EDITION_REV1]);
|
||||
return 0;
|
||||
}
|
||||
if (!(ipnum = lookupaddress(name)))
|
||||
return 0;
|
||||
return _get_region(gi, ipnum);
|
||||
}
|
||||
|
||||
void GeoIPRegion_delete (GeoIPRegion *gir) {
|
||||
free(gir);
|
||||
}
|
||||
|
||||
/* GeoIP Organization, ISP and AS Number Edition private method */
|
||||
char *_get_name (GeoIP* gi, unsigned long ipnum) {
|
||||
int seek_org;
|
||||
char buf[MAX_ORG_RECORD_LENGTH];
|
||||
char * org_buf, * buf_pointer;
|
||||
int record_pointer;
|
||||
|
||||
if (gi->databaseType != GEOIP_ORG_EDITION &&
|
||||
gi->databaseType != GEOIP_ISP_EDITION &&
|
||||
gi->databaseType != GEOIP_ASNUM_EDITION) {
|
||||
printf("Invalid database type %s, expected %s\n", GeoIPDBDescription[(int)gi->databaseType], GeoIPDBDescription[GEOIP_ORG_EDITION]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
seek_org = _seek_record(gi, ipnum);
|
||||
if (seek_org == gi->databaseSegments[0])
|
||||
return NULL;
|
||||
|
||||
record_pointer = seek_org + (2 * gi->record_length - 1) * gi->databaseSegments[0];
|
||||
|
||||
if (gi->cache == NULL) {
|
||||
fseek(gi->GeoIPDatabase, record_pointer, SEEK_SET);
|
||||
fread(buf, sizeof(char), MAX_ORG_RECORD_LENGTH, gi->GeoIPDatabase);
|
||||
org_buf = malloc(sizeof(char) * (strlen(buf)+1));
|
||||
strcpy(org_buf, buf);
|
||||
} else {
|
||||
buf_pointer = gi->cache + (long)record_pointer;
|
||||
org_buf = malloc(sizeof(char) * (strlen(buf_pointer)+1));
|
||||
strcpy(org_buf, buf_pointer);
|
||||
}
|
||||
return org_buf;
|
||||
}
|
||||
|
||||
char *GeoIP_name_by_addr (GeoIP* gi, const char *addr) {
|
||||
unsigned long ipnum;
|
||||
if (addr == NULL) {
|
||||
return 0;
|
||||
}
|
||||
ipnum = _addr_to_num(addr);
|
||||
return _get_name(gi, ipnum);
|
||||
}
|
||||
|
||||
char *GeoIP_name_by_name (GeoIP* gi, const char *name) {
|
||||
unsigned long ipnum;
|
||||
if (name == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (!(ipnum = lookupaddress(name)))
|
||||
return 0;
|
||||
return _get_name(gi, ipnum);
|
||||
}
|
||||
|
||||
char *GeoIP_org_by_addr (GeoIP* gi, const char *addr) {
|
||||
return GeoIP_name_by_addr(gi, addr);
|
||||
}
|
||||
|
||||
char *GeoIP_org_by_name (GeoIP* gi, const char *name) {
|
||||
return GeoIP_name_by_name(gi, name);
|
||||
}
|
||||
|
||||
unsigned char GeoIP_database_edition (GeoIP* gi) {
|
||||
return gi->databaseType;
|
||||
}
|
BIN
dlls/geoip/GeoIP.dat
Executable file
BIN
dlls/geoip/GeoIP.dat
Executable file
Binary file not shown.
158
dlls/geoip/GeoIP.h
Executable file
158
dlls/geoip/GeoIP.h
Executable file
@ -0,0 +1,158 @@
|
||||
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
|
||||
/* GeoIP.h
|
||||
*
|
||||
* Copyright (C) 2003 MaxMind LLC
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef GEOIP_H
|
||||
#define GEOIP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<string.h>
|
||||
#include <sys/types.h> /* for fstat */
|
||||
#include <sys/stat.h> /* for fstat */
|
||||
|
||||
//typedef int uint32_t;
|
||||
|
||||
#define SEGMENT_RECORD_LENGTH 3
|
||||
#define STANDARD_RECORD_LENGTH 3
|
||||
#define ORG_RECORD_LENGTH 4
|
||||
#define MAX_RECORD_LENGTH 4
|
||||
#define NUM_DB_TYPES 16
|
||||
|
||||
typedef struct GeoIPTag {
|
||||
FILE *GeoIPDatabase;
|
||||
char *file_path;
|
||||
unsigned char *cache;
|
||||
unsigned int *databaseSegments;
|
||||
char databaseType;
|
||||
time_t mtime;
|
||||
int flags;
|
||||
char record_length;
|
||||
int record_iter; /* used in GeoIP_next_record */
|
||||
} GeoIP;
|
||||
|
||||
typedef struct GeoIPRegionTag {
|
||||
char country_code[3];
|
||||
char region[3];
|
||||
} GeoIPRegion;
|
||||
|
||||
typedef enum {
|
||||
GEOIP_STANDARD = 0,
|
||||
GEOIP_MEMORY_CACHE = 1,
|
||||
GEOIP_CHECK_CACHE = 2,
|
||||
} GeoIPOptions;
|
||||
|
||||
typedef enum {
|
||||
GEOIP_COUNTRY_EDITION = 1,
|
||||
GEOIP_REGION_EDITION_REV0 = 7,
|
||||
GEOIP_CITY_EDITION_REV0 = 6,
|
||||
GEOIP_ORG_EDITION = 5,
|
||||
GEOIP_ISP_EDITION = 4,
|
||||
GEOIP_CITY_EDITION_REV1 = 2,
|
||||
GEOIP_REGION_EDITION_REV1 = 3,
|
||||
GEOIP_PROXY_EDITION = 8,
|
||||
GEOIP_ASNUM_EDITION = 9,
|
||||
GEOIP_NETSPEED_EDITION = 10,
|
||||
} GeoIPDBTypes;
|
||||
|
||||
typedef enum {
|
||||
GEOIP_ANON_PROXY = 1,
|
||||
GEOIP_HTTP_X_FORWARDED_FOR_PROXY = 2,
|
||||
GEOIP_HTTP_CLIENT_IP_PROXY = 3,
|
||||
} GeoIPProxyTypes;
|
||||
|
||||
typedef enum {
|
||||
GEOIP_UNKNOWN_SPEED = 0,
|
||||
GEOIP_DIALUP_SPEED = 1,
|
||||
GEOIP_CABLEDSL_SPEED = 2,
|
||||
GEOIP_CORPORATE_SPEED = 3,
|
||||
} GeoIPNetspeedValues;
|
||||
|
||||
extern char **GeoIPDBFileName;
|
||||
extern const char * GeoIPDBDescription[NUM_DB_TYPES];
|
||||
extern const char *GeoIPCountryDBFileName;
|
||||
extern const char *GeoIPRegionDBFileName;
|
||||
extern const char *GeoIPCityDBFileName;
|
||||
extern const char *GeoIPOrgDBFileName;
|
||||
extern const char *GeoIPISPDBFileName;
|
||||
|
||||
extern const char GeoIP_country_code[247][3];
|
||||
extern const char GeoIP_country_code3[247][4];
|
||||
extern const char * GeoIP_country_name[247];
|
||||
extern const char GeoIP_country_continent[247][3];
|
||||
|
||||
#ifdef DLL
|
||||
#define GEOIP_API __declspec(dllexport)
|
||||
#else
|
||||
#define GEOIP_API
|
||||
#endif /* DLL */
|
||||
|
||||
GEOIP_API GeoIP* GeoIP_open_type (int type, int flags);
|
||||
GEOIP_API GeoIP* GeoIP_new(int flags);
|
||||
GEOIP_API GeoIP* GeoIP_open(const char * filename, int flags);
|
||||
GEOIP_API int GeoIP_db_avail(int type);
|
||||
GEOIP_API void GeoIP_delete(GeoIP* gi);
|
||||
GEOIP_API const char *GeoIP_country_code_by_addr (GeoIP* gi, const char *addr);
|
||||
GEOIP_API const char *GeoIP_country_code_by_name (GeoIP* gi, const char *host);
|
||||
GEOIP_API const char *GeoIP_country_code3_by_addr (GeoIP* gi, const char *addr);
|
||||
GEOIP_API const char *GeoIP_country_code3_by_name (GeoIP* gi, const char *host);
|
||||
GEOIP_API const char *GeoIP_country_name_by_addr (GeoIP* gi, const char *addr);
|
||||
GEOIP_API const char *GeoIP_country_name_by_name (GeoIP* gi, const char *host);
|
||||
|
||||
/* Deprecated - for backwards compatibility only */
|
||||
GEOIP_API int GeoIP_country_id_by_addr (GeoIP* gi, const char *addr);
|
||||
GEOIP_API int GeoIP_country_id_by_name (GeoIP* gi, const char *host);
|
||||
GEOIP_API char *GeoIP_org_by_addr (GeoIP* gi, const char *addr);
|
||||
GEOIP_API char *GeoIP_org_by_name (GeoIP* gi, const char *host);
|
||||
/* End deprecated */
|
||||
|
||||
GEOIP_API int GeoIP_id_by_addr (GeoIP* gi, const char *addr);
|
||||
GEOIP_API int GeoIP_id_by_name (GeoIP* gi, const char *host);
|
||||
|
||||
GEOIP_API GeoIPRegion * GeoIP_region_by_addr (GeoIP* gi, const char *addr);
|
||||
GEOIP_API GeoIPRegion * GeoIP_region_by_name (GeoIP* gi, const char *host);
|
||||
|
||||
/* Warning - don't call this after GeoIP_assign_region_by_inetaddr calls */
|
||||
GEOIP_API void GeoIPRegion_delete (GeoIPRegion *gir);
|
||||
|
||||
GEOIP_API void GeoIP_assign_region_by_inetaddr(GeoIP* gi, unsigned long inetaddr, GeoIPRegion *gir);
|
||||
|
||||
/* Used to query GeoIP Organization, ISP and AS Number databases */
|
||||
GEOIP_API char *GeoIP_name_by_addr (GeoIP* gi, const char *addr);
|
||||
GEOIP_API char *GeoIP_name_by_name (GeoIP* gi, const char *host);
|
||||
|
||||
GEOIP_API char *GeoIP_database_info (GeoIP* gi);
|
||||
GEOIP_API unsigned char GeoIP_database_edition (GeoIP* gi);
|
||||
|
||||
GEOIP_API unsigned int _seek_record (GeoIP *gi, unsigned long ipnum);
|
||||
GEOIP_API unsigned long _addr_to_num (const char *addr);
|
||||
|
||||
#ifdef BSD
|
||||
#define memcpy(dest, src, n) bcopy(src, dest, n)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GEOIP_H */
|
2990
dlls/geoip/amxxmodule.cpp
Executable file
2990
dlls/geoip/amxxmodule.cpp
Executable file
File diff suppressed because it is too large
Load Diff
2152
dlls/geoip/amxxmodule.h
Executable file
2152
dlls/geoip/amxxmodule.h
Executable file
File diff suppressed because it is too large
Load Diff
163
dlls/geoip/geoip.vcproj
Executable file
163
dlls/geoip/geoip.vcproj
Executable file
@ -0,0 +1,163 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="geoip"
|
||||
ProjectGUID="{036FA046-A6BF-4D80-8986-71FDD1528B55}"
|
||||
Keyword="Win32Proj">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;GEOIP_EXPORTS"
|
||||
MinimalRebuild="TRUE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="5"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="ws2_32.lib zlib.lib"
|
||||
OutputFile="$(OutDir)/geoip_amxx.dll"
|
||||
LinkIncremental="2"
|
||||
IgnoreDefaultLibraryNames="LIBCMT"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/geoip.pdb"
|
||||
SubSystem="2"
|
||||
ImportLibrary="$(OutDir)/geoip.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="2"
|
||||
CharacterSet="2">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;GEOIP_EXPORTS"
|
||||
RuntimeLibrary="4"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="FALSE"
|
||||
DebugInformationFormat="3"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="ws2_32.lib zlib.lib"
|
||||
OutputFile="$(OutDir)/geoip_amxx.dll"
|
||||
LinkIncremental="1"
|
||||
GenerateDebugInformation="TRUE"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
ImportLibrary="$(OutDir)/geoip.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
|
||||
<File
|
||||
RelativePath=".\geoip_amxx.cpp">
|
||||
</File>
|
||||
<Filter
|
||||
Name="SDK"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\amxxmodule.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\amxxmodule.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\moduleconfig.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="GeoIP"
|
||||
Filter="">
|
||||
<File
|
||||
RelativePath=".\geolib\libGeoIP\GeoIP.c">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\geolib\libGeoIP\GeoIP.h">
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
|
||||
<File
|
||||
RelativePath=".\geoip_amxx.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
47
dlls/geoip/geoip_amxx.cpp
Executable file
47
dlls/geoip/geoip_amxx.cpp
Executable file
@ -0,0 +1,47 @@
|
||||
#include "geoip_amxx.h"
|
||||
|
||||
GeoIP *gi = NULL;
|
||||
|
||||
static cell AMX_NATIVE_CALL amx_geoip_code2(AMX *amx, cell *params)
|
||||
{
|
||||
int len = 0;
|
||||
char *ip = MF_GetAmxString(amx, params[1], 0, &len);
|
||||
const char *ccode = GeoIP_country_code_by_addr(gi, ip);
|
||||
return MF_SetAmxString(amx, params[2], ccode?ccode:"error", 3);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL amx_geoip_code3(AMX *amx, cell *params)
|
||||
{
|
||||
int len = 0;
|
||||
char *ip = MF_GetAmxString(amx, params[1], 0, &len);
|
||||
const char *ccode = GeoIP_country_code3_by_addr(gi, ip);
|
||||
return MF_SetAmxString(amx, params[2], ccode?ccode:"error", 4);
|
||||
}
|
||||
|
||||
static cell AMX_NATIVE_CALL amx_geoip_country(AMX *amx, cell *params)
|
||||
{
|
||||
int len = 0;
|
||||
char *ip = MF_GetAmxString(amx, params[1], 0, &len);
|
||||
const char *ccode = GeoIP_country_name_by_addr(gi, ip);
|
||||
return MF_SetAmxString(amx, params[2], ccode?ccode:"error", params[3]);
|
||||
}
|
||||
|
||||
void OnAmxxAttach()
|
||||
{
|
||||
char *path = MF_BuildPathname("addons/amxx/GeoIP.dat");
|
||||
gi = GeoIP_open(path, GEOIP_STANDARD);
|
||||
if (gi == NULL) {
|
||||
MF_Log("Failed to instantiate GeoIP!");
|
||||
return;
|
||||
}
|
||||
char *db_info = GeoIP_database_info(gi);
|
||||
MF_Log("Database info: %s", db_info);
|
||||
MF_AddNatives(geoip_natives);
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO geoip_natives[] = {
|
||||
{"geoip_code2", amx_geoip_code2},
|
||||
{"geoip_code3", amx_geoip_code3},
|
||||
{"geoip_country", amx_geoip_country},
|
||||
{NULL, NULL},
|
||||
};
|
9
dlls/geoip/geoip_amxx.h
Executable file
9
dlls/geoip/geoip_amxx.h
Executable file
@ -0,0 +1,9 @@
|
||||
#ifndef _INCLUDE_GEOIPAMXX_H
|
||||
#define _INCLUDE_GEOIPAMXX_H
|
||||
|
||||
#include <GeoIP.h>
|
||||
#include "amxxmodule.h"
|
||||
|
||||
extern AMX_NATIVE_INFO geoip_natives[];
|
||||
|
||||
#endif //_INCLUDE_GEOIPAMXX_H
|
462
dlls/geoip/moduleconfig.h
Executable file
462
dlls/geoip/moduleconfig.h
Executable file
@ -0,0 +1,462 @@
|
||||
// Configuration
|
||||
|
||||
#ifndef __MODULECONFIG_H__
|
||||
#define __MODULECONFIG_H__
|
||||
|
||||
// Module info
|
||||
#define MODULE_NAME "GeoIP"
|
||||
#define MODULE_VERSION "1.1"
|
||||
#define MODULE_AUTHOR "BAILOPAN"
|
||||
#define MODULE_URL "http://www.bailopan.com/"
|
||||
#define MODULE_LOGTAG "GEOIP"
|
||||
// If you want the module not to be reloaded on mapchange, remove / comment out the next line
|
||||
#define MODULE_RELOAD_ON_MAPCHANGE
|
||||
|
||||
#ifdef __DATE__
|
||||
#define MODULE_DATE __DATE__
|
||||
#else // __DATE__
|
||||
#define MODULE_DATE "Unknown"
|
||||
#endif // __DATE__
|
||||
|
||||
// metamod plugin?
|
||||
// #define USE_METAMOD
|
||||
|
||||
// - AMXX Init functions
|
||||
// Also consider using FN_META_*
|
||||
// AMXX query
|
||||
//#define FN_AMXX_QUERY OnAmxxQuery
|
||||
// AMXX attach
|
||||
// Do native functions init here (MF_AddNatives)
|
||||
#define FN_AMXX_ATTACH OnAmxxAttach
|
||||
// AMXX dettach
|
||||
//#define FN_AMXX_DETTACH OnAmxxDettach
|
||||
// All plugins loaded
|
||||
// Do forward functions init here (MF_RegisterForward)
|
||||
// #define FN_AMXX_PLUGINSLOADED OnPluginsLoaded
|
||||
|
||||
/**** METAMOD ****/
|
||||
// If your module doesn't use metamod, you may close the file now :)
|
||||
#ifdef USE_METAMOD
|
||||
// ----
|
||||
// Hook Functions
|
||||
// Uncomment these to be called
|
||||
// You can also change the function name
|
||||
|
||||
// - Metamod init functions
|
||||
// Also consider using FN_AMXX_*
|
||||
// Meta query
|
||||
//#define FN_META_QUERY OnMetaQuery
|
||||
// Meta attach
|
||||
//#define FN_META_ATTACH OnMetaAttach
|
||||
// Meta dettach
|
||||
//#define FN_META_DETTACH OnMetaDettach
|
||||
|
||||
// (wd) are Will Day's notes
|
||||
// - GetEntityAPI2 functions
|
||||
// #define FN_GameDLLInit GameDLLInit /* pfnGameInit() */
|
||||
// #define FN_DispatchSpawn DispatchSpawn /* pfnSpawn() */
|
||||
// #define FN_DispatchThink DispatchThink /* pfnThink() */
|
||||
// #define FN_DispatchUse DispatchUse /* pfnUse() */
|
||||
// #define FN_DispatchTouch DispatchTouch /* pfnTouch() */
|
||||
// #define FN_DispatchBlocked DispatchBlocked /* pfnBlocked() */
|
||||
// #define FN_DispatchKeyValue DispatchKeyValue /* pfnKeyValue() */
|
||||
// #define FN_DispatchSave DispatchSave /* pfnSave() */
|
||||
// #define FN_DispatchRestore DispatchRestore /* pfnRestore() */
|
||||
// #define FN_DispatchObjectCollsionBox DispatchObjectCollsionBox /* pfnSetAbsBox() */
|
||||
// #define FN_SaveWriteFields SaveWriteFields /* pfnSaveWriteFields() */
|
||||
// #define FN_SaveReadFields SaveReadFields /* pfnSaveReadFields() */
|
||||
// #define FN_SaveGlobalState SaveGlobalState /* pfnSaveGlobalState() */
|
||||
// #define FN_RestoreGlobalState RestoreGlobalState /* pfnRestoreGlobalState() */
|
||||
// #define FN_ResetGlobalState ResetGlobalState /* pfnResetGlobalState() */
|
||||
// #define FN_ClientConnect ClientConnect /* pfnClientConnect() (wd) Client has connected */
|
||||
// #define FN_ClientDisconnect ClientDisconnect /* pfnClientDisconnect() (wd) Player has left the game */
|
||||
// #define FN_ClientKill ClientKill /* pfnClientKill() (wd) Player has typed "kill" */
|
||||
// #define FN_ClientPutInServer ClientPutInServer /* pfnClientPutInServer() (wd) Client is entering the game */
|
||||
// #define FN_ClientCommand ClientCommand /* pfnClientCommand() (wd) Player has sent a command (typed or from a bind) */
|
||||
// #define FN_ClientUserInfoChanged ClientUserInfoChanged /* pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure */
|
||||
// #define FN_ServerActivate ServerActivate /* pfnServerActivate() (wd) Server is starting a new map */
|
||||
// #define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */
|
||||
// #define FN_PlayerPreThink PlayerPreThink /* pfnPlayerPreThink() */
|
||||
// #define FN_PlayerPostThink PlayerPostThink /* pfnPlayerPostThink() */
|
||||
// #define FN_StartFrame StartFrame /* pfnStartFrame() */
|
||||
// #define FN_ParmsNewLevel ParmsNewLevel /* pfnParmsNewLevel() */
|
||||
// #define FN_ParmsChangeLevel ParmsChangeLevel /* pfnParmsChangeLevel() */
|
||||
// #define FN_GetGameDescription GetGameDescription /* pfnGetGameDescription() Returns string describing current .dll. E.g. "TeamFotrress 2" "Half-Life" */
|
||||
// #define FN_PlayerCustomization PlayerCustomization /* pfnPlayerCustomization() Notifies .dll of new customization for player. */
|
||||
// #define FN_SpectatorConnect SpectatorConnect /* pfnSpectatorConnect() Called when spectator joins server */
|
||||
// #define FN_SpectatorDisconnect SpectatorDisconnect /* pfnSpectatorDisconnect() Called when spectator leaves the server */
|
||||
// #define FN_SpectatorThink SpectatorThink /* pfnSpectatorThink() Called when spectator sends a command packet (usercmd_t) */
|
||||
// #define FN_Sys_Error Sys_Error /* pfnSys_Error() Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint. SDK2 */
|
||||
// #define FN_PM_Move PM_Move /* pfnPM_Move() (wd) SDK2 */
|
||||
// #define FN_PM_Init PM_Init /* pfnPM_Init() Server version of player movement initialization; (wd) SDK2 */
|
||||
// #define FN_PM_FindTextureType PM_FindTextureType /* pfnPM_FindTextureType() (wd) SDK2 */
|
||||
// #define FN_SetupVisibility SetupVisibility /* pfnSetupVisibility() Set up PVS and PAS for networking for this client; (wd) SDK2 */
|
||||
// #define FN_UpdateClientData UpdateClientData /* pfnUpdateClientData() Set up data sent only to specific client; (wd) SDK2 */
|
||||
// #define FN_AddToFullPack AddToFullPack /* pfnAddToFullPack() (wd) SDK2 */
|
||||
// #define FN_CreateBaseline CreateBaseline /* pfnCreateBaseline() Tweak entity baseline for network encoding allows setup of player baselines too.; (wd) SDK2 */
|
||||
// #define FN_RegisterEncoders RegisterEncoders /* pfnRegisterEncoders() Callbacks for network encoding; (wd) SDK2 */
|
||||
// #define FN_GetWeaponData GetWeaponData /* pfnGetWeaponData() (wd) SDK2 */
|
||||
// #define FN_CmdStart CmdStart /* pfnCmdStart() (wd) SDK2 */
|
||||
// #define FN_CmdEnd CmdEnd /* pfnCmdEnd() (wd) SDK2 */
|
||||
// #define FN_ConnectionlessPacket ConnectionlessPacket /* pfnConnectionlessPacket() (wd) SDK2 */
|
||||
// #define FN_GetHullBounds GetHullBounds /* pfnGetHullBounds() (wd) SDK2 */
|
||||
// #define FN_CreateInstancedBaselines CreateInstancedBaselines /* pfnCreateInstancedBaselines() (wd) SDK2 */
|
||||
// #define FN_InconsistentFile InconsistentFile /* pfnInconsistentFile() (wd) SDK2 */
|
||||
// #define FN_AllowLagCompensation AllowLagCompensation /* pfnAllowLagCompensation() (wd) SDK2 */
|
||||
|
||||
// - GetEntityAPI2_Post functions
|
||||
// #define FN_GameDLLInit_Post GameDLLInit_Post
|
||||
// #define FN_DispatchSpawn_Post DispatchSpawn_Post
|
||||
// #define FN_DispatchThink_Post DispatchThink_Post
|
||||
// #define FN_DispatchUse_Post DispatchUse_Post
|
||||
// #define FN_DispatchTouch_Post DispatchTouch_Post
|
||||
// #define FN_DispatchBlocked_Post DispatchBlocked_Post
|
||||
// #define FN_DispatchKeyValue_Post DispatchKeyValue_Post
|
||||
// #define FN_DispatchSave_Post DispatchSave_Post
|
||||
// #define FN_DispatchRestore_Post DispatchRestore_Post
|
||||
// #define FN_DispatchObjectCollsionBox_Post DispatchObjectCollsionBox_Post
|
||||
// #define FN_SaveWriteFields_Post SaveWriteFields_Post
|
||||
// #define FN_SaveReadFields_Post SaveReadFields_Post
|
||||
// #define FN_SaveGlobalState_Post SaveGlobalState_Post
|
||||
// #define FN_RestoreGlobalState_Post RestoreGlobalState_Post
|
||||
// #define FN_ResetGlobalState_Post ResetGlobalState_Post
|
||||
// #define FN_ClientConnect_Post ClientConnect_Post
|
||||
// #define FN_ClientDisconnect_Post ClientDisconnect_Post
|
||||
// #define FN_ClientKill_Post ClientKill_Post
|
||||
// #define FN_ClientPutInServer_Post ClientPutInServer_Post
|
||||
// #define FN_ClientCommand_Post ClientCommand_Post
|
||||
// #define FN_ClientUserInfoChanged_Post ClientUserInfoChanged_Post
|
||||
// #define FN_ServerActivate_Post ServerActivate_Post
|
||||
// #define FN_ServerDeactivate_Post ServerDeactivate_Post
|
||||
// #define FN_PlayerPreThink_Post PlayerPreThink_Post
|
||||
// #define FN_PlayerPostThink_Post PlayerPostThink_Post
|
||||
// #define FN_StartFrame_Post StartFrame_Post
|
||||
// #define FN_ParmsNewLevel_Post ParmsNewLevel_Post
|
||||
// #define FN_ParmsChangeLevel_Post ParmsChangeLevel_Post
|
||||
// #define FN_GetGameDescription_Post GetGameDescription_Post
|
||||
// #define FN_PlayerCustomization_Post PlayerCustomization_Post
|
||||
// #define FN_SpectatorConnect_Post SpectatorConnect_Post
|
||||
// #define FN_SpectatorDisconnect_Post SpectatorDisconnect_Post
|
||||
// #define FN_SpectatorThink_Post SpectatorThink_Post
|
||||
// #define FN_Sys_Error_Post Sys_Error_Post
|
||||
// #define FN_PM_Move_Post PM_Move_Post
|
||||
// #define FN_PM_Init_Post PM_Init_Post
|
||||
// #define FN_PM_FindTextureType_Post PM_FindTextureType_Post
|
||||
// #define FN_SetupVisibility_Post SetupVisibility_Post
|
||||
// #define FN_UpdateClientData_Post UpdateClientData_Post
|
||||
// #define FN_AddToFullPack_Post AddToFullPack_Post
|
||||
// #define FN_CreateBaseline_Post CreateBaseline_Post
|
||||
// #define FN_RegisterEncoders_Post RegisterEncoders_Post
|
||||
// #define FN_GetWeaponData_Post GetWeaponData_Post
|
||||
// #define FN_CmdStart_Post CmdStart_Post
|
||||
// #define FN_CmdEnd_Post CmdEnd_Post
|
||||
// #define FN_ConnectionlessPacket_Post ConnectionlessPacket_Post
|
||||
// #define FN_GetHullBounds_Post GetHullBounds_Post
|
||||
// #define FN_CreateInstancedBaselines_Post CreateInstancedBaselines_Post
|
||||
// #define FN_InconsistentFile_Post InconsistentFile_Post
|
||||
// #define FN_AllowLagCompensation_Post AllowLagCompensation_Post
|
||||
|
||||
// - GetEngineAPI functions
|
||||
// #define FN_PrecacheModel PrecacheModel
|
||||
// #define FN_PrecacheSound PrecacheSound
|
||||
// #define FN_SetModel SetModel
|
||||
// #define FN_ModelIndex ModelIndex
|
||||
// #define FN_ModelFrames ModelFrames
|
||||
// #define FN_SetSize SetSize
|
||||
// #define FN_ChangeLevel ChangeLevel
|
||||
// #define FN_GetSpawnParms GetSpawnParms
|
||||
// #define FN_SaveSpawnParms SaveSpawnParms
|
||||
// #define FN_VecToYaw VecToYaw
|
||||
// #define FN_VecToAngles VecToAngles
|
||||
// #define FN_MoveToOrigin MoveToOrigin
|
||||
// #define FN_ChangeYaw ChangeYaw
|
||||
// #define FN_ChangePitch ChangePitch
|
||||
// #define FN_FindEntityByString FindEntityByString
|
||||
// #define FN_GetEntityIllum GetEntityIllum
|
||||
// #define FN_FindEntityInSphere FindEntityInSphere
|
||||
// #define FN_FindClientInPVS FindClientInPVS
|
||||
// #define FN_EntitiesInPVS EntitiesInPVS
|
||||
// #define FN_MakeVectors MakeVectors
|
||||
// #define FN_AngleVectors AngleVectors
|
||||
// #define FN_CreateEntity CreateEntity
|
||||
// #define FN_RemoveEntity RemoveEntity
|
||||
// #define FN_CreateNamedEntity CreateNamedEntity
|
||||
// #define FN_MakeStatic MakeStatic
|
||||
// #define FN_EntIsOnFloor EntIsOnFloor
|
||||
// #define FN_DropToFloor DropToFloor
|
||||
// #define FN_WalkMove WalkMove
|
||||
// #define FN_SetOrigin SetOrigin
|
||||
// #define FN_EmitSound EmitSound
|
||||
// #define FN_EmitAmbientSound EmitAmbientSound
|
||||
// #define FN_TraceLine TraceLine
|
||||
// #define FN_TraceToss TraceToss
|
||||
// #define FN_TraceMonsterHull TraceMonsterHull
|
||||
// #define FN_TraceHull TraceHull
|
||||
// #define FN_TraceModel TraceModel
|
||||
// #define FN_TraceTexture TraceTexture
|
||||
// #define FN_TraceSphere TraceSphere
|
||||
// #define FN_GetAimVector GetAimVector
|
||||
// #define FN_ServerCommand ServerCommand
|
||||
// #define FN_ServerExecute ServerExecute
|
||||
// #define FN_engClientCommand engClientCommand
|
||||
// #define FN_ParticleEffect ParticleEffect
|
||||
// #define FN_LightStyle LightStyle
|
||||
// #define FN_DecalIndex DecalIndex
|
||||
// #define FN_PointContents PointContents
|
||||
// #define FN_MessageBegin MessageBegin
|
||||
// #define FN_MessageEnd MessageEnd
|
||||
// #define FN_WriteByte WriteByte
|
||||
// #define FN_WriteChar WriteChar
|
||||
// #define FN_WriteShort WriteShort
|
||||
// #define FN_WriteLong WriteLong
|
||||
// #define FN_WriteAngle WriteAngle
|
||||
// #define FN_WriteCoord WriteCoord
|
||||
// #define FN_WriteString WriteString
|
||||
// #define FN_WriteEntity WriteEntity
|
||||
// #define FN_CVarRegister CVarRegister
|
||||
// #define FN_CVarGetFloat CVarGetFloat
|
||||
// #define FN_CVarGetString CVarGetString
|
||||
// #define FN_CVarSetFloat CVarSetFloat
|
||||
// #define FN_CVarSetString CVarSetString
|
||||
// #define FN_AlertMessage AlertMessage
|
||||
// #define FN_EngineFprintf EngineFprintf
|
||||
// #define FN_PvAllocEntPrivateData PvAllocEntPrivateData
|
||||
// #define FN_PvEntPrivateData PvEntPrivateData
|
||||
// #define FN_FreeEntPrivateData FreeEntPrivateData
|
||||
// #define FN_SzFromIndex SzFromIndex
|
||||
// #define FN_AllocString AllocString
|
||||
// #define FN_GetVarsOfEnt GetVarsOfEnt
|
||||
// #define FN_PEntityOfEntOffset PEntityOfEntOffset
|
||||
// #define FN_EntOffsetOfPEntity EntOffsetOfPEntity
|
||||
// #define FN_IndexOfEdict IndexOfEdict
|
||||
// #define FN_PEntityOfEntIndex PEntityOfEntIndex
|
||||
// #define FN_FindEntityByVars FindEntityByVars
|
||||
// #define FN_GetModelPtr GetModelPtr
|
||||
// #define FN_RegUserMsg RegUserMsg
|
||||
// #define FN_AnimationAutomove AnimationAutomove
|
||||
// #define FN_GetBonePosition GetBonePosition
|
||||
// #define FN_FunctionFromName FunctionFromName
|
||||
// #define FN_NameForFunction NameForFunction
|
||||
// #define FN_ClientPrintf ClientPrintf
|
||||
// #define FN_ServerPrint ServerPrint
|
||||
// #define FN_Cmd_Args Cmd_Args
|
||||
// #define FN_Cmd_Argv Cmd_Argv
|
||||
// #define FN_Cmd_Argc Cmd_Argc
|
||||
// #define FN_GetAttachment GetAttachment
|
||||
// #define FN_CRC32_Init CRC32_Init
|
||||
// #define FN_CRC32_ProcessBuffer CRC32_ProcessBuffer
|
||||
// #define FN_CRC32_ProcessByte CRC32_ProcessByte
|
||||
// #define FN_CRC32_Final CRC32_Final
|
||||
// #define FN_RandomLong RandomLong
|
||||
// #define FN_RandomFloat RandomFloat
|
||||
// #define FN_SetView SetView
|
||||
// #define FN_Time Time
|
||||
// #define FN_CrosshairAngle CrosshairAngle
|
||||
// #define FN_LoadFileForMe LoadFileForMe
|
||||
// #define FN_FreeFile FreeFile
|
||||
// #define FN_EndSection EndSection
|
||||
// #define FN_CompareFileTime CompareFileTime
|
||||
// #define FN_GetGameDir GetGameDir
|
||||
// #define FN_Cvar_RegisterVariable Cvar_RegisterVariable
|
||||
// #define FN_FadeClientVolume FadeClientVolume
|
||||
// #define FN_SetClientMaxspeed SetClientMaxspeed
|
||||
// #define FN_CreateFakeClient CreateFakeClient
|
||||
// #define FN_RunPlayerMove RunPlayerMove
|
||||
// #define FN_NumberOfEntities NumberOfEntities
|
||||
// #define FN_GetInfoKeyBuffer GetInfoKeyBuffer
|
||||
// #define FN_InfoKeyValue InfoKeyValue
|
||||
// #define FN_SetKeyValue SetKeyValue
|
||||
// #define FN_SetClientKeyValue SetClientKeyValue
|
||||
// #define FN_IsMapValid IsMapValid
|
||||
// #define FN_StaticDecal StaticDecal
|
||||
// #define FN_PrecacheGeneric PrecacheGeneric
|
||||
// #define FN_GetPlayerUserId GetPlayerUserId
|
||||
// #define FN_BuildSoundMsg BuildSoundMsg
|
||||
// #define FN_IsDedicatedServer IsDedicatedServer
|
||||
// #define FN_CVarGetPointer CVarGetPointer
|
||||
// #define FN_GetPlayerWONId GetPlayerWONId
|
||||
// #define FN_Info_RemoveKey Info_RemoveKey
|
||||
// #define FN_GetPhysicsKeyValue GetPhysicsKeyValue
|
||||
// #define FN_SetPhysicsKeyValue SetPhysicsKeyValue
|
||||
// #define FN_GetPhysicsInfoString GetPhysicsInfoString
|
||||
// #define FN_PrecacheEvent PrecacheEvent
|
||||
// #define FN_PlaybackEvent PlaybackEvent
|
||||
// #define FN_SetFatPVS SetFatPVS
|
||||
// #define FN_SetFatPAS SetFatPAS
|
||||
// #define FN_CheckVisibility CheckVisibility
|
||||
// #define FN_DeltaSetField DeltaSetField
|
||||
// #define FN_DeltaUnsetField DeltaUnsetField
|
||||
// #define FN_DeltaAddEncoder DeltaAddEncoder
|
||||
// #define FN_GetCurrentPlayer GetCurrentPlayer
|
||||
// #define FN_CanSkipPlayer CanSkipPlayer
|
||||
// #define FN_DeltaFindField DeltaFindField
|
||||
// #define FN_DeltaSetFieldByIndex DeltaSetFieldByIndex
|
||||
// #define FN_DeltaUnsetFieldByIndex DeltaUnsetFieldByIndex
|
||||
// #define FN_SetGroupMask SetGroupMask
|
||||
// #define FN_engCreateInstancedBaseline engCreateInstancedBaseline
|
||||
// #define FN_Cvar_DirectSet Cvar_DirectSet
|
||||
// #define FN_ForceUnmodified ForceUnmodified
|
||||
// #define FN_GetPlayerStats GetPlayerStats
|
||||
// #define FN_AddServerCommand AddServerCommand
|
||||
// #define FN_Voice_GetClientListening Voice_GetClientListening
|
||||
// #define FN_Voice_SetClientListening Voice_SetClientListening
|
||||
// #define FN_GetPlayerAuthId GetPlayerAuthId
|
||||
|
||||
// - GetEngineAPI_Post functions
|
||||
// #define FN_PrecacheModel_Post PrecacheModel_Post
|
||||
// #define FN_PrecacheSound_Post PrecacheSound_Post
|
||||
// #define FN_SetModel_Post SetModel_Post
|
||||
// #define FN_ModelIndex_Post ModelIndex_Post
|
||||
// #define FN_ModelFrames_Post ModelFrames_Post
|
||||
// #define FN_SetSize_Post SetSize_Post
|
||||
// #define FN_ChangeLevel_Post ChangeLevel_Post
|
||||
// #define FN_GetSpawnParms_Post GetSpawnParms_Post
|
||||
// #define FN_SaveSpawnParms_Post SaveSpawnParms_Post
|
||||
// #define FN_VecToYaw_Post VecToYaw_Post
|
||||
// #define FN_VecToAngles_Post VecToAngles_Post
|
||||
// #define FN_MoveToOrigin_Post MoveToOrigin_Post
|
||||
// #define FN_ChangeYaw_Post ChangeYaw_Post
|
||||
// #define FN_ChangePitch_Post ChangePitch_Post
|
||||
// #define FN_FindEntityByString_Post FindEntityByString_Post
|
||||
// #define FN_GetEntityIllum_Post GetEntityIllum_Post
|
||||
// #define FN_FindEntityInSphere_Post FindEntityInSphere_Post
|
||||
// #define FN_FindClientInPVS_Post FindClientInPVS_Post
|
||||
// #define FN_EntitiesInPVS_Post EntitiesInPVS_Post
|
||||
// #define FN_MakeVectors_Post MakeVectors_Post
|
||||
// #define FN_AngleVectors_Post AngleVectors_Post
|
||||
// #define FN_CreateEntity_Post CreateEntity_Post
|
||||
// #define FN_RemoveEntity_Post RemoveEntity_Post
|
||||
// #define FN_CreateNamedEntity_Post CreateNamedEntity_Post
|
||||
// #define FN_MakeStatic_Post MakeStatic_Post
|
||||
// #define FN_EntIsOnFloor_Post EntIsOnFloor_Post
|
||||
// #define FN_DropToFloor_Post DropToFloor_Post
|
||||
// #define FN_WalkMove_Post WalkMove_Post
|
||||
// #define FN_SetOrigin_Post SetOrigin_Post
|
||||
// #define FN_EmitSound_Post EmitSound_Post
|
||||
// #define FN_EmitAmbientSound_Post EmitAmbientSound_Post
|
||||
// #define FN_TraceLine_Post TraceLine_Post
|
||||
// #define FN_TraceToss_Post TraceToss_Post
|
||||
// #define FN_TraceMonsterHull_Post TraceMonsterHull_Post
|
||||
// #define FN_TraceHull_Post TraceHull_Post
|
||||
// #define FN_TraceModel_Post TraceModel_Post
|
||||
// #define FN_TraceTexture_Post TraceTexture_Post
|
||||
// #define FN_TraceSphere_Post TraceSphere_Post
|
||||
// #define FN_GetAimVector_Post GetAimVector_Post
|
||||
// #define FN_ServerCommand_Post ServerCommand_Post
|
||||
// #define FN_ServerExecute_Post ServerExecute_Post
|
||||
// #define FN_engClientCommand_Post engClientCommand_Post
|
||||
// #define FN_ParticleEffect_Post ParticleEffect_Post
|
||||
// #define FN_LightStyle_Post LightStyle_Post
|
||||
// #define FN_DecalIndex_Post DecalIndex_Post
|
||||
// #define FN_PointContents_Post PointContents_Post
|
||||
// #define FN_MessageBegin_Post MessageBegin_Post
|
||||
// #define FN_MessageEnd_Post MessageEnd_Post
|
||||
// #define FN_WriteByte_Post WriteByte_Post
|
||||
// #define FN_WriteChar_Post WriteChar_Post
|
||||
// #define FN_WriteShort_Post WriteShort_Post
|
||||
// #define FN_WriteLong_Post WriteLong_Post
|
||||
// #define FN_WriteAngle_Post WriteAngle_Post
|
||||
// #define FN_WriteCoord_Post WriteCoord_Post
|
||||
// #define FN_WriteString_Post WriteString_Post
|
||||
// #define FN_WriteEntity_Post WriteEntity_Post
|
||||
// #define FN_CVarRegister_Post CVarRegister_Post
|
||||
// #define FN_CVarGetFloat_Post CVarGetFloat_Post
|
||||
// #define FN_CVarGetString_Post CVarGetString_Post
|
||||
// #define FN_CVarSetFloat_Post CVarSetFloat_Post
|
||||
// #define FN_CVarSetString_Post CVarSetString_Post
|
||||
// #define FN_AlertMessage_Post AlertMessage_Post
|
||||
// #define FN_EngineFprintf_Post EngineFprintf_Post
|
||||
// #define FN_PvAllocEntPrivateData_Post PvAllocEntPrivateData_Post
|
||||
// #define FN_PvEntPrivateData_Post PvEntPrivateData_Post
|
||||
// #define FN_FreeEntPrivateData_Post FreeEntPrivateData_Post
|
||||
// #define FN_SzFromIndex_Post SzFromIndex_Post
|
||||
// #define FN_AllocString_Post AllocString_Post
|
||||
// #define FN_GetVarsOfEnt_Post GetVarsOfEnt_Post
|
||||
// #define FN_PEntityOfEntOffset_Post PEntityOfEntOffset_Post
|
||||
// #define FN_EntOffsetOfPEntity_Post EntOffsetOfPEntity_Post
|
||||
// #define FN_IndexOfEdict_Post IndexOfEdict_Post
|
||||
// #define FN_PEntityOfEntIndex_Post PEntityOfEntIndex_Post
|
||||
// #define FN_FindEntityByVars_Post FindEntityByVars_Post
|
||||
// #define FN_GetModelPtr_Post GetModelPtr_Post
|
||||
// #define FN_RegUserMsg_Post RegUserMsg_Post
|
||||
// #define FN_AnimationAutomove_Post AnimationAutomove_Post
|
||||
// #define FN_GetBonePosition_Post GetBonePosition_Post
|
||||
// #define FN_FunctionFromName_Post FunctionFromName_Post
|
||||
// #define FN_NameForFunction_Post NameForFunction_Post
|
||||
// #define FN_ClientPrintf_Post ClientPrintf_Post
|
||||
// #define FN_ServerPrint_Post ServerPrint_Post
|
||||
// #define FN_Cmd_Args_Post Cmd_Args_Post
|
||||
// #define FN_Cmd_Argv_Post Cmd_Argv_Post
|
||||
// #define FN_Cmd_Argc_Post Cmd_Argc_Post
|
||||
// #define FN_GetAttachment_Post GetAttachment_Post
|
||||
// #define FN_CRC32_Init_Post CRC32_Init_Post
|
||||
// #define FN_CRC32_ProcessBuffer_Post CRC32_ProcessBuffer_Post
|
||||
// #define FN_CRC32_ProcessByte_Post CRC32_ProcessByte_Post
|
||||
// #define FN_CRC32_Final_Post CRC32_Final_Post
|
||||
// #define FN_RandomLong_Post RandomLong_Post
|
||||
// #define FN_RandomFloat_Post RandomFloat_Post
|
||||
// #define FN_SetView_Post SetView_Post
|
||||
// #define FN_Time_Post Time_Post
|
||||
// #define FN_CrosshairAngle_Post CrosshairAngle_Post
|
||||
// #define FN_LoadFileForMe_Post LoadFileForMe_Post
|
||||
// #define FN_FreeFile_Post FreeFile_Post
|
||||
// #define FN_EndSection_Post EndSection_Post
|
||||
// #define FN_CompareFileTime_Post CompareFileTime_Post
|
||||
// #define FN_GetGameDir_Post GetGameDir_Post
|
||||
// #define FN_Cvar_RegisterVariable_Post Cvar_RegisterVariable_Post
|
||||
// #define FN_FadeClientVolume_Post FadeClientVolume_Post
|
||||
// #define FN_SetClientMaxspeed_Post SetClientMaxspeed_Post
|
||||
// #define FN_CreateFakeClient_Post CreateFakeClient_Post
|
||||
// #define FN_RunPlayerMove_Post RunPlayerMove_Post
|
||||
// #define FN_NumberOfEntities_Post NumberOfEntities_Post
|
||||
// #define FN_GetInfoKeyBuffer_Post GetInfoKeyBuffer_Post
|
||||
// #define FN_InfoKeyValue_Post InfoKeyValue_Post
|
||||
// #define FN_SetKeyValue_Post SetKeyValue_Post
|
||||
// #define FN_SetClientKeyValue_Post SetClientKeyValue_Post
|
||||
// #define FN_IsMapValid_Post IsMapValid_Post
|
||||
// #define FN_StaticDecal_Post StaticDecal_Post
|
||||
// #define FN_PrecacheGeneric_Post PrecacheGeneric_Post
|
||||
// #define FN_GetPlayerUserId_Post GetPlayerUserId_Post
|
||||
// #define FN_BuildSoundMsg_Post BuildSoundMsg_Post
|
||||
// #define FN_IsDedicatedServer_Post IsDedicatedServer_Post
|
||||
// #define FN_CVarGetPointer_Post CVarGetPointer_Post
|
||||
// #define FN_GetPlayerWONId_Post GetPlayerWONId_Post
|
||||
// #define FN_Info_RemoveKey_Post Info_RemoveKey_Post
|
||||
// #define FN_GetPhysicsKeyValue_Post GetPhysicsKeyValue_Post
|
||||
// #define FN_SetPhysicsKeyValue_Post SetPhysicsKeyValue_Post
|
||||
// #define FN_GetPhysicsInfoString_Post GetPhysicsInfoString_Post
|
||||
// #define FN_PrecacheEvent_Post PrecacheEvent_Post
|
||||
// #define FN_PlaybackEvent_Post PlaybackEvent_Post
|
||||
// #define FN_SetFatPVS_Post SetFatPVS_Post
|
||||
// #define FN_SetFatPAS_Post SetFatPAS_Post
|
||||
// #define FN_CheckVisibility_Post CheckVisibility_Post
|
||||
// #define FN_DeltaSetField_Post DeltaSetField_Post
|
||||
// #define FN_DeltaUnsetField_Post DeltaUnsetField_Post
|
||||
// #define FN_DeltaAddEncoder_Post DeltaAddEncoder_Post
|
||||
// #define FN_GetCurrentPlayer_Post GetCurrentPlayer_Post
|
||||
// #define FN_CanSkipPlayer_Post CanSkipPlayer_Post
|
||||
// #define FN_DeltaFindField_Post DeltaFindField_Post
|
||||
// #define FN_DeltaSetFieldByIndex_Post DeltaSetFieldByIndex_Post
|
||||
// #define FN_DeltaUnsetFieldByIndex_Post DeltaUnsetFieldByIndex_Post
|
||||
// #define FN_SetGroupMask_Post SetGroupMask_Post
|
||||
// #define FN_engCreateInstancedBaseline_Post engCreateInstancedBaseline_Post
|
||||
// #define FN_Cvar_DirectSet_Post Cvar_DirectSet_Post
|
||||
// #define FN_ForceUnmodified_Post ForceUnmodified_Post
|
||||
// #define FN_GetPlayerStats_Post GetPlayerStats_Post
|
||||
// #define FN_AddServerCommand_Post AddServerCommand_Post
|
||||
// #define FN_Voice_GetClientListening_Post Voice_GetClientListening_Post
|
||||
// #define FN_Voice_SetClientListening_Post Voice_SetClientListening_Post
|
||||
// #define FN_GetPlayerAuthId_Post GetPlayerAuthId_Post
|
||||
|
||||
// #define FN_OnFreeEntPrivateData OnFreeEntPrivateData
|
||||
// #define FN_GameShutdown GameShutdown
|
||||
// #define FN_ShouldCollide ShouldCollide
|
||||
|
||||
// #define FN_OnFreeEntPrivateData_Post OnFreeEntPrivateData_Post
|
||||
// #define FN_GameShutdown_Post GameShutdown_Post
|
||||
// #define FN_ShouldCollide_Post ShouldCollide_Post
|
||||
|
||||
|
||||
#endif // USE_METAMOD
|
||||
|
||||
#endif // __MODULECONFIG_H__
|
Loading…
Reference in New Issue
Block a user