com.caucho.quercus.lib.zlib
Class ZlibModule

java.lang.Object
  extended by com.caucho.quercus.module.AbstractQuercusModule
      extended by com.caucho.quercus.lib.zlib.ZlibModule
All Implemented Interfaces:
QuercusModule

public class ZlibModule
extends AbstractQuercusModule

PHP Zlib


Field Summary
static int FORCE_DEFLATE
           
static int FORCE_GZIP
           
 
Fields inherited from class com.caucho.quercus.module.AbstractQuercusModule
PHP_INI_ALL, PHP_INI_PERDIR, PHP_INI_SYSTEM, PHP_INI_USER
 
Constructor Summary
ZlibModule()
           
 
Method Summary
 java.lang.String[] getLoadedExtensions()
          Returns the extensions loaded by the module.
 boolean gzclose(BinaryStream os)
          Closes the stream.
 Value gzcompress(Env env, java.io.InputStream data, int level)
          compresses data using zlib
 Value gzdeflate(Env env, java.io.InputStream data, int level)
           
 Value gzencode(Env env, java.io.InputStream is, int level, int encodingMode)
          Compresses data using the Deflate algorithm, output is compatible with gzwrite's output
 boolean gzeof(BinaryStream binaryStream)
          Returns true if the GZip stream is ended.
static ArrayValue gzfile(Env env, StringValue fileName, boolean useIncludePath)
           
static Value gzgetc(Env env, BinaryInput is)
          Reads a character from the stream.
static Value gzgets(Env env, BinaryInput is, int length)
          Reads a line from the input stream.
static Value gzgetss(Env env, BinaryInput is, int length, Value allowedTags)
          Reads a line from the zip stream, stripping tags.
 Value gzinflate(Env env, java.io.InputStream data, int length)
           
static BinaryStream gzopen(Env env, StringValue fileName, java.lang.String mode, boolean useIncludePath)
           
 Value gzpassthru(Env env, BinaryInput is)
          Prints out the remaining data in the stream to stdout
 int gzputs(Env env, BinaryOutput os, java.io.InputStream is, int length)
           
 Value gzread(BinaryInput is, int length)
          Reads a chunk of data from the gzip stream.
 boolean gzrewind(BinaryStream binaryStream)
          Rewinds the stream to the very beginning
 int gzseek(BinaryStream binaryStream, long offset, int whence)
          Set stream position to the offset
 Value gztell(BinaryStream binaryStream)
          Gets the current position in the stream
 Value gzuncompress(Env env, java.io.InputStream is, long length)
           
static int gzwrite(BinaryOutput os, java.io.InputStream is, int length)
          Writes a string to the gzip stream.
static Value ob_gzhandler(Env env, StringValue buffer, int state)
           
static Value readgzfile(Env env, StringValue fileName, boolean useIncludePath)
          outputs uncompressed bytes directly to browser, writes a warning message if an error has occured Note: PHP5 is supposed to print an error message but it doesn't do it
 Value zlib_get_coding_type(Env env)
          Returns the encoding type both allowed by the server and supported by the user's browser.
 
Methods inherited from class com.caucho.quercus.module.AbstractQuercusModule
addConstant, addConstant, addConstant, getConstMap, getIniDefinitions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORCE_GZIP

public static final int FORCE_GZIP
See Also:
Constant Field Values

FORCE_DEFLATE

public static final int FORCE_DEFLATE
See Also:
Constant Field Values
Constructor Detail

ZlibModule

public ZlibModule()
Method Detail

getLoadedExtensions

public java.lang.String[] getLoadedExtensions()
Description copied from class: AbstractQuercusModule
Returns the extensions loaded by the module.

Specified by:
getLoadedExtensions in interface QuercusModule
Overrides:
getLoadedExtensions in class AbstractQuercusModule

gzopen

public static BinaryStream gzopen(Env env,
                                  StringValue fileName,
                                  java.lang.String mode,
                                  boolean useIncludePath)
Parameters:
env -
fileName -
mode -
useIncludePath - always on
Returns:
Zlib

gzfile

public static ArrayValue gzfile(Env env,
                                StringValue fileName,
                                boolean useIncludePath)
Parameters:
env -
fileName -
useIncludePath -
Returns:
array of uncompressed lines from fileName

ob_gzhandler

public static Value ob_gzhandler(Env env,
                                 StringValue buffer,
                                 int state)

readgzfile

public static Value readgzfile(Env env,
                               StringValue fileName,
                               boolean useIncludePath)
outputs uncompressed bytes directly to browser, writes a warning message if an error has occured Note: PHP5 is supposed to print an error message but it doesn't do it

Parameters:
env -
fileName -
useIncludePath -
Returns:
number of bytes read from file, or FALSE if an error occurred

gzwrite

public static int gzwrite(BinaryOutput os,
                          java.io.InputStream is,
                          int length)
Writes a string to the gzip stream.


gzputs

public int gzputs(Env env,
                  BinaryOutput os,
                  java.io.InputStream is,
                  int length)
Parameters:
env -
zp -
s -
length -
Returns:
alias of gzwrite

gzclose

public boolean gzclose(BinaryStream os)
Closes the stream.


gzeof

public boolean gzeof(BinaryStream binaryStream)
Returns true if the GZip stream is ended.


gzgetc

public static Value gzgetc(Env env,
                           BinaryInput is)
Reads a character from the stream.


gzread

public Value gzread(BinaryInput is,
                    int length)
Reads a chunk of data from the gzip stream.


gzgets

public static Value gzgets(Env env,
                           BinaryInput is,
                           int length)
Reads a line from the input stream.


gzgetss

public static Value gzgetss(Env env,
                            BinaryInput is,
                            int length,
                            Value allowedTags)
Reads a line from the zip stream, stripping tags.


gzrewind

public boolean gzrewind(BinaryStream binaryStream)
Rewinds the stream to the very beginning


gzseek

public int gzseek(BinaryStream binaryStream,
                  long offset,
                  int whence)
Set stream position to the offset

Parameters:
offset - absolute position to set stream to
whence - if set, changes the interpretation of offset like fseek
Returns:
0 upon success, else -1 for error

gztell

public Value gztell(BinaryStream binaryStream)
Gets the current position in the stream

Returns:
the position in the stream, or FALSE for error

gzpassthru

public Value gzpassthru(Env env,
                        BinaryInput is)
Prints out the remaining data in the stream to stdout


zlib_get_coding_type

public Value zlib_get_coding_type(Env env)
Returns the encoding type both allowed by the server and supported by the user's browser.


gzcompress

public Value gzcompress(Env env,
                        java.io.InputStream data,
                        int level)
compresses data using zlib

Parameters:
data -
level - (default is Deflater.DEFAULT_COMPRESSION)
Returns:
compressed string

gzuncompress

public Value gzuncompress(Env env,
                          java.io.InputStream is,
                          long length)
Parameters:
data -
length - (maximum length of string returned)
Returns:
uncompressed string

gzdeflate

public Value gzdeflate(Env env,
                       java.io.InputStream data,
                       int level)
Parameters:
level -
Returns:
compressed using DEFLATE algorithm

gzinflate

public Value gzinflate(Env env,
                       java.io.InputStream data,
                       int length)
Parameters:
data - compressed using Deflate algorithm
length - of data to decompress
Returns:
uncompressed string

gzencode

public Value gzencode(Env env,
                      java.io.InputStream is,
                      int level,
                      int encodingMode)
Compresses data using the Deflate algorithm, output is compatible with gzwrite's output

Parameters:
data - compressed with the Deflate algorithm
level - Deflate compresion level [0-9]
encodingMode - CRC32 trailer is not written if encoding mode is FORCE_DEFLATE, default is to write CRC32
Returns:
StringValue with gzip header and trailer