Main Page | Data Structures | Directories | File List | Data Fields

httpd.h

00001 /*
00002 ** Copyright (c) 2002  Hughes Technologies Pty Ltd.  All rights
00003 ** reserved.
00004 **
00005 ** Terms under which this software may be used or copied are
00006 ** provided in the  specific license associated with this product.
00007 **
00008 ** hUghes Technologies disclaims all warranties with regard to this
00009 ** software, including all implied warranties of merchantability and
00010 ** fitness, in no event shall Hughes Technologies be liable for any
00011 ** special, indirect or consequential damages or any damages whatsoever
00012 ** resulting from loss of use, data or profits, whether in an action of
00013 ** contract, negligence or other tortious action, arising out of or in
00014 ** connection with the use or performance of this software.
00015 **
00016 **
00017 ** $Id: httpd.h,v 1.3 2004/11/17 23:54:24 alexcv Exp $
00018 **
00019 */
00020 
00021 /*
00022 **  libhttpd Header File
00023 */
00024 
00025 
00026 /***********************************************************************
00027 ** Standard header preamble.  Ensure singular inclusion, setup for
00028 ** function prototypes and c++ inclusion
00029 */
00030 
00031 #ifndef LIB_HTTPD_H
00032 
00033 #define LIB_HTTPD_H 1
00034 
00035 #if !defined(__ANSI_PROTO)
00036 #if defined(_WIN32) || defined(__STDC__) || defined(__cplusplus)
00037 #  define __ANSI_PROTO(x)       x
00038 #else
00039 #  define __ANSI_PROTO(x)       ()
00040 #endif
00041 #endif
00042 
00043 #ifdef __cplusplus
00044 extern "C" {
00045 #endif
00046 
00047 
00048 
00049 /***********************************************************************
00050 ** Macro Definitions
00051 */
00052 
00053 
00054 #define HTTP_PORT               80
00055 #define HTTP_MAX_LEN            10240
00056 #define HTTP_MAX_URL            1024
00057 #define HTTP_MAX_HEADERS        1024
00058 #define HTTP_MAX_AUTH           128
00059 #define HTTP_IP_ADDR_LEN        17
00060 #define HTTP_TIME_STRING_LEN    40
00061 #define HTTP_READ_BUF_LEN       4096
00062 #define HTTP_ANY_ADDR           NULL
00063 
00064 #define HTTP_GET                1
00065 #define HTTP_POST               2
00066 
00067 #define HTTP_TRUE               1
00068 #define HTTP_FALSE              0
00069 
00070 #define HTTP_FILE               1
00071 #define HTTP_C_FUNCT            2
00072 #define HTTP_EMBER_FUNCT        3
00073 #define HTTP_STATIC             4
00074 #define HTTP_WILDCARD           5
00075 #define HTTP_C_WILDCARD         6
00076 
00077 #define HTTP_METHOD_ERROR "\n<B>ERROR : Method Not Implemented</B>\n\n"
00078 
00079 #define httpdRequestMethod(s)           s->request.method
00080 #define httpdRequestPath(s)             s->request.path
00081 #define httpdRequestContentType(s)      s->request.contentType
00082 #define httpdRequestContentLength(s)    s->request.contentLength
00083 
00084 #define HTTP_ACL_PERMIT         1
00085 #define HTTP_ACL_DENY           2
00086 
00087 
00088 
00089 extern char     LIBHTTPD_VERSION[],
00090                 LIBHTTPD_VENDOR[];
00091 
00092 /***********************************************************************
00093 ** Type Definitions
00094 */
00095 
00096 typedef struct {
00097         int     method,
00098                 contentLength,
00099                 authLength;
00100         char    path[HTTP_MAX_URL],
00101                 host[HTTP_MAX_URL], /* acv@acv.ca/wifidog: Added decoding
00102                                        of host: header if present. */
00103                 userAgent[HTTP_MAX_URL],
00104                 referer[HTTP_MAX_URL],
00105                 ifModified[HTTP_MAX_URL],
00106                 contentType[HTTP_MAX_URL],
00107                 authUser[HTTP_MAX_AUTH],
00108                 authPassword[HTTP_MAX_AUTH];
00109 } httpReq;
00110 
00111 
00112 typedef struct _httpd_var{
00113         char    *name,
00114                 *value;
00115         struct  _httpd_var      *nextValue,
00116                                 *nextVariable;
00117 } httpVar;
00118 
00119 typedef struct _httpd_content{
00120         char    *name;
00121         int     type,
00122                 indexFlag;
00123         void    (*function)();
00124         char    *data,
00125                 *path;
00126         int     (*preload)();
00127         struct  _httpd_content  *next;
00128 } httpContent;
00129 
00130 typedef struct {
00131         int             responseLength;
00132         httpContent     *content;
00133         char            headersSent,
00134                         headers[HTTP_MAX_HEADERS],
00135                         response[HTTP_MAX_URL],
00136                         contentType[HTTP_MAX_URL];
00137 } httpRes;
00138 
00139 
00140 typedef struct _httpd_dir{
00141         char    *name;
00142         struct  _httpd_dir *children,
00143                         *next;
00144         struct  _httpd_content *entries;
00145 } httpDir;
00146 
00147 
00148 typedef struct ip_acl_s{
00149         int     addr;
00150         char    len,
00151                 action;
00152         struct  ip_acl_s *next;
00153 } httpAcl;
00154 
00155 typedef struct _httpd_404 {
00156         void    (*function)();
00157 } http404;
00158 
00159 typedef struct {
00160         int     port,
00161                 serverSock,
00162                 startTime,
00163                 lastError;
00164         char    fileBasePath[HTTP_MAX_URL],
00165                 *host;
00166         httpDir *content;
00167         httpAcl *defaultAcl;
00168         http404  *handle404;
00169         FILE    *accessLog,
00170                 *errorLog;
00171 } httpd;
00172 
00173 typedef struct {
00174         int     clientSock,
00175                 readBufRemain;
00176         httpReq request;
00177         httpRes response;
00178         httpVar *variables;
00179         char    readBuf[HTTP_READ_BUF_LEN + 1],
00180                 *readBufPtr,
00181                 clientAddr[HTTP_IP_ADDR_LEN];
00182 } request;
00183 
00184 /***********************************************************************
00185 ** Function Prototypes
00186 */
00187 
00188 
00189 int httpdAddCContent __ANSI_PROTO((httpd*,char*,char*,int,int(*)(),void(*)()));
00190 int httpdAddFileContent __ANSI_PROTO((httpd*,char*,char*,int,int(*)(),char*));
00191 int httpdAddStaticContent __ANSI_PROTO((httpd*,char*,char*,int,int(*)(),char*));
00192 int httpdAddWildcardContent __ANSI_PROTO((httpd*,char*,int(*)(),char*));
00193 int httpdAddCWildcardContent __ANSI_PROTO((httpd*,char*,int(*)(),void(*)()));
00194 int httpdAddVariable __ANSI_PROTO((request*, char*, char*));
00195 request *httpdGetConnection __ANSI_PROTO((httpd*, struct timeval*));
00196 int httpdReadRequest __ANSI_PROTO((httpd*, request*));
00197 int httpdCheckAcl __ANSI_PROTO((httpd*, request *, httpAcl*));
00198 int httpdAddC404Content __ANSI_PROTO((httpd*,void(*)()));
00199 
00200 char *httpdRequestMethodName __ANSI_PROTO((request*));
00201 char *httpdUrlEncode __ANSI_PROTO((char *));
00202 
00203 void httpdAddHeader __ANSI_PROTO((request*, char*));
00204 void httpdSetContentType __ANSI_PROTO((request*, char*));
00205 void httpdSetResponse __ANSI_PROTO((request*, char*));
00206 void httpdEndRequest __ANSI_PROTO((request*));
00207 
00208 httpd *httpdCreate __ANSI_PROTO(());
00209 void httpdFreeVariables __ANSI_PROTO((request*));
00210 void httpdDumpVariables __ANSI_PROTO((request*));
00211 void httpdOutput __ANSI_PROTO((request*, char*));
00212 void httpdPrintf __ANSI_PROTO((request*, char*, ...));
00213 void httpdProcessRequest __ANSI_PROTO((httpd*, request *));
00214 void httpdSendHeaders __ANSI_PROTO((request*));
00215 void httpdSetFileBase __ANSI_PROTO((httpd*, char*));
00216 void httpdSetCookie __ANSI_PROTO((request*, char*, char*));
00217 
00218 void httpdSetErrorLog __ANSI_PROTO((httpd*, FILE*));
00219 void httpdSetAccessLog __ANSI_PROTO((httpd*, FILE*));
00220 void httpdSetDefaultAcl __ANSI_PROTO((httpd*, httpAcl*));
00221 
00222 httpVar *httpdGetVariableByName __ANSI_PROTO((request*, char*));
00223 httpVar *httpdGetVariableByPrefix __ANSI_PROTO((request*, char*));
00224 httpVar *httpdGetVariableByPrefixedName __ANSI_PROTO((request*, char*, char*));
00225 httpVar *httpdGetNextVariableByPrefix __ANSI_PROTO((httpVar*, char*));
00226 
00227 httpAcl *httpdAddAcl __ANSI_PROTO((httpd*, httpAcl*, char*, int));
00228 
00229 
00230 /***********************************************************************
00231 ** Standard header file footer.  
00232 */
00233 
00234 #ifdef __cplusplus
00235         }
00236 #endif /* __cplusplus */
00237 #endif /* file inclusion */
00238 
00239 

Generated on Sun Apr 3 20:04:46 2005 for WifiDog by  doxygen 1.4.1