The qDecoder Project

qSed.c File Reference

Server Side Include and Variable Replacement API. More...


Defines

#define SSI_INCLUDE_START   "<!--#include file=\""
#define SSI_INCLUDE_END   "\"-->"

Functions

bool qSedStr (Q_ENTRY *entry, const char *srcstr, FILE *fpout)
 Perform text transformations on input string.
bool qSedFile (Q_ENTRY *entry, const char *filepath, FILE *fpout)
 Perform text transformations on input file.


Detailed Description

Server Side Include and Variable Replacement API.

filename is an input(target) file while fpout stands for output streams. When you wish to display the results in files, open files in "w" and then, hand over the corresponding file pointers. And if you wish to display them on-screen, just specify stdout.

It interprets the SSI grammar. (Currently, only [an error occurred while processing this directive] is supported.) If there is the following lines in a document, the corresponding document is included in the display. And the replacement and SSI functions are valid for the included document. (Cascading)

Note) The included file can be marked by relative paths on the basis of the location where CGI is executed. Or it may be marked by system absolute paths.

If you wish to use the SSI function only without replacing character strings, transmit the NULL value using the arg argument as follows:

ex) qSedFile(NULL, "streamedit.html.in", stdout);


Function Documentation

bool qSedStr ( Q_ENTRY entry,
const char *  srcstr,
FILE *  fpout 
)

Perform text transformations on input string.

Parameters:
entry arguments to be transformed
srcstr source string
fpout output stream
Returns:
true if successful, otherwise returns false.
   Q_ENTRY *args = qEntryInit();
   args = qEntryPutStr(args, "${NAME}", "The qDecoder Project");
   args = qEntryPutStr(args, "${HOBBY}", "Open Source Project");
   qSedStr(args, "${NAME} : ${HOBBY}", stdout);
   qEntryFree(args);

bool qSedFile ( Q_ENTRY entry,
const char *  filepath,
FILE *  fpout 
)

Perform text transformations on input file.

Parameters:
entry arguments to be transformed
filepath socket descriptor
fpout output stream
Returns:
true if successful, otherwise returns false.
   <!--#include file="streamedit-header.html.in"-->
   <p>Hi <b>${NAME}</b>.
   <p>You got a really cool hobby.
   <br>I'm sure that your hobby, <b>${HOBBY}</b>, can give you more fun in your life time.
   <p>Bye :)
   <!--#include file="streamedit-tailer.html.in"-->

   Q_ENTRY *args = qEntryInit();
   args = qEntryPutStr(args, "${NAME}", "The qDecoder Project");
   args = qEntryPutStr(args, "${HOBBY}", "Open Source Project");
   qSedFile(args, "streamedit.html.in", stdout);
   qEntryFree(args);


[Home] [About] [Examples] [Changes] [Download] [SVN Repository] [Install] [Reference]