Skip to content

Commit 09eeaf8

Browse files
committed
Fix symbol conflicts
1 parent 925ddfe commit 09eeaf8

File tree

5 files changed

+77
-6
lines changed

5 files changed

+77
-6
lines changed

config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ if test "$PHP_ZOOKEEPER" != "no"; then
108108

109109
AC_DEFINE(THREADED,1,[Must define this constant after zookeeper-3.5.0 to use multi-threaded library])
110110
PHP_SUBST(ZOOKEEPER_SHARED_LIBADD)
111-
PHP_NEW_EXTENSION(zookeeper, php_zookeeper.c zoo_lock.c $SESSION_EXTRA_FILES php_zookeeper_exceptions.c php_zookeeper_config_class.c php_zookeeper_stat.c php_zookeeper_callback.c, $ext_shared,,$SESSION_INCLUDES)
111+
PHP_NEW_EXTENSION(zookeeper, php_zookeeper.c zoo_lock.c $SESSION_EXTRA_FILES php_zookeeper_exceptions.c php_zookeeper_config_class.c php_zookeeper_stat.c php_zookeeper_callback.c php_zookeeper_log.c, $ext_shared,,$SESSION_INCLUDES)
112112

113113
fi
114114

php_zookeeper.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
#include "php_zookeeper_config_class.h"
5555
#include "php_zookeeper_stat.h"
5656
#include "php_zookeeper_callback.h"
57-
#include "zookeeper34to35.h"
57+
#include "php_zookeeper_log.h"
5858

5959
/****************************************
6060
Helper macros
@@ -396,7 +396,7 @@ static PHP_METHOD(Zookeeper, get)
396396
RETURN_NULL();
397397
}
398398

399-
PHP_ZK_LOG_INFO(i_obj->zk, "path=%s, cb_data=%p", path, cb_data);
399+
php_zk_log_info(i_obj->zk, "path=%s, cb_data=%p", path, cb_data);
400400

401401
buffer = emalloc (length+1);
402402
status = zoo_wget(i_obj->zk, path, (fci.size != 0) ? php_zk_node_watcher_marshal : NULL,
@@ -1074,7 +1074,7 @@ static void php_zk_node_watcher_marshal(zhandle_t *zk, int type, int state, cons
10741074

10751075
void php_zk_watcher_marshal(zhandle_t *zk, int type, int state, const char *path, void *context)
10761076
{
1077-
PHP_ZK_LOG_DEBUG(zk, "type=%d, state=%d, path=%s, path(p)=%p, context=%p", type, state, path?path:"", path, context);
1077+
php_zk_log_debug(zk, "type=%d, state=%d, path=%s, path(p)=%p, context=%p", type, state, path?path:"", path, context);
10781078

10791079
php_cb_data_t *cb_data = context;
10801080

@@ -1120,7 +1120,7 @@ void php_zk_watcher_marshal(zhandle_t *zk, int type, int state, const char *path
11201120

11211121
static void php_zk_completion_marshal(int rc, const void *context)
11221122
{
1123-
PHP_ZK_LOG_DEBUG(NULL, "rc=%d, context=%p", rc, context);
1123+
php_zk_log_debug(NULL, "rc=%d, context=%p", rc, context);
11241124

11251125
php_cb_data_t *cb_data = (php_cb_data_t *)context;
11261126

php_zookeeper.h

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
#include <zookeeper.h>
2121
#include <zookeeper_version.h>
22-
#include <zookeeper_log.h>
2322
#include <php.h>
2423

2524
#ifdef HAVE_CONFIG_H

php_zookeeper_log.c

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| Copyright (c) 2010 The PHP Group |
4+
+----------------------------------------------------------------------+
5+
| This source file is subject to version 3.01 of the PHP license, |
6+
| that is bundled with this package in the file LICENSE, and is |
7+
| available through the world-wide-web at the following url: |
8+
| http://www.php.net/license/3_01.txt. |
9+
| If you did not receive a copy of the PHP license and are unable to |
10+
| obtain it through the world-wide-web, please send a note to |
11+
| [email protected] so we can mail you a copy immediately. |
12+
+----------------------------------------------------------------------+
13+
| Authors: Timandes White <[email protected]> |
14+
+----------------------------------------------------------------------+
15+
*/
16+
17+
#include <stdarg.h>
18+
#include <zookeeper.h>
19+
#include <zookeeper_log.h> /* Symbol LOG_INFO defined in this file conflicts with the symbol defined in syslog.h */
20+
#include "php_zookeeper_log.h"
21+
22+
#if ZOO_MAJOR_VERSION>=3 && ZOO_MINOR_VERSION>=5
23+
#define PHP_ZK_LOG_ERROR(_zh, ...) LOG_ERROR(LOGCALLBACK(_zh), __VA_ARGS__)
24+
#define PHP_ZK_LOG_WARN(_zh, ...) LOG_WARN(LOGCALLBACK(_zh), __VA_ARGS__)
25+
#define PHP_ZK_LOG_INFO(_zh, ...) LOG_INFO(LOGCALLBACK(_zh), __VA_ARGS__)
26+
#define PHP_ZK_LOG_DEBUG(_zh, ...) LOG_DEBUG(LOGCALLBACK(_zh), __VA_ARGS__)
27+
#else
28+
#define PHP_ZK_LOG_ERROR(_zh, ...) LOG_ERROR((__VA_ARGS__))
29+
#define PHP_ZK_LOG_WARN(_zh, ...) LOG_WARN((__VA_ARGS__))
30+
#define PHP_ZK_LOG_INFO(_zh, ...) LOG_INFO((__VA_ARGS__))
31+
#define PHP_ZK_LOG_DEBUG(_zh, ...) LOG_DEBUG((__VA_ARGS__))
32+
#endif
33+
34+
#define PHP_ZK_LOG_FUNC(func, FUNC) \
35+
void php_zk_log_##func(zhandle_t *zh, ...) \
36+
{ \
37+
va_list msg; \
38+
va_start(msg, zh); \
39+
PHP_ZK_LOG_##FUNC(zh, msg); \
40+
va_end(msg); \
41+
}
42+
43+
44+
PHP_ZK_LOG_FUNC(error, ERROR)
45+
PHP_ZK_LOG_FUNC(warn, WARN)
46+
PHP_ZK_LOG_FUNC(info, INFO)
47+
PHP_ZK_LOG_FUNC(debug, DEBUG)

php_zookeeper_log.h

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
+----------------------------------------------------------------------+
3+
| Copyright (c) 2010 The PHP Group |
4+
+----------------------------------------------------------------------+
5+
| This source file is subject to version 3.01 of the PHP license, |
6+
| that is bundled with this package in the file LICENSE, and is |
7+
| available through the world-wide-web at the following url: |
8+
| http://www.php.net/license/3_01.txt. |
9+
| If you did not receive a copy of the PHP license and are unable to |
10+
| obtain it through the world-wide-web, please send a note to |
11+
| [email protected] so we can mail you a copy immediately. |
12+
+----------------------------------------------------------------------+
13+
| Authors: Timandes White <[email protected]> |
14+
+----------------------------------------------------------------------+
15+
*/
16+
17+
#ifndef PHP_ZOOKEEPER_LOG_H
18+
#define PHP_ZOOKEEPER_LOG_H
19+
20+
void php_zk_log_error(zhandle_t *zh, ...);
21+
void php_zk_log_warn(zhandle_t *zh, ...);
22+
void php_zk_log_info(zhandle_t *zh, ...);
23+
void php_zk_log_debug(zhandle_t *zh, ...);
24+
25+
#endif /* PHP_ZOOKEEPER_LOG_H */

0 commit comments

Comments
 (0)