]> granicus.if.org Git - php/commitdiff
Fix TSRMLS_* and a few warnings
authorBob Weinand <bobwei9@hotmail.com>
Sun, 19 Oct 2014 19:20:43 +0000 (21:20 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Sun, 19 Oct 2014 19:20:43 +0000 (21:20 +0200)
phpdbg.c
phpdbg.h
phpdbg_io.c
phpdbg_io.h
phpdbg_utils.c
phpdbg_utils.h

index 72582ceeac794a802156b5ae0beb26b3eeb77732..71def1dd52e85e9456ad3a19efbd2fc71829c5f5 100644 (file)
--- a/phpdbg.c
+++ b/phpdbg.c
@@ -28,6 +28,7 @@
 #include "phpdbg_list.h"
 #include "phpdbg_utils.h"
 #include "phpdbg_set.h"
+#include "phpdbg_io.h"
 #include "zend_alloc.h"
 
 /* {{{ remote console headers */
@@ -793,7 +794,7 @@ static void phpdbg_remote_close(int socket, FILE *stream) {
 }
 
 /* don't inline this, want to debug it easily, will inline when done */
-static int phpdbg_remote_init(const char* address, unsigned short port, int server, int *socket, FILE **stream) {
+static int phpdbg_remote_init(const char* address, unsigned short port, int server, int *socket, FILE **stream TSRMLS_DC) {
        phpdbg_remote_close(*socket, *stream);
 
        if (server < 0) {
@@ -1255,8 +1256,8 @@ phpdbg_main:
 
        /* setup remote server if necessary */
        if (!cleaning && listen > 0) {
-               server = phpdbg_open_socket(address, listen);
-               if (-1 > server || phpdbg_remote_init(address, listen, server, &socket, &stream) == FAILURE) {
+               server = phpdbg_open_socket(address, listen TSRMLS_CC);
+               if (-1 > server || phpdbg_remote_init(address, listen, server, &socket, &stream TSRMLS_CC) == FAILURE) {
                        exit(0);
                }
 
@@ -1462,7 +1463,7 @@ phpdbg_interact:
                                        
                                                if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) {
                                                        /* renegociate connections */
-                                                       phpdbg_remote_init(address, listen, server, &socket, &stream);
+                                                       phpdbg_remote_init(address, listen, server, &socket, &stream TSRMLS_CC);
                                
                                                        /* set streams */
                                                        if (stream) {
index fc9944111eb0cb5c373b685eba9488505ee4315f..2cb73ff43fa941c23b859b20adf738e82f7e3ed6 100644 (file)
--- a/phpdbg.h
+++ b/phpdbg.h
 #include "zend_ini_scanner.h"
 #include "zend_stream.h"
 #ifndef _WIN32
-# include "zend_signal.h"
+#      include "zend_signal.h"
 #endif
 #include "SAPI.h"
 #include <fcntl.h>
 #include <sys/types.h>
 #if defined(_WIN32) && !defined(__MINGW32__)
-# include <windows.h>
-# include "config.w32.h"
-# undef  strcasecmp
-# undef  strncasecmp
-# define strcasecmp _stricmp 
-# define strncasecmp _strnicmp 
+#      include <windows.h>
+#      include "config.w32.h"
+#      undef  strcasecmp
+#      undef  strncasecmp
+#      define strcasecmp _stricmp 
+#      define strncasecmp _strnicmp 
 #else
-# include "php_config.h"
+#      include "php_config.h"
 #endif
 #ifndef O_BINARY
 #      define O_BINARY 0
 #endif
 
 #ifdef HAVE_LIBREADLINE
-#   include <readline/readline.h>
-#   include <readline/history.h>
+#      include <readline/readline.h>
+#      include <readline/history.h>
 #endif
 #ifdef HAVE_LIBEDIT
-#   include <editline/readline.h>
+#      include <editline/readline.h>
 #endif
 
 /* {{{ remote console headers */
@@ -78,6 +78,7 @@
 #      include <sys/un.h>
 #      include <sys/select.h>
 #      include <sys/types.h>
+#      include <netdb.h>
 #endif /* }}} */
 
 /* {{{ strings */
index 437e3ec3af3d55e1e62edf0572e486dc44a50ebd..79fd55957dfef05a001f4182c2876abecdb264cf 100644 (file)
 ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
 
 
-PHPDBG_API int
-phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo)
-{/*{{{*/
+PHPDBG_API int phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo TSRMLS_DC) {
        int got_now, i = len, j;
        char *p = ptr;
 #ifndef PHP_WIN32
        struct pollfd pfd;
-       TSRMLS_FETCH();
 
        if (tmo < 0) goto recv_once;
        pfd.fd = sock;
@@ -70,7 +67,6 @@ phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo)
 #else
        struct fd_set readfds;
        struct timeval ttmo;
-       TSRMLS_FETCH();
 
        if (tmo < 0) goto recv_once;
        FD_ZERO(&readfds);
@@ -105,11 +101,9 @@ recv_once:
        }
 
        return p - ptr;
-}/*}}}*/
+}
 
-PHPDBG_API int
-phpdbg_send_bytes(int sock, char *ptr, int len)
-{/*{{{*/
+PHPDBG_API int phpdbg_send_bytes(int sock, const char *ptr, int len) {
        int sent, i = len;
        char *p = ptr;
 /* XXX poll/select needed here? */
@@ -123,36 +117,30 @@ phpdbg_send_bytes(int sock, char *ptr, int len)
        }
 
        return len;
-}/*}}}*/
+}
 
 
-PHPDBG_API int
-phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_CC)
-{/*{{{*/
+PHPDBG_API int phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_DC) {
        if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) {
-               return phpdbg_consume_bytes(sock, ptr, len, tmo);
+               return phpdbg_consume_bytes(sock, ptr, len, tmo TSRMLS_CC);
        }
 
        return read(sock, ptr, len);
-}/*}}}*/
+}
 
 
-PHPDBG_API int
-phpdbg_mixed_write(int sock, char *ptr, int len TSRMLS_CC)
-{/*{{{*/
+PHPDBG_API int phpdbg_mixed_write(int sock, const char *ptr, int len TSRMLS_DC) {
        if (PHPDBG_G(flags) & PHPDBG_IS_REMOTE) {
                return phpdbg_send_bytes(sock, ptr, len);
        }
 
        return write(sock, ptr, len);
-}/*}}}*/
+}
 
 
-PHPDBG_API int
-phpdbg_open_socket(const char *interface, short port) /* {{{ */
-{
+PHPDBG_API int phpdbg_open_socket(const char *interface, short port TSRMLS_DC) {
        struct addrinfo res;
-       int fd = phpdbg_create_listenable_socket(interface, port, &res);
+       int fd = phpdbg_create_listenable_socket(interface, port, &res TSRMLS_CC);
 
        if (fd == -1) {
                return -1;
@@ -166,19 +154,16 @@ phpdbg_open_socket(const char *interface, short port) /* {{{ */
        listen(fd, 5);
 
        return fd;
-} /* }}} */
+}
 
 
-PHPDBG_API int
-phpdbg_create_listenable_socket(const char *addr, int port, struct addrinfo *addr_res)
-{/*{{{*/
+PHPDBG_API int phpdbg_create_listenable_socket(const char *addr, int port, struct addrinfo *addr_res TSRMLS_DC) {
        int sock = -1, rc;
        int reuse = 1;
        struct in6_addr serveraddr;
        struct addrinfo hints, *res = NULL;
        char port_buf[8];
        int8_t any_addr = *addr == '*';
-       TSRMLS_FETCH();
 
        do {
                memset(&hints, 0, sizeof hints);
@@ -263,11 +248,9 @@ phpdbg_create_listenable_socket(const char *addr, int port, struct addrinfo *add
        *addr_res = *res;
 
        return sock;
-}/*}}}*/
+}
 
-PHPDBG_API void
-phpdbg_close_socket(int sock)
-{
+PHPDBG_API void phpdbg_close_socket(int sock) {
        if (socket >= 0) {
 #ifdef _WIN32
                closesocket(sock);
index 1edfe73662b8e22516a6600b78377a139f11aad3..4d1b74044b995f9ae09815468326e87da2bc9569 100644 (file)
 
 #include "phpdbg.h"
 
-PHPDBG_API int
-phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo);
-
-PHPDBG_API int
-phpdbg_send_bytes(int sock, char *ptr, int len);
-
-PHPDBG_API int
-phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_CC);
-
-PHPDBG_API int
-phpdbg_mixed_write(int sock, char *ptr, int len TSRMLS_CC);
-
-PHPDBG_API int
-phpdbg_create_listenable_socket(const char *addr, int port, struct addrinfo *res);
-
-PHPDBG_API int
-phpdbg_open_socket(const char *interface, short port); 
-
-PHPDBG_API void
-phpdbg_close_socket(int sock);
+PHPDBG_API int phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo TSRMLS_DC);
+PHPDBG_API int phpdbg_send_bytes(int sock, const char *ptr, int len);
+PHPDBG_API int phpdbg_mixed_read(int sock, char *ptr, int len, int tmo TSRMLS_DC);
+PHPDBG_API int phpdbg_mixed_write(int sock, const char *ptr, int len TSRMLS_DC);
+
+PHPDBG_API int phpdbg_create_listenable_socket(const char *addr, int port, struct addrinfo *res TSRMLS_DC);
+PHPDBG_API int phpdbg_open_socket(const char *interface, short port TSRMLS_DC);
+PHPDBG_API void phpdbg_close_socket(int sock);
 
 #endif /* PHPDBG_IO_H */
 
index 4a45642a4d71c7010c1aace3352b9901230e8581..0768726e6e16285814f8fd15ea9d545126fde789 100644 (file)
@@ -1129,7 +1129,7 @@ static int phpdbg_process_print(int fd, int type, const char *tag, const char *m
        const char *severity;
 
        if ((PHPDBG_G(flags) & PHPDBG_WRITE_XML) && PHPDBG_G(in_script_xml) && PHPDBG_G(in_script_xml) != type) {
-               phpdbg_mixed_write(fd, ZEND_STRL("</stream>"));
+               phpdbg_mixed_write(fd, ZEND_STRL("</stream>") TSRMLS_CC);
                PHPDBG_G(in_script_xml) = 0;
        }
 
@@ -1140,9 +1140,9 @@ static int phpdbg_process_print(int fd, int type, const char *tag, const char *m
                        severity = "error";
                        if (!PHPDBG_G(last_was_newline)) {
                                if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) {
-                                       phpdbg_mixed_write(fd, ZEND_STRL("<phpdbg>\n" "</phpdbg>"));
+                                       phpdbg_mixed_write(fd, ZEND_STRL("<phpdbg>\n" "</phpdbg>") TSRMLS_CC);
                                } else {
-                                       phpdbg_mixed_write(fd, ZEND_STRL("\n"));
+                                       phpdbg_mixed_write(fd, ZEND_STRL("\n") TSRMLS_CC);
                                }
                                PHPDBG_G(last_was_newline) = 1;
                        }
@@ -1157,9 +1157,9 @@ static int phpdbg_process_print(int fd, int type, const char *tag, const char *m
                        severity = "notice";
                        if (!PHPDBG_G(last_was_newline)) {
                                if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) {
-                                       phpdbg_mixed_write(fd, ZEND_STRL("<phpdbg>\n" "</phpdbg>"));
+                                       phpdbg_mixed_write(fd, ZEND_STRL("<phpdbg>\n" "</phpdbg>") TSRMLS_CC);
                                } else {
-                                       phpdbg_mixed_write(fd, ZEND_STRL("\n"));
+                                       phpdbg_mixed_write(fd, ZEND_STRL("\n") TSRMLS_CC);
                                }
                                PHPDBG_G(last_was_newline) = 1;
                        }
@@ -1201,16 +1201,16 @@ static int phpdbg_process_print(int fd, int type, const char *tag, const char *m
                                        if (PHPDBG_G(in_script_xml) != type) {
                                                char *stream_buf;
                                                int stream_buflen = spprintf(&stream_buf, 0, "<stream type=\"%s\">", type == P_STDERR ? "stderr" : "stdout");
-                                               phpdbg_mixed_write(fd, stream_buf, stream_buflen);
+                                               phpdbg_mixed_write(fd, stream_buf, stream_buflen TSRMLS_CC);
                                                efree(stream_buf);
                                                PHPDBG_G(in_script_xml) = type;
                                        }
                                        buf = php_escape_html_entities((unsigned char *) msg, msglen, (size_t *) &buflen, 0, ENT_NOQUOTES, PG(internal_encoding) && PG(internal_encoding)[0] ? PG(internal_encoding) : (SG(default_charset) ? SG(default_charset) : "UTF-8") TSRMLS_CC);
                                        phpdbg_encode_ctrl_chars(&buf, &buflen);
-                                       phpdbg_mixed_write(fd, buf, buflen);
+                                       phpdbg_mixed_write(fd, buf, buflen TSRMLS_CC);
                                        efree(buf);
                                } else {
-                                       phpdbg_mixed_write(fd, msg, msglen);
+                                       phpdbg_mixed_write(fd, msg, msglen TSRMLS_CC);
                                }
                                return msglen;
                        }
@@ -1239,8 +1239,6 @@ static int phpdbg_process_print(int fd, int type, const char *tag, const char *m
                        xml = xmlbuf;
                }
                if (msgout) {
-//                     unsigned char *tmp = msgout;
-//                     buf = php_escape_html_entities(tmp, msgoutlen, (size_t *) &buflen, 0, ENT_COMPAT, PG(internal_encoding) && PG(internal_encoding)[0] ? PG(internal_encoding) : (SG(default_charset) ? SG(default_charset) : "UTF-8") TSRMLS_CC);
                        buflen = phpdbg_encode_xml(&buf, msgout, msgoutlen, '"', "&quot;");
                        xmloutlen = spprintf(&xmlout, 0, "<%s severity=\"%s\" %.*s msgout=\"%.*s\" />", tag, severity, xmllen, xml, buflen, buf);
 
@@ -1250,10 +1248,10 @@ static int phpdbg_process_print(int fd, int type, const char *tag, const char *m
                }
 
                phpdbg_encode_ctrl_chars(&xmlout, &xmloutlen);
-               phpdbg_mixed_write(fd, xmlout, xmloutlen);
+               phpdbg_mixed_write(fd, xmlout, xmloutlen TSRMLS_CC);
                efree(xmlout);
        } else if (msgout) {
-               phpdbg_mixed_write(fd, msgout, msgoutlen);
+               phpdbg_mixed_write(fd, msgout, msgoutlen TSRMLS_CC);
        }
 
        if (PHPDBG_G(req_id) && (PHPDBG_G(flags) & PHPDBG_WRITE_XML)) {
@@ -1381,11 +1379,11 @@ PHPDBG_API int phpdbg_xml_internal(int fd TSRMLS_DC, const char *fmt, ...) {
                phpdbg_encode_ctrl_chars(&buffer, &buflen);
 
                if (PHPDBG_G(in_script_xml)) {
-                       phpdbg_mixed_write(fd, ZEND_STRL("</stream>"));
+                       phpdbg_mixed_write(fd, ZEND_STRL("</stream>") TSRMLS_CC);
                        PHPDBG_G(in_script_xml) = 0;
                }
 
-               len = phpdbg_mixed_write(fd, buffer, buflen);
+               len = phpdbg_mixed_write(fd, buffer, buflen TSRMLS_CC);
                efree(buffer);
        }
 
@@ -1402,7 +1400,7 @@ PHPDBG_API int phpdbg_log_internal(int fd TSRMLS_DC, const char *fmt, ...) {
        buflen = vspprintf(&buffer, 0, fmt, args);
        va_end(args);
 
-       len = phpdbg_mixed_write(fd, buffer, buflen);
+       len = phpdbg_mixed_write(fd, buffer, buflen TSRMLS_CC);
        efree(buffer);
 
        return len;
@@ -1426,22 +1424,22 @@ PHPDBG_API int phpdbg_out_internal(int fd TSRMLS_DC, const char *fmt, ...) {
                phpdbg_encode_ctrl_chars(&msg, &msglen);
 
                if (PHPDBG_G(in_script_xml)) {
-                       phpdbg_mixed_write(fd, ZEND_STRL("</stream>"));
+                       phpdbg_mixed_write(fd, ZEND_STRL("</stream>") TSRMLS_CC);
                        PHPDBG_G(in_script_xml) = 0;
                }
 
-               phpdbg_mixed_write(fd, ZEND_STRL("<phpdbg>"));
-               len = phpdbg_mixed_write(fd, msg, msglen);
-               phpdbg_mixed_write(fd, ZEND_STRL("</phpdbg>"));
+               phpdbg_mixed_write(fd, ZEND_STRL("<phpdbg>") TSRMLS_CC);
+               len = phpdbg_mixed_write(fd, msg, msglen TSRMLS_CC);
+               phpdbg_mixed_write(fd, ZEND_STRL("</phpdbg>") TSRMLS_CC);
        } else {
-               len = phpdbg_mixed_write(fd, buffer, buflen);
+               len = phpdbg_mixed_write(fd, buffer, buflen TSRMLS_CC);
        }
 
        return len;
 }
 
 
-PHPDBG_API int phpdbg_rlog(int fd, const char *fmt, ...) { /* {{{ */
+PHPDBG_API int phpdbg_rlog_internal(int fd TSRMLS_DC, const char *fmt, ...) { /* {{{ */
        int rc = 0;
 
        va_list args;
@@ -1463,7 +1461,7 @@ PHPDBG_API int phpdbg_rlog(int fd, const char *fmt, ...) { /* {{{ */
                rc = vspprintf(&outbuf, 0, format, args);
 
                if (outbuf) {
-                       rc = phpdbg_mixed_write(fd, outbuf, rc);
+                       rc = phpdbg_mixed_write(fd, outbuf, rc TSRMLS_CC);
                        efree(outbuf);
                }
 
index 0a677b40c69d864806473211112440a404dcd9d0..cee39c4879f2b424625669e3096ccd5a9c6bb34c 100644 (file)
@@ -56,7 +56,8 @@ PHPDBG_API int phpdbg_xml_internal(int fd TSRMLS_DC, const char *fmt, ...);
 PHPDBG_API int phpdbg_log_internal(int fd TSRMLS_DC, const char *fmt, ...);
 PHPDBG_API int phpdbg_out_internal(int fd TSRMLS_DC, const char *fmt, ...);
 
-PHPDBG_API int phpdbg_rlog(int fd, const char *fmt, ...);
+PHPDBG_API int phpdbg_rlog_internal(int fd TSRMLS_DC, const char *fmt, ...);
+#define phpdbg_rlog(fd, fmt, ...) phpdbg_rlog_internal(fd TSRMLS_CC, fmt, ##__VA_ARGS__)
 
 #define phpdbg_error(tag, xmlfmt, strfmt, ...)              phpdbg_print(P_ERROR   TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT].fd, tag,  xmlfmt, strfmt, ##__VA_ARGS__)
 #define phpdbg_notice(tag, xmlfmt, strfmt, ...)             phpdbg_print(P_NOTICE  TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT].fd, tag,  xmlfmt, strfmt, ##__VA_ARGS__)