cvs: php-src(PHP_4_3) /ext/dbase dbase.c dbf_rec.c
| From: | Jani Taskinen | Date: | Sun, 03 Apr 2005 11:39:43 +0000 |
| Subject: | cvs: php-src(PHP_4_3) /ext/dbase dbase.c dbf_rec.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-31200@lists.php.net to get a copy of this message | ||
sniper Sun Apr 3 07:39:43 2005 EDT
Modified files: (Branch: PHP_4_3)
/php-src/ext/dbase dbase.c dbf_rec.c
Log:
- Sync with HEAD:
. php_error -> php_error_docref (fixes test)
. pval -> zval
. use modern parameter parsing
# No new functionality was added!
http://cvs.php.net/diff.php/php-src/ext/dbase/dbase.c?r1=1.60.2.4&r2=1.60.2.5&ty=u Index: php-src/ext/dbase/dbase.c diff -u php-src/ext/dbase/dbase.c:1.60.2.4 php-src/ext/dbase/dbase.c:1.60.2.5 --- php-src/ext/dbase/dbase.c:1.60.2.4 Fri Feb 4 09:29:20 2005 +++ php-src/ext/dbase/dbase.c Sun Apr 3 07:39:43 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dbase.c,v 1.60.2.4 2005/02/04 14:29:20 derick Exp $ */ +/* $Id: dbase.c,v 1.60.2.5 2005/04/03 11:39:43 sniper Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -118,33 +118,33 @@ Opens a dBase-format database file */ PHP_FUNCTION(dbase_open) { - pval *dbf_name, *options; + zval **dbf_name, **options; dbhead_t *dbh; int handle; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &dbf_name, &options)==FAILURE) { + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &dbf_name, &options) == FAILURE) { WRONG_PARAM_COUNT; } - convert_to_string(dbf_name); - convert_to_long(options); + convert_to_string_ex(dbf_name); + convert_to_long_ex(options); - if (Z_LVAL_P(options) == 1) { - php_error(E_WARNING, "Cannot open %s in write-only mode", Z_STRVAL_P(dbf_name)); + if (Z_LVAL_PP(options) == 1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot open %s in write-only mode", Z_STRVAL_PP(dbf_name)); RETURN_FALSE; } - - if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_P(dbf_name), NULL, CHECKUID_CHECK_FILE_AND_DIR))) { + + if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(dbf_name), NULL, CHECKUID_CHECK_FILE_AND_DIR))) { RETURN_FALSE; } - if (php_check_open_basedir(Z_STRVAL_P(dbf_name) TSRMLS_CC)) { + if (php_check_open_basedir(Z_STRVAL_PP(dbf_name) TSRMLS_CC)) { RETURN_FALSE; } - dbh = dbf_open(Z_STRVAL_P(dbf_name), Z_LVAL_P(options) TSRMLS_CC); + dbh = dbf_open(Z_STRVAL_PP(dbf_name), Z_LVAL_PP(options) TSRMLS_CC); if (dbh == NULL) { - php_error(E_WARNING, "unable to open database %s", Z_STRVAL_P(dbf_name)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to open database %s", Z_STRVAL_PP(dbf_name)); RETURN_FALSE; } @@ -157,22 +157,22 @@ Closes an open dBase-format database file */ PHP_FUNCTION(dbase_close) { - pval *dbh_id; + zval **dbh_id; dbhead_t *dbh; int dbh_type; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &dbh_id)==FAILURE) { + if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &dbh_id) == FAILURE)) { WRONG_PARAM_COUNT; } - convert_to_long(dbh_id); - dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type); + convert_to_long_ex(dbh_id); + dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type); if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) { - php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id)); RETURN_FALSE; } - zend_list_delete(Z_LVAL_P(dbh_id)); + zend_list_delete(Z_LVAL_PP(dbh_id)); RETURN_TRUE; } /* }}} */ @@ -181,18 +181,18 @@ Returns the number of records in the database */ PHP_FUNCTION(dbase_numrecords) { - pval *dbh_id; + zval **dbh_id; dbhead_t *dbh; int dbh_type; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &dbh_id)==FAILURE) { + if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &dbh_id) == FAILURE)) { WRONG_PARAM_COUNT; } - convert_to_long(dbh_id); - dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type); + convert_to_long_ex(dbh_id); + dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type); if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) { - php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id)); RETURN_FALSE; } @@ -204,18 +204,18 @@ Returns the number of fields (columns) in the database */ PHP_FUNCTION(dbase_numfields) { - pval *dbh_id; + zval **dbh_id; dbhead_t *dbh; int dbh_type; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &dbh_id)==FAILURE) { + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &dbh_id) == FAILURE) { WRONG_PARAM_COUNT; } - convert_to_long(dbh_id); - dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type); + convert_to_long_ex(dbh_id); + dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type); if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) { - php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id)); RETURN_FALSE; } @@ -227,18 +227,18 @@ Packs the database (deletes records marked for deletion) */ PHP_FUNCTION(dbase_pack) { - pval *dbh_id; + zval **dbh_id; dbhead_t *dbh; int dbh_type; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &dbh_id)==FAILURE) { + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &dbh_id) == FAILURE) { WRONG_PARAM_COUNT; } - convert_to_long(dbh_id); - dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type); + convert_to_long_ex(dbh_id); + dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type); if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) { - php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id)); RETURN_FALSE; } @@ -252,7 +252,7 @@ Adds a record to the database */ PHP_FUNCTION(dbase_add_record) { - pval *dbh_id, *fields, **field; + zval **dbh_id, **fields, **field; dbhead_t *dbh; int dbh_type; @@ -262,40 +262,36 @@ int i; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &dbh_id, &fields)==FAILURE) { + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &dbh_id, &fields) == FAILURE) { WRONG_PARAM_COUNT; } - convert_to_long(dbh_id); - if (Z_TYPE_P(fields) != IS_ARRAY) { - php_error(E_WARNING, "Expected array as second parameter"); + convert_to_long_ex(dbh_id); + if (Z_TYPE_PP(fields) != IS_ARRAY) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected array as second parameter"); RETURN_FALSE; } - dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type); + dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type); if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) { - php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id)); RETURN_FALSE; } - num_fields = zend_hash_num_elements(Z_ARRVAL_P(fields)); + num_fields = zend_hash_num_elements(Z_ARRVAL_PP(fields)); if (num_fields != dbh->db_nfields) { - php_error(E_WARNING, "Wrong number of fields specified"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Wrong number of fields specified"); RETURN_FALSE; } cp = t_cp = (char *)emalloc(dbh->db_rlen + 1); - if (!cp) { - php_error(E_WARNING, "unable to allocate memory"); - RETURN_FALSE; - } *t_cp++ = VALID_RECORD; dbf = dbh->db_fields; for (i = 0, cur_f = dbf; cur_f < &dbf[num_fields]; i++, cur_f++) { zval tmp; - if (zend_hash_index_find(Z_ARRVAL_P(fields), i, (void **)&field) == FAILURE) { - php_error(E_WARNING, "unexpected error"); + if (zend_hash_index_find(Z_ARRVAL_PP(fields), i, (void **)&field) == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "unexpected error"); efree(cp); RETURN_FALSE; } @@ -310,7 +306,7 @@ dbh->db_records++; if (put_dbf_record(dbh, dbh->db_records, cp) < 0) { - php_error(E_WARNING, "unable to put record at %ld", dbh->db_records); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to put record at %ld", dbh->db_records); efree(cp); RETURN_FALSE; } @@ -326,7 +322,7 @@ Replaces a record to the database */ PHP_FUNCTION(dbase_replace_record) { - pval *dbh_id, *fields, **field, *recnum; + zval **dbh_id, **fields, **field, **recnum; dbhead_t *dbh; int dbh_type; @@ -336,40 +332,36 @@ int i; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 3 || getParameters(ht, 3, &dbh_id, &fields, &recnum)==FAILURE) { + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &dbh_id, &fields, &recnum) == FAILURE) { WRONG_PARAM_COUNT; } - convert_to_long(dbh_id); - convert_to_long(recnum); - if (Z_TYPE_P(fields) != IS_ARRAY) { - php_error(E_WARNING, "Expected array as second parameter"); + convert_to_long_ex(dbh_id); + convert_to_long_ex(recnum); + if (Z_TYPE_PP(fields) != IS_ARRAY) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected array as second parameter"); RETURN_FALSE; } - dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type); + dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type); if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) { - php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id)); RETURN_FALSE; } - num_fields = zend_hash_num_elements(Z_ARRVAL_P(fields)); + num_fields = zend_hash_num_elements(Z_ARRVAL_PP(fields)); if (num_fields != dbh->db_nfields) { - php_error(E_WARNING, "Wrong number of fields specified"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Wrong number of fields specified"); RETURN_FALSE; } cp = t_cp = (char *)emalloc(dbh->db_rlen + 1); - if (!cp) { - php_error(E_WARNING, "unable to allocate memory"); - RETURN_FALSE; - } *t_cp++ = VALID_RECORD; dbf = dbh->db_fields; for (i = 0, cur_f = dbf; cur_f < &dbf[num_fields]; i++, cur_f++) { - if (zend_hash_index_find(Z_ARRVAL_P(fields), i, (void **)&field) == FAILURE) { - php_error(E_WARNING, "unexpected error"); + if (zend_hash_index_find(Z_ARRVAL_PP(fields), i, (void **)&field) == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "unexpected error"); efree(cp); RETURN_FALSE; } @@ -378,8 +370,8 @@ t_cp += cur_f->db_flen; } - if (put_dbf_record(dbh, Z_LVAL_P(recnum), cp) < 0) { - php_error(E_WARNING, "unable to put record at %ld", dbh->db_records); + if (put_dbf_record(dbh, Z_LVAL_PP(recnum), cp) < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to put record at %ld", dbh->db_records); efree(cp); RETURN_FALSE; } @@ -395,28 +387,28 @@ Marks a record to be deleted */ PHP_FUNCTION(dbase_delete_record) { - pval *dbh_id, *record; + zval **dbh_id, **record; dbhead_t *dbh; int dbh_type; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &dbh_id, &record)==FAILURE) { + if (ZEND_NUM_ARGS() != 2 || (zend_get_parameters_ex(2, &dbh_id, &record) == FAILURE)) { WRONG_PARAM_COUNT; } - convert_to_long(dbh_id); - convert_to_long(record); + convert_to_long_ex(dbh_id); + convert_to_long_ex(record); - dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type); + dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type); if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) { - php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id)); RETURN_FALSE; } - if (del_dbf_record(dbh, Z_LVAL_P(record)) < 0) { - if (Z_LVAL_P(record) > dbh->db_records) { - php_error(E_WARNING, "record %d out of bounds", Z_LVAL_P(record)); + if (del_dbf_record(dbh, Z_LVAL_PP(record)) < 0) { + if (Z_LVAL_PP(record) > dbh->db_records) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "record %ld out of bounds", Z_LVAL_PP(record)); } else { - php_error(E_WARNING, "unable to delete record %d", Z_LVAL_P(record)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to delete record %ld", Z_LVAL_PP(record)); } RETURN_FALSE; } @@ -430,7 +422,7 @@ */ static void php_dbase_get_record(INTERNAL_FUNCTION_PARAMETERS, int assoc) { - pval *dbh_id, *record; + zval **dbh_id, **record; dbhead_t *dbh; int dbh_type; dbfield_t *dbf, *cur_f; @@ -440,28 +432,26 @@ int errno_save; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &dbh_id, &record)==FAILURE) { + if (ZEND_NUM_ARGS() != 2 || (zend_get_parameters_ex(2, &dbh_id, &record) == FAILURE)) { WRONG_PARAM_COUNT; } - convert_to_long(dbh_id); - convert_to_long(record); + convert_to_long_ex(dbh_id); + convert_to_long_ex(record); - dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type); + dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type); if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) { - php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id)); RETURN_FALSE; } - if ((data = get_dbf_record(dbh, Z_LVAL_P(record))) == NULL) { - php_error(E_WARNING, "Tried to read bad record %d", Z_LVAL_P(record)); + if ((data = get_dbf_record(dbh, Z_LVAL_PP(record))) == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to read bad record %ld", Z_LVAL_PP(record)); RETURN_FALSE; } dbf = dbh->db_fields; - if (array_init(return_value) == FAILURE) { - RETURN_FALSE; - } + array_init(return_value); fnp = NULL; for (cur_f = dbf; cur_f < &dbf[dbh->db_nfields]; cur_f++) { @@ -582,7 +572,7 @@ Creates a new dBase-format database file */ PHP_FUNCTION(dbase_create) { - pval *filename, *fields, **field, **value; + zval **filename, **fields, **field, **value; int fd; dbhead_t *dbh; @@ -591,37 +581,37 @@ int i, rlen, handle; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &filename, &fields)==FAILURE) { + if (ZEND_NUM_ARGS() != 2 || (zend_get_parameters_ex(2, &filename, &fields) == FAILURE)) { WRONG_PARAM_COUNT; } - convert_to_string(filename); + convert_to_string_ex(filename); - if (Z_TYPE_P(fields) != IS_ARRAY) { - php_error(E_WARNING, "Expected array as second parameter"); + if (Z_TYPE_PP(fields) != IS_ARRAY) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected array as second parameter"); RETURN_FALSE; } - if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_P(filename), NULL, CHECKUID_CHECK_FILE_AND_DIR))) { + if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(filename), NULL, CHECKUID_CHECK_FILE_AND_DIR))) { RETURN_FALSE; } - if (php_check_open_basedir(Z_STRVAL_P(filename) TSRMLS_CC)) { + if (php_check_open_basedir(Z_STRVAL_PP(filename) TSRMLS_CC)) { RETURN_FALSE; } - if ((fd = VCWD_OPEN_MODE(Z_STRVAL_P(filename), O_BINARY|O_RDWR|O_CREAT, 0644)) < 0) { - php_error(E_WARNING, "Unable to create database (%d): %s", errno, strerror(errno)); + if ((fd = VCWD_OPEN_MODE(Z_STRVAL_PP(filename), O_BINARY|O_RDWR|O_CREAT, 0644)) < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create database (%d): %s", errno, strerror(errno)); RETURN_FALSE; } - num_fields = zend_hash_num_elements(Z_ARRVAL_P(fields)); + num_fields = zend_hash_num_elements(Z_ARRVAL_PP(fields)); /* have to use regular malloc() because this gets free()d by code in the dbase library */ dbh = (dbhead_t *)malloc(sizeof(dbhead_t)); dbf = (dbfield_t *)malloc(sizeof(dbfield_t) * num_fields); if (!dbh || !dbf) { - php_error(E_WARNING, "Unable to allocate memory for header info"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to allocate memory for header info"); RETURN_FALSE; } @@ -651,27 +641,27 @@ for (i = 0, cur_f = dbf; i < num_fields; i++, cur_f++) { /* look up the first field */ - if (zend_hash_index_find(Z_ARRVAL_P(fields), i, (void **)&field) == FAILURE) { - php_error(E_WARNING, "unable to find field %d", i); + if (zend_hash_index_find(Z_ARRVAL_PP(fields), i, (void **)&field) == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to find field %d", i); free_dbf_head(dbh); RETURN_FALSE; } if (Z_TYPE_PP (field) != IS_ARRAY) { - php_error(E_WARNING, "second parameter must be array of arrays"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "second parameter must be array of arrays"); free_dbf_head(dbh); RETURN_FALSE; } /* field name */ if (zend_hash_index_find(Z_ARRVAL_PP(field), 0, (void **)&value) == FAILURE) { - php_error(E_WARNING, "expected field name as first element of list in field %d", i); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "expected field name as first element of list in field %d", i); free_dbf_head(dbh); RETURN_FALSE; } convert_to_string_ex(value); if (Z_STRLEN_PP(value) > 10 || Z_STRLEN_PP(value) == 0) { - php_error(E_WARNING, "invalid field name '%s' (must be non-empty and less than or equal to 10 characters)", Z_STRVAL_PP(value)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid field name '%s' (must be non-empty and less than or equal to 10 characters)", Z_STRVAL_PP(value)); free_dbf_head(dbh); RETURN_FALSE; } @@ -679,7 +669,7 @@ /* field type */ if (zend_hash_index_find(Z_ARRVAL_PP (field), 1, (void **)&value) == FAILURE) { - php_error(E_WARNING, "expected field type as second element of list in field %d", i); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "expected field type as second element of list in field %d", i); RETURN_FALSE; } convert_to_string_ex(value); @@ -704,7 +694,7 @@ case 'C': /* field length */ if (zend_hash_index_find(Z_ARRVAL_PP (field), 2, (void **)&value) == FAILURE) { - php_error(E_WARNING, "expected field length as third element of list in field %d", i); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "expected field length as third element of list in field %d", i); free_dbf_head(dbh); RETURN_FALSE; } @@ -713,7 +703,7 @@ if (cur_f->db_type == 'N') { if (zend_hash_index_find(Z_ARRVAL_PP (field), 3, (void **)&value) == FAILURE) { - php_error(E_WARNING, "expected field precision as fourth element of list in field %d", i); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "expected field precision as fourth element of list in field %d", i); free_dbf_head(dbh); RETURN_FALSE; } @@ -722,7 +712,7 @@ } break; default: - php_error(E_WARNING, "unknown field type '%c'", cur_f->db_type); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "unknown field type '%c'", cur_f->db_type); } cur_f->db_foffset = rlen; rlen += cur_f->db_flen; http://cvs.php.net/diff.php/php-src/ext/dbase/dbf_rec.c?r1=1.7&r2=1.7.2.1&ty=u Index: php-src/ext/dbase/dbf_rec.c diff -u php-src/ext/dbase/dbf_rec.c:1.7 php-src/ext/dbase/dbf_rec.c:1.7.2.1 --- php-src/ext/dbase/dbf_rec.c:1.7 Tue Nov 12 16:03:10 2002 +++ php-src/ext/dbase/dbf_rec.c Sun Apr 3 07:39:43 2005 @@ -136,7 +136,8 @@ /* Try to truncate the file to the right size. */ if (ftruncate(dbh->db_fd, out_off) != 0) { - php_error(E_WARNING, "dbase_pack() couldn't truncate the file to the right size. Some deleted records may still be left in there."); + TSRMLS_FETCH(); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "dbase_pack() couldn't truncate the file to the right size. Some deleted records may still be left in there."); } if (rec_cnt == 0) @@ -167,16 +168,16 @@ */ void out_rec(dbhead_t *dbh, dbfield_t *dbf, char *cp) { - dbfield_t *cur_f; - int nfields = dbh->db_nfields; - char *fnp = (char *)malloc(dbh->db_rlen); - - printf("%c", *cp); - for (cur_f = dbf; cur_f < &dbf[nfields] ; cur_f++) { - printf(" "); + dbfield_t *cur_f; + int nfields = dbh->db_nfields; + char *fnp = (char *)malloc(dbh->db_rlen); + + printf("%c", *cp); + for (cur_f = dbf; cur_f < &dbf[nfields] ; cur_f++) { + printf(" "); printf(cur_f->db_format, get_field_val(cp, cur_f, fnp)); - } - printf("\n"); + } + printf("\n"); free(fnp); }
http://cvs.php.net/diff.php/php-src/ext/dbase/dbase.c?r1=1.60.2.4&r2=1.60.2.5&ty=u Index: php-src/ext/dbase/dbase.c diff -u php-src/ext/dbase/dbase.c:1.60.2.4 php-src/ext/dbase/dbase.c:1.60.2.5 --- php-src/ext/dbase/dbase.c:1.60.2.4 Fri Feb 4 09:29:20 2005 +++ php-src/ext/dbase/dbase.c Sun Apr 3 07:39:43 2005 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dbase.c,v 1.60.2.4 2005/02/04 14:29:20 derick Exp $ */ +/* $Id: dbase.c,v 1.60.2.5 2005/04/03 11:39:43 sniper Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -118,33 +118,33 @@ Opens a dBase-format database file */ PHP_FUNCTION(dbase_open) { - pval *dbf_name, *options; + zval **dbf_name, **options; dbhead_t *dbh; int handle; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &dbf_name, &options)==FAILURE) { + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &dbf_name, &options) == FAILURE) { WRONG_PARAM_COUNT; } - convert_to_string(dbf_name); - convert_to_long(options); + convert_to_string_ex(dbf_name); + convert_to_long_ex(options); - if (Z_LVAL_P(options) == 1) { - php_error(E_WARNING, "Cannot open %s in write-only mode", Z_STRVAL_P(dbf_name)); + if (Z_LVAL_PP(options) == 1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot open %s in write-only mode", Z_STRVAL_PP(dbf_name)); RETURN_FALSE; } - - if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_P(dbf_name), NULL, CHECKUID_CHECK_FILE_AND_DIR))) { + + if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(dbf_name), NULL, CHECKUID_CHECK_FILE_AND_DIR))) { RETURN_FALSE; } - if (php_check_open_basedir(Z_STRVAL_P(dbf_name) TSRMLS_CC)) { + if (php_check_open_basedir(Z_STRVAL_PP(dbf_name) TSRMLS_CC)) { RETURN_FALSE; } - dbh = dbf_open(Z_STRVAL_P(dbf_name), Z_LVAL_P(options) TSRMLS_CC); + dbh = dbf_open(Z_STRVAL_PP(dbf_name), Z_LVAL_PP(options) TSRMLS_CC); if (dbh == NULL) { - php_error(E_WARNING, "unable to open database %s", Z_STRVAL_P(dbf_name)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to open database %s", Z_STRVAL_PP(dbf_name)); RETURN_FALSE; } @@ -157,22 +157,22 @@ Closes an open dBase-format database file */ PHP_FUNCTION(dbase_close) { - pval *dbh_id; + zval **dbh_id; dbhead_t *dbh; int dbh_type; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &dbh_id)==FAILURE) { + if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &dbh_id) == FAILURE)) { WRONG_PARAM_COUNT; } - convert_to_long(dbh_id); - dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type); + convert_to_long_ex(dbh_id); + dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type); if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) { - php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id)); RETURN_FALSE; } - zend_list_delete(Z_LVAL_P(dbh_id)); + zend_list_delete(Z_LVAL_PP(dbh_id)); RETURN_TRUE; } /* }}} */ @@ -181,18 +181,18 @@ Returns the number of records in the database */ PHP_FUNCTION(dbase_numrecords) { - pval *dbh_id; + zval **dbh_id; dbhead_t *dbh; int dbh_type; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &dbh_id)==FAILURE) { + if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &dbh_id) == FAILURE)) { WRONG_PARAM_COUNT; } - convert_to_long(dbh_id); - dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type); + convert_to_long_ex(dbh_id); + dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type); if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) { - php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id)); RETURN_FALSE; } @@ -204,18 +204,18 @@ Returns the number of fields (columns) in the database */ PHP_FUNCTION(dbase_numfields) { - pval *dbh_id; + zval **dbh_id; dbhead_t *dbh; int dbh_type; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &dbh_id)==FAILURE) { + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &dbh_id) == FAILURE) { WRONG_PARAM_COUNT; } - convert_to_long(dbh_id); - dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type); + convert_to_long_ex(dbh_id); + dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type); if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) { - php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id)); RETURN_FALSE; } @@ -227,18 +227,18 @@ Packs the database (deletes records marked for deletion) */ PHP_FUNCTION(dbase_pack) { - pval *dbh_id; + zval **dbh_id; dbhead_t *dbh; int dbh_type; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &dbh_id)==FAILURE) { + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &dbh_id) == FAILURE) { WRONG_PARAM_COUNT; } - convert_to_long(dbh_id); - dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type); + convert_to_long_ex(dbh_id); + dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type); if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) { - php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id)); RETURN_FALSE; } @@ -252,7 +252,7 @@ Adds a record to the database */ PHP_FUNCTION(dbase_add_record) { - pval *dbh_id, *fields, **field; + zval **dbh_id, **fields, **field; dbhead_t *dbh; int dbh_type; @@ -262,40 +262,36 @@ int i; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &dbh_id, &fields)==FAILURE) { + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &dbh_id, &fields) == FAILURE) { WRONG_PARAM_COUNT; } - convert_to_long(dbh_id); - if (Z_TYPE_P(fields) != IS_ARRAY) { - php_error(E_WARNING, "Expected array as second parameter"); + convert_to_long_ex(dbh_id); + if (Z_TYPE_PP(fields) != IS_ARRAY) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected array as second parameter"); RETURN_FALSE; } - dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type); + dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type); if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) { - php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id)); RETURN_FALSE; } - num_fields = zend_hash_num_elements(Z_ARRVAL_P(fields)); + num_fields = zend_hash_num_elements(Z_ARRVAL_PP(fields)); if (num_fields != dbh->db_nfields) { - php_error(E_WARNING, "Wrong number of fields specified"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Wrong number of fields specified"); RETURN_FALSE; } cp = t_cp = (char *)emalloc(dbh->db_rlen + 1); - if (!cp) { - php_error(E_WARNING, "unable to allocate memory"); - RETURN_FALSE; - } *t_cp++ = VALID_RECORD; dbf = dbh->db_fields; for (i = 0, cur_f = dbf; cur_f < &dbf[num_fields]; i++, cur_f++) { zval tmp; - if (zend_hash_index_find(Z_ARRVAL_P(fields), i, (void **)&field) == FAILURE) { - php_error(E_WARNING, "unexpected error"); + if (zend_hash_index_find(Z_ARRVAL_PP(fields), i, (void **)&field) == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "unexpected error"); efree(cp); RETURN_FALSE; } @@ -310,7 +306,7 @@ dbh->db_records++; if (put_dbf_record(dbh, dbh->db_records, cp) < 0) { - php_error(E_WARNING, "unable to put record at %ld", dbh->db_records); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to put record at %ld", dbh->db_records); efree(cp); RETURN_FALSE; } @@ -326,7 +322,7 @@ Replaces a record to the database */ PHP_FUNCTION(dbase_replace_record) { - pval *dbh_id, *fields, **field, *recnum; + zval **dbh_id, **fields, **field, **recnum; dbhead_t *dbh; int dbh_type; @@ -336,40 +332,36 @@ int i; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 3 || getParameters(ht, 3, &dbh_id, &fields, &recnum)==FAILURE) { + if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &dbh_id, &fields, &recnum) == FAILURE) { WRONG_PARAM_COUNT; } - convert_to_long(dbh_id); - convert_to_long(recnum); - if (Z_TYPE_P(fields) != IS_ARRAY) { - php_error(E_WARNING, "Expected array as second parameter"); + convert_to_long_ex(dbh_id); + convert_to_long_ex(recnum); + if (Z_TYPE_PP(fields) != IS_ARRAY) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected array as second parameter"); RETURN_FALSE; } - dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type); + dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type); if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) { - php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id)); RETURN_FALSE; } - num_fields = zend_hash_num_elements(Z_ARRVAL_P(fields)); + num_fields = zend_hash_num_elements(Z_ARRVAL_PP(fields)); if (num_fields != dbh->db_nfields) { - php_error(E_WARNING, "Wrong number of fields specified"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Wrong number of fields specified"); RETURN_FALSE; } cp = t_cp = (char *)emalloc(dbh->db_rlen + 1); - if (!cp) { - php_error(E_WARNING, "unable to allocate memory"); - RETURN_FALSE; - } *t_cp++ = VALID_RECORD; dbf = dbh->db_fields; for (i = 0, cur_f = dbf; cur_f < &dbf[num_fields]; i++, cur_f++) { - if (zend_hash_index_find(Z_ARRVAL_P(fields), i, (void **)&field) == FAILURE) { - php_error(E_WARNING, "unexpected error"); + if (zend_hash_index_find(Z_ARRVAL_PP(fields), i, (void **)&field) == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "unexpected error"); efree(cp); RETURN_FALSE; } @@ -378,8 +370,8 @@ t_cp += cur_f->db_flen; } - if (put_dbf_record(dbh, Z_LVAL_P(recnum), cp) < 0) { - php_error(E_WARNING, "unable to put record at %ld", dbh->db_records); + if (put_dbf_record(dbh, Z_LVAL_PP(recnum), cp) < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to put record at %ld", dbh->db_records); efree(cp); RETURN_FALSE; } @@ -395,28 +387,28 @@ Marks a record to be deleted */ PHP_FUNCTION(dbase_delete_record) { - pval *dbh_id, *record; + zval **dbh_id, **record; dbhead_t *dbh; int dbh_type; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &dbh_id, &record)==FAILURE) { + if (ZEND_NUM_ARGS() != 2 || (zend_get_parameters_ex(2, &dbh_id, &record) == FAILURE)) { WRONG_PARAM_COUNT; } - convert_to_long(dbh_id); - convert_to_long(record); + convert_to_long_ex(dbh_id); + convert_to_long_ex(record); - dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type); + dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type); if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) { - php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id)); RETURN_FALSE; } - if (del_dbf_record(dbh, Z_LVAL_P(record)) < 0) { - if (Z_LVAL_P(record) > dbh->db_records) { - php_error(E_WARNING, "record %d out of bounds", Z_LVAL_P(record)); + if (del_dbf_record(dbh, Z_LVAL_PP(record)) < 0) { + if (Z_LVAL_PP(record) > dbh->db_records) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "record %ld out of bounds", Z_LVAL_PP(record)); } else { - php_error(E_WARNING, "unable to delete record %d", Z_LVAL_P(record)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to delete record %ld", Z_LVAL_PP(record)); } RETURN_FALSE; } @@ -430,7 +422,7 @@ */ static void php_dbase_get_record(INTERNAL_FUNCTION_PARAMETERS, int assoc) { - pval *dbh_id, *record; + zval **dbh_id, **record; dbhead_t *dbh; int dbh_type; dbfield_t *dbf, *cur_f; @@ -440,28 +432,26 @@ int errno_save; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &dbh_id, &record)==FAILURE) { + if (ZEND_NUM_ARGS() != 2 || (zend_get_parameters_ex(2, &dbh_id, &record) == FAILURE)) { WRONG_PARAM_COUNT; } - convert_to_long(dbh_id); - convert_to_long(record); + convert_to_long_ex(dbh_id); + convert_to_long_ex(record); - dbh = zend_list_find(Z_LVAL_P(dbh_id), &dbh_type); + dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type); if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) { - php_error(E_WARNING, "Unable to find database for identifier %d", Z_LVAL_P(dbh_id)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id)); RETURN_FALSE; } - if ((data = get_dbf_record(dbh, Z_LVAL_P(record))) == NULL) { - php_error(E_WARNING, "Tried to read bad record %d", Z_LVAL_P(record)); + if ((data = get_dbf_record(dbh, Z_LVAL_PP(record))) == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Tried to read bad record %ld", Z_LVAL_PP(record)); RETURN_FALSE; } dbf = dbh->db_fields; - if (array_init(return_value) == FAILURE) { - RETURN_FALSE; - } + array_init(return_value); fnp = NULL; for (cur_f = dbf; cur_f < &dbf[dbh->db_nfields]; cur_f++) { @@ -582,7 +572,7 @@ Creates a new dBase-format database file */ PHP_FUNCTION(dbase_create) { - pval *filename, *fields, **field, **value; + zval **filename, **fields, **field, **value; int fd; dbhead_t *dbh; @@ -591,37 +581,37 @@ int i, rlen, handle; DBase_TLS_VARS; - if (ZEND_NUM_ARGS() != 2 || getParameters(ht, 2, &filename, &fields)==FAILURE) { + if (ZEND_NUM_ARGS() != 2 || (zend_get_parameters_ex(2, &filename, &fields) == FAILURE)) { WRONG_PARAM_COUNT; } - convert_to_string(filename); + convert_to_string_ex(filename); - if (Z_TYPE_P(fields) != IS_ARRAY) { - php_error(E_WARNING, "Expected array as second parameter"); + if (Z_TYPE_PP(fields) != IS_ARRAY) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected array as second parameter"); RETURN_FALSE; } - if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_P(filename), NULL, CHECKUID_CHECK_FILE_AND_DIR))) { + if (PG(safe_mode) && (!php_checkuid(Z_STRVAL_PP(filename), NULL, CHECKUID_CHECK_FILE_AND_DIR))) { RETURN_FALSE; } - if (php_check_open_basedir(Z_STRVAL_P(filename) TSRMLS_CC)) { + if (php_check_open_basedir(Z_STRVAL_PP(filename) TSRMLS_CC)) { RETURN_FALSE; } - if ((fd = VCWD_OPEN_MODE(Z_STRVAL_P(filename), O_BINARY|O_RDWR|O_CREAT, 0644)) < 0) { - php_error(E_WARNING, "Unable to create database (%d): %s", errno, strerror(errno)); + if ((fd = VCWD_OPEN_MODE(Z_STRVAL_PP(filename), O_BINARY|O_RDWR|O_CREAT, 0644)) < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create database (%d): %s", errno, strerror(errno)); RETURN_FALSE; } - num_fields = zend_hash_num_elements(Z_ARRVAL_P(fields)); + num_fields = zend_hash_num_elements(Z_ARRVAL_PP(fields)); /* have to use regular malloc() because this gets free()d by code in the dbase library */ dbh = (dbhead_t *)malloc(sizeof(dbhead_t)); dbf = (dbfield_t *)malloc(sizeof(dbfield_t) * num_fields); if (!dbh || !dbf) { - php_error(E_WARNING, "Unable to allocate memory for header info"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to allocate memory for header info"); RETURN_FALSE; } @@ -651,27 +641,27 @@ for (i = 0, cur_f = dbf; i < num_fields; i++, cur_f++) { /* look up the first field */ - if (zend_hash_index_find(Z_ARRVAL_P(fields), i, (void **)&field) == FAILURE) { - php_error(E_WARNING, "unable to find field %d", i); + if (zend_hash_index_find(Z_ARRVAL_PP(fields), i, (void **)&field) == FAILURE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to find field %d", i); free_dbf_head(dbh); RETURN_FALSE; } if (Z_TYPE_PP (field) != IS_ARRAY) { - php_error(E_WARNING, "second parameter must be array of arrays"); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "second parameter must be array of arrays"); free_dbf_head(dbh); RETURN_FALSE; } /* field name */ if (zend_hash_index_find(Z_ARRVAL_PP(field), 0, (void **)&value) == FAILURE) { - php_error(E_WARNING, "expected field name as first element of list in field %d", i); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "expected field name as first element of list in field %d", i); free_dbf_head(dbh); RETURN_FALSE; } convert_to_string_ex(value); if (Z_STRLEN_PP(value) > 10 || Z_STRLEN_PP(value) == 0) { - php_error(E_WARNING, "invalid field name '%s' (must be non-empty and less than or equal to 10 characters)", Z_STRVAL_PP(value)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "invalid field name '%s' (must be non-empty and less than or equal to 10 characters)", Z_STRVAL_PP(value)); free_dbf_head(dbh); RETURN_FALSE; } @@ -679,7 +669,7 @@ /* field type */ if (zend_hash_index_find(Z_ARRVAL_PP (field), 1, (void **)&value) == FAILURE) { - php_error(E_WARNING, "expected field type as second element of list in field %d", i); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "expected field type as second element of list in field %d", i); RETURN_FALSE; } convert_to_string_ex(value); @@ -704,7 +694,7 @@ case 'C': /* field length */ if (zend_hash_index_find(Z_ARRVAL_PP (field), 2, (void **)&value) == FAILURE) { - php_error(E_WARNING, "expected field length as third element of list in field %d", i); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "expected field length as third element of list in field %d", i); free_dbf_head(dbh); RETURN_FALSE; } @@ -713,7 +703,7 @@ if (cur_f->db_type == 'N') { if (zend_hash_index_find(Z_ARRVAL_PP (field), 3, (void **)&value) == FAILURE) { - php_error(E_WARNING, "expected field precision as fourth element of list in field %d", i); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "expected field precision as fourth element of list in field %d", i); free_dbf_head(dbh); RETURN_FALSE; } @@ -722,7 +712,7 @@ } break; default: - php_error(E_WARNING, "unknown field type '%c'", cur_f->db_type); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "unknown field type '%c'", cur_f->db_type); } cur_f->db_foffset = rlen; rlen += cur_f->db_flen; http://cvs.php.net/diff.php/php-src/ext/dbase/dbf_rec.c?r1=1.7&r2=1.7.2.1&ty=u Index: php-src/ext/dbase/dbf_rec.c diff -u php-src/ext/dbase/dbf_rec.c:1.7 php-src/ext/dbase/dbf_rec.c:1.7.2.1 --- php-src/ext/dbase/dbf_rec.c:1.7 Tue Nov 12 16:03:10 2002 +++ php-src/ext/dbase/dbf_rec.c Sun Apr 3 07:39:43 2005 @@ -136,7 +136,8 @@ /* Try to truncate the file to the right size. */ if (ftruncate(dbh->db_fd, out_off) != 0) { - php_error(E_WARNING, "dbase_pack() couldn't truncate the file to the right size. Some deleted records may still be left in there."); + TSRMLS_FETCH(); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "dbase_pack() couldn't truncate the file to the right size. Some deleted records may still be left in there."); } if (rec_cnt == 0) @@ -167,16 +168,16 @@ */ void out_rec(dbhead_t *dbh, dbfield_t *dbf, char *cp) { - dbfield_t *cur_f; - int nfields = dbh->db_nfields; - char *fnp = (char *)malloc(dbh->db_rlen); - - printf("%c", *cp); - for (cur_f = dbf; cur_f < &dbf[nfields] ; cur_f++) { - printf(" "); + dbfield_t *cur_f; + int nfields = dbh->db_nfields; + char *fnp = (char *)malloc(dbh->db_rlen); + + printf("%c", *cp); + for (cur_f = dbf; cur_f < &dbf[nfields] ; cur_f++) { + printf(" "); printf(cur_f->db_format, get_field_val(cp, cur_f, fnp)); - } - printf("\n"); + } + printf("\n"); free(fnp); }