Back to index

php5  5.3.10
zend_ini.h
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | Zend Engine                                                          |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1998-2012 Zend Technologies Ltd. (http://www.zend.com) |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 2.00 of the Zend license,     |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.zend.com/license/2_00.txt.                                |
00011    | If you did not receive a copy of the Zend license and are unable to  |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@zend.com so we can mail you a copy immediately.              |
00014    +----------------------------------------------------------------------+
00015    | Author: Zeev Suraski <zeev@zend.com>                                 |
00016    +----------------------------------------------------------------------+
00017 */
00018 
00019 /* $Id: zend_ini.h 321634 2012-01-01 13:15:04Z felipe $ */
00020 
00021 #ifndef ZEND_INI_H
00022 #define ZEND_INI_H
00023 
00024 #define ZEND_INI_USER       (1<<0)
00025 #define ZEND_INI_PERDIR     (1<<1)
00026 #define ZEND_INI_SYSTEM     (1<<2)
00027 
00028 #define ZEND_INI_ALL (ZEND_INI_USER|ZEND_INI_PERDIR|ZEND_INI_SYSTEM)
00029 
00030 #ifndef XtOffsetOf
00031 # if defined(CRAY) || (defined(__arm) && !defined(LINUX))
00032 # ifdef __STDC__
00033 # define XtOffset(p_type, field) _Offsetof(p_type, field)
00034 # else
00035 # ifdef CRAY2
00036 # define XtOffset(p_type, field) \
00037     (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
00038 
00039 # else /* !CRAY2 */
00040 
00041 # define XtOffset(p_type, field) ((unsigned int)&(((p_type)NULL)->field))
00042 
00043 # endif /* !CRAY2 */
00044 # endif /* __STDC__ */
00045 # else /* ! (CRAY || __arm) */
00046 
00047 # define XtOffset(p_type, field) \
00048     ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
00049 
00050 # endif /* !CRAY */
00051 
00052 # ifdef offsetof
00053 # define XtOffsetOf(s_type, field) offsetof(s_type, field)
00054 # else
00055 # define XtOffsetOf(s_type, field) XtOffset(s_type*, field)
00056 # endif
00057 
00058 #endif
00059 
00060 typedef struct _zend_ini_entry zend_ini_entry;
00061 
00062 #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)
00063 #define ZEND_INI_DISP(name) void name(zend_ini_entry *ini_entry, int type)
00064 
00065 struct _zend_ini_entry {
00066        int module_number;
00067        int modifiable;
00068        char *name;
00069        uint name_length;
00070        ZEND_INI_MH((*on_modify));
00071        void *mh_arg1;
00072        void *mh_arg2;
00073        void *mh_arg3;
00074 
00075        char *value;
00076        uint value_length;
00077 
00078        char *orig_value;
00079        uint orig_value_length;
00080        int orig_modifiable;
00081        int modified;
00082 
00083        void (*displayer)(zend_ini_entry *ini_entry, int type);
00084 };
00085 
00086 BEGIN_EXTERN_C()
00087 ZEND_API int zend_ini_startup(TSRMLS_D);
00088 ZEND_API int zend_ini_shutdown(TSRMLS_D);
00089 ZEND_API int zend_ini_global_shutdown(TSRMLS_D);
00090 ZEND_API int zend_ini_deactivate(TSRMLS_D);
00091 
00092 ZEND_API int zend_copy_ini_directives(TSRMLS_D);
00093 
00094 ZEND_API void zend_ini_sort_entries(TSRMLS_D);
00095 
00096 ZEND_API int zend_register_ini_entries(const zend_ini_entry *ini_entry, int module_number TSRMLS_DC);
00097 ZEND_API void zend_unregister_ini_entries(int module_number TSRMLS_DC);
00098 ZEND_API void zend_ini_refresh_caches(int stage TSRMLS_DC);
00099 ZEND_API int zend_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type, int stage);
00100 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);
00101 ZEND_API int zend_restore_ini_entry(char *name, uint name_length, int stage);
00102 ZEND_API void display_ini_entries(zend_module_entry *module);
00103 
00104 ZEND_API long zend_ini_long(char *name, uint name_length, int orig);
00105 ZEND_API double zend_ini_double(char *name, uint name_length, int orig);
00106 ZEND_API char *zend_ini_string(char *name, uint name_length, int orig);
00107 ZEND_API char *zend_ini_string_ex(char *name, uint name_length, int orig, zend_bool *exists);
00108 
00109 ZEND_API int zend_ini_register_displayer(char *name, uint name_length, void (*displayer)(zend_ini_entry *ini_entry, int type));
00110 
00111 ZEND_API ZEND_INI_DISP(zend_ini_boolean_displayer_cb);
00112 ZEND_API ZEND_INI_DISP(zend_ini_color_displayer_cb);
00113 ZEND_API ZEND_INI_DISP(display_link_numbers);
00114 END_EXTERN_C()
00115 
00116 #define ZEND_INI_BEGIN()           static const zend_ini_entry ini_entries[] = {
00117 #define ZEND_INI_END()             { 0, 0, NULL, 0, NULL, NULL, NULL, NULL, NULL, 0, NULL, 0, 0, 0, NULL } };
00118 
00119 #define ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, arg1, arg2, arg3, displayer) \
00120        { 0, modifiable, name, sizeof(name), on_modify, arg1, arg2, arg3, default_value, sizeof(default_value)-1, NULL, 0, 0, 0, displayer },
00121 
00122 #define ZEND_INI_ENTRY3(name, default_value, modifiable, on_modify, arg1, arg2, arg3) \
00123        ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, arg1, arg2, arg3, NULL)
00124 
00125 #define ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, arg1, arg2, displayer) \
00126        ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, arg1, arg2, NULL, displayer)
00127 
00128 #define ZEND_INI_ENTRY2(name, default_value, modifiable, on_modify, arg1, arg2) \
00129        ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, arg1, arg2, NULL)
00130 
00131 #define ZEND_INI_ENTRY1_EX(name, default_value, modifiable, on_modify, arg1, displayer) \
00132        ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, arg1, NULL, NULL, displayer)
00133 
00134 #define ZEND_INI_ENTRY1(name, default_value, modifiable, on_modify, arg1) \
00135        ZEND_INI_ENTRY1_EX(name, default_value, modifiable, on_modify, arg1, NULL)
00136        
00137 #define ZEND_INI_ENTRY_EX(name, default_value, modifiable, on_modify, displayer) \
00138        ZEND_INI_ENTRY3_EX(name, default_value, modifiable, on_modify, NULL, NULL, NULL, displayer)
00139 
00140 #define ZEND_INI_ENTRY(name, default_value, modifiable, on_modify) \
00141        ZEND_INI_ENTRY_EX(name, default_value, modifiable, on_modify, NULL)
00142 
00143 #ifdef ZTS
00144 #define STD_ZEND_INI_ENTRY(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
00145        ZEND_INI_ENTRY2(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id)
00146 #define STD_ZEND_INI_ENTRY_EX(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr, displayer) \
00147        ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr##_id, displayer)
00148 #define STD_ZEND_INI_BOOLEAN(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
00149        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)
00150 #else
00151 #define STD_ZEND_INI_ENTRY(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
00152        ZEND_INI_ENTRY2(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr)
00153 #define STD_ZEND_INI_ENTRY_EX(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr, displayer) \
00154        ZEND_INI_ENTRY2_EX(name, default_value, modifiable, on_modify, (void *) XtOffsetOf(struct_type, property_name), (void *) &struct_ptr, displayer)
00155 #define STD_ZEND_INI_BOOLEAN(name, default_value, modifiable, on_modify, property_name, struct_type, struct_ptr) \
00156        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)
00157 #endif
00158 
00159 #define INI_INT(name) zend_ini_long((name), sizeof(name), 0)
00160 #define INI_FLT(name) zend_ini_double((name), sizeof(name), 0)
00161 #define INI_STR(name) zend_ini_string_ex((name), sizeof(name), 0, NULL)
00162 #define INI_BOOL(name) ((zend_bool) INI_INT(name))
00163 
00164 #define INI_ORIG_INT(name)  zend_ini_long((name), sizeof(name), 1)
00165 #define INI_ORIG_FLT(name)  zend_ini_double((name), sizeof(name), 1)
00166 #define INI_ORIG_STR(name)  zend_ini_string((name), sizeof(name), 1)
00167 #define INI_ORIG_BOOL(name) ((zend_bool) INI_ORIG_INT(name))
00168 
00169 #define REGISTER_INI_ENTRIES() zend_register_ini_entries(ini_entries, module_number TSRMLS_CC)
00170 #define UNREGISTER_INI_ENTRIES() zend_unregister_ini_entries(module_number TSRMLS_CC)
00171 #define DISPLAY_INI_ENTRIES() display_ini_entries(zend_module)
00172 
00173 #define REGISTER_INI_DISPLAYER(name, displayer) zend_ini_register_displayer((name), sizeof(name), displayer)
00174 #define REGISTER_INI_BOOLEAN(name) REGISTER_INI_DISPLAYER(name, zend_ini_boolean_displayer_cb)
00175 
00176 /* Standard message handlers */
00177 BEGIN_EXTERN_C()
00178 ZEND_API ZEND_INI_MH(OnUpdateBool);
00179 ZEND_API ZEND_INI_MH(OnUpdateLong);
00180 ZEND_API ZEND_INI_MH(OnUpdateLongGEZero);
00181 ZEND_API ZEND_INI_MH(OnUpdateReal);
00182 ZEND_API ZEND_INI_MH(OnUpdateString);
00183 ZEND_API ZEND_INI_MH(OnUpdateStringUnempty);
00184 END_EXTERN_C()
00185 
00186 #define ZEND_INI_DISPLAY_ORIG      1
00187 #define ZEND_INI_DISPLAY_ACTIVE    2
00188 
00189 #define ZEND_INI_STAGE_STARTUP            (1<<0)
00190 #define ZEND_INI_STAGE_SHUTDOWN           (1<<1)
00191 #define ZEND_INI_STAGE_ACTIVATE           (1<<2)
00192 #define ZEND_INI_STAGE_DEACTIVATE  (1<<3)
00193 #define ZEND_INI_STAGE_RUNTIME            (1<<4)
00194 #define ZEND_INI_STAGE_HTACCESS           (1<<5)
00195 
00196 /* INI parsing engine */
00197 typedef void (*zend_ini_parser_cb_t)(zval *arg1, zval *arg2, zval *arg3, int callback_type, void *arg TSRMLS_DC);
00198 BEGIN_EXTERN_C()
00199 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);
00200 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);
00201 END_EXTERN_C()
00202 
00203 /* INI entries */
00204 #define ZEND_INI_PARSER_ENTRY     1 /* Normal entry: foo = bar */
00205 #define ZEND_INI_PARSER_SECTION      2 /* Section: [foobar] */
00206 #define ZEND_INI_PARSER_POP_ENTRY 3 /* Offset entry: foo[] = bar */
00207 
00208 typedef struct _zend_ini_parser_param {
00209        zend_ini_parser_cb_t ini_parser_cb;
00210        void *arg;
00211 } zend_ini_parser_param;
00212 
00213 #endif /* ZEND_INI_H */
00214 
00215 /*
00216  * Local variables:
00217  * tab-width: 4
00218  * c-basic-offset: 4
00219  * indent-tabs-mode: t
00220  * End:
00221  */