Name

gzsetparams — Sets the compression level and compression strategy on the compressed file stream referenced by file.


Library

Libz.lib


Synopsis

#include <zlib.h>

int gzsetparams (gzFile file, int level, int strategy);


Return Value

On success, the gzsetparams() function shall return Z_OK.


Detailed Description

The gzsetparams() function shall set the compression level and compression strategy on the compressed file stream referenced by file. The compressed file stream shall have been opened in a write mode. The level and strategy are as defined in deflateInit2_. If there is any data pending writing, it shall be flushed before the parameters are updated.


Examples

To set the compression level=Z_BEST_SPEED and compression strategy=Z_DEFAULT_STRATEGY on the compressed file stream referenced by file:

#include <stdio.h>
#include <zlib.h>

void Gzsetparams( )
{
    const char hello[] = "hello, hello!";
    int len = (int)strlen(hello)+1;
    gzFile file;
    const char * fname = TESTFILE;     
    file = gzopen(fname, "wb");
    gzputc(file, 'h');     
    int u = gzsetparams(file, Z_BEST_SPEED, Z_DEFAULT_STRATEGY);
    int err=  gzclose(file);
}


Errors

On error, gzsetparams() shall return one of the following error indications:

Z_STREAM_ERROR

Invalid parameter, or file not open for writing.

Z_BUF_ERROR

An internal inconsistency was detected while flushing the previous buffer.


Feedback

For additional information or queries on this page send feedback

© 2007-2009 Nokia Corporation. All rights reserved. This documentation can be used in the connection with this Product to help and support the user.