Back to index

php5  5.3.10
Defines | Functions | Variables
php_zlib.h File Reference
#include <zlib.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define zlib_module_ptr   &php_zlib_module_entry
#define ZLIBG(v)   (zlib_globals.v)
#define phpext_zlib_ptr   zlib_module_ptr
#define CODING_GZIP   1
#define CODING_DEFLATE   2

Functions

PHPAPI ZEND_EXTERN_MODULE_GLOBALS (zlib) extern php_stream_filter_factory php_zlib_filter_factory
int php_ob_gzhandler_check (TSRMLS_D)
php_stream * php_stream_gzopen (php_stream_wrapper *wrapper, char *path, char *mode, int options, char **opened_path, php_stream_context *context STREAMS_DC TSRMLS_DC)

Variables

int compression_coding
z_stream stream
uLong crc
int ob_gzhandler_status
long output_compression
long output_compression_level
char * output_handler
zend_module_entry php_zlib_module_entry
php_stream_wrapper php_stream_gzip_wrapper

Define Documentation

#define CODING_DEFLATE   2

Definition at line 58 of file php_zlib.h.

#define CODING_GZIP   1

Definition at line 57 of file php_zlib.h.

Definition at line 55 of file php_zlib.h.

Definition at line 42 of file php_zlib.h.

#define ZLIBG (   v)    (zlib_globals.v)

Definition at line 52 of file php_zlib.h.


Function Documentation

Definition at line 959 of file zlib.c.

{
       /* check for wrong usages */
       if (OG(ob_nesting_level > 0)) {
              if (php_ob_handler_used("ob_gzhandler" TSRMLS_CC)) {
                     php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "output handler 'ob_gzhandler' cannot be used twice");
                     return FAILURE;
              }
              if (php_ob_handler_used("mb_output_handler" TSRMLS_CC)) {
                     php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "output handler 'ob_gzhandler' cannot be used after 'mb_output_handler'");
                     return FAILURE;
              }
              if (php_ob_handler_used("URL-Rewriter" TSRMLS_CC)) {
                     php_error_docref("ref.outcontrol" TSRMLS_CC, E_WARNING, "output handler 'ob_gzhandler' cannot be used after 'URL-Rewriter'");
                     return FAILURE;
              }
              if (php_ob_init_conflict("ob_gzhandler", "zlib output compression" TSRMLS_CC)) {
                     return FAILURE;
              }
       }

       return SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

php_stream* php_stream_gzopen ( php_stream_wrapper *  wrapper,
char *  path,
char *  mode,
int  options,
char **  opened_path,
php_stream_context *context STREAMS_DC  TSRMLS_DC 
)

Definition at line 109 of file zlib_fopen_wrapper.c.

{
       struct php_gz_stream_data_t *self = {0};
       php_stream *stream = NULL, *innerstream = NULL;

       /* sanity check the stream: it can be either read-only or write-only */
       if (strchr(mode, '+')) {
              if (options & REPORT_ERRORS) {
                     php_error_docref(NULL TSRMLS_CC, E_WARNING, "cannot open a zlib stream for reading and writing at the same time!");
              }
              return NULL;
       }
       
       self = emalloc(sizeof(*self));

       if (strncasecmp("compress.zlib://", path, 16) == 0) {
              path += 16;
       } else if (strncasecmp("zlib:", path, 5) == 0) {
              path += 5;
       }
       
       innerstream = php_stream_open_wrapper_ex(path, mode, STREAM_MUST_SEEK | options | STREAM_WILL_CAST, opened_path, context);
       
       if (innerstream) {
              int fd;

              if (SUCCESS == php_stream_cast(innerstream, PHP_STREAM_AS_FD, (void **) &fd, REPORT_ERRORS)) {
                     self->gz_file = gzdopen(dup(fd), mode);
                     self->stream = innerstream;
                     if (self->gz_file)   {
                            stream = php_stream_alloc_rel(&php_stream_gzio_ops, self, 0, mode);
                            if (stream) {
                                   stream->flags |= PHP_STREAM_FLAG_NO_BUFFER;
                                   return stream;
                            }
                            gzclose(self->gz_file);
                     }
                     if (options & REPORT_ERRORS) {
                            php_error_docref(NULL TSRMLS_CC, E_WARNING, "gzopen failed");
                     }
              } else if (innerstream) {
                     php_stream_close(innerstream);
              }
       }

       if (stream) {
              php_stream_close(stream);
       }
       
       if (self) {
              efree(self);
       }
       
       return NULL;
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 29 of file php_zlib.h.

uLong crc

Definition at line 31 of file php_zlib.h.

Definition at line 32 of file php_zlib.h.

Definition at line 33 of file php_zlib.h.

Definition at line 34 of file php_zlib.h.

Definition at line 35 of file php_zlib.h.

php_stream_wrapper php_stream_gzip_wrapper

Definition at line 179 of file zlib_fopen_wrapper.c.

zend_module_entry php_zlib_module_entry

Definition at line 225 of file zlib.c.

z_stream stream

Definition at line 30 of file php_zlib.h.