adpparse.c File Reference

#include "nsd.h"

Data Structures

struct  Tag
struct  Parse

Defines

#define SERV_STREAM   1
#define SERV_RUNAT   2
#define SERV_NOTTCL   4
#define TAG_ADP   1
#define TAG_PROC   2
#define TAG_SCRIPT   3
#define TAG_SERVER   4
#define APPEND   "ns_adp_append "
#define APPEND_LEN   (sizeof(APPEND)-1)
#define LENSZ   (sizeof(int))

Functions

int Ns_AdpRegisterParser (char *extension, Ns_AdpParserProc *proc)
int NsTclAdpRegisterAdpObjCmd (ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj **objv)
int NsTclAdpRegisterProcObjCmd (ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj **objv)
int NsTclAdpRegisterScriptObjCmd (ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj **objv)
void NsAdpParse (AdpCode *codePtr, NsServer *servPtr, char *adp, int flags)
void NsAdpFreeCode (AdpCode *codePtr)

Define Documentation

#define APPEND   "ns_adp_append "

#define APPEND_LEN   (sizeof(APPEND)-1)

#define LENSZ   (sizeof(int))

#define SERV_NOTTCL   4

#define SERV_RUNAT   2

#define SERV_STREAM   1

#define TAG_ADP   1

#define TAG_PROC   2

#define TAG_SCRIPT   3

#define TAG_SERVER   4


Function Documentation

int Ns_AdpRegisterParser ( char *  extension,
Ns_AdpParserProc *  proc 
)

----------------------------------------------------------------------

Ns_AdpRegisterParser --

Register an ADP parser (no longer supported).

Results: NS_ERROR.

Side effects: None.

----------------------------------------------------------------------

void NsAdpFreeCode ( AdpCode codePtr  ) 

----------------------------------------------------------------------

NsAdpFreeCode --

Free internal AdpCode storage.

Results: None.

Side effects: None.

----------------------------------------------------------------------

void NsAdpParse ( AdpCode codePtr,
NsServer servPtr,
char *  adp,
int  flags 
)

----------------------------------------------------------------------

NsAdpParse --

Parse a string of ADP text/script. Parsing is done in a single, top to bottom pass, looking for the following four types of embedded script sequences:

1. <% tcl script %> 2. <script runat="server" language="tcl>"> tcl script </script> 3. <registered-tag arg=val arg=val> 4. <registered-start-tag arg=val arg=val> text </registered-end-tag>

Nested sequences are handled for each case, for example:

Text <% ns_adp_eval {<% ... %>} %> text ...

Results: None.

Side effects: Given AdpCode structure is initialized and filled in with copy of parsed ADP.

----------------------------------------------------------------------

Initialize the code and parse structures.

Parse ADP one tag at a time.

Process the tag depending on the current state.

Look for a <% ... %> sequence.

NB: Avoid <%>.

Find the cooresponding %> beyond any additional nested <% ... %> sequences.

No matching %> found. Append text and invalid opening <% before searching for next ADP tag.

NB: Next text after invalid opening <%.

Append text block followed by script block unless in safe mode which suppresses in-line scripts and continue looking for next ADP tag.

NB: Next text after valid closing %>.

NB: Will incr +1, past text, below.

Check for <script> tags or registered tags.

Append text and begin looking for closing </script> tag.

Append text and the registered tag content if the tag does not require a closing tag. Otherwise, save the tag attribute offsets and begin looking for required closing tag.

Look for cooresponding closing </script> tag, handling possible nesting of other <script> tags.

Found closing tag. If not in safe mode, enable streaming if requested and appending the embedded script and then begin looking for next ADP tag.

Looking for cooresponding closing tag for a registered tag, handling possible nesting of the same tag.

Found closing tag. Append tag content and being looking for next ADP tag.

Skip to next possible ADP tag location.

Append the remaining text block and complete the parse code structure.

If requested, collapse blocks to a single Tcl script.

int NsTclAdpRegisterAdpObjCmd ( ClientData  arg,
Tcl_Interp *  interp,
int  objc,
Tcl_Obj **  objv 
)

----------------------------------------------------------------------

NsTclAdpRegisterAdpObjCmd, NsTclAdpRegisterProcObjCmd, NsTclAdpRegisterScriptObjCmd --

Register an proc, script, are ADP string tag.

Results: Standard Tcl result.

Side effects: An ADP tag may be added to the hashtable.

----------------------------------------------------------------------

int NsTclAdpRegisterProcObjCmd ( ClientData  arg,
Tcl_Interp *  interp,
int  objc,
Tcl_Obj **  objv 
)

int NsTclAdpRegisterScriptObjCmd ( ClientData  arg,
Tcl_Interp *  interp,
int  objc,
Tcl_Obj **  objv 
)


Generated on Tue Sep 4 19:58:55 2007 by  doxygen 1.5.1