1: /*
2: +----------------------------------------------------------------------+
3: | Zend Engine |
4: +----------------------------------------------------------------------+
5: | Copyright (c) 1998-2014 Zend Technologies Ltd. (http://www.zend.com) |
6: +----------------------------------------------------------------------+
7: | This source file is subject to version 2.00 of the Zend license, |
8: | that is bundled with this package in the file LICENSE, and is |
9: | available through the world-wide-web at the following url: |
10: | http://www.zend.com/license/2_00.txt. |
11: | If you did not receive a copy of the Zend license and are unable to |
12: | obtain it through the world-wide-web, please send a note to |
13: | license@zend.com so we can mail you a copy immediately. |
14: +----------------------------------------------------------------------+
15: | Author: Zeev Suraski <zeev@zend.com> |
16: +----------------------------------------------------------------------+
17: */
18:
19: /* $Id: zend_ini.h,v 1.1.1.4 2014/06/15 20:04:03 misho Exp $ */
20:
21: #ifndef ZEND_INI_H
22: #define ZEND_INI_H
23:
24: #define ZEND_INI_USER (1<<0)
25: #define ZEND_INI_PERDIR (1<<1)
26: #define ZEND_INI_SYSTEM (1<<2)
27:
28: #define ZEND_INI_ALL (ZEND_INI_USER|ZEND_INI_PERDIR|ZEND_INI_SYSTEM)
29:
30: #ifndef XtOffsetOf
31: # if defined(CRAY) || (defined(__ARMCC_VERSION) && !defined(LINUX))
32: # ifdef __STDC__
33: # define XtOffset(p_type, field) _Offsetof(p_type, field)
34: # else
35: # ifdef CRAY2
36: # define XtOffset(p_type, field) \
37: (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
38:
39: # else /* !CRAY2 */
40:
41: # define XtOffset(p_type, field) ((unsigned int)&(((p_type)NULL)->field))
42:
43: # endif /* !CRAY2 */
44: # endif /* __STDC__ */
45: # else /* ! (CRAY || __arm) */
46:
47: # define XtOffset(p_type, field) \
48: ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
49:
50: # endif /* !CRAY */
51:
52: # ifdef offsetof
53: # define XtOffsetOf(s_type, field) offsetof(s_type, field)
54: # else
55: # define XtOffsetOf(s_type, field) XtOffset(s_type*, field)
56: # endif
57:
58: #endif
59:
60: #define ZEND_INI_MH(name) int name(zend_ini_entry *entry, char *new_value, uint new_value_length, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage TSRMLS_DC)
61: #define ZEND_INI_DISP(name) void name(zend_ini_entry *ini_entry, int type)
62:
63: struct _zend_ini_entry {
64: int module_number;
65: int modifiable;
66: char *name;
67: uint name_length;
68: ZEND_INI_MH((*on_modify));
69: void *mh_arg1;
70: void *mh_arg2;
71: void *mh_arg3;
72:
73: char *value;
74: uint value_length;
75:
76: char *orig_value;
77: uint orig_value_length;
78: int orig_modifiable;
79: int modified;
80:
81: void (*displayer)(zend_ini_entry *ini_entry, int type);
82: };
83:
84: BEGIN_EXTERN_C()
85: ZEND_API int zend_ini_startup(TSRMLS_D);
86: ZEND_API int zend_ini_shutdown(TSRMLS_D);
87: ZEND_API int zend_ini_global_shutdown(TSRMLS_D);
88: ZEND_API int zend_ini_deactivate(TSRMLS_D);
89:
90: ZEND_API int zend_copy_ini_directives(TSRMLS_D);
91:
92: ZEND_API void zend_ini_sort_entries(TSRMLS_D);
93:
94: ZEND_API int zend_register_ini_entries(const zend_ini_entry *ini_entry, int module_number TSRMLS_DC);
95: ZEND_API void zend_unregister_ini_entries(int module_number TSRMLS_DC);
96: ZEND_API void zend_ini_refresh_caches(int stage TSRMLS_DC);
97: ZEND_API int zend_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type, int stage);
98: ZEND_API int zend_alter_ini_entry_ex(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type, int stage, int force_change TSRMLS_DC);
99: ZEND_API int zend_restore_ini_entry(char *name, uint name_length, int stage);
100: ZEND_API void display_ini_entries(zend_module_entry *module);
101:
102: ZEND_API long zend_ini_long(char *name, uint name_length, int orig);
103: ZEND_API double zend_ini_double(char *name, uint name_length, int orig);
104: ZEND_API char *zend_ini_string(char *name, uint name_length, int orig);
105: ZEND_API char *zend_ini_string_ex(char *name, uint name_length, int orig, zend_bool *exists);
106:
107: ZEND_API int zend_ini_register_displayer(char *name, uint name_length, void (*displayer)(zend_ini_entry *ini_entry, int type));
108:
109: ZEND_API ZEND_INI_DISP(zend_ini_boolean_displayer_cb);
110: ZEND_API ZEND_INI_DISP(zend_ini_color_displayer_cb);
111: ZEND_API ZEND_INI_DISP(display_link_numbers);
112: END_EXTERN_C()
113:
114: #define ZEND_INI_BEGIN() static const zend_ini_entry ini_entries[] = {
115: #define ZEND_INI_END() { 0, 0, NULL, 0, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0, 0, NULL } };
116:
117: #define ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, arg1, arg2, arg3, displayer) \
118: { 0, modifiable, name, sizeof(name), on_modify, arg1, arg2, arg3, default_value, sizeof(default_value)-1, NULL, 0, 0, 0, displayer },
119:
120: #define ZEND_INI_ENTRY3(name, default_value, modifiable, on_modify, arg1, arg2, arg3) \
121: ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, arg1, arg2, arg3, NULL)
122:
123: #define ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, arg1, arg2, displayer) \
124: ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, arg1, arg2, NULL, displayer)
125:
126: #define ZEND_INI_ENTRY2(name, default_value, modifiable, on_modify, arg1, arg2) \
127: ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, arg1, arg2, NULL)
128:
129: #define ZEND_INI_ENTRY1_EX(name, default_value, modifiable, on_modify, arg1, displayer) \
130: ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, arg1, NULL, NULL, displayer)
131:
132: #define ZEND_INI_ENTRY1(name, default_value, modifiable, on_modify, arg1) \
133: ZEND_INI_ENTRY1_EX(name, default_value, modifiable, on_modify, arg1, NULL)
134:
135: #define ZEND_INI_ENTRY_EX(name, default_value, modifiable, on_modify, displayer) \
136: ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, NULL, NULL, NULL, displayer)
137:
138: #define ZEND_INI_ENTRY(name, default_value, modifiable, on_modify) \
139: ZEND_INI_ENTRY_EX(name, default_value, modifiable, on_modify, NULL)
140:
141: #ifdef ZTS
142: #define STD_ZEND_INI_ENTRY(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
143: ZEND_INI_ENTRY2(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id)
144: #define STD_ZEND_INI_ENTRY_EX(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr, displayer) \
145: ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id, displayer)
146: #define STD_ZEND_INI_BOOLEAN(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
147: ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id, NULL, zend_ini_boolean_displayer_cb)
148: #else
149: #define STD_ZEND_INI_ENTRY(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
150: ZEND_INI_ENTRY2(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr)
151: #define STD_ZEND_INI_ENTRY_EX(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr, displayer) \
152: ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr, displayer)
153: #define STD_ZEND_INI_BOOLEAN(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
154: ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr, NULL, zend_ini_boolean_displayer_cb)
155: #endif
156:
157: #define INI_INT(name) zend_ini_long((name), sizeof(name), 0)
158: #define INI_FLT(name) zend_ini_double((name), sizeof(name), 0)
159: #define INI_STR(name) zend_ini_string_ex((name), sizeof(name), 0, NULL)
160: #define INI_BOOL(name) ((zend_bool) INI_INT(name))
161:
162: #define INI_ORIG_INT(name) zend_ini_long((name), sizeof(name), 1)
163: #define INI_ORIG_FLT(name) zend_ini_double((name), sizeof(name), 1)
164: #define INI_ORIG_STR(name) zend_ini_string((name), sizeof(name), 1)
165: #define INI_ORIG_BOOL(name) ((zend_bool) INI_ORIG_INT(name))
166:
167: #define REGISTER_INI_ENTRIES() zend_register_ini_entries(ini_entries, module_number TSRMLS_CC)
168: #define UNREGISTER_INI_ENTRIES() zend_unregister_ini_entries(module_number TSRMLS_CC)
169: #define DISPLAY_INI_ENTRIES() display_ini_entries(zend_module)
170:
171: #define REGISTER_INI_DISPLAYER(name, displayer) zend_ini_register_displayer((name), sizeof(name), displayer)
172: #define REGISTER_INI_BOOLEAN(name) REGISTER_INI_DISPLAYER(name, zend_ini_boolean_displayer_cb)
173:
174: /* Standard message handlers */
175: BEGIN_EXTERN_C()
176: ZEND_API ZEND_INI_MH(OnUpdateBool);
177: ZEND_API ZEND_INI_MH(OnUpdateLong);
178: ZEND_API ZEND_INI_MH(OnUpdateLongGEZero);
179: ZEND_API ZEND_INI_MH(OnUpdateReal);
180: ZEND_API ZEND_INI_MH(OnUpdateString);
181: ZEND_API ZEND_INI_MH(OnUpdateStringUnempty);
182: END_EXTERN_C()
183:
184: #define ZEND_INI_DISPLAY_ORIG 1
185: #define ZEND_INI_DISPLAY_ACTIVE 2
186:
187: #define ZEND_INI_STAGE_STARTUP (1<<0)
188: #define ZEND_INI_STAGE_SHUTDOWN (1<<1)
189: #define ZEND_INI_STAGE_ACTIVATE (1<<2)
190: #define ZEND_INI_STAGE_DEACTIVATE (1<<3)
191: #define ZEND_INI_STAGE_RUNTIME (1<<4)
192: #define ZEND_INI_STAGE_HTACCESS (1<<5)
193:
194: /* INI parsing engine */
195: typedef void (*zend_ini_parser_cb_t)(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg TSRMLS_DC);
196: BEGIN_EXTERN_C()
197: ZEND_API int zend_parse_ini_file(zend_file_handle *fh, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg TSRMLS_DC);
198: ZEND_API int zend_parse_ini_string(char *str, zend_bool unbuffered_errors, int scanner_mode, zend_ini_parser_cb_t ini_parser_cb, void *arg TSRMLS_DC);
199: END_EXTERN_C()
200:
201: /* INI entries */
202: #define ZEND_INI_PARSER_ENTRY 1 /* Normal entry: foo = bar */
203: #define ZEND_INI_PARSER_SECTION 2 /* Section: [foobar] */
204: #define ZEND_INI_PARSER_POP_ENTRY 3 /* Offset entry: foo[] = bar */
205:
206: typedef struct _zend_ini_parser_param {
207: zend_ini_parser_cb_t ini_parser_cb;
208: void *arg;
209: } zend_ini_parser_param;
210:
211: #endif /* ZEND_INI_H */
212:
213: /*
214: * Local variables:
215: * tab-width: 4
216: * c-basic-offset: 4
217: * indent-tabs-mode: t
218: * End:
219: */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>