- PHP4, configure, ZTS, license fixes
authorMichael Wallner <mike@php.net>
Mon, 3 Apr 2006 13:52:37 +0000 (13:52 +0000)
committerMichael Wallner <mike@php.net>
Mon, 3 Apr 2006 13:52:37 +0000 (13:52 +0000)
- prepare release

ares.c
config.m4
package.xml
package2.xml
php_ares.h

diff --git a/ares.c b/ares.c
index 567039793af691b7fe44b2f3c6062c98e8856edc..6f0342b6e5340c02f97298a52ffed2a73d34e4af 100644 (file)
--- a/ares.c
+++ b/ares.c
@@ -1,19 +1,13 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 5                                                        |
-  +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2006 The PHP Group                                |
-  +----------------------------------------------------------------------+
-  | This source file is subject to version 3.01 of the PHP license,      |
-  | that is bundled with this package in the file LICENSE, and is        |
-  | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
-  | If you did not receive a copy of the PHP license and are unable to   |
-  | obtain it through the world-wide-web, please send a note to          |
-  | license@php.net so we can mail you a copy immediately.               |
-  +----------------------------------------------------------------------+
-  | Author:                                                              |
-  +----------------------------------------------------------------------+
+    +--------------------------------------------------------------------+
+    | PECL :: ares                                                       |
+    +--------------------------------------------------------------------+
+    | Redistribution and use in source and binary forms, with or without |
+    | modification, are permitted provided that the conditions mentioned |
+    | in the accompanying LICENSE file are met.                          |
+    +--------------------------------------------------------------------+
+    | Copyright (c) 2006, Michael Wallner <mike@php.net>                 |
+    +--------------------------------------------------------------------+
 */
 
 /* $Id$ */
 
 #ifndef ZEND_ENGINE_2
 #      define zend_is_callable(a,b,c) 1
+#      ifndef ZTS
+#              undef TSRMLS_SET_CTX
+#              define TSRMLS_SET_CTX
+#              undef TSRMLS_FETCH_FROM_CTX
+#              define TSRMLS_FETCH_FROM_CTX
+#      endif
 #endif
 
 #define PHP_ARES_LE_NAME "AsyncResolver"
 static int le_ares;
 static int le_ares_query;
 
-#define PHP_ARES_ERROR(err) \
+#ifdef HAVE_OLD_ARES_STRERROR
+#      define PHP_ARES_ERROR(err) { \
+       char *__tmp = NULL; \
+       php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ares_strerror(err, &__tmp)); \
+       if (__tmp) ares_free_errmem(__tmp); \
+}
+#else
+#      define PHP_ARES_ERROR(err) \
        php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", ares_strerror(err))
+#endif
+
 #define RETURN_ARES_ERROR(err) \
        PHP_ARES_ERROR(err); \
        RETURN_FALSE
@@ -76,7 +85,7 @@ typedef struct _php_ares {
        ares_channel channel;
        php_ares_options options;
        zend_llist queries;
-       TSRMLS_D;
+       void ***tsrm_ls;
        unsigned in_callback:1;
        unsigned reserved:31;
 } php_ares;
@@ -776,12 +785,24 @@ static PHP_FUNCTION(ares_destroy)
 static PHP_FUNCTION(ares_strerror)
 {
        long err;
+#ifdef HAVE_OLD_ARES_STRERROR
+       char *__tmp = NULL;
+       const char *__err;
+#endif
        
        if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &err)) {
                RETURN_FALSE;
        }
        
+#ifdef HAVE_OLD_ARES_STRERROR
+       __err = ares_strerror(err, &__tmp);
+       RETVAL_STRING(estrdup(__err), 0);
+       if (__tmp) {
+               ares_free_errmem(__tmp);
+       }
+#else
        RETURN_STRING(estrdup(ares_strerror(err)), 0);
+#endif
 }
 /* }}} */
 
@@ -1069,7 +1090,14 @@ static PHP_FUNCTION(ares_result)
                        break;
                default:
                        if (zerror) {
+#ifdef HAVE_OLD_ARES_STRERROR
+                               char *__tmp = NULL;
+                               const char *__err = ares_strerror(query->error, &__tmp);
+                               ZVAL_STRING(zerror, estrdup(__err), 0);
+                               if (__tmp) ares_free_errmem(__tmp);
+#else
                                ZVAL_STRING(zerror, estrdup(ares_strerror(query->error)), 0);
+#endif
                        }
                        RETVAL_FALSE;
                        break;
index 2acb051eaee8f21d4f1fde38ac1177a7bb7ea10d..46d96a37256a4240fed96d5bbe74f785ee49c1fb 100644 (file)
--- a/config.m4
+++ b/config.m4
@@ -3,8 +3,6 @@ dnl config.m4 for extension ares
 
 PHP_ARG_WITH(ares, for asynchronous resolver support,
 [  --with-ares             Include asynchronous resolver support])
-PHP_ARG_WITH(ares-lib, type of ares library (cares),
-[  --with-ares-lib         MIT/ares or CURL/cares], "cares", "cares")
 
 if test "$PHP_ARES" != "no"; then
        PHP_ARES_DIR=
@@ -20,28 +18,34 @@ if test "$PHP_ARES" != "no"; then
                AC_MSG_ERROR(could not find ares.h)
        fi
        
-       case "$PHP_ARES_LIB" in
-               MIT* [)]
-                       PHP_ARES_LIB=ares
-                       ;;
-               ares [)]
-                       ;;
-               CURL* [)]
+       PHP_ARES_LIB=
+       PHP_CHECK_LIBRARY(cares, ares_init, [
                        PHP_ARES_LIB=cares
-                       ;;
-               cares [)]
-                       ;;
-               * [)]
-                       PHP_ARES_LIB=cares
-                       ;;
-       esac
+               ], [
+                       PHP_CHECK_LIBRARY(ares, ares_init, [
+                                       PHP_ARES_LIB=ares
+                               ], [
+                                       PHP_ARES_LIB=unknown
+                               ], [
+                                       -L$PHP_ARES_DIR/$PHP_LIBDIR
+                               ]
+                       )
+               ], [
+                       -L$PHP_ARES_DIR/$PHP_LIBDIR
+               ]
+       )
+       AC_MSG_CHECKING(for libares/libcares)
+       AC_MSG_RESULT($PHP_ARES_LIB)
        
-       if test $PHP_ARES_LIB = "cares"; then
+       if test $PHP_ARES_LIB = "unknown"; then
+               AC_MSG_ERROR(could neither find libares nor libcares)
+       elif test $PHP_ARES_LIB = "cares"; then
                AC_DEFINE_UNQUOTED([PHP_ARES_LIBNAME], "c-ares (CURL)", [ ])
                AC_DEFINE([PHP_ARES_EXPAND_LEN_TYPE], [long], [ ])
        else
                AC_DEFINE_UNQUOTED([PHP_ARES_LIBNAME], "ares (MIT)", [ ])
                AC_DEFINE([PHP_ARES_EXPAND_LEN_TYPE], [int], [ ])
+               AC_DEFINE([HAVE_OLD_ARES_STRERROR], [1], [ ])
        fi
        
        PHP_CHECK_LIBRARY($PHP_ARES_LIB, ares_cancel, 
@@ -70,8 +74,10 @@ if test "$PHP_ARES" != "no"; then
        )
        
        AC_CHECK_HEADERS([netdb.h unistd.h arpa/inet.h arpa/nameser.h])
+       
        PHP_ADD_INCLUDE($PHP_ARES_DIR/include)
        PHP_ADD_LIBRARY_WITH_PATH($PHP_ARES_LIB, $PHP_ARES_DIR/$PHP_LIBDIR, ARES_SHARED_LIBADD)
+       
        PHP_SUBST(ARES_SHARED_LIBADD)
        PHP_NEW_EXTENSION(ares, ares.c, $ext_shared)
 fi
index 6a076bb8fd5a7f38803646347ef2594e298c75c3..6629871fa5ad49c8e06850b6c51dcd689069b3d7 100644 (file)
@@ -24,6 +24,9 @@
    <dep type="php" rel="ge" version="4.3"/>
    <dep type="php" rel="le" version="6.0"/>
   </deps>
+  <configureoptions>
+   <configureoption name="with-ares" default="yes" prompt="whether to enable asynchronous resolver support"/>
+  </configureoptions>
   <filelist>
    <dir name="tests">
     <file role="test" name="001.phpt"/>
@@ -34,6 +37,7 @@
    <file role="src" name="config.m4"/>
    <file role="doc" name="CREDITS"/>
    <file role="doc" name="EXPERIMENTAL"/>
+   <file role="doc" name="LICENSE"/>
    <file role="src" name="php_ares.h"/>
   </filelist>
  </release>
index c0b74867c582eb63b48bec13c00afcb72189e82d..1af328e40c023bcdfaef5e4da963c6025b5b13e8 100644 (file)
@@ -1,12 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<package 
+<package
                packagerversion="1.4.6" 
                version="2.0" 
                xmlns="http://pear.php.net/dtd/package-2.0" 
                xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
-                        http://pear.php.net/dtd/tasks-1.0.xsd
+                       http://pear.php.net/dtd/tasks-1.0.xsd
                        http://pear.php.net/dtd/package-2.0
                        http://pear.php.net/dtd/package-2.0.xsd">
  <name>ares</name>
@@ -21,8 +21,7 @@
   <email>mike@php.net</email>
   <active>yes</active>
  </lead>
- <date>2006-04-02</date>
- <time>12:07:07</time>
+ <date>2006-00-00</date>
  <version>
   <release>0.5.0</release>
   <api>0.5.0</api>
@@ -37,16 +36,17 @@ Initial PECL release
 ]]></notes>
  <contents>
   <dir name="/">
+   <file role="doc" name="CREDITS"/>
+   <file role="doc" name="EXPERIMENTAL"/>
+   <file role="doc" name="LICENSE"/>
+   <file role="src" name="config.m4"/>
+   <file role="src" name="ares.c"/>
+   <file role="src" name="php_ares.h"/>
    <dir name="tests">
-    <file name="001.phpt" role="test" />
-    <file name="002.phpt" role="test" />
-    <file name="003.phpt" role="test" />
+    <file role="test" name="001.phpt"/>
+    <file role="test" name="002.phpt"/>
+    <file role="test" name="003.phpt"/>
    </dir>
-   <file name="ares.c" role="src" />
-   <file name="config.m4" role="src" />
-   <file name="CREDITS" role="doc" />
-   <file name="EXPERIMENTAL" role="doc" />
-   <file name="php_ares.h" role="src" />
   </dir>
  </contents>
  <dependencies>
@@ -62,5 +62,7 @@ Initial PECL release
   </required>
  </dependencies>
  <providesextension>ares</providesextension>
- <extsrcrelease />
+ <extsrcrelease>
+  <configureoption name="with-ares" prompt="whether to enable asynchronous resolver support" default="yes"/>
+ </extsrcrelease>
 </package>
index b7c8228afdec9faf8f5587acff3f2b9a4d89ef66..04d374d9e1ea6af9485fab141c37290753bad88b 100644 (file)
@@ -1,19 +1,13 @@
 /*
-  +----------------------------------------------------------------------+
-  | PHP Version 5                                                        |
-  +----------------------------------------------------------------------+
-  | Copyright (c) 1997-2006 The PHP Group                                |
-  +----------------------------------------------------------------------+
-  | This source file is subject to version 3.01 of the PHP license,      |
-  | that is bundled with this package in the file LICENSE, and is        |
-  | available through the world-wide-web at the following url:           |
-  | http://www.php.net/license/3_01.txt                                  |
-  | If you did not receive a copy of the PHP license and are unable to   |
-  | obtain it through the world-wide-web, please send a note to          |
-  | license@php.net so we can mail you a copy immediately.               |
-  +----------------------------------------------------------------------+
-  | Author:                                                              |
-  +----------------------------------------------------------------------+
+    +--------------------------------------------------------------------+
+    | PECL :: ares                                                       |
+    +--------------------------------------------------------------------+
+    | Redistribution and use in source and binary forms, with or without |
+    | modification, are permitted provided that the conditions mentioned |
+    | in the accompanying LICENSE file are met.                          |
+    +--------------------------------------------------------------------+
+    | Copyright (c) 2006, Michael Wallner <mike@php.net>                 |
+    +--------------------------------------------------------------------+
 */
 
 /* $Id$ */