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