---
name: "Ns_Adp"
section: "3"
platform: "linux"
package: "aolserver4"
version: "4.0.10-7"
release: "Debian 4.0 (Etch)"
platforms: ["linux"]
url: "https://new.carta.tech/Ns_Adp"
---

# Ns\_Adp(3)

Create and use ADP parsers

```

```

## NAME

Ns\_AdpRegisterParser, Ns\_AdpRequest - Create and use ADP parsers

## SYNOPSIS

```
#include "ns.h"

int
Ns_AdpRegisterParser(char *extension, Ns_AdpParserProc *newParserProc)

int
Ns_AdpRequest(arg, arg)
```

## DESCRIPTION

These functions register new ADP parsers and run ADP requests.

- **Ns\_AdpRegisterParser**(*extension, newParserProc*)

  Registers a new, named ADP parser procedure with the name given in *extension*. You can tie a file extension to a particular named parser in the **nsd.tcl** file. The *newParserProc* will be called when an ADP with the associated file extension needs to be parsed. If a file extension is registered as an ADP in the **nsd.tcl** but no parser is associated with that file extension, the default ADP parser is used.

  The *newParserProc* must accept two arguments:

  typedef void (Ns\_AdpParserProc)(Ns\_DString \*out, char \*in);

  The ADP input is pointed to by *in*. Your parser must process the content of *in* and append the parsed output to *out*.

  The output should be formatted as a series of concatenated "chunks". A chunk is a string of the format:

  \<type character\>\<string\>\<null\>

  where \<type character\> = 't' or 's'. A 't' means what follows is HTML and should be returned directly to the browser. An 's' means what follows is Tcl and should be evaluated.

  After the last chunk there should be an extra \<null\> character. For example, the "adp" parser will take a page like this:

  This is a test page\<%ns\_puts hi%\>The end\<%ns\_puts bye%\>

  And create this output:

  "tThis is a test page\\0sns\_puts hi\\0tThe end\\0sns\_puts bye\\0\\0"

- **Ns\_AdpRequest**(*conn*, *file*)

  Parse and evaluate an ADP file.

## SEE ALSO

nsd(1), [info(n)](/info/n.md)

## KEYWORDS
