]> granicus.if.org Git - php/commitdiff
- Merge back changes which where in 4.3 but somehow didn't make it into the new
authorDerick Rethans <derick@php.net>
Mon, 6 Jun 2005 10:59:47 +0000 (10:59 +0000)
committerDerick Rethans <derick@php.net>
Mon, 6 Jun 2005 10:59:47 +0000 (10:59 +0000)
  branch.

ext/bz2/bz2.c
scripts/man1/php-config.1.in [new file with mode: 0644]
scripts/man1/phpize.1.in [new file with mode: 0644]

index 4d041511cd18741e015f7a2e38822613dc414f9b..f32d97822df0ea7c9d8b74ad0abcee3298902977 100644 (file)
@@ -40,9 +40,6 @@
 #define PHP_BZ_ERRSTR  1
 #define PHP_BZ_ERRBOTH 2
 
-/* Blocksize of the decompression buffer */
-#define PHP_BZ_DECOMPRESS_SIZE 4096
-
 function_entry bz2_functions[] = {
        PHP_FE(bzopen,       NULL)
        PHP_FE(bzread,       NULL)
@@ -434,56 +431,49 @@ PHP_FUNCTION(bzcompress)
    Decompresses BZip2 compressed data */
 PHP_FUNCTION(bzdecompress)
 {
-       zval    **source,                             /* Source data to decompress */
-               **zsmall;                             /* (Optional) user specified small */
-       char     *dest;                               /* Destination buffer, initially allocated */
-       int       error,                              /* Error container */
-                 iter = 1,                           /* Iteration count for the compression loop */
-                         size,                               /* Current size to realloc the dest buffer to */
-                         dest_len = PHP_BZ_DECOMPRESS_SIZE,  /* Size of the destination length */
-                         small    = 0,                       /* The actual small */
-                         argc     = ZEND_NUM_ARGS();         /* Argument count */
-       
-       if (argc < 1 || argc > 2 || zend_get_parameters_ex(argc, &source, &zsmall) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       char *source, *dest;
+       int source_len, error;
+       long small = 0;
+       unsigned int size = 0;
+       bz_stream bzs;
+
+       if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l", &source, &source_len, &small)) {
+               RETURN_FALSE;
        }
 
-       convert_to_string_ex(source);
-       
-       /* optional small argument handling */
-       if (argc > 1) {
-               convert_to_long_ex(zsmall);
-               small = Z_LVAL_PP(zsmall);
+       bzs.bzalloc = NULL;
+       bzs.bzfree = NULL;
+
+       if (BZ2_bzDecompressInit(&bzs, 0, small) != BZ_OK) {
+               RETURN_FALSE;
        }
 
-       /* Depending on the size of the source buffer, either allocate
-         the length of the source buffer or the a default decompression
-         size */
-       dest = emalloc(PHP_BZ_DECOMPRESS_SIZE > Z_STRLEN_PP(source) ? PHP_BZ_DECOMPRESS_SIZE : Z_STRLEN_PP(source));
-
-       /* (de)Compression Loop */      
-       do {
-               /* Handle the (re)allocation of the buffer */
-               size = dest_len * iter;
-               if (iter > 1) {
-                       dest = erealloc(dest, size);
-               }
-               ++iter;
+       bzs.next_in = source;
+       bzs.avail_in = source_len;
 
-               /* Perform the decompression */
-               error = BZ2_bzBuffToBuffDecompress(dest, &size, Z_STRVAL_PP(source), Z_STRLEN_PP(source), small, 0);
-       } while (error == BZ_OUTBUFF_FULL);
+       /* in most cases bz2 offers at least 2:1 compression, so we use that as our base */
+       bzs.avail_out = source_len * 2;
+       bzs.next_out = dest = emalloc(bzs.avail_out + 1);
        
-       if (error != BZ_OK) {
-               efree(dest);
-               RETURN_LONG(error);
-       } else {
-               /* we might have allocated a little to much, so erealloc the buffer 
-                down to size, before returning it */
+       while ((error = BZ2_bzDecompress(&bzs)) == BZ_OK && bzs.avail_in > 0) {
+               /* compression is better then 2:1, need to allocate more memory */
+               bzs.avail_out = source_len;
+               size = (bzs.total_out_hi32 << 32) + bzs.total_out_lo32;
+               dest = erealloc(dest, size + bzs.avail_out + 1);
+               bzs.next_out = dest + size;
+       }
+
+       if (error == BZ_STREAM_END || error == BZ_OK) {
+               size = (bzs.total_out_hi32 << 32) + bzs.total_out_lo32;
                dest = erealloc(dest, size + 1);
-               dest[size] = 0;
-               RETURN_STRINGL(dest, size, 0);
+               dest[size] = '\0';
+               RETVAL_STRINGL(dest, size, 0);
+       } else { /* real error */
+               efree(dest);
+               RETVAL_LONG(error);
        }
+
+       BZ2_bzDecompressEnd(&bzs);
 }
 /* }}} */
 
diff --git a/scripts/man1/php-config.1.in b/scripts/man1/php-config.1.in
new file mode 100644 (file)
index 0000000..78b0252
--- /dev/null
@@ -0,0 +1,77 @@
+./"    +----------------------------------------------------------------------+
+./"    | PHP Version 5                                                        |
+./"    +----------------------------------------------------------------------+
+./"    | Copyright (c) 1997-2004 The PHP Group                                |
+./"    +----------------------------------------------------------------------+
+./"    | This source file is subject to version 3.0 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_0.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: Jakub Vrana <vrana@php.net>                                  |
+./"    +----------------------------------------------------------------------+
+./" 
+./" $Id$
+./" 
+.TH php\-config 1 "Apr 2005" "The PHP Group" "Scripting Language"
+.SH NAME
+.TP 15
+.B php\-config
+Get information about PHP configuration
+.SH SYNOPSIS
+.B php\-config
+[options]
+.LP
+.SH DESCRIPTION
+.B php\-config
+is a simple shell script for obtaining information about installed PHP configuration.
+.SH OPTIONS
+.TP 15
+.PD 0
+.B \-\-prefix
+Directory prefix where PHP is installed, e.g. /usr/local
+.TP
+.PD 0
+.B \-\-includes
+List of \-I options with all include files
+.TP
+.PD 0
+.B \-\-ldflags
+LD Flags which PHP was compiled with
+.TP
+.PD 0
+.B \-\-libs
+Extra libraries which PHP was compiled with
+.TP
+.PD 0
+.B \-\-extension-dir
+Directory where extensions are searched by default
+.TP
+.PD 0
+.B \-\-version
+PHP version
+.TP
+.PD 1
+.P
+.SH SEE ALSO
+.BR php (1)
+.SH VERSION INFORMATION
+This manpage describes \fBphp\fP, version @PHP_VERSION@.
+.SH COPYRIGHT
+Copyright \(co 1997\-2005 The PHP Group
+.LP
+This source file is subject to version 3.0 of the PHP license,
+that is bundled with this package in the file LICENSE, and is
+available through the world-wide-web at
+.PD 0
+.P
+.B http://www.php.net/license/3_0.txt
+.PD 1
+.P
+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
+.B license@php.net 
+so we can mail you a copy immediately.
diff --git a/scripts/man1/phpize.1.in b/scripts/man1/phpize.1.in
new file mode 100644 (file)
index 0000000..7ede86a
--- /dev/null
@@ -0,0 +1,68 @@
+./"    +----------------------------------------------------------------------+
+./"    | PHP Version 5                                                        |
+./"    +----------------------------------------------------------------------+
+./"    | Copyright (c) 1997-2004 The PHP Group                                |
+./"    +----------------------------------------------------------------------+
+./"    | This source file is subject to version 3.0 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_0.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: Jakub Vrana <vrana@php.net>                                  |
+./"    +----------------------------------------------------------------------+
+./" 
+./" $Id$
+./" 
+.TH phpize 1 "Apr 2005" "The PHP Group" "Scripting Language"
+.SH NAME
+.TP 15
+.B phpize
+Prepare PHP extension for compiling
+.SH SYNOPSIS
+.B phpize
+[options]
+.LP
+.SH DESCRIPTION
+.B phpize
+is a shell script to prepare PHP extension for compiling.
+.SH OPTIONS
+.TP 15
+.PD 0
+.B \-\-clean
+Remove all created files
+.TP
+.PD 0
+.B \-\-help
+Prints usage information
+.TP
+.PD 0
+.B \-\-version
+.TP
+.PD 1
+.B \-v
+Prints API version information
+.TP
+.PD 1
+.P
+.SH SEE ALSO
+.BR php (1)
+.SH VERSION INFORMATION
+This manpage describes \fBphp\fP, version @PHP_VERSION@.
+.SH COPYRIGHT
+Copyright \(co 1997\-2005 The PHP Group
+.LP
+This source file is subject to version 3.0 of the PHP license,
+that is bundled with this package in the file LICENSE, and is
+available through the world-wide-web at
+.PD 0
+.P
+.B http://www.php.net/license/3_0.txt
+.PD 1
+.P
+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
+.B license@php.net 
+so we can mail you a copy immediately.