]> granicus.if.org Git - php/commitdiff
* expanded the following constants and made them available in PHP:
authorStig Bakken <ssb@php.net>
Sun, 22 Apr 2001 01:09:14 +0000 (01:09 +0000)
committerStig Bakken <ssb@php.net>
Sun, 22 Apr 2001 01:09:14 +0000 (01:09 +0000)
  DEFAULT_INCLUDE_PATH
  PEAR_INSTALL_DIR
  PHP_EXTENSION_DIR
  PHP_BINDIR
  PHP_LIBDIR
  PHP_DATADIR
  PHP_SYSCONFDIR
  PHP_LOCALSTATEDIR
  PHP_CONFIG_FILE_PATH
* no longer generating pear/PEAR.php
* fixed some tests
* some more installer work

13 files changed:
Makefile.in
configure.in
ext/standard/info.c
footer
main/build-defs.h.in
main/main.c
main/php_ini.c
pear/Makefile.in
pear/PEAR.php [moved from pear/PEAR.php.in with 97% similarity]
pear/PEAR/Common.php [new file with mode: 0644]
pear/PEAR/Installer.php
pear/PEAR/Uploader.php [new file with mode: 0644]
pear/tests/pear_error.phpt

index 10096465082ad60221057d1d09005be0bd2bffff..0bb067c87d7d0d96fbaa7e1444dcd5cd6ea62605 100644 (file)
@@ -50,7 +50,13 @@ install-modules:
        rm -f modules/*.la && \
        cp modules/* $(INSTALL_ROOT)$(moduledir) >/dev/null 2>&1 || true
 
-install-su: install-modules
+install-tester:
+       -$(mkinstalldirs) $(datadir)
+       $(INSTALL) -m 755 $(srcdir)/run-tests.php $(INSTALL_ROOT)$(datadir)
+
+install-pear: install-modules
        (cd pear && $(MAKE) install)
 
+install-su: install-pear install-tester
+
 .NOEXPORT:
index dbeb66d41b524384091ad00dce615c902437929c..5205b4911260b9349f6889178a9212856c118187 100644 (file)
@@ -461,24 +461,10 @@ fi
 
 divert(4)
 
-
-
-PHP_ARG_WITH(config-file-path,whether to use a configuration file,
+PHP_ARG_WITH(config-file-path,[path to configuration file],
 [  --with-config-file-path=PATH  
                           Sets the path in which to look for php.ini.
-                          defaults to /usr/local/lib], yes)
-
-if test "$PHP_CONFIG_FILE_PATH" = "yes"; then
-  PHP_CONFIG_FILE_PATH="/usr/local/lib"
-fi
-
-if test "$PHP_CONFIG_FILE_PATH" != "no"; then
-  AC_DEFINE_UNQUOTED(CONFIGURATION_FILE_PATH, "$PHP_CONFIG_FILE_PATH",[ ])
-  AC_DEFINE(USE_CONFIG_FILE, 1, [ ])
-else
-  AC_DEFINE(CONFIGURATION_FILE_PATH, 0, [ ])
-  AC_DEFINE(USE_CONFIG_FILE, 0, [ ])
-fi
+                          defaults to --sysconfdir, "none" to disable], $sysconfdir)
 
 PHP_ARG_ENABLE(debug, whether to include debugging symbols,
 [  --enable-debug          Compile with debugging symbols.], no)
@@ -525,6 +511,20 @@ AC_ARG_WITH(exec-dir,
        AC_MSG_RESULT(/usr/local/php/bin)
 ])
 
+# compatibility
+if test "x$with_pear" = "x" -a "x$enable_pear" = "xno"; then
+    with_pear="no"
+fi
+
+PHP_ARG_WITH(pear, [whether to install PEAR, and where],
+[  --with-pear=DIR         Install PEAR in DIR (default \$datadir/php/pear)
+  --without-pear          Do not install PEAR], $datadir/php/pear)
+
+if test "$PHP_PEAR" != "no"; then
+  PEAR_DIR=pear
+  PEAR_INSTALLDIR="$PHP_PEAR"
+fi
+
 PHP_ARG_WITH(openssl,for OpenSSL support,
 [  --with-openssl[=DIR]    Include OpenSSL support (requires OpenSSL >= 0.9.5) ])
 if test "$PHP_OPENSSL" = "yes"; then
@@ -592,13 +592,6 @@ if test "$PHP_DMALLOC" = "yes"; then
   CPPFLAGS="$CPPFLAGS -DDMALLOC_FUNC_CHECK"
 fi
 
-PHP_ARG_ENABLE(pear,whether to install PEAR,
-[  --disable-pear          Do not install PEAR],yes)
-
-if test "$PHP_PEAR" = "yes"; then
-  PEAR_DIR=pear
-fi
-
 # temporary until streams are better integrated
 PHP_ARG_ENABLE(php-streams,whether to enable php streams,
 [  --enable-php-streams    Include experimental php streams.
@@ -703,31 +696,67 @@ $php_shtool mkdir -p $phplibdir
 phptempdir="`pwd`/libs"
 
 test "$prefix" = "NONE" && prefix="/usr/local"
-test "$exec_prefix" = "NONE" && exec_prefix='$(prefix)'
+test "$exec_prefix" = "NONE" && exec_prefix='${prefix}'
+case $libdir in
+  */php) ;;
+  *) libdir="$libdir/php";;
+esac
+case $datadir in
+  */php) ;;
+  *) datadir="$datadir/php";;
+esac
 
 dnl Build extension directory path
 
-if test "$PHP_DEBUG" = "1"; then
-  PART1=debug
-else
-  PART1=no-debug
-fi
-
-if test "$enable_experimental_zts" = "yes"; then
-  PART2=zts
-else
-  PART2=non-zts
-fi
-
 ZEND_MODULE_API_NO=`egrep '#define ZEND_MODULE_API_NO ' $srcdir/Zend/zend_modules.h|sed 's/#define ZEND_MODULE_API_NO //'`
 
-if test -z "$PEAR_INSTALLDIR"; then
-  PEAR_INSTALLDIR="$prefix/lib/php"
-fi
+extbasedir="$ZEND_MODULE_API_NO"
 
-EXTENSION_DIR="${PEAR_INSTALLDIR}/extensions/$PART1-$PART2-$ZEND_MODULE_API_NO"
+if test "$enable_experimental_zts" = "yes"; then
+  extbasedir="${extbasedir}-zts"
+fi
 
-INCLUDE_PATH=".:${PEAR_INSTALLDIR}"
+if test "$PHP_DEBUG" = "1"; then
+  extbasedir="${extbasedir}-debug"
+fi
+
+if test "x$PEAR_INSTALLDIR" = "x"; then
+  PEAR_INSTALLDIR="$datadir/pear"
+fi
+
+if test "x$EXTENSION_DIR" = "x"; then
+  EXTENSION_DIR="$libdir/$extbasedir"
+fi
+
+old_exec_prefix="$exec_prefix"
+old_libdir="$libdir"
+old_datadir="$datadir"
+exec_prefix=`eval echo $exec_prefix`
+libdir=`eval echo $libdir`
+datadir=`eval echo $datadir`
+EXPANDED_PEAR_INSTALLDIR=`eval echo $PEAR_INSTALLDIR`
+EXPANDED_EXTENSION_DIR=`eval echo $EXTENSION_DIR`
+EXPANDED_LOCALSTATEDIR=`eval echo $localstatedir`
+EXPANDED_BINDIR=`eval echo $bindir`
+EXPANDED_LIBDIR="$libdir"
+EXPANDED_SYSCONFDIR=`eval echo $sysconfdir`
+EXPANDED_DATADIR="$datadir"
+EXPANDED_PHP_CONFIG_FILE_PATH=`eval echo "$PHP_CONFIG_FILE_PATH"`
+INCLUDE_PATH=".:${EXPANDED_PEAR_INSTALLDIR}"
+
+exec_prefix="$old_exec_prefix"
+libdir="$old_libdir"
+datadir="$old_datadir"
+
+AC_SUBST(INCLUDE_PATH)
+AC_SUBST(EXPANDED_PEAR_INSTALLDIR)
+AC_SUBST(EXPANDED_EXTENSION_DIR)
+AC_SUBST(EXPANDED_BINDIR)
+AC_SUBST(EXPANDED_LIBDIR)
+AC_SUBST(EXPANDED_DATADIR)
+AC_SUBST(EXPANDED_SYSCONFDIR)
+AC_SUBST(EXPANDED_LOCALSTATEDIR)
+AC_SUBST(EXPANDED_PHP_CONFIG_FILE_PATH)
 
 PHP_BUILD_RPATH
 
@@ -752,6 +781,8 @@ PHP_SUBST(phplibdir)
 PHP_SUBST(phptempdir)
 PHP_SUBST(prefix)
 PHP_SUBST(localstatedir)
+PHP_SUBST(datadir)
+PHP_SUBST(sysconfdir)
 
 PHP_SUBST(AWK)
 PHP_SUBST(CC)
@@ -856,7 +887,7 @@ PHP_GEN_CONFIG_VARS
 
 $php_shtool mkdir -p pear/scripts
 ALL_OUTPUT_FILES="php4.spec Zend/Makefile main/build-defs.h \
-pear/scripts/pear pear/scripts/phpize pear/scripts/php-config pear/PEAR.php \
+pear/scripts/pear pear/scripts/phpize pear/scripts/php-config \
 TSRM/Makefile $PHP_OUTPUT_FILES"
 
 AC_OUTPUT($ALL_OUTPUT_FILES, [], [
index e0233012c8765840dae821013c3dc4544e340f8f..7b67b7a693483e7c5324e2ea0f54ba3931e3aabf 100644 (file)
@@ -190,7 +190,7 @@ PHPAPI void php_print_info(int flag)
                php_info_print_table_row(2, "Virtual Directory Support", "disabled" );
 #endif
 
-               php_info_print_table_row(2, "Configuration File (php.ini) Path", php_ini_opened_path?php_ini_opened_path:CONFIGURATION_FILE_PATH);
+               php_info_print_table_row(2, "Configuration File (php.ini) Path", php_ini_opened_path?php_ini_opened_path:PHP_CONFIG_FILE_PATH);
 
 #if ZEND_DEBUG
                php_info_print_table_row(2, "ZEND_DEBUG", "enabled" );
diff --git a/footer b/footer
index c217e2be43be2082368b57006c2e6b42038f37b6..6513b56b0b12620d9f440afb34fbd71a36b71520 100644 (file)
--- a/footer
+++ b/footer
@@ -3,5 +3,6 @@
  * Local variables:
  * tab-width: 4
  * c-basic-offset: 4
+ * indent-tabs-mode: t
  * End:
  */
index 27deeeb9ff9675476daa0f9c5832a147a544c849..347e75d476817ab932803312ff3a9a362a2baaf7 100644 (file)
@@ -27,7 +27,6 @@
 #define PHP_FHTTPD_INCLUDE      ""
 #define PHP_FHTTPD_LIB          ""
 #define PHP_FHTTPD_TARGET       ""
-#define PHP_BINNAME            "@BINNAME@"
 #define PHP_CFLAGS             "@CFLAGS@"
 #define PHP_DBASE_LIB          ""
 #define PHP_BUILD_DEBUG                "@DEBUG_CFLAGS@"
@@ -50,9 +49,6 @@
 #define PHP_MYSQL_LFLAGS       ""
 #define PHP_MYSQL_LIBS         ""
 #define PHP_ODBC_TYPE       "@ODBC_TYPE@"
-#define PHP_ODBC_INCLUDE    "@ODBC_INCLUDE@"
-#define PHP_ODBC_LFLAGS     "@ODBC_LFLAGS@"
-#define PHP_ODBC_LIBS       "@ODBC_LIBS@"
 #define PHP_OCI8_SHARED_LIBADD         "@OCI8_SHARED_LIBADD@"
 #define PHP_OCI8_DIR                   "@OCI8_DIR@"
 #define PHP_OCI8_VERSION               "@OCI8_VERSION@"
 #define PHP_LDAP_LIBS          ""
 #define PHP_VELOCIS_INCLUDE     ""
 #define PHP_VELOCIS_LIBS        ""
-#define PHP_EXTENSION_DIR       "@EXTENSION_DIR@"
+#define PEAR_INSTALLDIR         "@EXPANDED_PEAR_INSTALLDIR@"
 #define PHP_INCLUDE_PATH       "@INCLUDE_PATH@"
+#define PHP_EXTENSION_DIR       "@EXPANDED_EXTENSION_DIR@"
+#define PHP_BINDIR              "@EXPANDED_BINDIR@"
+#define PHP_LIBDIR              "@EXPANDED_LIBDIR@"
+#define PHP_DATADIR             "@EXPANDED_DATADIR@"
+#define PHP_SYSCONFDIR          "@EXPANDED_SYSCONFDIR@"
+#define PHP_LOCALSTATEDIR       "@EXPANDED_LOCALSTATEDIR@"
+#define PHP_CONFIG_FILE_PATH    "@EXPANDED_PHP_CONFIG_FILE_PATH@"
index fd3e61c27d267e4dbd0285efda4bc2c3b22369e1..7a8cd972261314fd090d1880f9f9eca845c5cfea 100644 (file)
@@ -852,6 +852,15 @@ int php_module_startup(sapi_module_struct *sf)
 
        REGISTER_MAIN_STRINGL_CONSTANT("PHP_VERSION", PHP_VERSION, sizeof(PHP_VERSION)-1, CONST_PERSISTENT | CONST_CS);
        REGISTER_MAIN_STRINGL_CONSTANT("PHP_OS", php_os, strlen(php_os), CONST_PERSISTENT | CONST_CS);
+       REGISTER_MAIN_STRINGL_CONSTANT("DEFAULT_INCLUDE_PATH", PHP_INCLUDE_PATH, sizeof(PHP_INCLUDE_PATH)-1, CONST_PERSISTENT | CONST_CS);
+       REGISTER_MAIN_STRINGL_CONSTANT("PEAR_INSTALL_DIR", PEAR_INSTALLDIR, sizeof(PEAR_INSTALLDIR)-1, CONST_PERSISTENT | CONST_CS);
+       REGISTER_MAIN_STRINGL_CONSTANT("PHP_EXTENSION_DIR", PHP_EXTENSION_DIR, sizeof(PHP_EXTENSION_DIR)-1, CONST_PERSISTENT | CONST_CS);
+       REGISTER_MAIN_STRINGL_CONSTANT("PHP_BINDIR", PHP_BINDIR, sizeof(PHP_BINDIR)-1, CONST_PERSISTENT | CONST_CS);
+       REGISTER_MAIN_STRINGL_CONSTANT("PHP_LIBDIR", PHP_LIBDIR, sizeof(PHP_LIBDIR)-1, CONST_PERSISTENT | CONST_CS);
+       REGISTER_MAIN_STRINGL_CONSTANT("PHP_DATADIR", PHP_DATADIR, sizeof(PHP_DATADIR)-1, CONST_PERSISTENT | CONST_CS);
+       REGISTER_MAIN_STRINGL_CONSTANT("PHP_SYSCONFDIR", PHP_SYSCONFDIR, sizeof(PHP_SYSCONFDIR)-1, CONST_PERSISTENT | CONST_CS);
+       REGISTER_MAIN_STRINGL_CONSTANT("PHP_LOCALSTATEDIR", PHP_LOCALSTATEDIR, sizeof(PHP_LOCALSTATEDIR)-1, CONST_PERSISTENT | CONST_CS);
+       REGISTER_MAIN_STRINGL_CONSTANT("PHP_CONFIG_FILE_PATH", PHP_CONFIG_FILE_PATH, sizeof(PHP_CONFIG_FILE_PATH)-1, CONST_PERSISTENT | CONST_CS);
        php_output_register_constants();
 
        if (php_startup_ticks(PLS_C) == FAILURE) {
index 86e03b55b6aa2d9441c0db5df4ae58749f6fb15a..fe3121cf77b98899594af5fb5a2491717fc1e05b 100644 (file)
 
 
 #include "php.h"
+#include "build-defs.h"
 #include "ext/standard/info.h"
 #include "zend_ini.h"
 #include "php_ini.h"
 #include "ext/standard/dl.h"
 #include "zend_extensions.h"
 
-
 typedef struct _php_extension_lists {
        zend_llist engine;
        zend_llist functions;
@@ -210,7 +210,7 @@ int php_init_config(char *php_ini_path_override)
                }
                free_default_location=1;
 #else
-               default_location = CONFIGURATION_FILE_PATH;
+               default_location = PHP_CONFIG_FILE_PATH;
                free_default_location=0;
 #endif
                php_ini_search_path = (char *) emalloc(sizeof(".")+strlen(env_location)+strlen(default_location)+2+1);
@@ -332,3 +332,11 @@ PHPAPI int cfg_get_string(char *varname, char **result)
        *result = tmp->value.str.val;
        return SUCCESS;
 }
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: t
+ * End:
+ */
index b05fa1c161607e309e2a03474acae39b397e700f..282f90ddbac128ac7c71502467a9f3ec5a2eb686 100644 (file)
@@ -94,14 +94,18 @@ PEAR_FILES = \
        Net/SMTP.php \
        Net/Socket.php \
        Numbers/Roman.php \
+       PEAR.php \
+       PEAR/Common.php \
        PEAR/Installer.php \
+       PEAR/Packager.php \
+       PEAR/Updater.php \
        Payment/Verisign.php \
        Schedule/At.php \
        XML/Parser.php \
        XML/RPC.php \
        XML/RPC/Server.php
 
-install-data-local: PEAR.php
+install-data-local:
        @if $(mkinstalldirs) $(INSTALL_ROOT)$(peardir); then \
                for i in $(PEAR_SUBDIRS); do \
                        (set -x;$(mkinstalldirs) $(INSTALL_ROOT)$(peardir)/$$i); \
@@ -110,9 +114,6 @@ install-data-local: PEAR.php
                        dir=`echo $$i|sed 's%[^/][^/]*$$%%'`; \
                        (set -x;$(INSTALL_DATA) $(srcdir)/$$i $(INSTALL_ROOT)$(peardir)/$$dir); \
                done; \
-               for i in PEAR.php; do \
-                       (set -x;$(INSTALL_DATA) $$i $(INSTALL_ROOT)$(peardir)); \
-               done; \
        else \
                cat $(srcdir)/install-pear.txt; \
                exit 5; \
@@ -183,6 +184,3 @@ scripts/phpize: scripts/phpize.in $(top_builddir)/config.status
 
 scripts/php-config: scripts/php-config.in $(top_builddir)/config.status
        (cd ..;CONFIG_FILES=pear/scripts/php-config CONFIG_HEADERS= $(top_builddir)/config.status)
-
-PEAR.php: PEAR.php.in $(top_builddir)/config.status
-       (cd ..;CONFIG_FILES=pear/PEAR.php CONFIG_HEADERS= $(top_builddir)/config.status)
similarity index 97%
rename from pear/PEAR.php.in
rename to pear/PEAR.php
index ee5ccea9b132d7830e8a695556ed5f7417ced2ad..fcf86225ce1c892ec4b26494b1ce4f580bf4f3d8 100644 (file)
@@ -26,10 +26,6 @@ define('PEAR_ERROR_TRIGGER', 4);
 define('PEAR_ERROR_DIE', 8);
 define('PEAR_ERROR_CALLBACK', 16);
 
-define('PHP_BINDIR', '@prefix@/bin');
-define('PEAR_INSTALL_DIR', '@PEAR_INSTALLDIR@');
-define('PEAR_EXTENSION_DIR', '@EXTENSION_DIR@');
-
 if (substr(PHP_OS, 0, 3) == 'WIN') {
     define('OS_WINDOWS', true);
     define('OS_UNIX', false);
@@ -40,18 +36,10 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
     define('PEAR_OS', 'Unix'); // blatant assumption
 }
 
-if (!defined("DIRECTORY_SEPARATOR")) {
-    if (OS_WINDOWS) {
-        define("DIRECTORY_SEPARATOR", "\\");
-    } else {
-        define("DIRECTORY_SEPARATOR", "/");
-    }
-}
-
-$_PEAR_default_error_mode = PEAR_ERROR_RETURN;
-$_PEAR_default_error_options = E_USER_NOTICE;
-$_PEAR_default_error_callback = '';
-$_PEAR_destructor_object_list = array();
+$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN;
+$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE;
+$GLOBALS['_PEAR_default_error_callback'] = '';
+$GLOBALS['_PEAR_destructor_object_list'] = array();
 
 //
 // Tests needed: - PEAR inheritance
diff --git a/pear/PEAR/Common.php b/pear/PEAR/Common.php
new file mode 100644 (file)
index 0000000..8741da7
--- /dev/null
@@ -0,0 +1,174 @@
+<?php
+//
+// +----------------------------------------------------------------------+
+// | PHP version 4.0                                                      |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2001 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/2_02.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.               |
+// +----------------------------------------------------------------------+
+// | Authors: Stig Bakken <ssb@fast.no>                                   |
+// |                                                                      |
+// +----------------------------------------------------------------------+
+//
+
+require_once "PEAR.php";
+
+class PEAR_Common
+{
+    // {{{ properties
+
+    /** stack of elements, gives some sort of XML context */
+    var $element_stack;
+
+    /** name of currently parsed XML element */
+    var $current_element;
+
+    /** array of attributes of the currently parsed XML element */
+    var $current_attributes = array();
+
+    /** list of temporary files created by this object */
+    var $_tempfiles = array();
+
+    /** assoc with information about a package */
+    var $pkginfo = array();
+
+    // }}}
+
+    // {{{ constructor
+
+    function PEAR_Common()
+    {
+        $this->PEAR();
+    }
+
+    // }}}
+    // {{{ destructor
+
+    function _PEAR_Common() {
+       $this->_PEAR();
+        while (is_array($this->_tempfiles) &&
+               $file = array_shift($this->_tempfiles))
+        {
+            if (is_dir($file)) {
+                system("rm -rf $file"); // XXX FIXME Windows
+            } else {
+                unlink($file);
+            }
+        }
+    }
+
+    // }}}
+    // {{{ addTempFile()
+
+    function addTempFile($file)
+    {
+        $this->_tempfiles[] = $file;
+    }
+
+    // }}}
+
+    function _element_start($xp, $name, $attribs)
+    {
+       array_push($this->element_stack, $name);
+       $this->current_element = $name;
+       $this->current_attributes = $attribs;
+    }
+
+
+    function _element_end($xp, $name)
+    {
+       array_pop($this->element_stack);
+       $this->current_element = $this->element_stack[sizeof($this->element_stack)-1];
+    }
+
+
+    function _pkginfo_cdata($xp, $data)
+    {
+        $next = $this->element_stack[sizeof($this->element_stack)-1];
+       switch ($this->current_element) {
+            case "Name":
+                switch ($next) {
+                    case "Package":
+                        $this->pkginfo["package"] = trim($data);
+                        break;
+                    case "Maintainer":
+                        $this->pkginfo["maintainer_name"] = trim($data);
+                        break;
+                }
+                break;
+            case "Summary":
+                $this->pkginfo["summary"] = trim($data);
+                break;
+            case "Initials":
+                $this->pkginfo["maintainer_handle"] = trim($data);
+                break;
+            case "Email":
+                $this->pkginfo["maintainer_email"] = trim($data);
+                break;
+            case "Version":
+                $this->pkginfo["version"] = trim($data);
+                break;
+            case "Date":
+                $this->pkginfo["release_date"] = trim($data);
+                break;
+            case "Notes":
+                $this->pkginfo["release_notes"] = trim($data);
+                break;
+           case "Dir":
+               if (!$this->phpdir) {
+                   break;
+               }
+                $dir = trim($data);
+                // XXX add to file list
+               break;
+           case "File":
+                $role = strtolower($this->current_attributes["Role"]);
+               $file = trim($data);
+                // XXX add to file list
+               break;
+       }
+    }
+
+
+    function infoFromDescriptionFile($file)
+    {
+       $fp = fopen($descfile, "r");
+       $xp = xml_parser_create();
+       if (!$xp) {
+           return $this->raiseError("Unable to create XML parser.");
+       }
+       xml_set_object($xp, $this);
+       xml_set_element_handler($xp, "_element_start", "_element_end");
+       xml_set_character_data_handler($xp, "_pkginfo_cdata");
+       xml_parser_set_option($xp, XML_OPTION_CASE_FOLDING, false);
+
+       $this->element_stack = array();
+       $this->pkginfo = array();
+       $this->current_element = false;
+       $this->destdir = '';
+
+        // read the whole thing so we only get one cdata callback
+        // for each block of cdata
+       $data = fread($fp, filesize($descfile));
+        if (!xml_parse($xp, $data, 1)) {
+            $msg = sprintf("XML error: %s at line %d",
+                           xml_error_string(xml_get_error_code($xp)),
+                           xml_get_current_line_number($xp));
+            xml_parser_free($xp);
+            return $this->raiseError($msg);
+       }
+
+       xml_parser_free($xp);
+
+        return $this->pkginfo;
+    }
+}
+
+?>
index 23b0dc77aa750213d1b82f58405af5386d6dc7e0..912c3164169db67d5492b2197af85edecb526306 100644 (file)
@@ -18,7 +18,7 @@
 // +----------------------------------------------------------------------+
 //
 
-require_once "PEAR.php";
+require_once "PEAR/Common.php";
 
 /**
  * Administration class used to install PEAR packages and maintain the
@@ -27,22 +27,10 @@ require_once "PEAR.php";
  * @since PHP 4.0.2
  * @author Stig Bakken <ssb@fast.no>
  */
-class PEAR_Installer extends PEAR
+class PEAR_Installer extends PEAR_Common
 {
     // {{{ properties
 
-    /** stack of elements, gives some sort of XML context */
-    var $element_stack;
-
-    /** name of currently parsed XML element */
-    var $current_element;
-
-    /** array of attributes of the currently parsed XML element */
-    var $current_attributes = array();
-
-    /** assoc with information about the package */
-    var $pkginfo = array();
-
     /** name of the package directory, for example Foo-1.0 */
     var $pkgdir;
 
@@ -75,9 +63,6 @@ class PEAR_Installer extends PEAR
     /** file pointer for package list file if open */
     var $pkglist_fp;
 
-    /** list of temporary files created by this object */
-    var $_tempfiles = array();
-
     // }}}
 
     // {{{ constructor
@@ -98,7 +83,6 @@ class PEAR_Installer extends PEAR
     // {{{ destructor
 
     function _PEAR_Installer() {
-       $this->_PEAR();
        if ($this->tmpdir && is_dir($this->tmpdir)) {
            system("rm -rf $this->tmpdir"); // XXX FIXME Windows
        }
@@ -108,15 +92,7 @@ class PEAR_Installer extends PEAR
        }
        $this->tmpdir = null;
        $this->pkglist_fp = null;
-        while (is_array($this->_tempfiles) &&
-               $file = array_shift($this->_tempfiles))
-        {
-            if (is_dir($file)) {
-                system("rm -rf $file"); // XXX FIXME Windows
-            } else {
-                unlink($file);
-            }
-        }
+       $this->_PEAR_Common();
     }
 
     // }}}
@@ -261,7 +237,7 @@ class PEAR_Installer extends PEAR
 
         if ($need_download) {
             $file = basename($pkgfile);
-            // XXX FIXME Windows
+            // XXX FIXME use ??? on Windows, use $TMPDIR on unix
             $downloaddir = "/tmp/pearinstall";
             $this->mkDirHier($downloaddir);
             $downloadfile = $downloaddir.DIRECTORY_SEPARATOR.$file;
@@ -274,6 +250,7 @@ class PEAR_Installer extends PEAR
             if (!$wp) {
                 return $this->raiseError("$downloadfile: write failed ($php_errormsg)");
             }
+            $this->addTempFile($downloadfile);
             $bytes = 0;
             while ($data = @fread($fp, 16384)) {
                 $bytes += strlen($data);
@@ -285,9 +262,8 @@ class PEAR_Installer extends PEAR
             fclose($fp);
             fclose($wp);
             $this->log(1, "...done, $bytes bytes");
-            $this->tempfiles[] = $downloadfile;
         }
-        // XXX FIXME need internal support for gzip+tar
+        // XXX FIXME depends on external gzip+tar
        $fp = popen("gzip -dc $pkgfile | tar -tf -", "r");
        if (!$fp) {
            return $this->raiseError("Unable to examine $pkgfile (gzip or tar failed)");
@@ -313,9 +289,10 @@ class PEAR_Installer extends PEAR
        if (!mkdir($this->tmpdir, 0755)) {
            return $this->raiseError("Unable to create temporary directory $this->tmpdir.");
        }
-        $this->tempfiles[] = $this->tmpdir;
+        $this->addTempFile($this->tmpdir);
        $pwd = getcwd();
 
+        // XXX FIXME Windows should check for drive
        if (substr($pkgfile, 0, 1) == DIRECTORY_SEPARATOR) {
            $pkgfilepath = $pkgfile;
        } else {
diff --git a/pear/PEAR/Uploader.php b/pear/PEAR/Uploader.php
new file mode 100644 (file)
index 0000000..575e3ed
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+//
+// +----------------------------------------------------------------------+
+// | PHP version 4.0                                                      |
+// +----------------------------------------------------------------------+
+// | Copyright (c) 1997-2001 The PHP Group                                |
+// +----------------------------------------------------------------------+
+// | This source file is subject to version 2.02 of the PHP license,      |
+// | that is bundled with this package in the file LICENSE, and is        |
+// | available at through the world-wide-web at                           |
+// | http://www.php.net/license/2_02.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.               |
+// +----------------------------------------------------------------------+
+// | Authors: Stig Bakken <ssb@fast.no>                                   |
+// |                                                                      |
+// +----------------------------------------------------------------------+
+//
+
+require_once "PEAR/Common.php";
+
+/**
+ * Administration class used to install PEAR packages and maintain the
+ * installed package database.
+ *
+ * @since PHP 4.0.2
+ * @author Stig Bakken <ssb@fast.no>
+ */
+class PEAR_Uploader extends PEAR_Common
+{
+    // {{{ properties
+
+    var $_tempfiles = array();
+
+    // }}}
+
+    // {{{ constructor
+
+    function PEAR_Uploader()
+    {
+        $this->PEAR_Common();
+    }
+
+    // }}}
+
+    function Upload($pkgfile, $infofile)
+    {
+    }
+}
+
+?>
index 3d1a9f26011028b58d6ec6c268795eb2ca1d73dd..e42085403b4c10cb52967114583d2ce12dad0ea7 100644 (file)
@@ -113,16 +113,16 @@ mode=print: test error[pear_error: message="test error" code=-42 mode=print leve
 mode=callback(function): errorhandler function called, obj=[pear_error: message="test error" code=-42 mode=callback callback=errorhandler prefix="" prepend="" append="" info=""]
 mode=callback(method): errorhandler method called, obj=[pear_error: message="test error" code=-42 mode=callback callback=errorclass::errorhandler prefix="" prepend="" append="" info=""]
 mode=print&trigger: test error<br>
-<b>Notice</b>:  test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>413</b><br>
+<b>Notice</b>:  test error in <b>/usr/local/share/php/pear/PEAR.php</b> on line <b>401</b><br>
 [pear_error: message="test error" code=-42 mode=print|trigger level=notice prefix="" prepend="" append="" info=""]
 mode=trigger: <br>
-<b>Notice</b>:  test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>413</b><br>
+<b>Notice</b>:  test error in <b>/usr/local/share/php/pear/PEAR.php</b> on line <b>401</b><br>
 [pear_error: message="test error" code=-42 mode=trigger level=notice prefix="" prepend="" append="" info=""]
 mode=trigger,level=notice: <br>
-<b>Notice</b>:  test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>413</b><br>
+<b>Notice</b>:  test error in <b>/usr/local/share/php/pear/PEAR.php</b> on line <b>401</b><br>
 [pear_error: message="test error" code=-42 mode=trigger level=notice prefix="" prepend="" append="" info=""]
 mode=trigger,level=warning: <br>
-<b>Warning</b>:  test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>413</b><br>
+<b>Warning</b>:  test error in <b>/usr/local/share/php/pear/PEAR.php</b> on line <b>401</b><br>
 [pear_error: message="test error" code=-42 mode=trigger level=warning prefix="" prepend="" append="" info=""]
 mode=trigger,level=error: <br>
-<b>Fatal error</b>:  test error in <b>/usr/local/lib/php/PEAR.php</b> on line <b>413</b><br>
+<b>Fatal error</b>:  test error in <b>/usr/local/share/php/pear/PEAR.php</b> on line <b>401</b><br>