tony2001                Mon Dec 25 19:34:00 2006 UTC

  Modified files:              
    /php-src/ext/sockets        sockets.c 
  Log:
  fix CS, add missing folding markers
  mark Unicode safe functions as they are
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/sockets/sockets.c?r1=1.184&r2=1.185&diff_format=u
Index: php-src/ext/sockets/sockets.c
diff -u php-src/ext/sockets/sockets.c:1.184 php-src/ext/sockets/sockets.c:1.185
--- php-src/ext/sockets/sockets.c:1.184 Sun Oct  8 13:34:23 2006
+++ php-src/ext/sockets/sockets.c       Mon Dec 25 19:34:00 2006
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sockets.c,v 1.184 2006/10/08 13:34:23 bjori Exp $ */
+/* $Id: sockets.c,v 1.185 2006/12/25 19:34:00 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -176,15 +176,16 @@
 /* inet_ntop should be used instead of inet_ntoa */
 int inet_ntoa_lock = 0;
 
-static void php_destroy_socket(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+static void php_destroy_socket(zend_rsrc_list_entry *rsrc TSRMLS_DC) /* {{{ */
 {
        php_socket *php_sock = (php_socket *) rsrc->ptr;
 
        close(php_sock->bsd_socket);
        efree(php_sock);
 }
+/* }}} */
 
-static int php_open_listen_sock(php_socket **php_sock, int port, int backlog 
TSRMLS_DC)
+static int php_open_listen_sock(php_socket **php_sock, int port, int backlog 
TSRMLS_DC) /* {{{ */
 {
        struct sockaddr_in  la;
        struct hostent          *hp;
@@ -231,8 +232,9 @@
 
        return 1;
 }
+/* }}} */
 
-static int php_accept_connect(php_socket *in_sock, php_socket **new_sock, 
struct sockaddr *la TSRMLS_DC)
+static int php_accept_connect(php_socket *in_sock, php_socket **new_sock, 
struct sockaddr *la TSRMLS_DC) /* {{{ */
 {
        socklen_t       salen;
        php_socket      *out_sock = (php_socket*)emalloc(sizeof(php_socket));
@@ -250,6 +252,7 @@
        
        return 1;
 }
+/* }}} */
 
 /* {{{ php_read -- wrapper around read() so that it only reads to a \r or \n. 
*/
 static int php_read(int bsd_socket, void *buf, size_t maxlen, int flags)
@@ -314,7 +317,7 @@
 }
 /* }}} */
 
-static char *php_strerror(int error TSRMLS_DC)
+static char *php_strerror(int error TSRMLS_DC) /* {{{ */
 {
        const char *buf;
 
@@ -359,10 +362,11 @@
        
        return (buf ? (char *) buf : "");
 }
+/* }}} */
 
 #if HAVE_IPV6
 /* Sets addr by hostname, or by ip in string form (AF_INET6) */
-static int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, 
php_socket *php_sock TSRMLS_DC)
+static int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, 
php_socket *php_sock TSRMLS_DC) /* {{{ */
 {
        struct in6_addr tmp;
 #if HAVE_GETADDRINFO
@@ -405,10 +409,11 @@
 
        return 1;
 }
+/* }}} */
 #endif
 
 /* Sets addr by hostname, or by ip in string form (AF_INET)  */
-static int php_set_inet_addr(struct sockaddr_in *sin, char *string, php_socket 
*php_sock TSRMLS_DC)
+static int php_set_inet_addr(struct sockaddr_in *sin, char *string, php_socket 
*php_sock TSRMLS_DC) /* {{{ */
 {
        struct in_addr tmp;
        struct hostent *host_entry;
@@ -434,12 +439,15 @@
 
        return 1;
 }
+/* }}} */
 
+/* {{{ PHP_GINIT_FUNCTION */
 static PHP_GINIT_FUNCTION(sockets)
 {
        sockets_globals->last_error = 0;
        sockets_globals->strerror_buf = NULL;
 }
+/* }}} */
 
 /* {{{ PHP_MINIT_FUNCTION
  */
@@ -530,7 +538,7 @@
 }
 /* }}} */
 
-static int php_sock_array_to_fd_set(zval *sock_array, fd_set *fds, PHP_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;
@@ -554,8 +562,9 @@
 
        return num ? 1 : 0;
 }
+/* }}} */
 
-static int php_sock_array_from_fd_set(zval *sock_array, fd_set *fds TSRMLS_DC)
+static int php_sock_array_from_fd_set(zval *sock_array, fd_set *fds TSRMLS_DC) 
/* {{{ */
 {
        zval            **element;
        zval            **dest_element;
@@ -591,8 +600,9 @@
 
        return num ? 1 : 0;
 }
+/* }}} */
 
-/* {{{ proto int socket_select(array &read_fds, array &write_fds, &array 
except_fds, int tv_sec[, int tv_usec])
+/* {{{ proto int socket_select(array &read_fds, array &write_fds, &array 
except_fds, int tv_sec[, int tv_usec]) U
    Runs the select() system call on the sets mentioned with a timeout 
specified by tv_sec and tv_usec */
 PHP_FUNCTION(socket_select)
 {
@@ -604,8 +614,9 @@
        int                     retval, sets = 0;
        long                    usec = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a!a!a!z!|l", 
&r_array, &w_array, &e_array, &sec, &usec) == FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a!a!a!z!|l", 
&r_array, &w_array, &e_array, &sec, &usec) == FAILURE) {
                return;
+       }
 
        FD_ZERO(&rfds);
        FD_ZERO(&wfds);
@@ -665,15 +676,16 @@
 }
 /* }}} */
 
-/* {{{ proto resource socket_create_listen(int port[, int backlog])
+/* {{{ proto resource socket_create_listen(int port[, int backlog]) U
    Opens a socket on port to accept connections */
 PHP_FUNCTION(socket_create_listen)
 {
        php_socket      *php_sock;
        long            port, backlog = 128;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &port, 
&backlog) == FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &port, 
&backlog) == FAILURE) {
                return;
+       }
 
        if (!php_open_listen_sock(&php_sock, port, backlog TSRMLS_CC)) {
                RETURN_FALSE;
@@ -685,7 +697,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource socket_accept(resource socket)
+/* {{{ proto resource socket_accept(resource socket) U
    Accepts a connection on the listening socket fd */
 PHP_FUNCTION(socket_accept)
 {
@@ -693,8 +705,9 @@
        php_socket                      *php_sock, *new_sock;
        struct sockaddr_in      sa;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == 
FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == 
FAILURE) {
                return;
+       }
 
        ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, 
le_socket);
        
@@ -708,7 +721,7 @@
 }
 /* }}} */
 
-/* {{{ proto bool socket_set_nonblock(resource socket)
+/* {{{ proto bool socket_set_nonblock(resource socket) U
    Sets nonblocking mode on a socket resource */
 PHP_FUNCTION(socket_set_nonblock)
 {
@@ -716,8 +729,9 @@
        php_socket      *php_sock;
        int                     flags;
    
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == 
FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == 
FAILURE) {
                return;
+       }
        
        ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, 
le_socket);
        
@@ -737,7 +751,7 @@
 }
 /* }}} */
 
-/* {{{ proto bool socket_set_block(resource socket)
+/* {{{ proto bool socket_set_block(resource socket) U
    Sets blocking mode on a socket resource */
 PHP_FUNCTION(socket_set_block)
 {
@@ -745,8 +759,9 @@
        php_socket      *php_sock;
        int                     flags;
    
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == 
FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == 
FAILURE) {
                return;
+       }
        
        ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, 
le_socket);
        
@@ -766,16 +781,17 @@
 }
 /* }}} */
 
-/* {{{ proto bool socket_listen(resource socket[, int backlog])
+/* {{{ proto bool socket_listen(resource socket[, int backlog]) U
    Sets the maximum number of connections allowed to be waited for on the 
socket specified by fd */
 PHP_FUNCTION(socket_listen)
 {
        zval            *arg1;
        php_socket      *php_sock;
-       long                    backlog = 0;
+       long            backlog = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &arg1, 
&backlog) == FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &arg1, 
&backlog) == FAILURE) {
                return;
+       }
 
        ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, 
le_socket);
 
@@ -788,15 +804,16 @@
 }
 /* }}} */
 
-/* {{{ proto void socket_close(resource socket)
+/* {{{ proto void socket_close(resource socket) U
    Closes a file descriptor */
 PHP_FUNCTION(socket_close)
 {
        zval            *arg1;
        php_socket      *php_sock;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == 
FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == 
FAILURE) {
                return;
+       }
 
        ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, 
le_socket);
        zend_list_delete(Z_RESVAL_P(arg1));
@@ -810,11 +827,12 @@
        zval            *arg1;
        php_socket      *php_sock;
        int                     retval, str_len;
-       long                    length;
+       long            length;
        char            *str;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &arg1, 
&str, &str_len, &length) == FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &arg1, 
&str, &str_len, &length) == FAILURE) {
                return;
+       }
 
        ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, 
le_socket);
 
@@ -837,7 +855,7 @@
 }
 /* }}} */
 
-/* {{{ proto string socket_read(resource socket, int length [, int type])
+/* {{{ proto string socket_read(resource socket, int length [, int type]) U
    Reads a maximum of length bytes from socket */
 PHP_FUNCTION(socket_read)
 {
@@ -847,8 +865,9 @@
        int                     retval;
        long                    length, type = PHP_BINARY_READ;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &arg1, 
&length, &type) == FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|l", &arg1, 
&length, &type) == FAILURE) {
                return;
+       }
 
        /* overflow check */
        if ((length + 1) < 2) {
@@ -907,8 +926,9 @@
        char                                    *addr_string;
        socklen_t                               salen = 
sizeof(php_sockaddr_storage);
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|z", &arg1, 
&addr, &port) == FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|z", &arg1, 
&addr, &port) == FAILURE) {
                return;
+       }
 
        ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, 
le_socket);
 
@@ -983,8 +1003,9 @@
        char                                    *addr_string;
        socklen_t                               salen = 
sizeof(php_sockaddr_storage);
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|z", &arg1, 
&arg2, &arg3) == FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|z", &arg1, 
&arg2, &arg3) == FAILURE) {
                return;
+       }
 
        ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, 
le_socket);
 
@@ -1044,7 +1065,7 @@
 }
 /* }}} */
 
-/* {{{ proto resource socket_create(int domain, int type, int protocol)
+/* {{{ proto resource socket_create(int domain, int type, int protocol) U
    Creates an endpoint for communication in the domain specified by domain, of 
type specified by type */
 PHP_FUNCTION(socket_create)
 {
@@ -1102,8 +1123,9 @@
        long                            port;
        int                                     argc = ZEND_NUM_ARGS();
 
-       if (zend_parse_parameters(argc TSRMLS_CC, "rs|l", &arg1, &addr, 
&addr_len, &port) == FAILURE)
+       if (zend_parse_parameters(argc TSRMLS_CC, "rs|l", &arg1, &addr, 
&addr_len, &port) == FAILURE) {
                return;
+       }
 
        ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, 
le_socket);
 
@@ -1167,8 +1189,9 @@
 {
        long    arg1;
        
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &arg1) == 
FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &arg1) == 
FAILURE) {
                return;
+       }
 
        RETURN_STRING(php_strerror(arg1 TSRMLS_CC), 1);
 }
@@ -1187,8 +1210,9 @@
        long                                            port = 0;
        long                                    retval = 0;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &arg1, 
&addr, &addr_len, &port) == FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &arg1, 
&addr, &addr_len, &port) == FAILURE) {
                return;
+       }
 
        ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, 
le_socket);
        
@@ -1261,8 +1285,9 @@
        int                     retval;
        long                    len, flags;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rzll", 
&php_sock_res, &buf, &len, &flags) == FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rzll", 
&php_sock_res, &buf, &len, &flags) == FAILURE) {
                return;
+       }
 
        ZEND_FETCH_RESOURCE(php_sock, php_socket *, &php_sock_res, -1, 
le_socket_name, le_socket);
 
@@ -1309,8 +1334,9 @@
        long                    len, flags;
        char            *buf;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsll", &arg1, 
&buf, &buf_len, &len, &flags) == FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsll", &arg1, 
&buf, &buf_len, &len, &flags) == FAILURE) {
                return;
+       }
 
        ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, 
le_socket);
 
@@ -1342,8 +1368,9 @@
        long                                    arg3, arg4;
        char                            *recv_buf, *address;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rzllz|z", &arg1, 
&arg2, &arg3, &arg4, &arg5, &arg6) == FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rzllz|z", &arg1, 
&arg2, &arg3, &arg4, &arg5, &arg6) == FAILURE) {
                return;
+       }
 
        ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, 
le_socket);
 
@@ -1455,8 +1482,9 @@
        char                            *buf, *addr;
        int                                     argc = ZEND_NUM_ARGS();
 
-       if (zend_parse_parameters(argc TSRMLS_CC, "rslls|l", &arg1, &buf, 
&buf_len, &len, &flags, &addr, &addr_len, &port) == FAILURE)
+       if (zend_parse_parameters(argc TSRMLS_CC, "rslls|l", &arg1, &buf, 
&buf_len, &len, &flags, &addr, &addr_len, &port) == FAILURE) {
                return;
+       }
 
        ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, 
le_socket);
 
@@ -1516,7 +1544,7 @@
 }
 /* }}} */
 
-/* {{{ proto mixed socket_get_option(resource socket, int level, int optname)
+/* {{{ proto mixed socket_get_option(resource socket, int level, int optname) U
    Gets socket options for the socket */
 PHP_FUNCTION(socket_get_option)
 {
@@ -1531,8 +1559,9 @@
        int                             other_val;
        long                            level, optname;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll", &arg1, 
&level, &optname) == FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll", &arg1, 
&level, &optname) == FAILURE) {
                return;
+       }
 
        ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, 
le_socket);
        
@@ -1617,8 +1646,9 @@
        char                    *sec_key = "sec";
        char                    *usec_key = "usec";
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllZ", &arg1, 
&level, &optname, &arg4) == FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllZ", &arg1, 
&level, &optname, &arg4) == FAILURE) {
                return;
+       }
 
        ZEND_FETCH_RESOURCE(php_sock, php_socket *, &arg1, -1, le_socket_name, 
le_socket);
 
@@ -1694,7 +1724,7 @@
 }
 /* }}} */
 
-/* {{{ proto bool socket_create_pair(int domain, int type, int protocol, array 
&fd)
+/* {{{ proto bool socket_create_pair(int domain, int type, int protocol, array 
&fd) U
    Creates a pair of indistinguishable sockets and stores them in fds. */
 PHP_FUNCTION(socket_create_pair)
 {
@@ -1703,8 +1733,9 @@
        PHP_SOCKET              fds_array[2];
        long                    domain, type, protocol;
        
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lllz", &domain, 
&type, &protocol, &fds_array_zval) == FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lllz", &domain, 
&type, &protocol, &fds_array_zval) == FAILURE) {
                return;
+       }
 
        php_sock[0] = (php_socket*)emalloc(sizeof(php_socket));
        php_sock[1] = (php_socket*)emalloc(sizeof(php_socket));
@@ -1754,7 +1785,7 @@
 }
 /* }}} */
 
-/* {{{ proto bool socket_shutdown(resource socket[, int how])
+/* {{{ proto bool socket_shutdown(resource socket[, int how]) U
    Shuts down a socket for receiving, sending, or both. */
 PHP_FUNCTION(socket_shutdown)
 {
@@ -1762,8 +1793,9 @@
        long                    how_shutdown = 2;
        php_socket      *php_sock;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &arg1, 
&how_shutdown) == FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r|l", &arg1, 
&how_shutdown) == FAILURE) {
                return;
+       }
 
        ZEND_FETCH_RESOURCE(php_sock, php_socket*, &arg1, -1, le_socket_name, 
le_socket);
        
@@ -1776,15 +1808,16 @@
 }
 /* }}} */
 
-/* {{{ proto int socket_last_error([resource socket])
+/* {{{ proto int socket_last_error([resource socket]) U
    Returns the last socket error (either the last used or the provided socket 
resource) */
 PHP_FUNCTION(socket_last_error)
 {
        zval            *arg1 = NULL;
        php_socket      *php_sock;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &arg1) == 
FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &arg1) == 
FAILURE) {
                return;
+       }
 
        if (arg1) {
                ZEND_FETCH_RESOURCE(php_sock, php_socket*, &arg1, -1, 
le_socket_name, le_socket);
@@ -1795,15 +1828,16 @@
 }
 /* }}} */
 
-/* {{{ proto void socket_clear_error([resource socket])
+/* {{{ proto void socket_clear_error([resource socket]) U
    Clears the error on the socket or the last error code. */
 PHP_FUNCTION(socket_clear_error)
 {
        zval            *arg1 = NULL;
        php_socket      *php_sock;
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &arg1) == 
FAILURE)
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &arg1) == 
FAILURE) {
                return;
+       }
 
        if (arg1) {
                ZEND_FETCH_RESOURCE(php_sock, php_socket*, &arg1, -1, 
le_socket_name, le_socket);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to