bfrance         Mon Dec  5 15:41:57 2005 EDT

  Modified files:              
    /php-src/ext/sqlite sqlite.c 
  Log:
          Wrap the php_session.h include in the same ifdef as the rest of the
          session code.
  
  
http://cvs.php.net/diff.php/php-src/ext/sqlite/sqlite.c?r1=1.178&r2=1.179&ty=u
Index: php-src/ext/sqlite/sqlite.c
diff -u php-src/ext/sqlite/sqlite.c:1.178 php-src/ext/sqlite/sqlite.c:1.179
--- php-src/ext/sqlite/sqlite.c:1.178   Fri Nov 25 10:40:14 2005
+++ php-src/ext/sqlite/sqlite.c Mon Dec  5 15:41:57 2005
@@ -17,7 +17,7 @@
    |          Marcus Boerger <[EMAIL PROTECTED]>                              |
    +----------------------------------------------------------------------+
 
-   $Id: sqlite.c,v 1.178 2005/11/25 15:40:14 sniper Exp $ 
+   $Id: sqlite.c,v 1.179 2005/12/05 20:41:57 bfrance Exp $
 */
 
 #ifdef HAVE_CONFIG_H
@@ -29,7 +29,9 @@
 #include "php.h"
 #include "php_ini.h"
 #include "ext/standard/info.h"
+#if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
 #include "ext/session/php_session.h"
+#endif
 #include "php_sqlite.h"
 
 #if HAVE_TIME_H
@@ -346,11 +348,11 @@
 {
        if (rsrc->ptr) {
                struct php_sqlite_db *db = (struct php_sqlite_db*)rsrc->ptr;
-       
+
                sqlite_close(db->db);
 
                zend_hash_destroy(&db->callbacks);
-               
+
                pefree(db, db->is_persistent);
 
                rsrc->ptr = NULL;
@@ -413,7 +415,7 @@
 
        /* don't leave pending commits hanging around */
        sqlite_exec(db->db, "ROLLBACK", NULL, NULL, NULL);
-       
+
        return 0;
 }
 
@@ -439,7 +441,7 @@
                sqlite_set_result_error(func, "not enough parameters", -1);
                return;
        }
-       
+
        ZVAL_STRING(&funcname, (char*)argv[0], 1);
 
        if (!zend_make_callable(&funcname, &callable TSRMLS_CC)) {
@@ -450,10 +452,10 @@
                zval_dtor(&funcname);
                return;
        }
-       
+
        if (argc > 1) {
                zargs = (zval ***)safe_emalloc((argc - 1), sizeof(zval **), 0);
-               
+
                for (i = 0; i < argc-1; i++) {
                        zargs[i] = emalloc(sizeof(zval *));
                        MAKE_STD_ZVAL(*zargs[i]);
@@ -530,7 +532,7 @@
 
        if (argc > 0) {
                zargs = (zval ***)safe_emalloc(argc, sizeof(zval **), 0);
-               
+
                for (i = 0; i < argc; i++) {
                        zargs[i] = emalloc(sizeof(zval *));
                        MAKE_STD_ZVAL(*zargs[i]);
@@ -609,10 +611,10 @@
        if (argc < 1) {
                return;
        }
-       
+
        zargc = argc + 1;
        zargs = (zval ***)safe_emalloc(zargc, sizeof(zval **), 0);
-               
+
        /* first arg is always the context zval */
        context_p = (zval **)sqlite_aggregate_context(func, sizeof(*context_p));
 
@@ -674,9 +676,9 @@
                sqlite_set_result_error(func, "this function has not been 
correctly defined for this request", -1);
                return;
        }
-       
+
        context_p = (zval **)sqlite_aggregate_context(func, sizeof(*context_p));
-       
+
        res = call_user_function_ex(EG(function_table),
                        NULL,
                        funcs->fini,
@@ -838,7 +840,7 @@
 static zend_object_value sqlite_object_new_db(zend_class_entry *class_type 
TSRMLS_DC)
 {
        zend_object_value retval;
-       
+
        sqlite_object_new(class_type, &sqlite_object_handlers_db, &retval 
TSRMLS_CC);
        return retval;
 }
@@ -846,7 +848,7 @@
 static zend_object_value sqlite_object_new_query(zend_class_entry *class_type 
TSRMLS_DC)
 {
        zend_object_value retval;
-       
+
        sqlite_object_new(class_type, &sqlite_object_handlers_query, &retval 
TSRMLS_CC);
        return retval;
 }
@@ -854,7 +856,7 @@
 static zend_object_value sqlite_object_new_ub_query(zend_class_entry 
*class_type TSRMLS_DC)
 {
        zend_object_value retval;
-       
+
        sqlite_object_new(class_type, &sqlite_object_handlers_ub_query, &retval 
TSRMLS_CC);
        return retval;
 }
@@ -862,7 +864,7 @@
 static zend_object_value sqlite_object_new_exception(zend_class_entry 
*class_type TSRMLS_DC)
 {
        zend_object_value retval;
-       
+
        sqlite_object_new(class_type, &sqlite_object_handlers_exception, 
&retval TSRMLS_CC);
        return retval;
 }
@@ -948,7 +950,7 @@
                MAKE_STD_ZVAL(**data);
                php_sqlite_fetch_array(res, res->mode, 1, 0, **data TSRMLS_CC);
        }
-       
+
 }
 
 int sqlite_iterator_get_current_key(zend_object_iterator *iter, char 
**str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
@@ -977,7 +979,7 @@
                        /* php_error_docref(NULL TSRMLS_CC, E_WARNING, "no more 
rows available"); */
                        return;
                }
-       
+
                res->curr_row++;
        }
 }
@@ -1030,7 +1032,7 @@
        REGISTER_SQLITE_CLASS(Exception,  exception, spl_ce_RuntimeException);
 #else
        REGISTER_SQLITE_CLASS(Exception,  exception, 
zend_exception_get_default(TSRMLS_C));
-#endif 
+#endif
 
        sqlite_ce_db->ce_flags &= ~ZEND_ACC_FINAL_CLASS;
        sqlite_ce_db->constructor->common.fn_flags |= ZEND_ACC_FINAL;
@@ -1045,7 +1047,7 @@
 #if defined(HAVE_SPL) && ((PHP_MAJOR_VERSION > 5) || (PHP_MAJOR_VERSION == 5 
&& PHP_MINOR_VERSION >= 1))
        zend_class_implements(sqlite_ce_query TSRMLS_CC, 2, zend_ce_iterator, 
spl_ce_Countable);
 #else
-       zend_class_implements(sqlite_ce_query TSRMLS_CC, 1, zend_ce_iterator);  
+       zend_class_implements(sqlite_ce_query TSRMLS_CC, 1, zend_ce_iterator);
 #endif
        sqlite_ce_query->get_iterator = sqlite_get_iterator;
        sqlite_ce_query->iterator_funcs.funcs = &sqlite_query_iterator_funcs;
@@ -1057,7 +1059,7 @@
 #if HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)
        php_session_register_module(ps_sqlite_ptr);
 #endif
-       
+
        le_sqlite_db = zend_register_list_destructors_ex(php_sqlite_db_dtor, 
NULL, "sqlite database", module_number);
        le_sqlite_pdb = zend_register_list_destructors_ex(NULL, 
php_sqlite_db_dtor, "sqlite database (persistent)", module_number);
        le_sqlite_result = 
zend_register_list_destructors_ex(php_sqlite_result_dtor, NULL, "sqlite 
result", module_number);
@@ -1065,7 +1067,7 @@
        REGISTER_LONG_CONSTANT("SQLITE_BOTH",   PHPSQLITE_BOTH, 
CONST_CS|CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("SQLITE_NUM",    PHPSQLITE_NUM, 
CONST_CS|CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("SQLITE_ASSOC",  PHPSQLITE_ASSOC, 
CONST_CS|CONST_PERSISTENT);
-       
+
        REGISTER_LONG_CONSTANT("SQLITE_OK",                             
SQLITE_OK, CONST_CS|CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("SQLITE_ERROR",                  SQLITE_ERROR, 
CONST_CS|CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("SQLITE_INTERNAL",               
SQLITE_INTERNAL, CONST_CS|CONST_PERSISTENT);
@@ -1099,7 +1101,7 @@
 
 #ifdef PHP_SQLITE2_HAVE_PDO
     if (FAILURE == php_pdo_register_driver(&pdo_sqlite2_driver)) {
-        return FAILURE;
+       return FAILURE;
     }
 #endif
 
@@ -1126,7 +1128,7 @@
 {
        php_info_print_table_start();
        php_info_print_table_header(2, "SQLite support", "enabled");
-       php_info_print_table_row(2, "PECL Module version", 
PHP_SQLITE_MODULE_VERSION " $Id: sqlite.c,v 1.178 2005/11/25 15:40:14 sniper 
Exp $");
+       php_info_print_table_row(2, "PECL Module version", 
PHP_SQLITE_MODULE_VERSION " $Id: sqlite.c,v 1.179 2005/12/05 20:41:57 bfrance 
Exp $");
        php_info_print_table_row(2, "SQLite Library", sqlite_libversion());
        php_info_print_table_row(2, "SQLite Encoding", sqlite_libencoding());
        php_info_print_table_end();
@@ -1167,7 +1169,7 @@
        db->db = sdb;
 
        zend_hash_init(&db->callbacks, 0, NULL, php_sqlite_callback_dtor, 
db->is_persistent);
-       
+
        /* register the PHP functions */
        sqlite_create_function(sdb, "php", -1, 
php_sqlite_generic_function_callback, 0);
 
@@ -1181,7 +1183,7 @@
        if (PG(safe_mode) || (PG(open_basedir) && *PG(open_basedir))) {
                sqlite_set_authorizer(sdb, php_sqlite_authorizer, NULL);
        }
-       
+
        db->rsrc_id = ZEND_REGISTER_RESOURCE(object ? NULL : return_value, db, 
persistent_id ? le_sqlite_pdb : le_sqlite_db);
        if (object) {
                /* if object is not an object then we're called from the 
factory() function */
@@ -1204,7 +1206,7 @@
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to 
register persistent resource");
                }
        }
-       
+
        return db;
 }
 
@@ -1218,7 +1220,7 @@
        zval *errmsg = NULL;
        struct php_sqlite_db *db = NULL;
        list_entry *le;
-       
+
        if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz/",
                                &filename, &filename_len, &mode, &errmsg)) {
                return;
@@ -1231,7 +1233,7 @@
        if (strncmp(filename, ":memory:", sizeof(":memory:") - 1)) {
                /* resolve the fully-qualified path name to use as the hash key 
*/
                fullpath = expand_filepath(filename, NULL TSRMLS_CC);
-       
+
                if (PG(safe_mode) && (!php_checkuid(fullpath, NULL, 
CHECKUID_CHECK_FILE_AND_DIR))) {
                        RETURN_FALSE;
                }
@@ -1244,12 +1246,12 @@
        }
 
        hashkeylen = spprintf(&hashkey, 0, "sqlite_pdb_%s:%ld", fullpath, mode);
-       
+
        /* do we have an existing persistent connection ? */
        if (SUCCESS == zend_hash_find(&EG(persistent_list), hashkey, 
hashkeylen+1, (void*)&le)) {
                if (Z_TYPE_P(le) == le_sqlite_pdb) {
                        db = (struct php_sqlite_db*)le->ptr;
-                       
+
                        if (db->rsrc_id == FAILURE) {
                                /* give it a valid resource id for this request 
*/
                                db->rsrc_id = 
ZEND_REGISTER_RESOURCE(return_value, db, le_sqlite_pdb);
@@ -1307,7 +1309,7 @@
        if (strncmp(filename, ":memory:", sizeof(":memory:") - 1)) {
                /* resolve the fully-qualified path name to use as the hash key 
*/
                fullpath = expand_filepath(filename, NULL TSRMLS_CC);
-       
+
                if (PG(safe_mode) && (!php_checkuid(fullpath, NULL, 
CHECKUID_CHECK_FILE_AND_DIR))) {
                        php_std_error_handling();
                        efree(fullpath);
@@ -1362,13 +1364,13 @@
        if (strncmp(filename, ":memory:", sizeof(":memory:") - 1)) {
                /* resolve the fully-qualified path name to use as the hash key 
*/
                fullpath = expand_filepath(filename, NULL TSRMLS_CC);
-       
+
                if (PG(safe_mode) && (!php_checkuid(fullpath, NULL, 
CHECKUID_CHECK_FILE_AND_DIR))) {
                        efree(fullpath);
                        php_std_error_handling();
                        RETURN_NULL();
                }
-       
+
                if (php_check_open_basedir(fullpath TSRMLS_CC)) {
                        efree(fullpath);
                        php_std_error_handling();
@@ -1557,7 +1559,7 @@
        memcpy(*prres, &res, sizeof(**prres));
        (*prres)->db = db;
        zend_list_addref(db->rsrc_id);
-       
+
 
        /* now the result set is ready for stepping: get first row */
        if (php_sqlite_fetch((*prres) TSRMLS_CC) != SQLITE_OK) {
@@ -1566,10 +1568,10 @@
                if (return_value) {
                        RETURN_FALSE;
                } else {
-                       return; 
+                       return;
                }
        }
-       
+
        (*prres)->curr_row = 0;
 
        if (object) {
@@ -1608,7 +1610,7 @@
                DB_FROM_OBJECT(db, object);
        } else {
                if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
-                               ZEND_NUM_ARGS() TSRMLS_CC, "sr|lz/", &sql, 
&sql_len, &zdb, &mode, &errmsg) && 
+                               ZEND_NUM_ARGS() TSRMLS_CC, "sr|lz/", &sql, 
&sql_len, &zdb, &mode, &errmsg) &&
                        FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() 
TSRMLS_CC, "rs|lz/", &zdb, &sql, &sql_len, &mode, &errmsg)) {
                        return;
                }
@@ -1662,7 +1664,7 @@
                DB_FROM_OBJECT(db, object);
        } else {
                if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
-                               ZEND_NUM_ARGS() TSRMLS_CC, "sr|l", &tbl, 
&tbl_len, &zdb, &result_type) && 
+                               ZEND_NUM_ARGS() TSRMLS_CC, "sr|l", &tbl, 
&tbl_len, &zdb, &result_type) &&
                        FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() 
TSRMLS_CC, "rs|l", &zdb, &tbl, &tbl_len, &result_type)) {
                        return;
                }
@@ -1749,7 +1751,7 @@
                DB_FROM_OBJECT(db, object);
        } else {
                if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
-                               ZEND_NUM_ARGS() TSRMLS_CC, "sr|lz/", &sql, 
&sql_len, &zdb, &mode, &errmsg) && 
+                               ZEND_NUM_ARGS() TSRMLS_CC, "sr|lz/", &sql, 
&sql_len, &zdb, &mode, &errmsg) &&
                        FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() 
TSRMLS_CC, "rs|lz/", &zdb, &sql, &sql_len, &mode, &errmsg)) {
                        return;
                }
@@ -1800,7 +1802,7 @@
                DB_FROM_OBJECT(db, object);
        } else {
                if(FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
-                       ZEND_NUM_ARGS() TSRMLS_CC, "sr", &sql, &sql_len, &zdb) 
&& 
+                       ZEND_NUM_ARGS() TSRMLS_CC, "sr", &sql, &sql_len, &zdb) 
&&
                   FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, 
"rs|z/", &zdb, &sql, &sql_len, &errmsg)) {
                        return;
                }
@@ -1953,7 +1955,7 @@
                if (!res->buffered) {
                        efree((char*)rowdata[j]);
                        rowdata[j] = NULL;
-               }               
+               }
        } else if (UG(unicode)) {
                UErrorCode status = U_ZERO_ERROR;
                UChar *u_str;
@@ -1964,12 +1966,12 @@
                if (!res->buffered) {
                        efree((char *)rowdata[j]);
                        rowdata[j] = NULL;
-               }               
+               }
        } else {
                RETVAL_STRING((char*)rowdata[j], res->buffered);
                if (!res->buffered) {
                        rowdata[j] = NULL;
-               }               
+               }
        }
 }
 /* }}} */
@@ -2067,7 +2069,7 @@
        zval dataset;
        zend_fcall_info fci;
        zend_fcall_info_cache fcc;
-       zval *retval_ptr; 
+       zval *retval_ptr;
        zval *ctor_params = NULL;
        zend_uchar class_name_type;
 
@@ -2136,7 +2138,7 @@
                        } else {
                                /* Two problems why we throw exceptions here: 
PHP is typeless
                                 * and hence passing one argument that's not an 
array could be
-                                * by mistake and the other way round is 
possible, too. The 
+                                * by mistake and the other way round is 
possible, too. The
                                 * single value is an array. Also we'd have to 
make that one
                                 * argument passed by reference.
                                 */
@@ -2191,7 +2193,7 @@
                DB_FROM_OBJECT(db, object);
        } else {
                if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
-                               ZEND_NUM_ARGS() TSRMLS_CC, "sr|lb", &sql, 
&sql_len, &zdb, &mode, &decode_binary) && 
+                               ZEND_NUM_ARGS() TSRMLS_CC, "sr|lb", &sql, 
&sql_len, &zdb, &mode, &decode_binary) &&
                        FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() 
TSRMLS_CC, "rs|lb", &zdb, &sql, &sql_len, &mode, &decode_binary)) {
                        return;
                }
@@ -2210,15 +2212,15 @@
                }
                return;
        }
-       
+
        rres = (struct php_sqlite_result *)emalloc(sizeof(*rres));
        sqlite_query(NULL, db, sql, sql_len, (int)mode, 0, NULL, &rres, NULL 
TSRMLS_CC);
-       if (db->last_err_code != SQLITE_OK) {
-               if (rres) {
-                       efree(rres);
-               }
-               RETURN_FALSE;
-       }
+       if (db->last_err_code != SQLITE_OK) {
+               if (rres) {
+                       efree(rres);
+               }
+               RETURN_FALSE;
+       }
 
        array_init(return_value);
 
@@ -2238,13 +2240,13 @@
        char *decoded;
        int decoded_len;
        int free_decoded = 0;
-       
+
        /* check range of the row */
        if (res->curr_row >= res->nrows) {
                /* no more */
                RETURN_FALSE;
        }
-       
+
        if (res->buffered) {
                rowdata = (const char**)&res->table[res->curr_row * 
res->ncolumns];
        } else {
@@ -2324,7 +2326,7 @@
                RES_FROM_OBJECT(db, object);
        } else {
                if (FAILURE == zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET,
-                               ZEND_NUM_ARGS() TSRMLS_CC, "sr|bb", &sql, 
&sql_len, &zdb, &srow, &decode_binary) && 
+                               ZEND_NUM_ARGS() TSRMLS_CC, "sr|bb", &sql, 
&sql_len, &zdb, &srow, &decode_binary) &&
                        FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() 
TSRMLS_CC, "rs|bb", &zdb, &sql, &sql_len, &srow, &decode_binary)) {
                        return;
                }
@@ -2626,7 +2628,7 @@
                RETURN_FALSE;
        }
 
-       RETURN_BOOL(res->curr_row); 
+       RETURN_BOOL(res->curr_row);
 }
 /* }}} */
 
@@ -2709,7 +2711,7 @@
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot seek an 
unbuffered result set");
                RETURN_FALSE;
        }
-       
+
        if (row < 0 || row >= res->nrows) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "row %ld out of 
range", row);
                RETURN_FALSE;
@@ -2744,7 +2746,7 @@
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot rewind an 
unbuffered result set");
                RETURN_FALSE;
        }
-       
+
        if (!res->nrows) {
                php_error_docref(NULL TSRMLS_CC, E_NOTICE, "no rows received");
                RETURN_FALSE;
@@ -2865,12 +2867,12 @@
        if (stringlen && (string[0] == '\x01' || memchr(string, '\0', 
stringlen) != NULL)) {
                /* binary string */
                int enclen;
-               
+
                ret = safe_emalloc(1 + stringlen / 254, 257, 3);
                ret[0] = '\x01';
                enclen = php_sqlite_encode_binary(string, stringlen, ret+1);
                RETVAL_STRINGL(ret, enclen+1, 0);
-               
+
        } else if (stringlen) {
                ret = sqlite_mprintf("%q", string);
                if (ret) {
@@ -2917,7 +2919,7 @@
        if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", 
&code)) {
                return;
        }
-       
+
        msg = sqlite_error_string(code);
 
        if (msg) {
@@ -2985,7 +2987,7 @@
        }
        alloc_funcs->is_valid = 1;
        *funcs = alloc_funcs;
-       
+
        return ret;
 }
 
@@ -3021,7 +3023,7 @@
                return;
        }
        zval_dtor(&callable);
-       
+
        if (!zend_is_callable(zfinal, 0, &callable)) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "finalize function 
`%R' is not callable", Z_TYPE(callable), Z_UNIVAL(callable));
                zval_dtor(&callable);
@@ -3029,13 +3031,13 @@
        }
        zval_dtor(&callable);
 
-       
+
        if (prep_callback_struct(db, 1, funcname, zstep, zfinal, &funcs) == 
DO_REG) {
                sqlite_create_aggregate(db->db, funcname, num_args,
                                php_sqlite_agg_step_function_callback,
                                php_sqlite_agg_fini_function_callback, funcs);
        }
-       
+
 
 }
 /* }}} */
@@ -3051,7 +3053,7 @@
        struct php_sqlite_agg_functions *funcs;
        zval callable;
        long num_args = -1;
-       
+
        zval *object = getThis();
 
        if (object) {
@@ -3072,7 +3074,7 @@
                return;
        }
        zval_dtor(&callable);
-       
+
        if (prep_callback_struct(db, 0, funcname, zcall, NULL, &funcs) == 
DO_REG) {
                sqlite_create_function(db->db, funcname, num_args, 
php_sqlite_function_callback, funcs);
        }
@@ -3097,7 +3099,7 @@
                /* binary string */
                int enclen;
                char *ret;
-               
+
                ret = safe_emalloc(1 + datalen / 254, 257, 3);
                ret[0] = '\x01';
                enclen = php_sqlite_encode_binary(data, datalen, ret+1);
@@ -3126,7 +3128,7 @@
                /* encoded string */
                int enclen;
                char *ret;
-               
+
                ret = emalloc(datalen);
                enclen = php_sqlite_decode_binary(data+1, ret);
                ret[enclen] = '\0';

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to