[PHP-CVS] cvs: php-src /ext/dbase dbase.c
pollita Thu Jan 24 10:27:59 2008 UTC Modified files: /php-src/ext/dbase dbase.c Log: Fix potential crash when non-array is used optimisticly http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/dbase.c?r1=1.90&r2=1.91&diff_format=u Index: php-src/ext/dbase/dbase.c diff -u php-src/ext/dbase/dbase.c:1.90 php-src/ext/dbase/dbase.c:1.91 --- php-src/ext/dbase/dbase.c:1.90 Mon Dec 31 07:12:08 2007 +++ php-src/ext/dbase/dbase.c Thu Jan 24 10:27:59 2008 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dbase.c,v 1.90 2007/12/31 07:12:08 sebastian Exp $ */ +/* $Id: dbase.c,v 1.91 2008/01/24 10:27:59 pollita Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -270,6 +270,11 @@ } convert_to_long_ex(dbh_id); + if (Z_TYPE_PP(fields) != IS_ARRAY) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument two must be of type 'Array'"); + RETURN_FALSE; + } + dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type); if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id)); @@ -337,6 +342,11 @@ 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, "Argument two must be of type 'Array'"); + RETURN_FALSE; + } + dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type); if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %ld", Z_LVAL_PP(dbh_id)); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/dbase dbase.c /ext/dbase/tests 001.phpt 002.phpt
tony2001Sun Feb 25 23:16:32 2007 UTC Modified files: /php-src/ext/dbase dbase.c /php-src/ext/dbase/tests001.phpt 002.phpt Log: do not allow db without fields fix test http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/dbase.c?r1=1.87&r2=1.88&diff_format=u Index: php-src/ext/dbase/dbase.c diff -u php-src/ext/dbase/dbase.c:1.87 php-src/ext/dbase/dbase.c:1.88 --- php-src/ext/dbase/dbase.c:1.87 Mon Jan 1 09:29:23 2007 +++ php-src/ext/dbase/dbase.c Sun Feb 25 23:16:32 2007 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dbase.c,v 1.87 2007/01/01 09:29:23 sebastian Exp $ */ +/* $Id: dbase.c,v 1.88 2007/02/25 23:16:32 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -604,6 +604,11 @@ num_fields = zend_hash_num_elements(Z_ARRVAL_PP(fields)); + if (num_fields <= 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create database without fields"); + RETURN_FALSE; + } + /* have to use regular malloc() because this gets free()d by code in the dbase library */ dbh = (dbhead_t *)malloc(sizeof(dbhead_t)); http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/tests/001.phpt?r1=1.2&r2=1.3&diff_format=u Index: php-src/ext/dbase/tests/001.phpt diff -u php-src/ext/dbase/tests/001.phpt:1.2 php-src/ext/dbase/tests/001.phpt:1.3 --- php-src/ext/dbase/tests/001.phpt:1.2Wed Jul 12 13:17:25 2006 +++ php-src/ext/dbase/tests/001.phptSun Feb 25 23:16:32 2007 @@ -54,7 +54,8 @@ int(%d) string(71) "dbase_create(): expected field name as first element of list in field 0" bool(false) -int(%d) +string(56) "dbase_create(): Unable to create database without fields" +bool(false) string(67) "Argument 2 passed to dbase_create() must be an array, integer given" string(50) "dbase_create(): Expected array as second parameter" bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/tests/002.phpt?r1=1.4&r2=1.5&diff_format=u Index: php-src/ext/dbase/tests/002.phpt diff -u php-src/ext/dbase/tests/002.phpt:1.4 php-src/ext/dbase/tests/002.phpt:1.5 --- php-src/ext/dbase/tests/002.phpt:1.4Fri Dec 1 19:10:59 2006 +++ php-src/ext/dbase/tests/002.phptSun Feb 25 23:16:32 2007 @@ -35,7 +35,7 @@ echo "Done\n"; ?> --EXPECTF-- -Warning: dbase_open(): Invalid access mode -1 %s in %s on line %d +Warning: dbase_open(): Invalid access mode -1 in %s on line %d bool(false) Warning: dbase_open(): Invalid access mode 1000 in %s on line %d -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/dbase dbase.c /ext/dbase/tests 002.phpt
iliaa Fri Dec 1 19:10:59 2006 UTC Modified files: /php-src/ext/dbase dbase.c /php-src/ext/dbase/tests002.phpt Log: MFB: Fixed a possible memory corruption in dbase_open() with invalid open mode http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/dbase.c?r1=1.85&r2=1.86&diff_format=u Index: php-src/ext/dbase/dbase.c diff -u php-src/ext/dbase/dbase.c:1.85 php-src/ext/dbase/dbase.c:1.86 --- php-src/ext/dbase/dbase.c:1.85 Wed Nov 22 17:30:52 2006 +++ php-src/ext/dbase/dbase.c Fri Dec 1 19:10:59 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dbase.c,v 1.85 2006/11/22 17:30:52 iliaa Exp $ */ +/* $Id: dbase.c,v 1.86 2006/12/01 19:10:59 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -136,7 +136,7 @@ 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; - } else if (Z_LVAL_PP(options) < 0) { + } else if (Z_LVAL_PP(options) < 0 || Z_LVAL_PP(options) > 3) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid access mode %ld", Z_LVAL_PP(options)); RETURN_FALSE; } http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/tests/002.phpt?r1=1.3&r2=1.4&diff_format=u Index: php-src/ext/dbase/tests/002.phpt diff -u php-src/ext/dbase/tests/002.phpt:1.3 php-src/ext/dbase/tests/002.phpt:1.4 --- php-src/ext/dbase/tests/002.phpt:1.3Sun Nov 26 16:29:55 2006 +++ php-src/ext/dbase/tests/002.phptFri Dec 1 19:10:59 2006 @@ -38,7 +38,7 @@ Warning: dbase_open(): Invalid access mode -1 %s in %s on line %d bool(false) -Warning: dbase_open(): unable to open database %s in %s on line %d +Warning: dbase_open(): Invalid access mode 1000 in %s on line %d bool(false) Warning: dbase_open(): unable to open database %s in %s on line %d -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/dbase dbase.c
iliaa Wed Nov 22 17:30:52 2006 UTC Modified files: /php-src/ext/dbase dbase.c Log: MFB: Fixed a possible crash in dbase_open() on empty filename. http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/dbase.c?r1=1.84&r2=1.85&diff_format=u Index: php-src/ext/dbase/dbase.c diff -u php-src/ext/dbase/dbase.c:1.84 php-src/ext/dbase/dbase.c:1.85 --- php-src/ext/dbase/dbase.c:1.84 Tue Oct 10 23:00:48 2006 +++ php-src/ext/dbase/dbase.c Wed Nov 22 17:30:52 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dbase.c,v 1.84 2006/10/10 23:00:48 tony2001 Exp $ */ +/* $Id: dbase.c,v 1.85 2006/11/22 17:30:52 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -128,6 +128,11 @@ convert_to_string_ex(dbf_name); convert_to_long_ex(options); + if (!Z_STRLEN_PP(dbf_name)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "The filename cannot be empty."); + RETURN_FALSE; + } + 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; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/dbase dbase.c
tony2001Tue Oct 10 23:00:48 2006 UTC Modified files: /php-src/ext/dbase dbase.c Log: access mode for dbase_open() cannot be < 0 http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/dbase.c?r1=1.83&r2=1.84&diff_format=u Index: php-src/ext/dbase/dbase.c diff -u php-src/ext/dbase/dbase.c:1.83 php-src/ext/dbase/dbase.c:1.84 --- php-src/ext/dbase/dbase.c:1.83 Tue Aug 8 15:53:54 2006 +++ php-src/ext/dbase/dbase.c Tue Oct 10 23:00:48 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dbase.c,v 1.83 2006/08/08 15:53:54 mike Exp $ */ +/* $Id: dbase.c,v 1.84 2006/10/10 23:00:48 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -131,6 +131,9 @@ 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; + } else if (Z_LVAL_PP(options) < 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid access mode %ld", Z_LVAL_PP(options)); + RETURN_FALSE; } if (php_check_open_basedir(Z_STRVAL_PP(dbf_name) TSRMLS_CC)) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/dbase dbase.c dbf_head.c
mikeTue Aug 8 15:53:54 2006 UTC Modified files: /php-src/ext/dbase dbase.c dbf_head.c Log: - implement #38357 (dbase_open can't open DBase 3 dbf file) http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/dbase.c?r1=1.82&r2=1.83&diff_format=u Index: php-src/ext/dbase/dbase.c diff -u php-src/ext/dbase/dbase.c:1.82 php-src/ext/dbase/dbase.c:1.83 --- php-src/ext/dbase/dbase.c:1.82 Wed Jul 12 13:17:25 2006 +++ php-src/ext/dbase/dbase.c Tue Aug 8 15:53:54 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dbase.c,v 1.82 2006/07/12 13:17:25 tony2001 Exp $ */ +/* $Id: dbase.c,v 1.83 2006/08/08 15:53:54 mike Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -490,6 +490,13 @@ } } break; + case 'F': + if (!assoc) { + add_next_index_double(return_value, atof(str_value)); + } else { + add_assoc_double(return_value, cur_f->db_fname, atof(str_value)); + } + break; case 'L': /* we used to FALL THROUGH, but now we check for T/Y and F/N and insert 1 or 0, respectively. db_fdc is the number of decimals, which we don't care about. 3/14/2001 LEW */ @@ -667,6 +674,9 @@ case 'D': cur_f->db_flen = 8; break; + case 'F': + cur_f->db_flen = 20; + break; case 'N': case 'C': /* field length */ @@ -839,6 +849,7 @@ case 'N': add_assoc_string(row, "type", "number", 1); break; case 'L': add_assoc_string(row, "type", "boolean", 1); break; case 'M': add_assoc_string(row, "type", "memo", 1); break; + case 'F': add_assoc_string(row, "type", "float", 1); break; default: add_assoc_string(row, "type", "unknown", 1); break; } http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/dbf_head.c?r1=1.16&r2=1.17&diff_format=u Index: php-src/ext/dbase/dbf_head.c diff -u php-src/ext/dbase/dbf_head.c:1.16 php-src/ext/dbase/dbf_head.c:1.17 --- php-src/ext/dbase/dbf_head.c:1.16 Thu May 25 11:46:12 2006 +++ php-src/ext/dbase/dbf_head.cTue Aug 8 15:53:54 2006 @@ -148,6 +148,7 @@ dbf->db_type = dbfield.dbf_type; switch (dbf->db_type) { case 'N': + case 'F': dbf->db_flen = dbfield.dbf_flen[0]; dbf->db_fdc = dbfield.dbf_flen[1]; break; @@ -231,6 +232,7 @@ case 'N': case 'L': case 'D': + case 'F': sprintf(format, "%%%ds", dbf->db_flen); break; case 'M': -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/dbase dbase.c /ext/dbase/tests 001.phpt
tony2001Wed Jul 12 13:17:25 2006 UTC Modified files: /php-src/ext/dbase dbase.c /php-src/ext/dbase/tests001.phpt Log: restore missing check and prevent segfaulting MFB and add test http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/dbase.c?r1=1.81&r2=1.82&diff_format=u Index: php-src/ext/dbase/dbase.c diff -u php-src/ext/dbase/dbase.c:1.81 php-src/ext/dbase/dbase.c:1.82 --- php-src/ext/dbase/dbase.c:1.81 Thu Jun 15 16:25:12 2006 +++ php-src/ext/dbase/dbase.c Wed Jul 12 13:17:25 2006 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dbase.c,v 1.81 2006/06/15 16:25:12 bjori Exp $ */ +/* $Id: dbase.c,v 1.82 2006/07/12 13:17:25 tony2001 Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -573,6 +573,11 @@ } convert_to_string_ex(filename); + if (Z_TYPE_PP(fields) != IS_ARRAY) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected array as second parameter"); + RETURN_FALSE; + } + if (php_check_open_basedir(Z_STRVAL_PP(filename) TSRMLS_CC)) { RETURN_FALSE; } @@ -685,6 +690,8 @@ break; default: php_error_docref(NULL TSRMLS_CC, E_WARNING, "unknown field type '%c'", cur_f->db_type); + free_dbf_head(dbh); + RETURN_FALSE; } cur_f->db_foffset = rlen; rlen += cur_f->db_flen; http://cvs.php.net/viewvc.cgi/php-src/ext/dbase/tests/001.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/dbase/tests/001.phpt diff -u /dev/null php-src/ext/dbase/tests/001.phpt:1.2 --- /dev/null Wed Jul 12 13:17:25 2006 +++ php-src/ext/dbase/tests/001.phptWed Jul 12 13:17:25 2006 @@ -0,0 +1,65 @@ +--TEST-- +dbase_create() tests +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +int(%d) +string(38) "dbase_create(): unknown field type 'E'" +bool(false) +string(38) "dbase_create(): unknown field type '-'" +bool(false) +int(%d) +string(71) "dbase_create(): expected field name as first element of list in field 0" +bool(false) +int(%d) +string(67) "Argument 2 passed to dbase_create() must be an array, integer given" +string(50) "dbase_create(): Expected array as second parameter" +bool(false) +string(%d) "unlink(%s001.dbf): No such file or directory" +string(66) "Argument 2 passed to dbase_create() must be an array, string given" +string(50) "dbase_create(): Expected array as second parameter" +bool(false) +Done -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/dbase dbase.c /ext/dbase/tests bug31754.phpt
derick Fri Feb 4 09:28:50 2005 EDT Added files: /php-src/ext/dbase/testsbug31754.phpt Modified files: /php-src/ext/dbase dbase.c Log: - Fixed bug #31754 (dbase_open() fails for mode = 1). (Mehdi, Derick) http://cvs.php.net/diff.php/php-src/ext/dbase/dbase.c?r1=1.72&r2=1.73&ty=u Index: php-src/ext/dbase/dbase.c diff -u php-src/ext/dbase/dbase.c:1.72 php-src/ext/dbase/dbase.c:1.73 --- php-src/ext/dbase/dbase.c:1.72 Thu Jan 8 03:15:07 2004 +++ php-src/ext/dbase/dbase.c Fri Feb 4 09:28:50 2005 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dbase.c,v 1.72 2004/01/08 08:15:07 andi Exp $ */ +/* $Id: dbase.c,v 1.73 2005/02/04 14:28:50 derick Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -129,6 +129,11 @@ convert_to_string_ex(dbf_name); convert_to_long_ex(options); + 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_PP(dbf_name), NULL, CHECKUID_CHECK_FILE_AND_DIR))) { RETURN_FALSE; } http://cvs.php.net/co.php/php-src/ext/dbase/tests/bug31754.phpt?r=1.1&p=1 Index: php-src/ext/dbase/tests/bug31754.phpt +++ php-src/ext/dbase/tests/bug31754.phpt --TEST-- Bug #31754: (dbase_open() fails for mode = 1) --SKIPIF-- --FILE-- --EXPECTF-- Warning: dbase_open(): Cannot open /tmp/bug31754.dbf in write-only mode in %sbug31754.php on line %d -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/dbase dbase.c
steinm Thu Nov 27 06:32:06 2003 EDT Modified files: /php-src/ext/dbase dbase.c Log: - set precision to 0 unless the field is of type N or I Index: php-src/ext/dbase/dbase.c diff -u php-src/ext/dbase/dbase.c:1.70 php-src/ext/dbase/dbase.c:1.71 --- php-src/ext/dbase/dbase.c:1.70 Tue Oct 14 03:49:34 2003 +++ php-src/ext/dbase/dbase.c Thu Nov 27 06:32:05 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dbase.c,v 1.70 2003/10/14 07:49:34 steinm Exp $ */ +/* $Id: dbase.c,v 1.71 2003/11/27 11:32:05 steinm Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -791,7 +791,14 @@ add_assoc_long(row, "length", cur_f->db_flen); /* number of decimals in field */ - add_assoc_long(row, "precision", cur_f->db_fdc); + switch (cur_f->db_type) { + case 'N': + case 'I': + add_assoc_long(row, "precision", cur_f->db_fdc); + break; + default: + add_assoc_long(row, "precision", 0); + } /* format for printing %s etc */ add_assoc_string(row, "format", cur_f->db_format, 1); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/dbase dbase.c
steinm Tue Oct 14 03:49:35 2003 EDT Modified files: /php-src/ext/dbase dbase.c Log: - limit writing of field data to field len + 1 This fixed many memory overrun errors which appeared in several scripts when writing a record. Index: php-src/ext/dbase/dbase.c diff -u php-src/ext/dbase/dbase.c:1.69 php-src/ext/dbase/dbase.c:1.70 --- php-src/ext/dbase/dbase.c:1.69 Sun Sep 21 09:17:20 2003 +++ php-src/ext/dbase/dbase.c Tue Oct 14 03:49:34 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dbase.c,v 1.69 2003/09/21 13:17:20 steinm Exp $ */ +/* $Id: dbase.c,v 1.70 2003/10/14 07:49:34 steinm Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -294,7 +294,7 @@ tmp = **field; zval_copy_ctor(&tmp); convert_to_string(&tmp); - sprintf(t_cp, cur_f->db_format, Z_STRVAL(tmp)); + snprintf(t_cp, cur_f->db_flen+1, cur_f->db_format, Z_STRVAL(tmp)); zval_dtor(&tmp); t_cp += cur_f->db_flen; } @@ -306,7 +306,7 @@ RETURN_FALSE; } -put_dbf_info(dbh); + put_dbf_info(dbh); efree(cp); RETURN_TRUE; @@ -361,7 +361,7 @@ RETURN_FALSE; } convert_to_string_ex(field); - sprintf(t_cp, cur_f->db_format, Z_STRVAL_PP(field)); + snprintf(t_cp, cur_f->db_flen+1, cur_f->db_format, Z_STRVAL_PP(field)); t_cp += cur_f->db_flen; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/dbase dbase.c
steinm Sun Sep 21 09:17:20 2003 EDT Modified files: /php-src/ext/dbase dbase.c Log: - fixed typo in error message Index: php-src/ext/dbase/dbase.c diff -u php-src/ext/dbase/dbase.c:1.68 php-src/ext/dbase/dbase.c:1.69 --- php-src/ext/dbase/dbase.c:1.68 Thu Aug 28 17:00:13 2003 +++ php-src/ext/dbase/dbase.c Sun Sep 21 09:17:20 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dbase.c,v 1.68 2003/08/28 21:00:13 andrey Exp $ */ +/* $Id: dbase.c,v 1.69 2003/09/21 13:17:20 steinm Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -664,7 +664,7 @@ /* field type */ if (zend_hash_index_find(Z_ARRVAL_PP (field), 1, (void **)&value) == FAILURE) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "expected field type as sececond 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); -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/dbase dbase.c
sniper Thu Jul 31 14:28:48 2003 EDT Modified files: /php-src/ext/dbase dbase.c Log: - Removed the unnecessary check of array_init() return value. Index: php-src/ext/dbase/dbase.c diff -u php-src/ext/dbase/dbase.c:1.66 php-src/ext/dbase/dbase.c:1.67 --- php-src/ext/dbase/dbase.c:1.66 Wed Jul 16 07:08:03 2003 +++ php-src/ext/dbase/dbase.c Thu Jul 31 14:28:47 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dbase.c,v 1.66 2003/07/16 11:08:03 zak Exp $ */ +/* $Id: dbase.c,v 1.67 2003/07/31 18:28:47 sniper Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -764,9 +764,7 @@ RETURN_FALSE; } - if (array_init(return_value)==FAILURE) { - RETURN_FALSE; - } + array_init(return_value); dbf = dbh->db_fields; for (cur_f = dbf; cur_f < &dbh->db_fields[dbh->db_nfields]; ++cur_f) { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/dbase dbase.c
woops :) -Sterling On Wed, 2003-07-16 at 10:06, Derick Rethans wrote: > On Wed, 16 Jul 2003, Sterling Hughes wrote: > > > Right, and if they change, then old code doesn't work. > > There is NO old code... this was added yesterday. > > Derick -- There is no safe investment. To love at all is to be vulnerable. ... The only place outside Heaven where you can be perfectly safe from all the dangers and pertubations of love is Hell. - CS Lewis, "The Four Loves" -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/dbase dbase.c
On Wed, 16 Jul 2003, Sterling Hughes wrote: > Right, and if they change, then old code doesn't work. There is NO old code... this was added yesterday. Derick -- "Interpreting what the GPL actually means is a job best left to those that read the future by examining animal entrails." - Derick Rethans http://derickrethans.nl/ International PHP Magazine http://php-mag.net/ - -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/dbase dbase.c
Right, and if they change, then old code doesn't work. Function names are just elements within an associative array after all ;-) -Sterling On Wed, 2003-07-16 at 09:54, Derick Rethans wrote: > On Wed, 16 Jul 2003, Sterling Hughes wrote: > > > Why create such names? Where is the advantage? If you are going to > > change it, please just make them aliases, so you can use either. > > uhm? Those were just names for the keys of the elements in an > associative array... > > Derick -- UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things. - Doug Gwyn -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/dbase dbase.c
On Wed, 16 Jul 2003, Sterling Hughes wrote: > Why create such names? Where is the advantage? If you are going to > change it, please just make them aliases, so you can use either. uhm? Those were just names for the keys of the elements in an associative array... Derick -- "Interpreting what the GPL actually means is a job best left to those that read the future by examining animal entrails." - Derick Rethans http://derickrethans.nl/ International PHP Magazine http://php-mag.net/ - -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php-src /ext/dbase dbase.c
Why create such names? Where is the advantage? If you are going to change it, please just make them aliases, so you can use either. -Sterling On Wed, 2003-07-16 at 07:08, Zak Greant wrote: > zak Wed Jul 16 07:08:03 2003 EDT > > Modified files: > /php-src/ext/dbasedbase.c > Log: > Created shorter/sensible key names for dbase_get_header_info >* 'decimal places' becomes 'precision' >* 'printf format' becomes 'format' >* 'record offset' becomes 'offset' > >BTW No docs have been committed for this function yet, nor is it part of any >release. This change should affect no users. > > > Index: php-src/ext/dbase/dbase.c > diff -u php-src/ext/dbase/dbase.c:1.65 php-src/ext/dbase/dbase.c:1.66 > --- php-src/ext/dbase/dbase.c:1.65Tue Jul 15 14:19:51 2003 > +++ php-src/ext/dbase/dbase.c Wed Jul 16 07:08:03 2003 > @@ -16,7 +16,7 @@ > +--+ > */ > > -/* $Id: dbase.c,v 1.65 2003/07/15 18:19:51 zak Exp $ */ > +/* $Id: dbase.c,v 1.66 2003/07/16 11:08:03 zak Exp $ */ > > #ifdef HAVE_CONFIG_H > #include "config.h" > @@ -793,13 +793,13 @@ > add_assoc_long(row, "length", cur_f->db_flen); > > /* number of decimals in field */ > - add_assoc_long(row, "decimal places", cur_f->db_fdc); > + add_assoc_long(row, "precision", cur_f->db_fdc); > > /* format for printing %s etc */ > - add_assoc_string(row, "printf format", cur_f->db_format, 1); > + add_assoc_string(row, "format", cur_f->db_format, 1); > > /* offset within record */ > - add_assoc_long(row, "record offset", cur_f->db_foffset); > + add_assoc_long(row, "offset", cur_f->db_foffset); > } > } > /* }}} */ -- King's Law of Clues : Common sense is inversely proportional to the academic intelligence of the person concerned. -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/dbase dbase.c
zak Wed Jul 16 07:08:03 2003 EDT Modified files: /php-src/ext/dbase dbase.c Log: Created shorter/sensible key names for dbase_get_header_info * 'decimal places' becomes 'precision' * 'printf format' becomes 'format' * 'record offset' becomes 'offset' BTW No docs have been committed for this function yet, nor is it part of any release. This change should affect no users. Index: php-src/ext/dbase/dbase.c diff -u php-src/ext/dbase/dbase.c:1.65 php-src/ext/dbase/dbase.c:1.66 --- php-src/ext/dbase/dbase.c:1.65 Tue Jul 15 14:19:51 2003 +++ php-src/ext/dbase/dbase.c Wed Jul 16 07:08:03 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dbase.c,v 1.65 2003/07/15 18:19:51 zak Exp $ */ +/* $Id: dbase.c,v 1.66 2003/07/16 11:08:03 zak Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -793,13 +793,13 @@ add_assoc_long(row, "length", cur_f->db_flen); /* number of decimals in field */ - add_assoc_long(row, "decimal places", cur_f->db_fdc); + add_assoc_long(row, "precision", cur_f->db_fdc); /* format for printing %s etc */ - add_assoc_string(row, "printf format", cur_f->db_format, 1); + add_assoc_string(row, "format", cur_f->db_format, 1); /* offset within record */ - add_assoc_long(row, "record offset", cur_f->db_foffset); + add_assoc_long(row, "offset", cur_f->db_foffset); } } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php-src /ext/dbase dbase.c php_dbase.h
zak Tue Jul 15 14:19:51 2003 EDT Modified files: /php-src/ext/dbase php_dbase.h dbase.c Log: Added function dbase_get_header_info * Passed a handle for an open dbase database, it returns an array of associative arrays. Each associative array contains information on a single column, including name, column type, length, precision, ... Index: php-src/ext/dbase/php_dbase.h diff -u php-src/ext/dbase/php_dbase.h:1.12 php-src/ext/dbase/php_dbase.h:1.13 --- php-src/ext/dbase/php_dbase.h:1.12 Tue Jun 10 16:03:27 2003 +++ php-src/ext/dbase/php_dbase.h Tue Jul 15 14:19:51 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: php_dbase.h,v 1.12 2003/06/10 20:03:27 imajes Exp $ */ +/* $Id: php_dbase.h,v 1.13 2003/07/15 18:19:51 zak Exp $ */ #ifndef PHP_DBASE_H #define PHP_DBASE_H @@ -35,6 +35,7 @@ PHP_FUNCTION(dbase_delete_record); PHP_FUNCTION(dbase_pack); PHP_FUNCTION(dbase_get_record_with_names); +PHP_FUNCTION(dbase_get_header_info); #else #define dbase_module_ptr NULL #endif Index: php-src/ext/dbase/dbase.c diff -u php-src/ext/dbase/dbase.c:1.64 php-src/ext/dbase/dbase.c:1.65 --- php-src/ext/dbase/dbase.c:1.64 Tue Jun 10 16:03:27 2003 +++ php-src/ext/dbase/dbase.c Tue Jul 15 14:19:51 2003 @@ -16,7 +16,7 @@ +--+ */ -/* $Id: dbase.c,v 1.64 2003/06/10 20:03:27 imajes Exp $ */ +/* $Id: dbase.c,v 1.65 2003/07/15 18:19:51 zak Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -737,8 +737,71 @@ PHP_FE(dbase_get_record_with_names, NULL) PHP_FE(dbase_delete_record, NULL) PHP_FE(dbase_pack, NULL) + PHP_FE(dbase_get_header_info, NULL) {NULL, NULL, NULL} }; +/* }}} */ + +/* Added by Zak Greant <[EMAIL PROTECTED]> */ +/* {{{ proto array dbase_get_header_info(int database_handle) + */ +PHP_FUNCTION(dbase_get_header_info) +{ + zval**dbh_id, *row; + dbfield_t *dbf, *cur_f; + dbhead_t*dbh; + int dbh_type; + DBase_TLS_VARS; + + if (ZEND_NUM_ARGS() != 1 || (zend_get_parameters_ex(1, &dbh_id) == FAILURE)) { + WRONG_PARAM_COUNT; + } + 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_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find database for identifier %d", Z_LVAL_PP(dbh_id)); + RETURN_FALSE; + } + + if (array_init(return_value)==FAILURE) { + RETURN_FALSE; + } + + dbf = dbh->db_fields; + for (cur_f = dbf; cur_f < &dbh->db_fields[dbh->db_nfields]; ++cur_f) { + MAKE_STD_ZVAL(row); + array_init(row); + + add_next_index_zval(return_value, row); + + /* field name */ + add_assoc_string(row, "name", cur_f->db_fname, 1); + + /* field type */ + switch (cur_f->db_type) { + case 'C': add_assoc_string(row, "type", "character", 1); break; + case 'D': add_assoc_string(row, "type", "date", 1); break; + case 'I': add_assoc_string(row, "type", "integer", 1); break; + case 'N': add_assoc_string(row, "type", "number", 1); break; + case 'L': add_assoc_string(row, "type", "boolean", 1); break; + case 'M': add_assoc_string(row, "type", "memo", 1); break; + default: add_assoc_string(row, "type", "unknown", 1); break; + } + + /* length of field */ + add_assoc_long(row, "length", cur_f->db_flen); + + /* number of decimals in field */ + add_assoc_long(row, "decimal places", cur_f->db_fdc); + + /* format for printing %s etc */ + add_assoc_string(row, "printf format", cur_f->db_format, 1); + + /* offset within record */ + add_assoc_long(row, "record offset", cur_f->db_foffset); + } +} /* }}} */ zend_module_entry dbase_module_entry = { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php