Annotation of embedaddon/php/Zend/zend_ini.h, revision 1.1.1.1
1.1 misho 1: /*
2: +----------------------------------------------------------------------+
3: | Zend Engine |
4: +----------------------------------------------------------------------+
5: | Copyright (c) 1998-2012 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 321634 2012-01-01 13:15:04Z felipe $ */
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(__arm) && !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: typedef struct _zend_ini_entry zend_ini_entry;
61:
62: #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)
63: #define ZEND_INI_DISP(name) void name(zend_ini_entry *ini_entry, int type)
64:
65: struct _zend_ini_entry {
66: int module_number;
67: int modifiable;
68: char *name;
69: uint name_length;
70: ZEND_INI_MH((*on_modify));
71: void *mh_arg1;
72: void *mh_arg2;
73: void *mh_arg3;
74:
75: char *value;
76: uint value_length;
77:
78: char *orig_value;
79: uint orig_value_length;
80: int orig_modifiable;
81: int modified;
82:
83: void (*displayer)(zend_ini_entry *ini_entry, int type);
84: };
85:
86: BEGIN_EXTERN_C()
87: ZEND_API int zend_ini_startup(TSRMLS_D);
88: ZEND_API int zend_ini_shutdown(TSRMLS_D);
89: ZEND_API int zend_ini_global_shutdown(TSRMLS_D);
90: ZEND_API int zend_ini_deactivate(TSRMLS_D);
91:
92: ZEND_API int zend_copy_ini_directives(TSRMLS_D);
93:
94: ZEND_API void zend_ini_sort_entries(TSRMLS_D);
95:
96: ZEND_API int zend_register_ini_entries(const zend_ini_entry *ini_entry, int module_number TSRMLS_DC);
97: ZEND_API void zend_unregister_ini_entries(int module_number TSRMLS_DC);
98: ZEND_API void zend_ini_refresh_caches(int stage TSRMLS_DC);
99: ZEND_API int zend_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type, int stage);
100: 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);
101: ZEND_API int zend_restore_ini_entry(char *name, uint name_length, int stage);
102: ZEND_API void display_ini_entries(zend_module_entry *module);
103:
104: ZEND_API long zend_ini_long(char *name, uint name_length, int orig);
105: ZEND_API double zend_ini_double(char *name, uint name_length, int orig);
106: ZEND_API char *zend_ini_string(char *name, uint name_length, int orig);
107: ZEND_API char *zend_ini_string_ex(char *name, uint name_length, int orig, zend_bool *exists);
108:
109: ZEND_API int zend_ini_register_displayer(char *name, uint name_length, void (*displayer)(zend_ini_entry *ini_entry, int type));
110:
111: ZEND_API ZEND_INI_DISP(zend_ini_boolean_displayer_cb);
112: ZEND_API ZEND_INI_DISP(zend_ini_color_displayer_cb);
113: ZEND_API ZEND_INI_DISP(display_link_numbers);
114: END_EXTERN_C()
115:
116: #define ZEND_INI_BEGIN() static const zend_ini_entry ini_entries[] = {
117: #define ZEND_INI_END() { 0, 0, NULL, 0, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0, 0, NULL } };
118:
119: #define ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, arg1, arg2, arg3, displayer) \
120: { 0, modifiable, name, sizeof(name), on_modify, arg1, arg2, arg3, default_value, sizeof(default_value)-1, NULL, 0, 0, 0, displayer },
121:
122: #define ZEND_INI_ENTRY3(name, default_value, modifiable, on_modify, arg1, arg2, arg3) \
123: ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, arg1, arg2, arg3, NULL)
124:
125: #define ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, arg1, arg2, displayer) \
126: ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, arg1, arg2, NULL, displayer)
127:
128: #define ZEND_INI_ENTRY2(name, default_value, modifiable, on_modify, arg1, arg2) \
129: ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, arg1, arg2, NULL)
130:
131: #define ZEND_INI_ENTRY1_EX(name, default_value, modifiable, on_modify, arg1, displayer) \
132: ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, arg1, NULL, NULL, displayer)
133:
134: #define ZEND_INI_ENTRY1(name, default_value, modifiable, on_modify, arg1) \
135: ZEND_INI_ENTRY1_EX(name, default_value, modifiable, on_modify, arg1, NULL)
136:
137: #define ZEND_INI_ENTRY_EX(name, default_value, modifiable, on_modify, displayer) \
138: ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, NULL, NULL, NULL, displayer)
139:
140: #define ZEND_INI_ENTRY(name, default_value, modifiable, on_modify) \
141: ZEND_INI_ENTRY_EX(name, default_value, modifiable, on_modify, NULL)
142:
143: #ifdef ZTS
144: #define STD_ZEND_INI_ENTRY(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
145: ZEND_INI_ENTRY2(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id)
146: #define STD_ZEND_INI_ENTRY_EX(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr, displayer) \
147: ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id, displayer)
148: #define STD_ZEND_INI_BOOLEAN(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
149: 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)
150: #else
151: #define STD_ZEND_INI_ENTRY(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
152: ZEND_INI_ENTRY2(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr)
153: #define STD_ZEND_INI_ENTRY_EX(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr, displayer) \
154: ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr, displayer)
155: #define STD_ZEND_INI_BOOLEAN(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
156: 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)
157: #endif
158:
159: #define INI_INT(name) zend_ini_long((name), sizeof(name), 0)
160: #define INI_FLT(name) zend_ini_double((name), sizeof(name), 0)
161: #define INI_STR(name) zend_ini_string_ex((name), sizeof(name), 0, NULL)
162: #define INI_BOOL(name) ((zend_bool) INI_INT(name))
163:
164: #define INI_ORIG_INT(name) zend_ini_long((name), sizeof(name), 1)
165: #define INI_ORIG_FLT(name) zend_ini_double((name), sizeof(name), 1)
166: #define INI_ORIG_STR(name) zend_ini_string((name), sizeof(name), 1)
167: #define INI_ORIG_BOOL(name) ((zend_bool) INI_ORIG_INT(name))
168:
169: #define REGISTER_INI_ENTRIES() zend_register_ini_entries(ini_entries, module_number TSRMLS_CC)
170: #define UNREGISTER_INI_ENTRIES() zend_unregister_ini_entries(module_number TSRMLS_CC)
171: #define DISPLAY_INI_ENTRIES() display_ini_entries(zend_module)
172:
173: #define REGISTER_INI_DISPLAYER(name, displayer) zend_ini_register_displayer((name), sizeof(name), displayer)
174: #define REGISTER_INI_BOOLEAN(name) REGISTER_INI_DISPLAYER(name, zend_ini_boolean_displayer_cb)
175:
176: /* Standard message handlers */
177: BEGIN_EXTERN_C()
178: ZEND_API ZEND_INI_MH(OnUpdateBool);
179: ZEND_API ZEND_INI_MH(OnUpdateLong);
180: ZEND_API ZEND_INI_MH(OnUpdateLongGEZero);
181: ZEND_API ZEND_INI_MH(OnUpdateReal);
182: ZEND_API ZEND_INI_MH(OnUpdateString);
183: ZEND_API ZEND_INI_MH(OnUpdateStringUnempty);
184: END_EXTERN_C()
185:
186: #define ZEND_INI_DISPLAY_ORIG 1
187: #define ZEND_INI_DISPLAY_ACTIVE 2
188:
189: #define ZEND_INI_STAGE_STARTUP (1<<0)
190: #define ZEND_INI_STAGE_SHUTDOWN (1<<1)
191: #define ZEND_INI_STAGE_ACTIVATE (1<<2)
192: #define ZEND_INI_STAGE_DEACTIVATE (1<<3)
193: #define ZEND_INI_STAGE_RUNTIME (1<<4)
194: #define ZEND_INI_STAGE_HTACCESS (1<<5)
195:
196: /* INI parsing engine */
197: typedef void (*zend_ini_parser_cb_t)(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg TSRMLS_DC);
198: BEGIN_EXTERN_C()
199: 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);
200: 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);
201: END_EXTERN_C()
202:
203: /* INI entries */
204: #define ZEND_INI_PARSER_ENTRY 1 /* Normal entry: foo = bar */
205: #define ZEND_INI_PARSER_SECTION 2 /* Section: [foobar] */
206: #define ZEND_INI_PARSER_POP_ENTRY 3 /* Offset entry: foo[] = bar */
207:
208: typedef struct _zend_ini_parser_param {
209: zend_ini_parser_cb_t ini_parser_cb;
210: void *arg;
211: } zend_ini_parser_param;
212:
213: #endif /* ZEND_INI_H */
214:
215: /*
216: * Local variables:
217: * tab-width: 4
218: * c-basic-offset: 4
219: * indent-tabs-mode: t
220: * End:
221: */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>