[PHP-CVS] cvs: php4 /main php_embed.c php_embed.h
derick Sun Sep 29 06:00:07 2002 EDT Modified files: /php4/main php_embed.c php_embed.h Log: - Fix Edin's name Index: php4/main/php_embed.c diff -u php4/main/php_embed.c:1.1 php4/main/php_embed.c:1.2 --- php4/main/php_embed.c:1.1 Sat Sep 28 22:45:25 2002 +++ php4/main/php_embed.c Sun Sep 29 06:00:07 2002 @@ -12,10 +12,10 @@ | obtain it through the world-wide-web, please send a note to | | [EMAIL PROTECTED] so we can mail you a copy immediately. | +--+ - | Author: Edin Kadrinasic [EMAIL PROTECTED] | + | Author: Edin Kadribasic [EMAIL PROTECTED] | +--+ */ -/* $Id: php_embed.c,v 1.1 2002/09/29 02:45:25 edink Exp $ */ +/* $Id: php_embed.c,v 1.2 2002/09/29 10:00:07 derick Exp $ */ #include php_embed.h Index: php4/main/php_embed.h diff -u php4/main/php_embed.h:1.1 php4/main/php_embed.h:1.2 --- php4/main/php_embed.h:1.1 Sat Sep 28 22:45:25 2002 +++ php4/main/php_embed.h Sun Sep 29 06:00:07 2002 @@ -12,10 +12,10 @@ | obtain it through the world-wide-web, please send a note to | | [EMAIL PROTECTED] so we can mail you a copy immediately. | +--+ - | Author: Edin Kadrinasic [EMAIL PROTECTED] | + | Author: Edin Kadribasic [EMAIL PROTECTED] | +--+ */ -/* $Id: php_embed.h,v 1.1 2002/09/29 02:45:25 edink Exp $ */ +/* $Id: php_embed.h,v 1.2 2002/09/29 10:00:07 derick Exp $ */ #ifndef _PHP_EMBED_H_ #define _PHP_EMBED_H_ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/session session.c
iliaa Sun Sep 29 11:26:51 2002 EDT Modified files: /php4/ext/session session.c Log: Fixed bugs #16995 and #19392 Index: php4/ext/session/session.c diff -u php4/ext/session/session.c:1.318 php4/ext/session/session.c:1.319 --- php4/ext/session/session.c:1.318Thu Sep 26 14:12:27 2002 +++ php4/ext/session/session.c Sun Sep 29 11:26:50 2002 -17,7 +17,7 +--+ */ -/* $Id: session.c,v 1.318 2002/09/26 18:12:27 iliaa Exp $ */ +/* $Id: session.c,v 1.319 2002/09/29 15:26:50 iliaa Exp $ */ #ifdef HAVE_CONFIG_H #include config.h -567,6 +567,10 HashPosition pos; if (!PG(register_globals) !PS(http_session_vars)) { + return; + } + + if (PS(http_session_vars) PS(http_session_vars)-type!=IS_ARRAY) { return; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 / Makefile.global
sas Sun Sep 29 12:25:24 2002 EDT Modified files: /php4 Makefile.global Log: Fix some typos Index: php4/Makefile.global diff -u php4/Makefile.global:1.26 php4/Makefile.global:1.27 --- php4/Makefile.global:1.26 Sun Sep 29 12:22:47 2002 +++ php4/Makefile.globalSun Sep 29 12:25:23 2002 -46,14 +46,14 install-su: install-pear install-tester -test: $(SAPI_CLI_PHP) - TEST_PHP_EXECUTABLE=$(top_builddir)/$(SAPI_CLI_PHP) \ - $(top_builddir)/$(SAPI_CLI_PHP) -c php.ini-dist $(top_srcdir)/run-tests.php $(TESTS) +test: $(SAPI_CLI_PATH) + TEST_PHP_EXECUTABLE=$(top_builddir)/$(SAPI_CLI_PATH) \ + $(top_builddir)/$(SAPI_CLI_PATH) -c php.ini-dist +$(top_srcdir)/run-tests.php $(TESTS) clean: find . -name \*.lo -o -name \*.o -o -name \*.la -o -name \*.a -o -name \*.so| xargs rm -f find . -name .libs -a -type d|xargs rm -rf - rm -f libphp4.la $(SAPI_CLI_PHP) $(SAPI_CGI_PHP) modules/* libs/* + rm -f libphp4.la $(SAPI_CLI_PATH) $(OVERALL_TARGET) modules/* libs/* distclean: clean rm -f config.cache config.log config.status Makefile.objects Makefile.fragments libtool main/php_config.h stamp-h php4.spec sapi/apache/libphp4.module buildmk.stamp -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php4 / Makefile.global acinclude.m4 configure.in /main php_embed.c php_embed.h /sapi/cgi Makefile.frag config.m4 /sapi/cliMakefile.frag config.m4 /sapi/embed config.m4 php_embed.c
Hi, can you now build all three sapis at once like you could before? Derick On Sun, 29 Sep 2002, Sascha Schumann wrote: sas Sun Sep 29 12:22:50 2002 EDT Added files: /php4/sapi/cgiMakefile.frag /php4/sapi/cliMakefile.frag /php4/sapi/embed config.m4 php_embed.c php_embed.h /php4/sapi/fastcgiMakefile.frag Removed files: /php4/mainphp_embed.c php_embed.h Modified files: /php4 Makefile.global acinclude.m4 configure.in /php4/sapi/cgiconfig.m4 /php4/sapi/cliconfig.m4 /php4/sapi/fastcgiconfig.m4 /php4/win32 phpembed.dsp Log: Follow Yasuo's suggestion and build sapi program's under the sapi-specific directory. Move sapi-specific makefile fragments to their respective directory. Create an embed sapi module which resides in its own dir now. -- --- Derick Rethans http://derickrethans.nl/ JDI Media Solutions --[ if you hold a unix shell to your ear, do you hear the c? ]- -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-CVS] cvs: php4 / Makefile.global acinclude.m4 configure.in /main php_embed.c php_embed.h /sapi/cgi Makefile.frag config.m4 /sapi/cliMakefile.frag config.m4 /sapi/embed config.m4 php_embe
That might be, but this doesn't answer my question :) Wouldn't it be very useful of the PHP lib gets compiled/installed on every compile just like CLI? I think it would be very useful that lib, CLI and the SAPI of choice are compiled at the same time. This was also Edin's reasoning to implement it like he did. I disagree. There is nothing special about the embedded SAPI module and thus it does not get special treatment, including poluting all kind of files. The Unix build chain has been crafted around the idea that there is one specific target with an explicit set of requirements (especially regarding type of linkage). The CLI SAPI module is a target which does not care how its modules were compiled. This is not the same case with the embedded SAPI module where the target is a library. We could come up with an extension to the build chain which allows us to build multiple SAPI modules in a single build tree. This extension would have to analyze the requirements of a set of activated SAPI modules and would then choose the best build target (shared, static) for the set. - Sascha -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/fribidi fribidi.c
sniper Sun Sep 29 14:53:19 2002 EDT Modified files: /php4/ext/fribidi fribidi.c Log: Make it compile with the latest _release_ too.. Index: php4/ext/fribidi/fribidi.c diff -u php4/ext/fribidi/fribidi.c:1.27 php4/ext/fribidi/fribidi.c:1.28 --- php4/ext/fribidi/fribidi.c:1.27 Sat Sep 28 11:41:57 2002 +++ php4/ext/fribidi/fribidi.c Sun Sep 29 14:53:19 2002 -17,7 +17,7 +--+ */ -/* $Id: fribidi.c,v 1.27 2002/09/28 15:41:57 tal Exp $ */ +/* $Id: fribidi.c,v 1.28 2002/09/29 18:53:19 sniper Exp $ */ #ifdef HAVE_CONFIG_H #include config.h -32,8 +32,7 #include fribidi/fribidi.h /* The fribidi guys dont believe in BC */ -#ifndef FRIBIDI_CHARSET_NOT_FOUND - +#ifdef FRIBIDI_CHAR_SET_UTF8 #define FRIBIDI_CHARSET_UTF8FRIBIDI_CHAR_SET_UTF8 #define FRIBIDI_CHARSET_ISO8859_6 FRIBIDI_CHAR_SET_ISO8859_6 #define FRIBIDI_CHARSET_ISO8859_8 FRIBIDI_CHAR_SET_ISO8859_8 -41,7 +40,6 #define FRIBIDI_CHARSET_CP1256 FRIBIDI_CHAR_SET_CP1256 #define FRIBIDI_CHARSET_ISIRI_3342 FRIBIDI_CHAR_SET_ISIRI_3342 #define FRIBIDI_CHARSET_CAP_RTL FRIBIDI_CHAR_SET_CAP_RTL - #endif function_entry fribidi_functions[] = { -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /main main.c
sniper Sun Sep 29 15:22:40 2002 EDT Modified files: /php4/main main.c Log: ws fix Index: php4/main/main.c diff -u php4/main/main.c:1.492 php4/main/main.c:1.493 --- php4/main/main.c:1.492 Sat Sep 28 16:13:28 2002 +++ php4/main/main.cSun Sep 29 15:22:39 2002 -18,7 +18,7 +--+ */ -/* $Id: main.c,v 1.492 2002/09/28 20:13:28 iliaa Exp $ */ +/* $Id: main.c,v 1.493 2002/09/29 19:22:39 sniper Exp $ */ /* {{{ includes */ -1505,11 +1505,11 VCWD_CHDIR_FILE(primary_file-filename); } - if(primary_file-filename) { + if (primary_file-filename) { char realfile[MAXPATHLEN]; int realfile_len; int dummy = 1; - if(VCWD_REALPATH(primary_file-filename, realfile)) { + if (VCWD_REALPATH(primary_file-filename, realfile)) { realfile_len = strlen(realfile); zend_hash_add(EG(included_files), realfile, realfile_len+1, (void *)dummy, sizeof(int), NULL); primary_file-opened_path = emalloc(realfile_len+1); -1527,6 +1527,7 } else { prepend_file_p = NULL; } + if (PG(auto_append_file) PG(auto_append_file)[0]) { append_file.filename = PG(auto_append_file); append_file.opened_path = NULL; -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/session session.c
sniper Sun Sep 29 15:28:12 2002 EDT Modified files: /php4/ext/session session.c Log: ws fix Index: php4/ext/session/session.c diff -u php4/ext/session/session.c:1.321 php4/ext/session/session.c:1.322 --- php4/ext/session/session.c:1.321Sun Sep 29 14:33:14 2002 +++ php4/ext/session/session.c Sun Sep 29 15:28:12 2002 -17,7 +17,7 +--+ */ -/* $Id: session.c,v 1.321 2002/09/29 18:33:14 iliaa Exp $ */ +/* $Id: session.c,v 1.322 2002/09/29 19:28:12 sniper Exp $ */ #ifdef HAVE_CONFIG_H #include config.h -580,7 +580,7 return; } - if (PS(http_session_vars) PS(http_session_vars)-type!=IS_ARRAY) { + if (PS(http_session_vars) PS(http_session_vars)-type != IS_ARRAY) { return; } -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/standard/tests/math floorceil.phpt
iliaa Sun Sep 29 17:45:55 2002 EDT Modified files: /php4/ext/standard/tests/math floorceil.phpt Log: Removed the ceil(-0.5); test. The return value is depedant on system's libc and even when proper value '-0' is returned, var_dump() converts it to 0 anyway. Index: php4/ext/standard/tests/math/floorceil.phpt diff -u php4/ext/standard/tests/math/floorceil.phpt:1.2 php4/ext/standard/tests/math/floorceil.phpt:1.3 --- php4/ext/standard/tests/math/floorceil.phpt:1.2 Sun Sep 29 15:21:10 2002 +++ php4/ext/standard/tests/math/floorceil.phpt Sun Sep 29 17:45:54 2002 -4,9 +4,9 --GET-- --FILE-- ?php -$a = ceil (-0); $b = ceil (-0.5); $c = ceil (-1); -$d = ceil (-1.5); $e = ceil (-1.8); $f = ceil (-2.7); -var_dump ($a, $b, $c, $d, $e, $f); +$a = ceil (-0); $b = ceil (-1); $c = ceil (-1.5); +$d = ceil (-1.8); $e = ceil (-2.7); +var_dump ($a, $b, $c, $d, $e); $a = ceil (0); $b = ceil (0.5); $c = ceil (1); $d = ceil (1.5); $e = ceil (1.8); $f = ceil (2.7); -21,7 +21,6 var_dump ($a, $b, $c, $d, $e, $f); ? --EXPECT-- -float(0) float(0) float(-1) float(-1) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4(PHP_4_2_0) / NEWS
mfischerSun Sep 29 18:15:15 2002 EDT Modified files: (Branch: PHP_4_2_0) /php4 NEWS Log: - Update Index: php4/NEWS diff -u php4/NEWS:1.885.2.63 php4/NEWS:1.885.2.64 --- php4/NEWS:1.885.2.63Tue Sep 17 05:18:45 2002 +++ php4/NEWS Sun Sep 29 18:15:14 2002 -1,6 +1,7 PHP 4 NEWS ||| ?? ??? 2002, Version 4.2.4 +- Fixed bug #19292 (open_basedir restriction problem). (Rasmus) - Fixed a corruption bug in the thread-safe version (Michael Sisolak) - Fixed file_exists(), is_readable(), is_writable(), and is_executable() on multi-threaded non-windows platforms. (Edin) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /sapi/nsapi config.m4
sniper Sun Sep 29 18:24:21 2002 EDT Modified files: /php4/sapi/nsapiconfig.m4 Log: Possible fix for #19290 Index: php4/sapi/nsapi/config.m4 diff -u php4/sapi/nsapi/config.m4:1.15 php4/sapi/nsapi/config.m4:1.16 --- php4/sapi/nsapi/config.m4:1.15 Sun Sep 8 14:13:56 2002 +++ php4/sapi/nsapi/config.m4 Sun Sep 29 18:24:20 2002 -1,5 +1,5 dnl -dnl $Id: config.m4,v 1.15 2002/09/08 18:13:56 kalowsky Exp $ +dnl $Id: config.m4,v 1.16 2002/09/29 22:24:20 sniper Exp $ dnl AC_MSG_CHECKING(for NSAPI support) -22,7 +22,7 AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h]) fi if test -d $PHP_NSAPI/plugins/include ; then -NSAPI_INC_DIR=$NSAPI_INCLUDE +test -n $NSAPI_INCLUDE NSAPI_INC_DIR=-I$NSAPI_INCLUDE NSAPI_INCLUDE=$PHP_NSAPI/plugins/include AC_MSG_RESULT(iPlanet/4.x style) AC_CHECK_HEADERS([$NSAPI_INCLUDE/nsapi.h]) -31,7 +31,8 if test $NSAPI_INCLUDE = ; then AC_MSG_ERROR(Please check you have nsapi.h in either $PHP_NSAPI/include or $PHP_NSAPI/plugins/include) fi - PHP_ADD_INCLUDE($NSAPI_INCLUDE) + + PHP_EVAL_INCLINE($NSAPI_INCLUDE) PHP_BUILD_THREAD_SAFE AC_DEFINE(HAVE_NSAPI,1,[Whether you have a Netscape Server]) PHP_SELECT_SAPI(nsapi, shared, nsapi.c) -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/ncurses ncurses_functions.c
wez Sun Sep 29 18:55:09 2002 EDT Modified files: /php4/ext/ncurses ncurses_functions.c Log: Prevent possible problems with two resource ids referencing the same panel. Index: php4/ext/ncurses/ncurses_functions.c diff -u php4/ext/ncurses/ncurses_functions.c:1.23 php4/ext/ncurses/ncurses_functions.c:1.24 --- php4/ext/ncurses/ncurses_functions.c:1.23 Sat Sep 28 18:50:23 2002 +++ php4/ext/ncurses/ncurses_functions.cSun Sep 29 18:55:09 2002 -2061,7 +2061,8 efree(panel); RETURN_FALSE; } else { - ZEND_REGISTER_RESOURCE(return_value, panel, le_ncurses_panels); + long id = ZEND_REGISTER_RESOURCE(return_value, panel, +le_ncurses_panels); + set_panel_userptr(*panel, (void*)id); } } -2196,7 +2197,7 { zval *phandle = NULL; PANEL **panel; - PANEL **above = (PANEL **)emalloc(sizeof(PANEL *)); + PANEL *above; if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r!, phandle)) { return; -2204,16 +2205,18 if (phandle) { FETCH_PANEL(panel, phandle); - *above = panel_above(*panel); + above = panel_above(*panel); } else { - *above = panel_above((PANEL *)0); + above = panel_above((PANEL *)0); } - if (*above == NULL) { - efree(above); + if (above) { + long id = (long)panel_userptr(above); + zend_list_addref(id); + RETURN_RESOURCE(id); + } else { RETURN_FALSE; } - ZEND_REGISTER_RESOURCE(return_value, above, le_ncurses_panels); } /* }}} */ -2223,7 +2226,7 { zval *phandle = NULL; PANEL **panel; - PANEL **below = (PANEL **)emalloc(sizeof(PANEL *)); + PANEL *below; if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r!, phandle)) { return; -2231,16 +2234,17 if (phandle) { FETCH_PANEL(panel, phandle); - *below = panel_below(*panel); + below = panel_below(*panel); } else { - *below = panel_below((PANEL *)0); + below = panel_below((PANEL *)0); } - - if (*below == NULL) { - efree(below); + if (below) { + long id = (long)panel_userptr(below); + zend_list_addref(id); + RETURN_RESOURCE(id); + } else { RETURN_FALSE; } - ZEND_REGISTER_RESOURCE(return_value, below, le_ncurses_panels); } /* }}} */ -- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-CVS] cvs: php4 /ext/sockets php_sockets.h sockets.c
jason Sun Sep 29 22:09:43 2002 EDT Modified files: /php4/ext/sockets php_sockets.h sockets.c Log: Fix thread safety issue Index: php4/ext/sockets/php_sockets.h diff -u php4/ext/sockets/php_sockets.h:1.24 php4/ext/sockets/php_sockets.h:1.25 --- php4/ext/sockets/php_sockets.h:1.24 Wed May 1 07:08:08 2002 +++ php4/ext/sockets/php_sockets.h Sun Sep 29 22:09:42 2002 -22,7 +22,7 #ifndef PHP_SOCKETS_H #define PHP_SOCKETS_H -/* $Id: php_sockets.h,v 1.24 2002/05/01 11:08:08 mfischer Exp $ */ +/* $Id: php_sockets.h,v 1.25 2002/09/30 02:09:42 jason Exp $ */ #if HAVE_SOCKETS -41,6 +41,8 PHP_MINIT_FUNCTION(sockets); PHP_MINFO_FUNCTION(sockets); +PHP_RINIT_FUNCTION(sockets); +PHP_RSHUTDOWN_FUNCTION(sockets); PHP_FUNCTION(socket_iovec_alloc); PHP_FUNCTION(socket_iovec_free); -103,7 +105,8 int php_read(int bsd_socket, void *buf, int maxlen); ZEND_BEGIN_MODULE_GLOBALS(sockets) -int last_error; + int last_error; + char *strerror_buf; ZEND_END_MODULE_GLOBALS(sockets) #ifdef ZTS Index: php4/ext/sockets/sockets.c diff -u php4/ext/sockets/sockets.c:1.122 php4/ext/sockets/sockets.c:1.123 --- php4/ext/sockets/sockets.c:1.122Sun Sep 22 23:34:21 2002 +++ php4/ext/sockets/sockets.c Sun Sep 29 22:09:42 2002 -19,7 +19,7 +--+ */ -/* $Id: sockets.c,v 1.122 2002/09/23 03:34:21 jason Exp $ */ +/* $Id: sockets.c,v 1.123 2002/09/30 02:09:42 jason Exp $ */ #ifdef HAVE_CONFIG_H #include config.h -86,7 +86,7 #define PHP_SOCKET_ERROR(socket,msg,errn) socket-error = errn; \ SOCKETS_G(last_error) = errn; \ php_error(E_WARNING, %s() %s [%d]: %s, \ - get_active_function_name(TSRMLS_C), msg, errn, php_strerror(errn)) + + get_active_function_name(TSRMLS_C), msg, errn, php_strerror(errn +TSRMLS_CC)) static int le_iov; #define le_iov_name Socket I/O vector -111,11 +111,6 static unsigned char third_through_seventh_args_force_ref[] = {7, BYREF_NONE, BYREF_NONE, BYREF_FORCE, BYREF_FORCE, BYREF_FORCE, BYREF_FORCE, BYREF_FORCE}; -/* Global buffer for php_strerror() */ -#if defined(PHP_WIN32) || (! defined(HAVE_HSTRERROR)) -static char php_strerror_buf[1]; -#endif - /* {{{ sockets_functions[] */ function_entry sockets_functions[] = { -169,8 +164,8 sockets_functions, PHP_MINIT(sockets), NULL, - NULL, - NULL, + PHP_RINIT(sockets), + PHP_RSHUTDOWN(sockets), PHP_MINFO(sockets), NO_VERSION_YET, STANDARD_MODULE_PROPERTIES -207,7 +202,7 efree(php_sock); } -static char *php_strerror(int error); +static char *php_strerror(int error TSRMLS_DC); int open_listen_sock(php_socket **php_sock, int port, int backlog TSRMLS_DC) { -337,7 +332,7 } /* }}} */ -static char *php_strerror(int error) { +static char *php_strerror(int error TSRMLS_DC) { const char *buf; #ifndef PHP_WIN32 -348,8 +343,8 buf = hstrerror(error); #else { - sprintf(php_strerror_buf, Host lookup error %d, error); - buf = php_strerror_buf; + sprintf(SOCKETS_G(strerror_buf), Host lookup error %d, +error); + buf = SOCKETS_G(strerror_buf); } #endif } else { -362,10 +357,10 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) tmp, 0, NULL); - strlcpy(php_strerror_buf, (char *) tmp, 1); + strlcpy(SOCKETS_G(strerror_buf), (char *) tmp, 1); LocalFree(tmp); - buf = php_strerror_buf; + buf = SOCKETS_G(strerror_buf); } #endif -403,6 +398,7 static void php_sockets_init_globals(zend_sockets_globals *sockets_globals TSRMLS_DC) { sockets_globals-last_error = 0; + sockets_globals-strerror_buf = NULL; } /* {{{ PHP_MINIT_FUNCTION -475,6 +471,25 } /* }}} */ +/* {{{ PHP_RINIT_FUNCTION */ +PHP_RINIT_FUNCTION(sockets) +{ + if (SOCKETS_G(strerror_buf) = emalloc(16384)) + return SUCCESS; + + return FAILURE; +} +/* }}} */ + +/* {{{ PHP_RSHUTDOWN_FUNCTION */ +PHP_RSHUTDOWN_FUNCTION(sockets) +{ + efree(SOCKETS_G(strerror_buf)); + + return SUCCESS; +} +/* }}} */ + int php_sock_array_to_fd_set(zval *sock_array,
[PHP-CVS] cvs: php4 /ext/standard basic_functions.c basic_functions.h
jon Sun Sep 29 23:02:52 2002 EDT Modified files: /php4/ext/standard basic_functions.c basic_functions.h Log: - Added getopt() for parsing command line options and arguments. (Jon) Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.515 php4/ext/standard/basic_functions.c:1.516 --- php4/ext/standard/basic_functions.c:1.515 Sat Sep 28 18:14:20 2002 +++ php4/ext/standard/basic_functions.c Sun Sep 29 23:02:51 2002 -17,7 +17,7 +--+ */ -/* $Id: basic_functions.c,v 1.515 2002/09/28 22:14:20 wez Exp $ */ +/* $Id: basic_functions.c,v 1.516 2002/09/30 03:02:51 jon Exp $ */ #include php.h #include php_streams.h -498,6 +498,10 PHP_FE(putenv, NULL) #endif +#ifdef HAVE_GETOPT + PHP_FE(getopt, + NULL) +#endif + PHP_FE(microtime, NULL) PHP_FE(gettimeofday, NULL) -1337,6 +1341,105 RETURN_FALSE; } } +} +/* }}} */ +#endif + +#ifdef HAVE_GETOPT +/* {{{ free_argv + Free the memory allocated to an argv array. */ +static void free_argv(char **argv, int argc) +{ + int i; + + if (argv) { + for (i = 0; i argc; i++) { + if (argv[i]) { + efree(argv[i]); + } + } + efree(argv); + } +} +/* }}} */ + +/* {{{ proto array getopt(string options) + Get options from the command line argument list */ +PHP_FUNCTION(getopt) +{ + char *options = NULL, **argv = NULL; + char opt[1] = { '\0' }; + int argc = 0, options_len = 0; + zval *val, **args = NULL; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, + options, options_len) == +FAILURE) { + return; + } + + /* +* Get argv from the global symbol table. We calculate argc ourselves +* in order to be on the safe side, even though it is also available +* from the symbol table. +*/ + if (zend_hash_find(EG(symbol_table), argv, sizeof(argv), + (void **) args) != FAILURE) { + int pos = 0; + zval **arg; + + argc = zend_hash_num_elements(Z_ARRVAL_PP(args)); + + /* Attempt to allocate enough memory to hold all of the arguments. */ + if ((argv = (char **) emalloc(argc * sizeof(char *))) == NULL) { + RETURN_FALSE; + } + + /* Reset the array indexes. */ + zend_hash_internal_pointer_reset(Z_ARRVAL_PP(args)); + + /* Iterate over the hash to construct the argv array. */ + while (zend_hash_get_current_data(Z_ARRVAL_PP(args), + +(void **)arg) == SUCCESS) { + argv[pos++] = estrdup(Z_STRVAL_PP(arg)); + zend_hash_move_forward(Z_ARRVAL_PP(args)); + } + } + + /* Initialize the return value as an array. */ + if (array_init(return_value)) { + RETURN_FALSE; + } + + /* Disable getopt()'s error messages. */ + opterr = 0; + + /* Invoke getopt(3) on the argument array. */ + while (getopt(argc, argv, options) != -1) { + + /* Skip unknown arguments. */ + if (optopt == '?') { + continue; + } + + /* Prepare the option character and the argument string. */ + opt[0] = optopt; + + MAKE_STD_ZVAL(val); + if (optarg != NULL) { + ZVAL_STRING(val, optarg, 1); + } else { + ZVAL_NULL(val); + } + + /* Add this option / argument pair to the result hash. */ + if (zend_hash_add(HASH_OF(return_value), opt, 1, (void *)val, +sizeof(zval *), NULL) == +FAILURE) { + free_argv(argv, argc); + RETURN_FALSE; + } + } + + free_argv(argv, argc); } /* }}} */ #endif Index: php4/ext/standard/basic_functions.h diff -u php4/ext/standard/basic_functions.h:1.107 php4/ext/standard/basic_functions.h:1.108 ---
[PHP-CVS] cvs: php4 /ext/pgsql pgsql.c
yohgaki Sun Sep 29 23:51:54 2002 EDT Modified files: /php4/ext/pgsql pgsql.c Log: Improve error message. Fix proto. Index: php4/ext/pgsql/pgsql.c diff -u php4/ext/pgsql/pgsql.c:1.218 php4/ext/pgsql/pgsql.c:1.219 --- php4/ext/pgsql/pgsql.c:1.218Wed Sep 4 18:25:13 2002 +++ php4/ext/pgsql/pgsql.c Sun Sep 29 23:51:54 2002 -19,7 +19,7 +--+ */ -/* $Id: pgsql.c,v 1.218 2002/09/04 22:25:13 yohgaki Exp $ */ +/* $Id: pgsql.c,v 1.219 2002/09/30 03:51:54 yohgaki Exp $ */ #include stdlib.h -2296,7 +2296,7 } /* }}} */ -/* {{{ proto array pg_copy_to(int connection, string table_name [, string delimiter [, string null_as]]) +/* {{{ proto array pg_copy_to(resource connection, string table_name [, string +delimiter [, string null_as]]) Copy table to array */ PHP_FUNCTION(pg_copy_to) { -2357,7 +2357,7 while (!copydone) { if ((ret = PQgetline(pgsql, copybuf, COPYBUFSIZ))) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, Query failed: %s, PQerrorMessage(pgsql)); + php_error_docref(NULL TSRMLS_CC, +E_WARNING, getline failed: %s, PQerrorMessage(pgsql)); RETURN_FALSE; } -2391,7 +2391,7 } } if (PQendcopy(pgsql)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, Query failed: %s, PQerrorMessage(pgsql)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, +endcopy failed: %s, PQerrorMessage(pgsql)); RETURN_FALSE; } while ((pgsql_result = PQgetResult(pgsql))) { -2404,14 +2404,14 break; default: PQclear(pgsql_result); - php_error_docref(NULL TSRMLS_CC, E_WARNING, Query failed: %s, PQerrorMessage(pgsql)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, COPY command +failed: %s, PQerrorMessage(pgsql)); RETURN_FALSE; break; } } /* }}} */ -/* {{{ proto bool pg_copy_from(int connection, string table_name , array rows [, string delimiter [, string null_as]]) +/* {{{ proto bool pg_copy_from(resource connection, string table_name , array rows [, +string delimiter [, string null_as]]) Copy table from array */ PHP_FUNCTION(pg_copy_from) { -2468,21 +2468,22 convert_to_string_ex(tmp); query = (char *)emalloc(Z_STRLEN_PP(tmp) +2); strcpy(query, Z_STRVAL_PP(tmp)); - if(*(query+Z_STRLEN_PP(tmp)-1) != '\n') strcat(query, \n); + if(*(query+Z_STRLEN_PP(tmp)-1) != '\n') + strcat(query, \n); if (PQputline(pgsql, query)) { efree(query); - php_error_docref(NULL TSRMLS_CC, E_WARNING, Query failed: %s, PQerrorMessage(pgsql)); + php_error_docref(NULL TSRMLS_CC, +E_WARNING, copy failed: %s, PQerrorMessage(pgsql)); RETURN_FALSE; } efree(query); zend_hash_move_forward_ex(Z_ARRVAL_P(pg_rows), pos); } - if (PQputline(pgsql, \\.\n)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, Query failed: %s, PQerrorMessage(pgsql)); + if (PQputline(pgsql, \\.\n) == EOF) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, +putline failed: %s, PQerrorMessage(pgsql)); RETURN_FALSE; } if (PQendcopy(pgsql)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, Query failed: %s, PQerrorMessage(pgsql)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, +endcopy failed: %s, PQerrorMessage(pgsql)); RETURN_FALSE; } while ((pgsql_result = PQgetResult(pgsql)))