-
Notifications
You must be signed in to change notification settings - Fork 1
/
php_geoip_class.h
116 lines (101 loc) · 4.04 KB
/
php_geoip_class.h
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
* Copyright 2022. JoungKyun.Kim All rights reserved.
*
* This file is part of mod_geoip
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE as published
* by the Free Software Foundation; either version 2 of the License.
*
* This program 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 LESSER GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef PHP_GEOIP_CLASS_H
#define PHP_GEOIP_CLASS_H
/* {{{ Exception entry */
const zend_function_entry geoip_methods_exception[] = {
{NULL, NULL, NULL}
};
/* }}} */
/* Exception declear {{{
*
*/
#if defined(HAVE_SPL)
extern PHPAPI zend_class_entry *spl_ce_RuntimeException;
extern PHPAPI zend_class_entry *spl_ce_Countable;
#endif
#define GEOIP_REPLACE_ERROR_HANDLING \
zend_replace_error_handling ( \
EH_THROW, \
geoip_ce_exception, \
&error_handling \
)
// object ? EH_THROW : EH_NORMAL, \
#define GEOIP_RESTORE_ERROR_HANDLING zend_restore_error_handling (&error_handling)
/* }}} */
/* {{{ geoip_deps[]
*
* GEOIP dependancies
*/
const zend_module_dep geoip_deps[] = {
#if defined(HAVE_SPL)
ZEND_MOD_REQUIRED("spl")
#endif
{NULL, NULL, NULL}
};
/* }}} */
/* {{{ For Class declears */
const zend_function_entry geoip_methods[] = {
PHP_ME_MAPPING (__construct, geoip_open, arginfo_class_GeoIP___construct, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING (close, geoip_close, arginfo_class_GeoIP_close, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING (database_info, geoip_database_info, arginfo_class_GeoIP_database_info, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING (db_avail, geoip_db_avail, arginfo_class_GeoIP_db_avail, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING (country_code_by_name, geoip_country_code_by_name, arginfo_class_GeoIP_country_code_by_name, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING (country_name_by_name, geoip_country_name_by_name, arginfo_class_GeoIP_country_name_by_name, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING (id_by_name, geoip_id_by_name, arginfo_class_GeoIP_id_by_name, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING (record_by_name, geoip_record_by_name, arginfo_class_GeoIP_record_by_name, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING (org_by_name, geoip_org_by_name, arginfo_class_GeoIP_org_by_name, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
#define REGISTER_GEOIP_CLASS(parent) { \
zend_class_entry ce; \
INIT_CLASS_ENTRY (ce, "GeoIP", geoip_methods); \
ce.create_object = geoip_object_new_main; \
geoip_ce = zend_register_internal_class_ex (&ce, parent); \
memcpy(&geoip_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); \
geoip_object_handlers.clone_obj = NULL; \
geoip_ce->ce_flags |= ZEND_ACC_FINAL; \
}
#define REGISTER_GEOIP_PER_CLASS(name, c_name, parent) { \
zend_class_entry ce; \
INIT_CLASS_ENTRY(ce, "GeoIP" # name, geoip_methods_ ## c_name); \
ce.create_object = geoip_object_new_ ## c_name; \
geoip_ce_ ## c_name = zend_register_internal_class_ex(&ce, parent); \
memcpy(&geoip_object_handlers_ ## c_name, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); \
geoip_object_handlers_ ## c_name.clone_obj = NULL; \
geoip_ce_ ## c_name->ce_flags |= ZEND_ACC_FINAL; \
}
zend_class_entry * geoip_ce;
zend_class_entry * geoip_ce_exception;
static zend_object_handlers geoip_object_handlers;
static zend_object_handlers geoip_object_handlers_exception;
typedef struct _geoip_object {
GeoIP_API * db;
zend_object std;
} geoip_object;
/* For Class declears }}} */
#endif
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/