1346481f2cd7f3bda32d9a919153bf8c57dd5542
[feed/packages.git] / lang / php7 / patches / 1006-multiline-syslog.patch
1 commit f11d40ef88f640fe4764d2731d3061472aefe556
2 Author: Philip Prindeville <philipp@redfish-solutions.com>
3 Date: Wed Aug 9 20:55:25 2017 -0600
4
5 Turn php_syslog() into wrapper for syslog and split lines
6
7 diff --git a/Zend/zend_smart_string.h b/Zend/zend_smart_string.h
8 index 2282202..12d755e 100644
9 --- a/Zend/zend_smart_string.h
10 +++ b/Zend/zend_smart_string.h
11 @@ -136,6 +136,10 @@ static zend_always_inline void smart_string_setl(smart_string *dest, char *src,
12 dest->c = src;
13 }
14
15 +static zend_always_inline void smart_string_reset(smart_string *str) {
16 + str->len = 0;
17 +}
18 +
19 #endif
20
21 /*
22 diff --git a/configure.ac b/configure.ac
23 index cb95d86..a63354f 100644
24 --- a/configure.ac
25 +++ b/configure.ac
26 @@ -1443,7 +1443,7 @@ PHP_ADD_SOURCES(main, main.c snprintf.c spprintf.c php_sprintf.c \
27 php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
28 strlcat.c explicit_bzero.c mergesort.c reentrancy.c php_variables.c php_ticks.c \
29 network.c php_open_temporary_file.c \
30 - output.c getopt.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
31 + output.c getopt.c php_syslog.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
32
33 PHP_ADD_SOURCES_X(main, fastcgi.c, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1, PHP_FASTCGI_OBJS, no)
34
35 diff --git a/main/php_syslog.c b/main/php_syslog.c
36 new file mode 100644
37 index 0000000..c351951
38 --- /dev/null
39 +++ b/main/php_syslog.c
40 @@ -0,0 +1,81 @@
41 +/*
42 + +----------------------------------------------------------------------+
43 + | PHP Version 7 |
44 + +----------------------------------------------------------------------+
45 + | Copyright (c) 2017 The PHP Group |
46 + +----------------------------------------------------------------------+
47 + | This source file is subject to version 3.01 of the PHP license, |
48 + | that is bundled with this package in the file LICENSE, and is |
49 + | available through the world-wide-web at the following url: |
50 + | http://www.php.net/license/3_01.txt |
51 + | If you did not receive a copy of the PHP license and are unable to |
52 + | obtain it through the world-wide-web, please send a note to |
53 + | license@php.net so we can mail you a copy immediately. |
54 + +----------------------------------------------------------------------+
55 + | Author: Philip Prindeville <philipp@redfish-solutions.com> |
56 + +----------------------------------------------------------------------+
57 +*/
58 +
59 +/* $Id$ */
60 +
61 +#include <stdio.h>
62 +#include <string.h>
63 +#include <assert.h>
64 +#include <stdlib.h>
65 +#include "php.h"
66 +#include "php_syslog.h"
67 +
68 +#include "zend.h"
69 +#include "zend_smart_string.h"
70 +
71 +/*
72 + * The SCO OpenServer 5 Development System (not the UDK)
73 + * defines syslog to std_syslog.
74 + */
75 +
76 +#ifdef HAVE_STD_SYSLOG
77 +#define syslog std_syslog
78 +#endif
79 +
80 +PHPAPI void php_syslog(int priority, const char *format, ...) /* {{{ */
81 +{
82 + const char *ptr;
83 + unsigned char c;
84 + smart_string fbuf = {0};
85 + smart_string sbuf = {0};
86 + va_list args;
87 +
88 + va_start(args, format);
89 + zend_printf_to_smart_string(&fbuf, format, args);
90 + smart_string_0(&fbuf);
91 + va_end(args);
92 +
93 + for (ptr = fbuf.c; ; ++ptr) {
94 + c = *ptr;
95 + if (c == '\0') {
96 + syslog(priority, "%.*s", (int)sbuf.len, sbuf.c);
97 + break;
98 + }
99 +
100 + if (c != '\n')
101 + smart_string_appendc(&sbuf, c);
102 + else {
103 + syslog(priority, "%.*s", (int)sbuf.len, sbuf.c);
104 + smart_string_reset(&sbuf);
105 + }
106 + }
107 +
108 + smart_string_free(&fbuf);
109 + smart_string_free(&sbuf);
110 +}
111 +
112 +/* }}} */
113 +
114 +/*
115 + * Local variables:
116 + * tab-width: 4
117 + * c-basic-offset: 4
118 + * End:
119 + * vim600: sw=4 ts=4 fdm=marker
120 + * vim<600: sw=4 ts=4
121 + */
122 diff --git a/main/php_syslog.h b/main/php_syslog.h
123 index be68cc4..4c4ca4e 100644
124 --- a/main/php_syslog.h
125 +++ b/main/php_syslog.h
126 @@ -21,6 +21,8 @@
127 #ifndef PHP_SYSLOG_H
128 #define PHP_SYSLOG_H
129
130 +#include "php.h"
131 +
132 #ifdef PHP_WIN32
133 #include "win32/syslog.h"
134 #else
135 @@ -30,26 +32,12 @@
136 #endif
137 #endif
138
139 -/*
140 - * The SCO OpenServer 5 Development System (not the UDK)
141 - * defines syslog to std_syslog.
142 - */
143 -
144 -#ifdef syslog
145 -
146 -#ifdef HAVE_STD_SYSLOG
147 -#define php_syslog std_syslog
148 -#endif
149 -
150 -#undef syslog
151 +BEGIN_EXTERN_C()
152 +PHPAPI void php_syslog(int, const char *format, ...);
153 +END_EXTERN_C()
154
155 #endif
156
157 -#ifndef php_syslog
158 -#define php_syslog syslog
159 -#endif
160 -
161 -#endif
162 /*
163 * Local variables:
164 * tab-width: 4
165 diff --git a/win32/build/config.w32 b/win32/build/config.w32
166 index 6cbb18b..71cf491 100644
167 --- a/win32/build/config.w32
168 +++ b/win32/build/config.w32
169 @@ -244,7 +244,8 @@ ADD_FLAG("CFLAGS_BD_ZEND", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
170 ADD_SOURCES("main", "main.c snprintf.c spprintf.c getopt.c fopen_wrappers.c \
171 php_scandir.c php_ini.c SAPI.c rfc1867.c php_content_types.c strlcpy.c \
172 strlcat.c mergesort.c reentrancy.c php_variables.c php_ticks.c network.c \
173 - php_open_temporary_file.c output.c internal_functions.c php_sprintf.c");
174 + php_open_temporary_file.c output.c internal_functions.c php_sprintf.c \
175 + php_syslog.c");
176 ADD_FLAG("CFLAGS_BD_MAIN", "/D ZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
177
178 AC_DEFINE('HAVE_STRNLEN', 1);