[PHP-CVS] cvs: php4 /ext/sockets php_sockets.h sockets.c

2003-06-16 Thread Sterling Hughes
sterlingTue Jun 17 00:44:31 2003 EDT

  Modified files:  
/php4/ext/sockets   php_sockets.h sockets.c 
  Log:
  rename SOCKET to PHP_SOCKET to avoid conflicts with Mono
  
  
Index: php4/ext/sockets/php_sockets.h
diff -u php4/ext/sockets/php_sockets.h:1.31 php4/ext/sockets/php_sockets.h:1.32
--- php4/ext/sockets/php_sockets.h:1.31 Tue Jun 10 16:03:36 2003
+++ php4/ext/sockets/php_sockets.h  Tue Jun 17 00:44:30 2003
@@ -22,7 +22,7 @@
 #ifndef PHP_SOCKETS_H
 #define PHP_SOCKETS_H
 
-/* $Id: php_sockets.h,v 1.31 2003/06/10 20:03:36 imajes Exp $ */
+/* $Id: php_sockets.h,v 1.32 2003/06/17 04:44:30 sterling Exp $ */
 
 #if HAVE_SOCKETS
 
@@ -88,11 +88,13 @@
 } php_iovec_t;
 
 #ifndef PHP_WIN32
-typedef int SOCKET;
+typedef int PHP_SOCKET;
+#else
+typedef SOCKET PHP_SOCKET;
 #endif
 
 typedef struct {
-   SOCKET  bsd_socket;
+   PHP_SOCKET bsd_socket;
int type;
int error;
 } php_socket;
Index: php4/ext/sockets/sockets.c
diff -u php4/ext/sockets/sockets.c:1.142 php4/ext/sockets/sockets.c:1.143
--- php4/ext/sockets/sockets.c:1.142Tue Jun 10 16:03:36 2003
+++ php4/ext/sockets/sockets.c  Tue Jun 17 00:44:30 2003
@@ -19,7 +19,7 @@
+--+
  */
 
-/* $Id: sockets.c,v 1.142 2003/06/10 20:03:36 imajes Exp $ */
+/* $Id: sockets.c,v 1.143 2003/06/17 04:44:30 sterling Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -527,7 +527,7 @@
 }
 /* }}} */
 
-static int php_sock_array_to_fd_set(zval *sock_array, fd_set *fds, SOCKET *max_fd 
TSRMLS_DC)
+static int php_sock_array_to_fd_set(zval *sock_array, fd_set *fds, PHP_SOCKET *max_fd 
TSRMLS_DC)
 {
zval**element;
php_socket  *php_sock;
@@ -593,7 +593,7 @@
struct timeval  tv;
struct timeval *tv_p = NULL;
fd_set  rfds, wfds, efds;
-   SOCKET  max_fd = 0;
+   PHP_SOCKET  max_fd = 0;
int retval, sets = 0;
longusec = 0;
 
@@ -2179,7 +2179,7 @@
 {
zval*retval[2], *fds_array_zval;
php_socket  *php_sock[2];
-   SOCKET  fds_array[2];
+   PHP_SOCKET  fds_array[2];
longdomain, type, protocol;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, lllz, domain, type, 
protocol, fds_array_zval) == FAILURE)



-- 
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

2003-05-27 Thread Ilia Alshanetsky
iliaa   Tue May 27 21:04:06 2003 EDT

  Modified files:  
/php4/ext/sockets   php_sockets.h sockets.c 
  Log:
  Fixed compiler warnings.
  
  
Index: php4/ext/sockets/php_sockets.h
diff -u php4/ext/sockets/php_sockets.h:1.29 php4/ext/sockets/php_sockets.h:1.30
--- php4/ext/sockets/php_sockets.h:1.29 Thu Apr 17 19:18:58 2003
+++ php4/ext/sockets/php_sockets.h  Tue May 27 21:04:06 2003
@@ -22,7 +22,7 @@
 #ifndef PHP_SOCKETS_H
 #define PHP_SOCKETS_H
 
-/* $Id: php_sockets.h,v 1.29 2003/04/17 23:18:58 sniper Exp $ */
+/* $Id: php_sockets.h,v 1.30 2003/05/28 01:04:06 iliaa Exp $ */
 
 #if HAVE_SOCKETS
 
@@ -102,10 +102,12 @@
 } php_sockets_globals;
 
 /* Prototypes */
+#ifdef ilia_0 /* not needed, only causes a compiler warning */
 static int php_open_listen_sock(php_socket **php_sock, int port, int backlog 
TSRMLS_DC);
 static int php_accept_connect(php_socket *in_sock, php_socket **new_sock, struct 
sockaddr *la TSRMLS_DC);
 static int php_read(int bsd_socket, void *buf, size_t maxlen, int flags);
 static char *php_strerror(int error TSRMLS_DC);
+#endif
 
 ZEND_BEGIN_MODULE_GLOBALS(sockets)
int last_error;
Index: php4/ext/sockets/sockets.c
diff -u php4/ext/sockets/sockets.c:1.140 php4/ext/sockets/sockets.c:1.141
--- php4/ext/sockets/sockets.c:1.140Fri Apr 25 04:10:11 2003
+++ php4/ext/sockets/sockets.c  Tue May 27 21:04:06 2003
@@ -19,7 +19,7 @@
+--+
  */
 
-/* $Id: sockets.c,v 1.140 2003/04/25 08:10:11 sniper Exp $ */
+/* $Id: sockets.c,v 1.141 2003/05/28 01:04:06 iliaa Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -82,6 +82,7 @@
 #define PF_INET AF_INET
 #endif
 
+static char *php_strerror(int error TSRMLS_DC);
 
 #define PHP_NORMAL_READ 0x0001
 #define PHP_BINARY_READ 0x0002



-- 
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

2002-09-29 Thread Jason Greene

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,