Diff for /embedaddon/php/ext/dba/dba.c between versions 1.1.1.1 and 1.1.1.4

version 1.1.1.1, 2012/02/21 23:47:54 version 1.1.1.4, 2013/10/14 08:02:11
Line 2 Line 2
    +----------------------------------------------------------------------+     +----------------------------------------------------------------------+
    | PHP Version 5                                                        |     | PHP Version 5                                                        |
    +----------------------------------------------------------------------+     +----------------------------------------------------------------------+
   | Copyright (c) 1997-2012 The PHP Group                                |   | Copyright (c) 1997-2013 The PHP Group                                |
    +----------------------------------------------------------------------+     +----------------------------------------------------------------------+
    | This source file is subject to version 3.01 of the PHP license,      |     | This source file is subject to version 3.01 of the PHP license,      |
    | that is bundled with this package in the file LICENSE, and is        |     | that is bundled with this package in the file LICENSE, and is        |
Line 50 Line 50
 #include "php_flatfile.h"  #include "php_flatfile.h"
 #include "php_inifile.h"  #include "php_inifile.h"
 #include "php_qdbm.h"  #include "php_qdbm.h"
   #include "php_tcadb.h"
   
 /* {{{ arginfo */  /* {{{ arginfo */
 ZEND_BEGIN_ARG_INFO_EX(arginfo_dba_popen, 0, 0, 2)  ZEND_BEGIN_ARG_INFO_EX(arginfo_dba_popen, 0, 0, 2)
Line 337  static dba_handler handler[] = { Line 338  static dba_handler handler[] = {
 #if DBA_QDBM  #if DBA_QDBM
         DBA_HND(qdbm, DBA_LOCK_EXT)          DBA_HND(qdbm, DBA_LOCK_EXT)
 #endif  #endif
   #if DBA_TCADB
           DBA_HND(tcadb, DBA_LOCK_ALL)
   #endif
         { NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }          { NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
 };  };
   
Line 358  static dba_handler handler[] = { Line 362  static dba_handler handler[] = {
 #define DBA_DEFAULT "dbm"  #define DBA_DEFAULT "dbm"
 #elif DBA_QDBM  #elif DBA_QDBM
 #define DBA_DEFAULT "qdbm"  #define DBA_DEFAULT "qdbm"
   #elif DBA_TCADB
   #define DBA_DEFAULT "tcadb"
 #else  #else
 #define DBA_DEFAULT ""  #define DBA_DEFAULT ""
 #endif  #endif
Line 532  PHP_MINFO_FUNCTION(dba) Line 538  PHP_MINFO_FUNCTION(dba)
  */   */
 static void php_dba_update(INTERNAL_FUNCTION_PARAMETERS, int mode)  static void php_dba_update(INTERNAL_FUNCTION_PARAMETERS, int mode)
 {  {
         char *v;  
         int val_len;          int val_len;
         zval *id;          zval *id;
         dba_info *info = NULL;          dba_info *info = NULL;
Line 554  static void php_dba_update(INTERNAL_FUNCTION_PARAMETER Line 559  static void php_dba_update(INTERNAL_FUNCTION_PARAMETER
   
         DBA_WRITE_CHECK;          DBA_WRITE_CHECK;
   
        if (PG(magic_quotes_runtime)) {        if (info->hnd->update(info, key_str, key_len, val, val_len, mode TSRMLS_CC) == SUCCESS) {
                v = estrndup(val, val_len);                DBA_ID_DONE;
                php_stripslashes(v, &val_len TSRMLS_CC);                RETURN_TRUE;
                if (info->hnd->update(info, key_str, key_len, v, val_len, mode TSRMLS_CC) == SUCCESS) { 
                        efree(v); 
                        DBA_ID_DONE; 
                        RETURN_TRUE; 
                } 
                efree(v); 
        } else { 
                if (info->hnd->update(info, key_str, key_len, val, val_len, mode TSRMLS_CC) == SUCCESS) { 
                        DBA_ID_DONE; 
                        RETURN_TRUE; 
                } 
         }          }
   
         DBA_ID_DONE;          DBA_ID_DONE;
Line 832  static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, Line 826  static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS,
                                 /* when in read only mode try to use existing .lck file first */                                  /* when in read only mode try to use existing .lck file first */
                                 /* do not log errors for .lck file while in read ony mode on .lck file */                                  /* do not log errors for .lck file while in read ony mode on .lck file */
                                 lock_file_mode = "rb";                                  lock_file_mode = "rb";
                                info->lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|IGNORE_PATH|ENFORCE_SAFE_MODE|persistent_flag, &opened_path);                                info->lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|IGNORE_PATH|persistent_flag, &opened_path);
                         }                          }
                         if (!info->lock.fp) {                          if (!info->lock.fp) {
                                 /* when not in read mode or failed to open .lck file read only. now try again in create(write) mode and log errors */                                  /* when not in read mode or failed to open .lck file read only. now try again in create(write) mode and log errors */
Line 847  static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, Line 841  static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS,
                         }                          }
                 }                  }
                 if (!info->lock.fp) {                  if (!info->lock.fp) {
                        info->lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE|persistent_flag, &opened_path);                        info->lock.fp = php_stream_open_wrapper(lock_name, lock_file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|persistent_flag, &opened_path);
                         if (info->lock.fp) {                          if (info->lock.fp) {
                                 if (lock_dbf) {                                  if (lock_dbf) {
                                         /* replace the path info with the real path of the opened file */                                          /* replace the path info with the real path of the opened file */
Line 885  static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, Line 879  static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS,
                 if (info->lock.fp && lock_dbf) {                  if (info->lock.fp && lock_dbf) {
                         info->fp = info->lock.fp; /* use the same stream for locking and database access */                          info->fp = info->lock.fp; /* use the same stream for locking and database access */
                 } else {                  } else {
                        info->fp = php_stream_open_wrapper(info->path, file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|ENFORCE_SAFE_MODE|persistent_flag, NULL);                        info->fp = php_stream_open_wrapper(info->path, file_mode, STREAM_MUST_SEEK|REPORT_ERRORS|IGNORE_PATH|persistent_flag, NULL);
                 }                  }
                 if (!info->fp) {                  if (!info->fp) {
                         dba_close(info TSRMLS_CC);                          dba_close(info TSRMLS_CC);
Line 894  static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, Line 888  static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS,
                         RETURN_FALSE;                          RETURN_FALSE;
                 }                  }
                 if (hptr->flags & (DBA_NO_APPEND|DBA_CAST_AS_FD)) {                  if (hptr->flags & (DBA_NO_APPEND|DBA_CAST_AS_FD)) {
                        /* Needed becasue some systems do not allow to write to the original                         /* Needed because some systems do not allow to write to the original 
                          * file contents with O_APPEND being set.                           * file contents with O_APPEND being set.
                          */                           */
                         if (SUCCESS != php_stream_cast(info->fp, PHP_STREAM_AS_FD, (void*)&info->fd, 1)) {                          if (SUCCESS != php_stream_cast(info->fp, PHP_STREAM_AS_FD, (void*)&info->fd, 1)) {
Line 1023  PHP_FUNCTION(dba_fetch) Line 1017  PHP_FUNCTION(dba_fetch)
                 skip = 0;                   skip = 0; 
         }          }
         if((val = info->hnd->fetch(info, key_str, key_len, skip, &len TSRMLS_CC)) != NULL) {          if((val = info->hnd->fetch(info, key_str, key_len, skip, &len TSRMLS_CC)) != NULL) {
                 if (val && PG(magic_quotes_runtime)) {  
                         val = php_addslashes(val, len, &len, 1 TSRMLS_CC);  
                 }  
                 DBA_ID_DONE;                  DBA_ID_DONE;
                 RETURN_STRINGL(val, len, 0);                  RETURN_STRINGL(val, len, 0);
         }           } 

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.4


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>