---
name: "Ns_Gzip"
section: "3aolserver"
platform: "linux"
package: "aolserver4-dev"
version: "4.5.1-18.1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/Ns_Gzip"
---

# Ns\_Gzip(3aolserver)

GZIP compression support

```

```

## NAME

Ns\_Gzip, Ns\_SetGzipProc - GZIP compression support

## SYNOPSIS

```
#include "ns.h"

int
Ns_Gzip(buf, len, level, dsPtr)

void
Ns_SetGzipProc(proc)
```

## ARGUMENTS

- Tcl\_DString *dsPtr* (out)

  Output buffer to placed compressed string.

- int *len* (in)

  Length of string pointed to by *buf*.

- char *\*buf* (in)

  Pointer to string to compress.

- int *level* (in)

  Requested GZIP compression level.

- Ns\_GzipProc *proc* (in)

  Procedure to GZIP content.

  ```

  ```

## DESCRIPTION

These functions enable GZIP compress of text buffers.

- int **Ns\_Gzip**(*buf, len, level, dsPtr*)

  This function compresses a string pointed to by *buf* of length *len*, appending the output to the given *dsPtr*. The output buffer must already be initialized.  The *level* parameter specifies the compress level between 0 and 9; see the documentation in the zlib.h for details.

  The function will return NS\_OK if compression was successful, otherwise NS\_ERROR.  A call to **Ns\_SetGzipProc** to install a compression function must have already occured.  The *nszlib* module will install a suitable function when loaded.

- void **Ns\_SetGzipProc**(*proc*)

  This function is used to install a compression function for **Ns\_Gzip**.  A call to **Ns\_SetGzipProc** would normally be in the module-load routine of a module which provides compression support, e.g., the *nszlib* module.  The function should match the type **Ns\_GzipProc**:

  ```
  typedef int Ns_GzipProc(
  	char *buf, int len, int level, Tcl_DString *dsPtr
  );
  ```

## KEYWORDS

compress, gzip
