00001 /****************************************************************************
00002 *
00003 * (C) 1999 by BECK IPC GmbH
00004 *
00005 * BECK IPC GmbH
00006 * Garbenheimerstr. 38
00007 * D-35578 Wetzlar
00008 *
00009 * Phone : (49)-6441-905-240
00010 * Fax : (49)-6441-905-245
00011 *
00012 * ---------------------------------------------------------------------------
00013 * Module : CGI.H
00014 * Function : access to webservers cgi
00015 *
00016 *
00017 * Author : Bartat
00018 * Date : 05.11.99
00019 * Version : V1.00
00020 * ---------------------------------------------------------------------------
00021 * History :
00022 *
00023 * Vx.yy Author Changes
00024 *
00025 * V1.00 mb Create
00026 * V1.01 12.01.00 mb added func getformitem
00027 * V1.01 04.04.00 mb added new mimetype defines
00028 * ,available at SC12 BIOS V0.65
00029 * added cgi install func for Pascal CGI procedures
00030 *****************************************************************************/
00031 #ifndef _CGI_H__
00032 #define _CGI_H__
00033
00034 /*****************************************************************************/
00035 //CGI defines
00036 /*****************************************************************************/
00037
00038 //Cgi HTTP requests
00039 #define CgiHttpGet 1 /* Cgi request is HTTP GET */
00040 #define CgiHttpHead 2 /* Cgi request is HTTP HEAD */
00041 #define CgiHttpPost 3 /* Cgi request is HTTP POST */
00042
00043
00044 //Cgi HTTP responses
00045 #define CgiHttpOk 0 /* Cgi returns HTTP 200 Ok */
00046 #define CgiHttpOkStatic 1 /* Cgi returns HTTP 200 Ok - Static Object */
00047 #define CgiHttpRedirect 2 /* Cgi returns HTTP 302 Moved Temp */
00048 #define CgiHttpNotModified 3 /* Cgi returns HTTP 304 Not Modified */
00049 #define CgiHttpUnauthorized 4 /* Cgi returns HTTP 401 Unauthorized */
00050 #define CgiHttpNotFound 5 /* Cgi returns HTTP 404 Not Found */
00051 #define CgiHttpOKNoDoc 6 /* Cgi returns HTTP 204 No document follows*/
00052
00053
00054 //CGI constants for content types ,fDatatype
00055
00056 #define CGIDataTypeHtml 0 /* CGI returns text/html */
00057 #define CGIDataTypeImageGif 1 /* image/gif */
00058 #define CGIDataTypeApplet 2 /* application/octet-stream */
00059 #define CGIDataTypeText 3 /* text/plain */
00060 #define CGIDataTypeImageJpeg 4 /* image/jpeg */
00061 #define CGIDataTypeImagePict 5 /* image/pict */
00062 #define CGIDataTypeImageTiff 6 /* image/tiff */
00063 #define CGIDataTypeImagePng 7 /* image/png */
00064 #define CGIDataTypeForm 8 /* application/x-www-form-urlencoded */
00065 #define CGIDataTypeIpp 9 /* application/ipp */
00066 #define CGIDataTypeCss 10 /* text/css */
00067 #define CGIDataTypeXml 11 /* text/xml */
00068 #define CGIDataTypeWav 12 /* audio/wav */
00069 #define CGIDataTypePdf 13 /* application/pdf */
00070 #define CGIDataTypeJavaArchive 14 /* application/java-archive */
00071 #define CGIDataTypeOctet 15 /* application/octet-stream */
00072 #define CGIDataTypeVndWapWml 16 /* text/vnd.wap.wml */
00073 #define CGIDataTypeVndWapWbmp 17 /* image/vnd.wap.wbmp */
00074 #define CGIDataTypeVndWapWmlc 18 /* application/vnd.wap.wmlc */
00075 #define CGIDataTypeVndWapWmlscript 19 /* text/vnd.wap.wmlscript */
00076 #define CGIDataTypeVndWapWmlscriptc 20 /* text/vnd.wap.wmlscriptc */
00077
00078
00079 /*****************************************************************************/
00080 //Cgi API calls
00081 /*****************************************************************************/
00082 #define CGI_INSTALL 1 /* Install a cgi function */
00083 #define CGI_REMOVE 2 /* Delete a cgi function */
00084 #define CGI_SETMAIN 3 /* Set new main page name */
00085 #define CGI_SETROOTDIR 4 /* Set webservers root directory */
00086 #define CGI_GETROOTDIR 5 /* Get webservers root directory */
00087 #define CGI_GETMAIN 6 /* Get name of main page*/
00088 #define CGI_GETFORMITEM 7 /* Split argumentbuf into formular name and value*/
00089 #define CGI_FINDNEXTITEM 8 /* Find next formitem, if one */
00090 #define CGI_INSTALL_PAS 9 /* Install a Turbo Pascal cgi procedure */
00091
00092
00093 /*****************************************************************************/
00094 //CGI API general Errorcodes
00095 /*****************************************************************************/
00096 #define CGI_NOT_SUPPORTED -2
00097 #define CGI_ERROR -1
00098 #define CGI_ENOERROR 0
00099
00100 /*****************************************************************************/
00101 //CGI API special Errorcodes, returned at the ax-register
00102 /*****************************************************************************/
00103
00104 #define CGI_INVALID_METHOD -1
00105 #define CGI_INVALID_NAME -2
00106 #define CGI_INVALID_DIR -3
00107
00108
00109 /*****************************************************************************/
00110 //types
00111 /*****************************************************************************/
00112 typedef struct tag_cgi_table{
00113
00114 char * PathPtr; //name of the page
00115 int method; //httpmethod: get,put or post
00116 void * CgiFuncPtr; //ptr to callback function of this page
00117 }CGI_Entry;
00118
00119
00120
00121 /*
00122 this type is needed, if the function CGI_GETFORMITEM will be used,
00123 the user must set the pointers of the structure
00124 to his own buffers look at example submit.c.
00125 */
00126
00127 typedef struct tag_form_item{
00128
00129 char * NamePtr;
00130 char * ValuePtr;
00131 }FormItem;
00132
00133
00134
00135 /*
00136 the called cgi function gets as a parmeter
00137 a pointer of the following structure, which contains
00138 the needed http-request data and response data
00139 */
00140
00141 typedef struct {
00142
00143 //Request fields, read only!!!!
00144
00145 unsigned char fConnectionId; // internal use only
00146 int fHttpRequest; // internal use only
00147 char * fPathPtr; // URL
00148 char * fHostPtr; // Host:
00149 char * fRefererPtr; // Referer:
00150 char * fAgentPtr; // User-Agent:
00151 char * fLanguagePtr; // Content-Language:
00152 unsigned long fBrowserDate; // Date: (internal)
00153 char * fArgumentBufferPtr; // Pointer at argument buffer
00154 long fArgumentBufferLength; // length of argument buffer, -1 buffer empty
00155 char * fUserNamePtr; // Username from Authorization
00156 char * fPasswordPtr; // Password from Authorization
00157
00158
00159 void * fUserDataPtr; // reserved
00160
00161 //Response fields,
00162
00163 int fResponseState; // internal, do not modify
00164 int fHttpResponse; // response msg mostly CgiHttpOK
00165 int fDataType; // content type mostly text/html
00166 char * fResponseBufferPtr; // pointer to created dynamic html page
00167 long fResponseBufferLength; // length of the created page
00168 unsigned long fObjectDate; // internal, do not modify
00169 unsigned int fHostIndex; // internal, do not modify
00170 } rpCgi, *rpCgiPtr;
00171 /*****************************************************************************/
00172 #endif /*_CGI_H__*/