Back to index

php5  5.3.10
zend_ini.c
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.c 321634 2012-01-01 13:15:04Z felipe $ */
00020 
00021 #include "zend.h"
00022 #include "zend_qsort.h"
00023 #include "zend_API.h"
00024 #include "zend_ini.h"
00025 #include "zend_alloc.h"
00026 #include "zend_operators.h"
00027 #include "zend_strtod.h"
00028 
00029 static HashTable *registered_zend_ini_directives;
00030 
00031 #define NO_VALUE_PLAINTEXT         "no value"
00032 #define NO_VALUE_HTML                     "<i>no value</i>"
00033 
00034 /*
00035  * hash_apply functions
00036  */
00037 static int zend_remove_ini_entries(zend_ini_entry *ini_entry, int *module_number TSRMLS_DC) /* {{{ */
00038 {
00039        if (ini_entry->module_number == *module_number) {
00040               return 1;
00041        } else {
00042               return 0;
00043        }
00044 }
00045 /* }}} */
00046 
00047 static int zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stage TSRMLS_DC) /* {{{ */
00048 {
00049        int result = FAILURE;
00050 
00051        if (ini_entry->modified) {
00052               if (ini_entry->on_modify) {
00053                      zend_try {
00054                      /* even if on_modify bails out, we have to continue on with restoring,
00055                             since there can be allocated variables that would be freed on MM shutdown
00056                             and would lead to memory corruption later ini entry is modified again */
00057                             result = ini_entry->on_modify(ini_entry, ini_entry->orig_value, ini_entry->orig_value_length, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage TSRMLS_CC);
00058                      } zend_end_try();
00059               }
00060               if (stage == ZEND_INI_STAGE_RUNTIME && result == FAILURE) {
00061                      /* runtime failure is OK */
00062                      return 1;
00063               }
00064               if (ini_entry->value != ini_entry->orig_value) {
00065                      efree(ini_entry->value);
00066               }
00067               ini_entry->value = ini_entry->orig_value;
00068               ini_entry->value_length = ini_entry->orig_value_length;
00069               ini_entry->modifiable = ini_entry->orig_modifiable;
00070               ini_entry->modified = 0;
00071               ini_entry->orig_value = NULL;
00072               ini_entry->orig_value_length = 0;
00073               ini_entry->orig_modifiable = 0;
00074        }
00075        return 0;
00076 }
00077 /* }}} */
00078 
00079 static int zend_restore_ini_entry_wrapper(zend_ini_entry **ini_entry TSRMLS_DC) /* {{{ */
00080 {
00081        zend_restore_ini_entry_cb(*ini_entry, ZEND_INI_STAGE_DEACTIVATE TSRMLS_CC);
00082        return 1;
00083 }
00084 /* }}} */
00085 
00086 /*
00087  * Startup / shutdown
00088  */
00089 ZEND_API int zend_ini_startup(TSRMLS_D) /* {{{ */
00090 {
00091        registered_zend_ini_directives = (HashTable *) malloc(sizeof(HashTable));
00092 
00093        EG(ini_directives) = registered_zend_ini_directives;
00094        EG(modified_ini_directives) = NULL;
00095        if (zend_hash_init_ex(registered_zend_ini_directives, 100, NULL, NULL, 1, 0) == FAILURE) {
00096               return FAILURE;
00097        }
00098        return SUCCESS;
00099 }
00100 /* }}} */
00101 
00102 ZEND_API int zend_ini_shutdown(TSRMLS_D) /* {{{ */
00103 {
00104        zend_hash_destroy(EG(ini_directives));
00105        free(EG(ini_directives));
00106        return SUCCESS;
00107 }
00108 /* }}} */
00109 
00110 ZEND_API int zend_ini_global_shutdown(TSRMLS_D) /* {{{ */
00111 {
00112        zend_hash_destroy(registered_zend_ini_directives);
00113        free(registered_zend_ini_directives);
00114        return SUCCESS;
00115 }
00116 /* }}} */
00117 
00118 ZEND_API int zend_ini_deactivate(TSRMLS_D) /* {{{ */
00119 {
00120        if (EG(modified_ini_directives)) {
00121               zend_hash_apply(EG(modified_ini_directives), (apply_func_t) zend_restore_ini_entry_wrapper TSRMLS_CC);
00122               zend_hash_destroy(EG(modified_ini_directives));
00123               FREE_HASHTABLE(EG(modified_ini_directives));
00124               EG(modified_ini_directives) = NULL;
00125        }
00126        return SUCCESS;
00127 }
00128 /* }}} */
00129 
00130 #ifdef ZTS
00131 ZEND_API int zend_copy_ini_directives(TSRMLS_D) /* {{{ */
00132 {
00133        zend_ini_entry ini_entry;
00134 
00135        EG(modified_ini_directives) = NULL;
00136        EG(ini_directives) = (HashTable *) malloc(sizeof(HashTable));
00137        if (zend_hash_init_ex(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, NULL, 1, 0) == FAILURE) {
00138               return FAILURE;
00139        }
00140        zend_hash_copy(EG(ini_directives), registered_zend_ini_directives, NULL, &ini_entry, sizeof(zend_ini_entry));
00141        return SUCCESS;
00142 }
00143 /* }}} */
00144 #endif
00145 
00146 static int ini_key_compare(const void *a, const void *b TSRMLS_DC) /* {{{ */
00147 {
00148        Bucket *f;
00149        Bucket *s;
00150 
00151        f = *((Bucket **) a);
00152        s = *((Bucket **) b);
00153 
00154        if (f->nKeyLength == 0 && s->nKeyLength == 0) { /* both numeric */
00155               return ZEND_NORMALIZE_BOOL(f->nKeyLength - s->nKeyLength);
00156        } else if (f->nKeyLength == 0) { /* f is numeric, s is not */
00157               return -1;
00158        } else if (s->nKeyLength == 0) { /* s is numeric, f is not */
00159               return 1;
00160        } else { /* both strings */
00161               return zend_binary_strcasecmp(f->arKey, f->nKeyLength, s->arKey, s->nKeyLength);
00162        }
00163 }
00164 /* }}} */
00165 
00166 ZEND_API void zend_ini_sort_entries(TSRMLS_D) /* {{{ */
00167 {
00168        zend_hash_sort(EG(ini_directives), zend_qsort, ini_key_compare, 0 TSRMLS_CC);
00169 }
00170 /* }}} */
00171 
00172 /*
00173  * Registration / unregistration
00174  */
00175 ZEND_API int zend_register_ini_entries(const zend_ini_entry *ini_entry, int module_number TSRMLS_DC) /* {{{ */
00176 {
00177        const zend_ini_entry *p = ini_entry;
00178        zend_ini_entry *hashed_ini_entry;
00179        zval default_value;
00180        HashTable *directives = registered_zend_ini_directives;
00181        zend_bool config_directive_success = 0;
00182 
00183 #ifdef ZTS
00184        /* if we are called during the request, eg: from dl(),
00185         * then we should not touch the global directives table,
00186         * and should update the per-(request|thread) version instead.
00187         * This solves two problems: one is that ini entries for dl()'d
00188         * extensions will now work, and the second is that updating the
00189         * global hash here from dl() is not mutex protected and can
00190         * lead to death.
00191         */
00192        if (directives != EG(ini_directives)) {
00193               directives = EG(ini_directives);
00194        }
00195 #endif
00196 
00197        while (p->name) {
00198               config_directive_success = 0;
00199               if (zend_hash_add(directives, p->name, p->name_length, (void*)p, sizeof(zend_ini_entry), (void **) &hashed_ini_entry) == FAILURE) {
00200                      zend_unregister_ini_entries(module_number TSRMLS_CC);
00201                      return FAILURE;
00202               }
00203               hashed_ini_entry->module_number = module_number;
00204               if ((zend_get_configuration_directive(p->name, p->name_length, &default_value)) == SUCCESS) {
00205                      if (!hashed_ini_entry->on_modify
00206                             || hashed_ini_entry->on_modify(hashed_ini_entry, Z_STRVAL(default_value), Z_STRLEN(default_value), hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3, ZEND_INI_STAGE_STARTUP TSRMLS_CC) == SUCCESS) {
00207                             hashed_ini_entry->value = Z_STRVAL(default_value);
00208                             hashed_ini_entry->value_length = Z_STRLEN(default_value);
00209                             config_directive_success = 1;
00210                      }
00211               }
00212 
00213               if (!config_directive_success && hashed_ini_entry->on_modify) {
00214                      hashed_ini_entry->on_modify(hashed_ini_entry, hashed_ini_entry->value, hashed_ini_entry->value_length, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3, ZEND_INI_STAGE_STARTUP TSRMLS_CC);
00215               }
00216               p++;
00217        }
00218        return SUCCESS;
00219 }
00220 /* }}} */
00221 
00222 ZEND_API void zend_unregister_ini_entries(int module_number TSRMLS_DC) /* {{{ */
00223 {
00224        zend_hash_apply_with_argument(registered_zend_ini_directives, (apply_func_arg_t) zend_remove_ini_entries, (void *) &module_number TSRMLS_CC);
00225 }
00226 /* }}} */
00227 
00228 #ifdef ZTS
00229 static int zend_ini_refresh_cache(zend_ini_entry *p, int stage TSRMLS_DC) /* {{{ */
00230 {
00231        if (p->on_modify) {
00232               p->on_modify(p, p->value, p->value_length, p->mh_arg1, p->mh_arg2, p->mh_arg3, stage TSRMLS_CC);
00233        }
00234        return 0;
00235 }
00236 /* }}} */
00237 
00238 ZEND_API void zend_ini_refresh_caches(int stage TSRMLS_DC) /* {{{ */
00239 {
00240        zend_hash_apply_with_argument(EG(ini_directives), (apply_func_arg_t) zend_ini_refresh_cache, (void *)(zend_intptr_t) stage TSRMLS_CC);
00241 }
00242 /* }}} */
00243 #endif
00244 
00245 ZEND_API int zend_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type, int stage) /* {{{ */
00246 {
00247        TSRMLS_FETCH();
00248 
00249        return zend_alter_ini_entry_ex(name, name_length, new_value, new_value_length, modify_type, stage, 0 TSRMLS_CC);
00250 }
00251 /* }}} */
00252 
00253 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) /* {{{ */
00254 {
00255        zend_ini_entry *ini_entry;
00256        char *duplicate;
00257        zend_bool modifiable;
00258        zend_bool modified;
00259 
00260        if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry) == FAILURE) {
00261               return FAILURE;
00262        }
00263 
00264        modifiable = ini_entry->modifiable;
00265        modified = ini_entry->modified;
00266 
00267        if (stage == ZEND_INI_STAGE_ACTIVATE && modify_type == ZEND_INI_SYSTEM) {
00268               ini_entry->modifiable = ZEND_INI_SYSTEM;
00269        }
00270 
00271        if (!force_change) {
00272               if (!(ini_entry->modifiable & modify_type)) {
00273                      return FAILURE;
00274               }
00275        }
00276 
00277        if (!EG(modified_ini_directives)) {
00278               ALLOC_HASHTABLE(EG(modified_ini_directives));
00279               zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, 0);
00280        }
00281        if (!modified) {
00282               ini_entry->orig_value = ini_entry->value;
00283               ini_entry->orig_value_length = ini_entry->value_length;
00284               ini_entry->orig_modifiable = modifiable;
00285               ini_entry->modified = 1;
00286               zend_hash_add(EG(modified_ini_directives), name, name_length, &ini_entry, sizeof(zend_ini_entry*), NULL);
00287        }
00288 
00289        duplicate = estrndup(new_value, new_value_length);
00290 
00291        if (!ini_entry->on_modify
00292               || ini_entry->on_modify(ini_entry, duplicate, new_value_length, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage TSRMLS_CC) == SUCCESS) {
00293               if (modified && ini_entry->orig_value != ini_entry->value) { /* we already changed the value, free the changed value */
00294                      efree(ini_entry->value);
00295               }
00296               ini_entry->value = duplicate;
00297               ini_entry->value_length = new_value_length;
00298        } else {
00299               efree(duplicate);
00300               return FAILURE;
00301        }
00302 
00303        return SUCCESS;
00304 }
00305 /* }}} */
00306 
00307 ZEND_API int zend_restore_ini_entry(char *name, uint name_length, int stage) /* {{{ */
00308 {
00309        zend_ini_entry *ini_entry;
00310        TSRMLS_FETCH();
00311 
00312        if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry) == FAILURE ||
00313               (stage == ZEND_INI_STAGE_RUNTIME && (ini_entry->modifiable & ZEND_INI_USER) == 0)) {
00314               return FAILURE;
00315        }
00316 
00317        if (EG(modified_ini_directives)) {
00318               if (zend_restore_ini_entry_cb(ini_entry, stage TSRMLS_CC) == 0) {
00319                      zend_hash_del(EG(modified_ini_directives), name, name_length);
00320               } else {
00321                      return FAILURE;
00322               }
00323        }
00324 
00325        return SUCCESS;
00326 }
00327 /* }}} */
00328 
00329 ZEND_API int zend_ini_register_displayer(char *name, uint name_length, void (*displayer)(zend_ini_entry *ini_entry, int type)) /* {{{ */
00330 {
00331        zend_ini_entry *ini_entry;
00332 
00333        if (zend_hash_find(registered_zend_ini_directives, name, name_length, (void **) &ini_entry) == FAILURE) {
00334               return FAILURE;
00335        }
00336 
00337        ini_entry->displayer = displayer;
00338        return SUCCESS;
00339 }
00340 /* }}} */
00341 
00342 /*
00343  * Data retrieval
00344  */
00345 
00346 ZEND_API long zend_ini_long(char *name, uint name_length, int orig) /* {{{ */
00347 {
00348        zend_ini_entry *ini_entry;
00349        TSRMLS_FETCH();
00350 
00351        if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry) == SUCCESS) {
00352               if (orig && ini_entry->modified) {
00353                      return (ini_entry->orig_value ? strtol(ini_entry->orig_value, NULL, 0) : 0);
00354               } else {
00355                      return (ini_entry->value      ? strtol(ini_entry->value, NULL, 0)      : 0);
00356               }
00357        }
00358 
00359        return 0;
00360 }
00361 /* }}} */
00362 
00363 ZEND_API double zend_ini_double(char *name, uint name_length, int orig) /* {{{ */
00364 {
00365        zend_ini_entry *ini_entry;
00366        TSRMLS_FETCH();
00367 
00368        if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry) == SUCCESS) {
00369               if (orig && ini_entry->modified) {
00370                      return (double) (ini_entry->orig_value ? zend_strtod(ini_entry->orig_value, NULL) : 0.0);
00371               } else {
00372                      return (double) (ini_entry->value      ? zend_strtod(ini_entry->value, NULL)      : 0.0);
00373               }
00374        }
00375 
00376        return 0.0;
00377 }
00378 /* }}} */
00379 
00380 ZEND_API char *zend_ini_string_ex(char *name, uint name_length, int orig, zend_bool *exists) /* {{{ */
00381 {
00382        zend_ini_entry *ini_entry;
00383        TSRMLS_FETCH();
00384 
00385        if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry) == SUCCESS) {
00386               if (exists) {
00387                      *exists = 1;
00388               }
00389 
00390               if (orig && ini_entry->modified) {
00391                      return ini_entry->orig_value;
00392               } else {
00393                      return ini_entry->value;
00394               }
00395        } else {
00396               if (exists) {
00397                      *exists = 0;
00398               }
00399               return NULL;
00400        }
00401 }
00402 /* }}} */
00403 
00404 ZEND_API char *zend_ini_string(char *name, uint name_length, int orig) /* {{{ */
00405 {
00406        zend_bool exists = 1;
00407        char *return_value;
00408 
00409        return_value = zend_ini_string_ex(name, name_length, orig, &exists);
00410        if (!exists) {
00411               return NULL;
00412        } else if (!return_value) {
00413               return_value = "";
00414        }
00415        return return_value;
00416 }
00417 /* }}} */
00418 
00419 #if TONY_20070307
00420 static void zend_ini_displayer_cb(zend_ini_entry *ini_entry, int type) /* {{{ */
00421 {
00422        if (ini_entry->displayer) {
00423               ini_entry->displayer(ini_entry, type);
00424        } else {
00425               char *display_string;
00426               uint display_string_length;
00427 
00428               if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
00429                      if (ini_entry->orig_value) {
00430                             display_string = ini_entry->orig_value;
00431                             display_string_length = ini_entry->orig_value_length;
00432                      } else {
00433                             if (zend_uv.html_errors) {
00434                                    display_string = NO_VALUE_HTML;
00435                                    display_string_length = sizeof(NO_VALUE_HTML) - 1;
00436                             } else {
00437                                    display_string = NO_VALUE_PLAINTEXT;
00438                                    display_string_length = sizeof(NO_VALUE_PLAINTEXT) - 1;
00439                             }
00440                      }
00441               } else if (ini_entry->value && ini_entry->value[0]) {
00442                      display_string = ini_entry->value;
00443                      display_string_length = ini_entry->value_length;
00444               } else {
00445                      if (zend_uv.html_errors) {
00446                             display_string = NO_VALUE_HTML;
00447                             display_string_length = sizeof(NO_VALUE_HTML) - 1;
00448                      } else {
00449                             display_string = NO_VALUE_PLAINTEXT;
00450                             display_string_length = sizeof(NO_VALUE_PLAINTEXT) - 1;
00451                      }
00452               }
00453               ZEND_WRITE(display_string, display_string_length);
00454        }
00455 }
00456 /* }}} */
00457 #endif
00458 
00459 ZEND_INI_DISP(zend_ini_boolean_displayer_cb) /* {{{ */
00460 {
00461        int value, tmp_value_len;
00462        char *tmp_value;
00463 
00464        if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
00465               tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL );
00466               tmp_value_len = ini_entry->orig_value_length;
00467        } else if (ini_entry->value) {
00468               tmp_value = ini_entry->value;
00469               tmp_value_len = ini_entry->value_length;
00470        } else {
00471               tmp_value = NULL;
00472               tmp_value_len = 0;
00473        }
00474 
00475        if (tmp_value) {
00476               if (tmp_value_len == 4 && strcasecmp(tmp_value, "true") == 0) {
00477                      value = 1;
00478               } else if (tmp_value_len == 3 && strcasecmp(tmp_value, "yes") == 0) {
00479                      value = 1;
00480               } else if (tmp_value_len == 2 && strcasecmp(tmp_value, "on") == 0) {
00481                      value = 1;
00482               } else {
00483                      value = atoi(tmp_value);
00484               }
00485        } else {
00486               value = 0;
00487        }
00488 
00489        if (value) {
00490               ZEND_PUTS("On");
00491        } else {
00492               ZEND_PUTS("Off");
00493        }
00494 }
00495 /* }}} */
00496 
00497 ZEND_INI_DISP(zend_ini_color_displayer_cb) /* {{{ */
00498 {
00499        char *value;
00500 
00501        if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
00502               value = ini_entry->orig_value;
00503        } else if (ini_entry->value) {
00504               value = ini_entry->value;
00505        } else {
00506               value = NULL;
00507        }
00508        if (value) {
00509               if (zend_uv.html_errors) {
00510                      zend_printf("<font style=\"color: %s\">%s</font>", value, value);
00511               } else {
00512                      ZEND_PUTS(value);
00513               }
00514        } else {
00515               if (zend_uv.html_errors) {
00516                      ZEND_PUTS(NO_VALUE_HTML);
00517               } else {
00518                      ZEND_PUTS(NO_VALUE_PLAINTEXT);
00519               }
00520        }
00521 }
00522 /* }}} */
00523 
00524 ZEND_INI_DISP(display_link_numbers) /* {{{ */
00525 {
00526        char *value;
00527 
00528        if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
00529               value = ini_entry->orig_value;
00530        } else if (ini_entry->value) {
00531               value = ini_entry->value;
00532        } else {
00533               value = NULL;
00534        }
00535 
00536        if (value) {
00537               if (atoi(value) == -1) {
00538                      ZEND_PUTS("Unlimited");
00539               } else {
00540                      zend_printf("%s", value);
00541               }
00542        }
00543 }
00544 /* }}} */
00545 
00546 /* Standard message handlers */
00547 ZEND_API ZEND_INI_MH(OnUpdateBool) /* {{{ */
00548 {
00549        zend_bool *p;
00550 #ifndef ZTS
00551        char *base = (char *) mh_arg2;
00552 #else
00553        char *base;
00554 
00555        base = (char *) ts_resource(*((int *) mh_arg2));
00556 #endif
00557 
00558        p = (zend_bool *) (base+(size_t) mh_arg1);
00559 
00560        if (new_value_length == 2 && strcasecmp("on", new_value) == 0) {
00561               *p = (zend_bool) 1;
00562        }
00563        else if (new_value_length == 3 && strcasecmp("yes", new_value) == 0) {
00564               *p = (zend_bool) 1;
00565        }
00566        else if (new_value_length == 4 && strcasecmp("true", new_value) == 0) {
00567               *p = (zend_bool) 1;
00568        }
00569        else {
00570               *p = (zend_bool) atoi(new_value);
00571        }
00572        return SUCCESS;
00573 }
00574 /* }}} */
00575 
00576 ZEND_API ZEND_INI_MH(OnUpdateLong) /* {{{ */
00577 {
00578        long *p;
00579 #ifndef ZTS
00580        char *base = (char *) mh_arg2;
00581 #else
00582        char *base;
00583 
00584        base = (char *) ts_resource(*((int *) mh_arg2));
00585 #endif
00586 
00587        p = (long *) (base+(size_t) mh_arg1);
00588 
00589        *p = zend_atol(new_value, new_value_length);
00590        return SUCCESS;
00591 }
00592 /* }}} */
00593 
00594 ZEND_API ZEND_INI_MH(OnUpdateLongGEZero) /* {{{ */
00595 {
00596        long *p, tmp;
00597 #ifndef ZTS
00598        char *base = (char *) mh_arg2;
00599 #else
00600        char *base;
00601 
00602        base = (char *) ts_resource(*((int *) mh_arg2));
00603 #endif
00604 
00605        tmp = zend_atol(new_value, new_value_length);
00606        if (tmp < 0) {
00607               return FAILURE;
00608        }
00609 
00610        p = (long *) (base+(size_t) mh_arg1);
00611        *p = tmp;
00612 
00613        return SUCCESS;
00614 }
00615 /* }}} */
00616 
00617 ZEND_API ZEND_INI_MH(OnUpdateReal) /* {{{ */
00618 {
00619        double *p;
00620 #ifndef ZTS
00621        char *base = (char *) mh_arg2;
00622 #else
00623        char *base;
00624 
00625        base = (char *) ts_resource(*((int *) mh_arg2));
00626 #endif
00627 
00628        p = (double *) (base+(size_t) mh_arg1);
00629 
00630        *p = zend_strtod(new_value, NULL);
00631        return SUCCESS;
00632 }
00633 /* }}} */
00634 
00635 ZEND_API ZEND_INI_MH(OnUpdateString) /* {{{ */
00636 {
00637        char **p;
00638 #ifndef ZTS
00639        char *base = (char *) mh_arg2;
00640 #else
00641        char *base;
00642 
00643        base = (char *) ts_resource(*((int *) mh_arg2));
00644 #endif
00645 
00646        p = (char **) (base+(size_t) mh_arg1);
00647 
00648        *p = new_value;
00649        return SUCCESS;
00650 }
00651 /* }}} */
00652 
00653 ZEND_API ZEND_INI_MH(OnUpdateStringUnempty) /* {{{ */
00654 {
00655        char **p;
00656 #ifndef ZTS
00657        char *base = (char *) mh_arg2;
00658 #else
00659        char *base;
00660 
00661        base = (char *) ts_resource(*((int *) mh_arg2));
00662 #endif
00663 
00664        if (new_value && !new_value[0]) {
00665               return FAILURE;
00666        }
00667 
00668        p = (char **) (base+(size_t) mh_arg1);
00669 
00670        *p = new_value;
00671        return SUCCESS;
00672 }
00673 /* }}} */
00674 
00675 /*
00676  * Local variables:
00677  * tab-width: 4
00678  * c-basic-offset: 4
00679  * indent-tabs-mode: t
00680  * End:
00681  */