/*****************************************************************************/
/*
                                  CGI.h

Defines and function prototypes for CGI module.

*/
/*****************************************************************************/

#ifndef CGI_H_LOADED
#define CGI_H_LOADED 1

#include "wasd.h"

#define CGI_VARIABLE_DCL     1
#define CGI_VARIABLE_STREAM  2

#define CGI_OUTPUT_MODE_STREAM   1
#define CGI_OUTPUT_MODE_RECORD   2
#define CGI_OUTPUT_MODE_RECORD0  3
#define CGI_OUTPUT_MODE_CRLF     4

#define CGI_OUTPUT_GZIP      1
#define CGI_OUTPUT_NO_GZIP   2

#define CGI_OUTPUT_CHUNK     1
#define CGI_OUTPUT_NO_CHUNK  2

/* just magic numbers that could never be a buffer length */
#define CGI_OUTPUT_CUTOFF        0xABADABA1
#define CGI_OUTPUT_END           0xABADABA2 
#define CGI_OUTPUT_ESCAPE_BEGIN  0xABADABA3
#define CGI_OUTPUT_ESCAPE        0xABADABA4
#define CGI_OUTPUT_ESCAPE_END    0xABADABA5
#define CGI_OUTPUT_NOT_STRICT    0xABADABA6
#define CGI_OUTPUT_RAW           0xABADABA7

/***********************/
/* function prototypes */
/***********************/

#define CgiSequenceBel(charptr,lenptr) CgiSequence ('G', charptr, lenptr);
#define CgiSequenceEot(charptr,lenptr) CgiSequence ('D', charptr, lenptr);
#define CgiSequenceEof(charptr,lenptr) CgiSequence ('Z', charptr, lenptr);
#define CgiSequenceEsc(charptr,lenptr) CgiSequence ('E', charptr, lenptr);

int CgiGenerateVariables (REQUEST_STRUCT*, int);
int CgiOutput (REQUEST_STRUCT*, char*, int);
void CgiOutputFile (REQUEST_STRUCT*, char*, int);
int CgiScriptControlField (REQUEST_STRUCT*, char*);
void CgiSequence (char, char*, int*);
int CgiVariable (REQUEST_STRUCT*, char*, char*, int);
void CgiVariableBufferMemory (REQUEST_STRUCT*, int);
int CgiUrlDecodeString (REQUEST_STRUCT*, char*, char*, int, char);

#endif /* CGI_H_LOADED */

/*****************************************************************************/

