ns_adp(3)

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 re
quests.
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 exten
sion, 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 con
catenated "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 evaluat
ed.
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 sns_puts hi tThe end sns_puts
bye "
Ns_AdpRequest(conn, file)

Parse and evaluate an ADP file.

SEE ALSO

nsd(1), info(n)

KEYWORDS

Copyright © 2010-2025 Platon Technologies, s.r.o.           Home | Man pages | tLDP | Documents | Utilities | About
Design by styleshout