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

Generated by: LTP GCOV extension version 1.5

Generated at Thu, 19 Nov 2009 08:20:04 +0000 (5 days ago)

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