mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Wrap the php_session.h include in the same ifdef as the rest of the
session code.
This commit is contained in:
parent
6aba1816ee
commit
7154c617bf
1 changed files with 71 additions and 69 deletions
|
@ -17,7 +17,7 @@
|
|||
| Marcus Boerger <helly@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
|
||||
$Id$
|
||||
$Id$
|
||||
*/
|
||||
|
||||
#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 @@ static ZEND_RSRC_DTOR_FUNC(php_sqlite_db_dtor)
|
|||
{
|
||||
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 @@ static int php_sqlite_forget_persistent_id_numbers(zend_rsrc_list_entry *rsrc TS
|
|||
|
||||
/* don't leave pending commits hanging around */
|
||||
sqlite_exec(db->db, "ROLLBACK", NULL, NULL, NULL);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -438,7 +440,7 @@ static void php_sqlite_generic_function_callback(sqlite_func *func, int argc, co
|
|||
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)) {
|
||||
|
@ -449,10 +451,10 @@ static void php_sqlite_generic_function_callback(sqlite_func *func, int argc, co
|
|||
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]);
|
||||
|
@ -529,7 +531,7 @@ static void php_sqlite_function_callback(sqlite_func *func, int argc, const char
|
|||
|
||||
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]);
|
||||
|
@ -608,10 +610,10 @@ static void php_sqlite_agg_step_function_callback(sqlite_func *func, int argc, c
|
|||
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));
|
||||
|
||||
|
@ -673,9 +675,9 @@ static void php_sqlite_agg_fini_function_callback(sqlite_func *func)
|
|||
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,
|
||||
|
@ -837,7 +839,7 @@ static void sqlite_object_new(zend_class_entry *class_type, zend_object_handlers
|
|||
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;
|
||||
}
|
||||
|
@ -845,7 +847,7 @@ static zend_object_value sqlite_object_new_db(zend_class_entry *class_type TSRML
|
|||
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;
|
||||
}
|
||||
|
@ -853,7 +855,7 @@ static zend_object_value sqlite_object_new_query(zend_class_entry *class_type TS
|
|||
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;
|
||||
}
|
||||
|
@ -861,7 +863,7 @@ static zend_object_value sqlite_object_new_ub_query(zend_class_entry *class_type
|
|||
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;
|
||||
}
|
||||
|
@ -947,7 +949,7 @@ void sqlite_iterator_get_current_data(zend_object_iterator *iter, zval ***data T
|
|||
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)
|
||||
|
@ -976,7 +978,7 @@ void sqlite_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC)
|
|||
/* php_error_docref(NULL TSRMLS_CC, E_WARNING, "no more rows available"); */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
res->curr_row++;
|
||||
}
|
||||
}
|
||||
|
@ -1029,7 +1031,7 @@ PHP_MINIT_FUNCTION(sqlite)
|
|||
REGISTER_SQLITE_CLASS(Exception, exception, spl_ce_RuntimeException);
|
||||
#else
|
||||
REGISTER_SQLITE_CLASS(Exception, exception, zend_exception_get_default());
|
||||
#endif
|
||||
#endif
|
||||
|
||||
sqlite_ce_db->ce_flags &= ~ZEND_ACC_FINAL_CLASS;
|
||||
sqlite_ce_db->constructor->common.fn_flags |= ZEND_ACC_FINAL;
|
||||
|
@ -1044,7 +1046,7 @@ PHP_MINIT_FUNCTION(sqlite)
|
|||
#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;
|
||||
|
@ -1056,7 +1058,7 @@ PHP_MINIT_FUNCTION(sqlite)
|
|||
#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);
|
||||
|
@ -1064,7 +1066,7 @@ PHP_MINIT_FUNCTION(sqlite)
|
|||
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);
|
||||
|
@ -1098,7 +1100,7 @@ PHP_MINIT_FUNCTION(sqlite)
|
|||
|
||||
#ifdef PHP_SQLITE2_HAVE_PDO
|
||||
if (FAILURE == php_pdo_register_driver(&pdo_sqlite2_driver)) {
|
||||
return FAILURE;
|
||||
return FAILURE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1166,7 +1168,7 @@ static struct php_sqlite_db *php_sqlite_open(char *filename, int mode, char *per
|
|||
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);
|
||||
|
||||
|
@ -1180,7 +1182,7 @@ static struct php_sqlite_db *php_sqlite_open(char *filename, int mode, char *per
|
|||
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 */
|
||||
|
@ -1203,7 +1205,7 @@ static struct php_sqlite_db *php_sqlite_open(char *filename, int mode, char *per
|
|||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to register persistent resource");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return db;
|
||||
}
|
||||
|
||||
|
@ -1217,7 +1219,7 @@ PHP_FUNCTION(sqlite_popen)
|
|||
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;
|
||||
|
@ -1230,7 +1232,7 @@ PHP_FUNCTION(sqlite_popen)
|
|||
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;
|
||||
}
|
||||
|
@ -1243,12 +1245,12 @@ PHP_FUNCTION(sqlite_popen)
|
|||
}
|
||||
|
||||
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);
|
||||
|
@ -1306,7 +1308,7 @@ PHP_FUNCTION(sqlite_open)
|
|||
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);
|
||||
|
@ -1361,13 +1363,13 @@ PHP_FUNCTION(sqlite_factory)
|
|||
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();
|
||||
|
@ -1556,7 +1558,7 @@ terminate:
|
|||
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) {
|
||||
|
@ -1565,10 +1567,10 @@ terminate:
|
|||
if (return_value) {
|
||||
RETURN_FALSE;
|
||||
} else {
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
(*prres)->curr_row = 0;
|
||||
|
||||
if (object) {
|
||||
|
@ -1607,7 +1609,7 @@ PHP_FUNCTION(sqlite_unbuffered_query)
|
|||
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;
|
||||
}
|
||||
|
@ -1661,7 +1663,7 @@ PHP_FUNCTION(sqlite_fetch_column_types)
|
|||
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;
|
||||
}
|
||||
|
@ -1732,7 +1734,7 @@ PHP_FUNCTION(sqlite_query)
|
|||
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;
|
||||
}
|
||||
|
@ -1783,7 +1785,7 @@ PHP_FUNCTION(sqlite_exec)
|
|||
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;
|
||||
}
|
||||
|
@ -1924,12 +1926,12 @@ static void php_sqlite_fetch_column(struct php_sqlite_result *res, zval *which,
|
|||
if (!res->buffered) {
|
||||
efree((char*)rowdata[j]);
|
||||
rowdata[j] = NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
RETVAL_STRING((char*)rowdata[j], res->buffered);
|
||||
if (!res->buffered) {
|
||||
rowdata[j] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -2027,7 +2029,7 @@ PHP_FUNCTION(sqlite_fetch_object)
|
|||
zval dataset;
|
||||
zend_fcall_info fci;
|
||||
zend_fcall_info_cache fcc;
|
||||
zval *retval_ptr;
|
||||
zval *retval_ptr;
|
||||
zval *ctor_params = NULL;
|
||||
|
||||
php_set_error_handling(object ? EH_THROW : EH_NORMAL, sqlite_ce_exception TSRMLS_CC);
|
||||
|
@ -2095,7 +2097,7 @@ PHP_FUNCTION(sqlite_fetch_object)
|
|||
} 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.
|
||||
*/
|
||||
|
@ -2150,7 +2152,7 @@ PHP_FUNCTION(sqlite_array_query)
|
|||
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;
|
||||
}
|
||||
|
@ -2169,15 +2171,15 @@ PHP_FUNCTION(sqlite_array_query)
|
|||
}
|
||||
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);
|
||||
|
||||
|
@ -2196,13 +2198,13 @@ static void php_sqlite_fetch_single(struct php_sqlite_result *res, zend_bool dec
|
|||
const char **rowdata;
|
||||
char *decoded;
|
||||
int decoded_len;
|
||||
|
||||
|
||||
/* 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 {
|
||||
|
@ -2266,7 +2268,7 @@ PHP_FUNCTION(sqlite_single_query)
|
|||
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;
|
||||
}
|
||||
|
@ -2568,7 +2570,7 @@ PHP_FUNCTION(sqlite_has_prev)
|
|||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
RETURN_BOOL(res->curr_row);
|
||||
RETURN_BOOL(res->curr_row);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -2651,7 +2653,7 @@ PHP_FUNCTION(sqlite_seek)
|
|||
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;
|
||||
|
@ -2686,7 +2688,7 @@ PHP_FUNCTION(sqlite_rewind)
|
|||
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;
|
||||
|
@ -2807,12 +2809,12 @@ PHP_FUNCTION(sqlite_escape_string)
|
|||
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) {
|
||||
|
@ -2859,7 +2861,7 @@ PHP_FUNCTION(sqlite_error_string)
|
|||
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &code)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
msg = sqlite_error_string(code);
|
||||
|
||||
if (msg) {
|
||||
|
@ -2927,7 +2929,7 @@ static enum callback_prep_t prep_callback_struct(struct php_sqlite_db *db, int i
|
|||
}
|
||||
alloc_funcs->is_valid = 1;
|
||||
*funcs = alloc_funcs;
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2963,7 +2965,7 @@ PHP_FUNCTION(sqlite_create_aggregate)
|
|||
return;
|
||||
}
|
||||
efree(callable);
|
||||
|
||||
|
||||
if (!zend_is_callable(zfinal, 0, &callable)) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "finalize function `%s' is not callable", callable);
|
||||
efree(callable);
|
||||
|
@ -2971,13 +2973,13 @@ PHP_FUNCTION(sqlite_create_aggregate)
|
|||
}
|
||||
efree(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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -2993,7 +2995,7 @@ PHP_FUNCTION(sqlite_create_function)
|
|||
struct php_sqlite_agg_functions *funcs;
|
||||
char *callable = NULL;
|
||||
long num_args = -1;
|
||||
|
||||
|
||||
zval *object = getThis();
|
||||
|
||||
if (object) {
|
||||
|
@ -3014,7 +3016,7 @@ PHP_FUNCTION(sqlite_create_function)
|
|||
return;
|
||||
}
|
||||
efree(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);
|
||||
}
|
||||
|
@ -3039,7 +3041,7 @@ PHP_FUNCTION(sqlite_udf_encode_binary)
|
|||
/* 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);
|
||||
|
@ -3068,7 +3070,7 @@ PHP_FUNCTION(sqlite_udf_decode_binary)
|
|||
/* encoded string */
|
||||
int enclen;
|
||||
char *ret;
|
||||
|
||||
|
||||
ret = emalloc(datalen);
|
||||
enclen = php_sqlite_decode_binary(data+1, ret);
|
||||
ret[enclen] = '\0';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue