PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LTP GCOV extension - code coverage report
Current view: directory - var/php_gcov/PHP_5_3/Zend - zend_ini.c
Test: PHP Code Coverage
Date: 2009-11-21 Instrumented lines: 244
Code covered: 79.9 % Executed lines: 195
Legend: not executed executed

       1                 : /*
       2                 :    +----------------------------------------------------------------------+
       3                 :    | Zend Engine                                                          |
       4                 :    +----------------------------------------------------------------------+
       5                 :    | Copyright (c) 1998-2009 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.c 284254 2009-07-17 11:49:50Z jani $ */
      20                 : 
      21                 : #include "zend.h"
      22                 : #include "zend_qsort.h"
      23                 : #include "zend_API.h"
      24                 : #include "zend_ini.h"
      25                 : #include "zend_alloc.h"
      26                 : #include "zend_operators.h"
      27                 : #include "zend_strtod.h"
      28                 : 
      29                 : static HashTable *registered_zend_ini_directives;
      30                 : 
      31                 : #define NO_VALUE_PLAINTEXT              "no value"
      32                 : #define NO_VALUE_HTML                   "<i>no value</i>"
      33                 : 
      34                 : /*
      35                 :  * hash_apply functions
      36                 :  */
      37                 : static int zend_remove_ini_entries(zend_ini_entry *ini_entry, int *module_number TSRMLS_DC) /* {{{ */
      38        73701115 : {
      39        73701115 :         if (ini_entry->module_number == *module_number) {
      40         3924150 :                 return 1;
      41                 :         } else {
      42        69776965 :                 return 0;
      43                 :         }
      44                 : }
      45                 : /* }}} */
      46                 : 
      47                 : static int zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stage TSRMLS_DC) /* {{{ */
      48            3073 : {
      49            3073 :         int result = FAILURE;
      50                 : 
      51            3073 :         if (ini_entry->modified) {
      52            3072 :                 if (ini_entry->on_modify) {
      53            3072 :                         zend_try {
      54                 :                         /* even if on_modify bails out, we have to continue on with restoring,
      55                 :                                 since there can be allocated variables that would be freed on MM shutdown
      56                 :                                 and would lead to memory corruption later ini entry is modified again */
      57            3072 :                                 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);
      58            3072 :                         } zend_end_try();
      59                 :                 }
      60            3072 :                 if (stage == ZEND_INI_STAGE_RUNTIME && result == FAILURE) {
      61                 :                         /* runtime failure is OK */
      62               0 :                         return 1;
      63                 :                 }
      64            3072 :                 if (ini_entry->value != ini_entry->orig_value) {
      65            3061 :                         efree(ini_entry->value);
      66                 :                 }
      67            3072 :                 ini_entry->value = ini_entry->orig_value;
      68            3072 :                 ini_entry->value_length = ini_entry->orig_value_length;
      69            3072 :                 ini_entry->modifiable = ini_entry->orig_modifiable;
      70            3072 :                 ini_entry->modified = 0;
      71            3072 :                 ini_entry->orig_value = NULL;
      72            3072 :                 ini_entry->orig_value_length = 0;
      73            3072 :                 ini_entry->orig_modifiable = 0;
      74                 :         }
      75            3073 :         return 0;
      76                 : }
      77                 : /* }}} */
      78                 : 
      79                 : static int zend_restore_ini_entry_wrapper(zend_ini_entry **ini_entry TSRMLS_DC) /* {{{ */
      80            3048 : {
      81            3048 :         zend_restore_ini_entry_cb(*ini_entry, ZEND_INI_STAGE_DEACTIVATE TSRMLS_CC);
      82            3048 :         return 1;
      83                 : }
      84                 : /* }}} */
      85                 : 
      86                 : /*
      87                 :  * Startup / shutdown
      88                 :  */
      89                 : ZEND_API int zend_ini_startup(TSRMLS_D) /* {{{ */
      90           17633 : {
      91           17633 :         registered_zend_ini_directives = (HashTable *) malloc(sizeof(HashTable));
      92                 : 
      93           17633 :         EG(ini_directives) = registered_zend_ini_directives;
      94           17633 :         EG(modified_ini_directives) = NULL;
      95           17633 :         if (zend_hash_init_ex(registered_zend_ini_directives, 100, NULL, NULL, 1, 0) == FAILURE) {
      96               0 :                 return FAILURE;
      97                 :         }
      98           17633 :         return SUCCESS;
      99                 : }
     100                 : /* }}} */
     101                 : 
     102                 : ZEND_API int zend_ini_shutdown(TSRMLS_D) /* {{{ */
     103           17665 : {
     104           17665 :         zend_hash_destroy(EG(ini_directives));
     105           17665 :         free(EG(ini_directives));
     106           17665 :         return SUCCESS;
     107                 : }
     108                 : /* }}} */
     109                 : 
     110                 : ZEND_API int zend_ini_global_shutdown(TSRMLS_D) /* {{{ */
     111               0 : {
     112               0 :         zend_hash_destroy(registered_zend_ini_directives);
     113               0 :         free(registered_zend_ini_directives);
     114               0 :         return SUCCESS;
     115                 : }
     116                 : /* }}} */
     117                 : 
     118                 : ZEND_API int zend_ini_deactivate(TSRMLS_D) /* {{{ */
     119           17665 : {
     120           17665 :         if (EG(modified_ini_directives)) {
     121            2937 :                 zend_hash_apply(EG(modified_ini_directives), (apply_func_t) zend_restore_ini_entry_wrapper TSRMLS_CC);
     122            2937 :                 zend_hash_destroy(EG(modified_ini_directives));
     123            2937 :                 FREE_HASHTABLE(EG(modified_ini_directives));
     124            2937 :                 EG(modified_ini_directives) = NULL;
     125                 :         }
     126           17665 :         return SUCCESS;
     127                 : }
     128                 : /* }}} */
     129                 : 
     130                 : #ifdef ZTS
     131                 : ZEND_API int zend_copy_ini_directives(TSRMLS_D) /* {{{ */
     132                 : {
     133                 :         zend_ini_entry ini_entry;
     134                 : 
     135                 :         EG(modified_ini_directives) = NULL;
     136                 :         EG(ini_directives) = (HashTable *) malloc(sizeof(HashTable));
     137                 :         if (zend_hash_init_ex(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, NULL, 1, 0) == FAILURE) {
     138                 :                 return FAILURE;
     139                 :         }
     140                 :         zend_hash_copy(EG(ini_directives), registered_zend_ini_directives, NULL, &ini_entry, sizeof(zend_ini_entry));
     141                 :         return SUCCESS;
     142                 : }
     143                 : /* }}} */
     144                 : #endif
     145                 : 
     146                 : static int ini_key_compare(const void *a, const void *b TSRMLS_DC) /* {{{ */
     147          109278 : {
     148                 :         Bucket *f;
     149                 :         Bucket *s;
     150                 : 
     151          109278 :         f = *((Bucket **) a);
     152          109278 :         s = *((Bucket **) b);
     153                 : 
     154          109278 :         if (f->nKeyLength == 0 && s->nKeyLength == 0) { /* both numeric */
     155               0 :                 return ZEND_NORMALIZE_BOOL(f->nKeyLength - s->nKeyLength);
     156          109278 :         } else if (f->nKeyLength == 0) { /* f is numeric, s is not */
     157               0 :                 return -1;
     158          109278 :         } else if (s->nKeyLength == 0) { /* s is numeric, f is not */
     159               0 :                 return 1;
     160                 :         } else { /* both strings */
     161          109278 :                 return zend_binary_strcasecmp(f->arKey, f->nKeyLength, s->arKey, s->nKeyLength);
     162                 :         }
     163                 : }
     164                 : /* }}} */
     165                 : 
     166                 : ZEND_API void zend_ini_sort_entries(TSRMLS_D) /* {{{ */
     167              59 : {
     168              59 :         zend_hash_sort(EG(ini_directives), zend_qsort, ini_key_compare, 0 TSRMLS_CC);
     169              59 : }
     170                 : /* }}} */
     171                 : 
     172                 : /*
     173                 :  * Registration / unregistration
     174                 :  */
     175                 : ZEND_API int zend_register_ini_entries(const zend_ini_entry *ini_entry, int module_number TSRMLS_DC) /* {{{ */
     176          546941 : {
     177          546941 :         const zend_ini_entry *p = ini_entry;
     178                 :         zend_ini_entry *hashed_ini_entry;
     179                 :         zval default_value;
     180          546941 :         HashTable *directives = registered_zend_ini_directives;
     181          546941 :         zend_bool config_directive_success = 0;
     182                 : 
     183                 : #ifdef ZTS
     184                 :         /* if we are called during the request, eg: from dl(),
     185                 :          * then we should not touch the global directives table,
     186                 :          * and should update the per-(request|thread) version instead.
     187                 :          * This solves two problems: one is that ini entries for dl()'d
     188                 :          * extensions will now work, and the second is that updating the
     189                 :          * global hash here from dl() is not mutex protected and can
     190                 :          * lead to death.
     191                 :          */
     192                 :         if (directives != EG(ini_directives)) {
     193                 :                 directives = EG(ini_directives);
     194                 :         }
     195                 : #endif
     196                 : 
     197         5063851 :         while (p->name) {
     198         3969969 :                 config_directive_success = 0;
     199         3969969 :                 if (zend_hash_add(directives, p->name, p->name_length, (void*)p, sizeof(zend_ini_entry), (void **) &hashed_ini_entry) == FAILURE) {
     200               0 :                         zend_unregister_ini_entries(module_number TSRMLS_CC);
     201               0 :                         return FAILURE;
     202                 :                 }
     203         3969969 :                 hashed_ini_entry->module_number = module_number;
     204         3969969 :                 if ((zend_get_configuration_directive(p->name, p->name_length, &default_value)) == SUCCESS) {
     205          580744 :                         if (!hashed_ini_entry->on_modify
     206                 :                                 || 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) {
     207          580744 :                                 hashed_ini_entry->value = Z_STRVAL(default_value);
     208          580744 :                                 hashed_ini_entry->value_length = Z_STRLEN(default_value);
     209          580744 :                                 config_directive_success = 1;
     210                 :                         }
     211                 :                 }
     212                 : 
     213         3969969 :                 if (!config_directive_success && hashed_ini_entry->on_modify) {
     214         3054037 :                         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);
     215                 :                 }
     216         3969969 :                 p++;
     217                 :         }
     218          546941 :         return SUCCESS;
     219                 : }
     220                 : /* }}} */
     221                 : 
     222                 : ZEND_API void zend_unregister_ini_entries(int module_number TSRMLS_DC) /* {{{ */
     223          477270 : {
     224          477270 :         zend_hash_apply_with_argument(registered_zend_ini_directives, (apply_func_arg_t) zend_remove_ini_entries, (void *) &module_number TSRMLS_CC);
     225          477270 : }
     226                 : /* }}} */
     227                 : 
     228                 : #ifdef ZTS
     229                 : static int zend_ini_refresh_cache(zend_ini_entry *p, int stage TSRMLS_DC) /* {{{ */
     230                 : {
     231                 :         if (p->on_modify) {
     232                 :                 p->on_modify(p, p->value, p->value_length, p->mh_arg1, p->mh_arg2, p->mh_arg3, stage TSRMLS_CC);
     233                 :         }
     234                 :         return 0;
     235                 : }
     236                 : /* }}} */
     237                 : 
     238                 : ZEND_API void zend_ini_refresh_caches(int stage TSRMLS_DC) /* {{{ */
     239                 : {
     240                 :         zend_hash_apply_with_argument(EG(ini_directives), (apply_func_arg_t) zend_ini_refresh_cache, (void *)(zend_intptr_t) stage TSRMLS_CC);
     241                 : }
     242                 : /* }}} */
     243                 : #endif
     244                 : 
     245                 : ZEND_API int zend_alter_ini_entry(char *name, uint name_length, char *new_value, uint new_value_length, int modify_type, int stage) /* {{{ */
     246            1091 : {
     247                 :         TSRMLS_FETCH();
     248                 : 
     249            1091 :         return zend_alter_ini_entry_ex(name, name_length, new_value, new_value_length, modify_type, stage, 0 TSRMLS_CC);
     250                 : }
     251                 : /* }}} */
     252                 : 
     253                 : 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) /* {{{ */
     254         2008489 : {
     255                 :         zend_ini_entry *ini_entry;
     256                 :         char *duplicate;
     257                 :         zend_bool modifiable;
     258                 :         zend_bool modified;
     259                 : 
     260         2008489 :         if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry) == FAILURE) {
     261              28 :                 return FAILURE;
     262                 :         }
     263                 : 
     264         2008461 :         modifiable = ini_entry->modifiable;
     265         2008461 :         modified = ini_entry->modified;
     266                 : 
     267         2008461 :         if (stage == ZEND_INI_STAGE_ACTIVATE && modify_type == ZEND_INI_SYSTEM) {
     268               0 :                 ini_entry->modifiable = ZEND_INI_SYSTEM;
     269                 :         }
     270                 : 
     271         2008461 :         if (!force_change) {
     272            1667 :                 if (!(ini_entry->modifiable & modify_type)) {
     273               3 :                         return FAILURE;
     274                 :                 }
     275                 :         }
     276                 : 
     277         2008458 :         if (!EG(modified_ini_directives)) {
     278            2936 :                 ALLOC_HASHTABLE(EG(modified_ini_directives));
     279            2936 :                 zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, 0);
     280                 :         }
     281         2008458 :         if (!modified) {
     282            3071 :                 ini_entry->orig_value = ini_entry->value;
     283            3071 :                 ini_entry->orig_value_length = ini_entry->value_length;
     284            3071 :                 ini_entry->orig_modifiable = modifiable;
     285            3071 :                 ini_entry->modified = 1;
     286            3071 :                 zend_hash_add(EG(modified_ini_directives), name, name_length, &ini_entry, sizeof(zend_ini_entry*), NULL);
     287                 :         }
     288                 : 
     289         2008458 :         duplicate = estrndup(new_value, new_value_length);
     290                 : 
     291         2008458 :         if (!ini_entry->on_modify
     292                 :                 || 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) {
     293         2008440 :                 if (modified && ini_entry->orig_value != ini_entry->value) { /* we already changed the value, free the changed value */
     294         2005380 :                         efree(ini_entry->value);
     295                 :                 }
     296         2008440 :                 ini_entry->value = duplicate;
     297         2008440 :                 ini_entry->value_length = new_value_length;
     298                 :         } else {
     299              18 :                 efree(duplicate);
     300              18 :                 return FAILURE;
     301                 :         }
     302                 : 
     303         2008440 :         return SUCCESS;
     304                 : }
     305                 : /* }}} */
     306                 : 
     307                 : ZEND_API int zend_restore_ini_entry(char *name, uint name_length, int stage) /* {{{ */
     308              26 : {
     309                 :         zend_ini_entry *ini_entry;
     310                 :         TSRMLS_FETCH();
     311                 : 
     312              26 :         if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry) == FAILURE ||
     313                 :                 (stage == ZEND_INI_STAGE_RUNTIME && (ini_entry->modifiable & ZEND_INI_USER) == 0)) {
     314               0 :                 return FAILURE;
     315                 :         }
     316                 : 
     317              26 :         if (EG(modified_ini_directives)) {
     318              25 :                 if (zend_restore_ini_entry_cb(ini_entry, stage TSRMLS_CC) == 0) {
     319              25 :                         zend_hash_del(EG(modified_ini_directives), name, name_length);
     320                 :                 } else {
     321               0 :                         return FAILURE;
     322                 :                 }
     323                 :         }
     324                 : 
     325              26 :         return SUCCESS;
     326                 : }
     327                 : /* }}} */
     328                 : 
     329                 : ZEND_API int zend_ini_register_displayer(char *name, uint name_length, void (*displayer)(zend_ini_entry *ini_entry, int type)) /* {{{ */
     330               0 : {
     331                 :         zend_ini_entry *ini_entry;
     332                 : 
     333               0 :         if (zend_hash_find(registered_zend_ini_directives, name, name_length, (void **) &ini_entry) == FAILURE) {
     334               0 :                 return FAILURE;
     335                 :         }
     336                 : 
     337               0 :         ini_entry->displayer = displayer;
     338               0 :         return SUCCESS;
     339                 : }
     340                 : /* }}} */
     341                 : 
     342                 : /*
     343                 :  * Data retrieval
     344                 :  */
     345                 : 
     346                 : ZEND_API long zend_ini_long(char *name, uint name_length, int orig) /* {{{ */
     347           53312 : {
     348                 :         zend_ini_entry *ini_entry;
     349                 :         TSRMLS_FETCH();
     350                 : 
     351           53312 :         if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry) == SUCCESS) {
     352           53312 :                 if (orig && ini_entry->modified) {
     353               0 :                         return (ini_entry->orig_value ? strtol(ini_entry->orig_value, NULL, 0) : 0);
     354                 :                 } else {
     355           53312 :                         return (ini_entry->value      ? strtol(ini_entry->value, NULL, 0)      : 0);
     356                 :                 }
     357                 :         }
     358                 : 
     359               0 :         return 0;
     360                 : }
     361                 : /* }}} */
     362                 : 
     363                 : ZEND_API double zend_ini_double(char *name, uint name_length, int orig) /* {{{ */
     364              48 : {
     365                 :         zend_ini_entry *ini_entry;
     366                 :         TSRMLS_FETCH();
     367                 : 
     368              48 :         if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry) == SUCCESS) {
     369              48 :                 if (orig && ini_entry->modified) {
     370               0 :                         return (double) (ini_entry->orig_value ? zend_strtod(ini_entry->orig_value, NULL) : 0.0);
     371                 :                 } else {
     372              48 :                         return (double) (ini_entry->value      ? zend_strtod(ini_entry->value, NULL)      : 0.0);
     373                 :                 }
     374                 :         }
     375                 : 
     376               0 :         return 0.0;
     377                 : }
     378                 : /* }}} */
     379                 : 
     380                 : ZEND_API char *zend_ini_string_ex(char *name, uint name_length, int orig, zend_bool *exists) /* {{{ */
     381          165285 : {
     382                 :         zend_ini_entry *ini_entry;
     383                 :         TSRMLS_FETCH();
     384                 : 
     385          165285 :         if (zend_hash_find(EG(ini_directives), name, name_length, (void **) &ini_entry) == SUCCESS) {
     386          165249 :                 if (exists) {
     387           53869 :                         *exists = 1;
     388                 :                 }
     389                 : 
     390          165249 :                 if (orig && ini_entry->modified) {
     391               0 :                         return ini_entry->orig_value;
     392                 :                 } else {
     393          165249 :                         return ini_entry->value;
     394                 :                 }
     395                 :         } else {
     396              36 :                 if (exists) {
     397              36 :                         *exists = 0;
     398                 :                 }
     399              36 :                 return NULL;
     400                 :         }
     401                 : }
     402                 : /* }}} */
     403                 : 
     404                 : ZEND_API char *zend_ini_string(char *name, uint name_length, int orig) /* {{{ */
     405           53905 : {
     406           53905 :         zend_bool exists = 1;
     407                 :         char *return_value;
     408                 : 
     409           53905 :         return_value = zend_ini_string_ex(name, name_length, orig, &exists);
     410           53905 :         if (!exists) {
     411              36 :                 return NULL;
     412           53869 :         } else if (!return_value) {
     413           35271 :                 return_value = "";
     414                 :         }
     415           53869 :         return return_value;
     416                 : }
     417                 : /* }}} */
     418                 : 
     419                 : #if TONY_20070307
     420                 : static void zend_ini_displayer_cb(zend_ini_entry *ini_entry, int type) /* {{{ */
     421                 : {
     422                 :         if (ini_entry->displayer) {
     423                 :                 ini_entry->displayer(ini_entry, type);
     424                 :         } else {
     425                 :                 char *display_string;
     426                 :                 uint display_string_length;
     427                 : 
     428                 :                 if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
     429                 :                         if (ini_entry->orig_value) {
     430                 :                                 display_string = ini_entry->orig_value;
     431                 :                                 display_string_length = ini_entry->orig_value_length;
     432                 :                         } else {
     433                 :                                 if (zend_uv.html_errors) {
     434                 :                                         display_string = NO_VALUE_HTML;
     435                 :                                         display_string_length = sizeof(NO_VALUE_HTML) - 1;
     436                 :                                 } else {
     437                 :                                         display_string = NO_VALUE_PLAINTEXT;
     438                 :                                         display_string_length = sizeof(NO_VALUE_PLAINTEXT) - 1;
     439                 :                                 }
     440                 :                         }
     441                 :                 } else if (ini_entry->value && ini_entry->value[0]) {
     442                 :                         display_string = ini_entry->value;
     443                 :                         display_string_length = ini_entry->value_length;
     444                 :                 } else {
     445                 :                         if (zend_uv.html_errors) {
     446                 :                                 display_string = NO_VALUE_HTML;
     447                 :                                 display_string_length = sizeof(NO_VALUE_HTML) - 1;
     448                 :                         } else {
     449                 :                                 display_string = NO_VALUE_PLAINTEXT;
     450                 :                                 display_string_length = sizeof(NO_VALUE_PLAINTEXT) - 1;
     451                 :                         }
     452                 :                 }
     453                 :                 ZEND_WRITE(display_string, display_string_length);
     454                 :         }
     455                 : }
     456                 : /* }}} */
     457                 : #endif
     458                 : 
     459                 : ZEND_INI_DISP(zend_ini_boolean_displayer_cb) /* {{{ */
     460            5040 : {
     461                 :         int value, tmp_value_len;
     462                 :         char *tmp_value;
     463                 : 
     464            5040 :         if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
     465               0 :                 tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL );
     466               0 :                 tmp_value_len = ini_entry->orig_value_length;
     467            5040 :         } else if (ini_entry->value) {
     468            5040 :                 tmp_value = ini_entry->value;
     469            5040 :                 tmp_value_len = ini_entry->value_length;
     470                 :         } else {
     471               0 :                 tmp_value = NULL;
     472               0 :                 tmp_value_len = 0;
     473                 :         }
     474                 : 
     475            5040 :         if (tmp_value) {
     476            5040 :                 if (tmp_value_len == 4 && strcasecmp(tmp_value, "true") == 0) {
     477               0 :                         value = 1;
     478            5040 :                 } else if (tmp_value_len == 3 && strcasecmp(tmp_value, "yes") == 0) {
     479               0 :                         value = 1;
     480            5040 :                 } else if (tmp_value_len == 2 && strcasecmp(tmp_value, "on") == 0) {
     481               0 :                         value = 1;
     482                 :                 } else {
     483            5040 :                         value = atoi(tmp_value);
     484                 :                 }
     485                 :         } else {
     486               0 :                 value = 0;
     487                 :         }
     488                 : 
     489            5040 :         if (value) {
     490            2264 :                 ZEND_PUTS("On");
     491                 :         } else {
     492            2776 :                 ZEND_PUTS("Off");
     493                 :         }
     494            5040 : }
     495                 : /* }}} */
     496                 : 
     497                 : ZEND_INI_DISP(zend_ini_color_displayer_cb) /* {{{ */
     498             504 : {
     499                 :         char *value;
     500                 : 
     501             504 :         if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
     502               0 :                 value = ini_entry->orig_value;
     503             504 :         } else if (ini_entry->value) {
     504             504 :                 value = ini_entry->value;
     505                 :         } else {
     506               0 :                 value = NULL;
     507                 :         }
     508             504 :         if (value) {
     509             504 :                 if (zend_uv.html_errors) {
     510             504 :                         zend_printf("<font style=\"color: %s\">%s</font>", value, value);
     511                 :                 } else {
     512               0 :                         ZEND_PUTS(value);
     513                 :                 }
     514                 :         } else {
     515               0 :                 if (zend_uv.html_errors) {
     516               0 :                         ZEND_PUTS(NO_VALUE_HTML);
     517                 :                 } else {
     518               0 :                         ZEND_PUTS(NO_VALUE_PLAINTEXT);
     519                 :                 }
     520                 :         }
     521             504 : }
     522                 : /* }}} */
     523                 : 
     524                 : ZEND_INI_DISP(display_link_numbers) /* {{{ */
     525             672 : {
     526                 :         char *value;
     527                 : 
     528             672 :         if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
     529               0 :                 value = ini_entry->orig_value;
     530             672 :         } else if (ini_entry->value) {
     531             672 :                 value = ini_entry->value;
     532                 :         } else {
     533               0 :                 value = NULL;
     534                 :         }
     535                 : 
     536             672 :         if (value) {
     537             672 :                 if (atoi(value) == -1) {
     538             588 :                         ZEND_PUTS("Unlimited");
     539                 :                 } else {
     540              84 :                         zend_printf("%s", value);
     541                 :                 }
     542                 :         }
     543             672 : }
     544                 : /* }}} */
     545                 : 
     546                 : /* Standard message handlers */
     547                 : ZEND_API ZEND_INI_MH(OnUpdateBool) /* {{{ */
     548          919859 : {
     549                 :         zend_bool *p;
     550                 : #ifndef ZTS
     551          919859 :         char *base = (char *) mh_arg2;
     552                 : #else
     553                 :         char *base;
     554                 : 
     555                 :         base = (char *) ts_resource(*((int *) mh_arg2));
     556                 : #endif
     557                 : 
     558          919859 :         p = (zend_bool *) (base+(size_t) mh_arg1);
     559                 : 
     560          919859 :         if (new_value_length == 2 && strcasecmp("on", new_value) == 0) {
     561               0 :                 *p = (zend_bool) 1;
     562                 :         }
     563          919859 :         else if (new_value_length == 3 && strcasecmp("yes", new_value) == 0) {
     564               0 :                 *p = (zend_bool) 1;
     565                 :         }
     566          919859 :         else if (new_value_length == 4 && strcasecmp("true", new_value) == 0) {
     567               0 :                 *p = (zend_bool) 1;
     568                 :         }
     569                 :         else {
     570          919859 :                 *p = (zend_bool) atoi(new_value);
     571                 :         }
     572          919859 :         return SUCCESS;
     573                 : }
     574                 : /* }}} */
     575                 : 
     576                 : ZEND_API ZEND_INI_MH(OnUpdateLong) /* {{{ */
     577         1022947 : {
     578                 :         long *p;
     579                 : #ifndef ZTS
     580         1022947 :         char *base = (char *) mh_arg2;
     581                 : #else
     582                 :         char *base;
     583                 : 
     584                 :         base = (char *) ts_resource(*((int *) mh_arg2));
     585                 : #endif
     586                 : 
     587         1022947 :         p = (long *) (base+(size_t) mh_arg1);
     588                 : 
     589         1022947 :         *p = zend_atol(new_value, new_value_length);
     590         1022947 :         return SUCCESS;
     591                 : }
     592                 : /* }}} */
     593                 : 
     594                 : ZEND_API ZEND_INI_MH(OnUpdateLongGEZero) /* {{{ */
     595           52899 : {
     596                 :         long *p, tmp;
     597                 : #ifndef ZTS
     598           52899 :         char *base = (char *) mh_arg2;
     599                 : #else
     600                 :         char *base;
     601                 : 
     602                 :         base = (char *) ts_resource(*((int *) mh_arg2));
     603                 : #endif
     604                 : 
     605           52899 :         tmp = zend_atol(new_value, new_value_length);
     606           52899 :         if (tmp < 0) {
     607               0 :                 return FAILURE;
     608                 :         }
     609                 : 
     610           52899 :         p = (long *) (base+(size_t) mh_arg1);
     611           52899 :         *p = tmp;
     612                 : 
     613           52899 :         return SUCCESS;
     614                 : }
     615                 : /* }}} */
     616                 : 
     617                 : ZEND_API ZEND_INI_MH(OnUpdateReal) /* {{{ */
     618               0 : {
     619                 :         double *p;
     620                 : #ifndef ZTS
     621               0 :         char *base = (char *) mh_arg2;
     622                 : #else
     623                 :         char *base;
     624                 : 
     625                 :         base = (char *) ts_resource(*((int *) mh_arg2));
     626                 : #endif
     627                 : 
     628               0 :         p = (double *) (base+(size_t) mh_arg1);
     629                 : 
     630               0 :         *p = zend_strtod(new_value, NULL);
     631               0 :         return SUCCESS;
     632                 : }
     633                 : /* }}} */
     634                 : 
     635                 : ZEND_API ZEND_INI_MH(OnUpdateString) /* {{{ */
     636          900170 : {
     637                 :         char **p;
     638                 : #ifndef ZTS
     639          900170 :         char *base = (char *) mh_arg2;
     640                 : #else
     641                 :         char *base;
     642                 : 
     643                 :         base = (char *) ts_resource(*((int *) mh_arg2));
     644                 : #endif
     645                 : 
     646          900170 :         p = (char **) (base+(size_t) mh_arg1);
     647                 : 
     648          900170 :         *p = new_value;
     649          900170 :         return SUCCESS;
     650                 : }
     651                 : /* }}} */
     652                 : 
     653                 : ZEND_API ZEND_INI_MH(OnUpdateStringUnempty) /* {{{ */
     654          176573 : {
     655                 :         char **p;
     656                 : #ifndef ZTS
     657          176573 :         char *base = (char *) mh_arg2;
     658                 : #else
     659                 :         char *base;
     660                 : 
     661                 :         base = (char *) ts_resource(*((int *) mh_arg2));
     662                 : #endif
     663                 : 
     664          176573 :         if (new_value && !new_value[0]) {
     665              11 :                 return FAILURE;
     666                 :         }
     667                 : 
     668          176562 :         p = (char **) (base+(size_t) mh_arg1);
     669                 : 
     670          176562 :         *p = new_value;
     671          176562 :         return SUCCESS;
     672                 : }
     673                 : /* }}} */
     674                 : 
     675                 : /*
     676                 :  * Local variables:
     677                 :  * tab-width: 4
     678                 :  * c-basic-offset: 4
     679                 :  * indent-tabs-mode: t
     680                 :  * End:
     681                 :  */

Generated by: LTP GCOV extension version 1.5

Generated at Sat, 21 Nov 2009 12:26:54 +0000 (3 days ago)

Copyright © 2005-2009 The PHP Group
All rights reserved.