root/trunk/wifidog/libhttpd/httpd.h @ 87

Revision 87, 5.8 KB (checked in by benoitg, 9 years ago)

2004-04-19 Benoit Gr�goire <bock@…>

  • Properly integrate libhttpd into the source tree ;) Note that this will create a proper system wide shared librery for libghttpd. Still to be done: 1- Store Mina's patch somewhere, in case we want to upgrade libhttpd. 2-Add configure option not to build httpd, and use an already installed one.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/*
2** Copyright (c) 2002  Hughes Technologies Pty Ltd.  All rights
3** reserved.
4**
5** Terms under which this software may be used or copied are
6** provided in the  specific license associated with this product.
7**
8** Hughes Technologies disclaims all warranties with regard to this
9** software, including all implied warranties of merchantability and
10** fitness, in no event shall Hughes Technologies be liable for any
11** special, indirect or consequential damages or any damages whatsoever
12** resulting from loss of use, data or profits, whether in an action of
13** contract, negligence or other tortious action, arising out of or in
14** connection with the use or performance of this software.
15**
16**
17** $Id$
18**
19*/
20
21/*
22**  libhttpd Header File
23*/
24
25
26/***********************************************************************
27** Standard header preamble.  Ensure singular inclusion, setup for
28** function prototypes and c++ inclusion
29*/
30
31#ifndef LIB_HTTPD_H
32
33#define LIB_HTTPD_H 1
34
35#if !defined(__ANSI_PROTO)
36#if defined(_WIN32) || defined(__STDC__) || defined(__cplusplus)
37#  define __ANSI_PROTO(x)       x
38#else
39#  define __ANSI_PROTO(x)       ()
40#endif
41#endif
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47
48
49/***********************************************************************
50** Macro Definitions
51*/
52
53
54#define HTTP_PORT               80
55#define HTTP_MAX_LEN            10240
56#define HTTP_MAX_URL            1024
57#define HTTP_MAX_HEADERS        1024
58#define HTTP_MAX_AUTH           128
59#define HTTP_IP_ADDR_LEN        17
60#define HTTP_TIME_STRING_LEN    40
61#define HTTP_READ_BUF_LEN       4096
62#define HTTP_ANY_ADDR           NULL
63
64#define HTTP_GET                1
65#define HTTP_POST               2
66
67#define HTTP_TRUE               1
68#define HTTP_FALSE              0
69
70#define HTTP_FILE               1
71#define HTTP_C_FUNCT            2
72#define HTTP_EMBER_FUNCT        3
73#define HTTP_STATIC             4
74#define HTTP_WILDCARD           5
75#define HTTP_C_WILDCARD         6
76
77#define HTTP_METHOD_ERROR "\n<B>ERROR : Method Not Implemented</B>\n\n"
78
79#define httpdRequestMethod(s)           s->request.method
80#define httpdRequestPath(s)             s->request.path
81#define httpdRequestContentType(s)      s->request.contentType
82#define httpdRequestContentLength(s)    s->request.contentLength
83
84#define HTTP_ACL_PERMIT         1
85#define HTTP_ACL_DENY           2
86
87
88
89extern char     LIBHTTPD_VERSION[],
90                LIBHTTPD_VENDOR[];
91
92/***********************************************************************
93** Type Definitions
94*/
95
96typedef struct {
97        int     method,
98                contentLength,
99                authLength;
100        char    path[HTTP_MAX_URL],
101                userAgent[HTTP_MAX_URL],
102                referer[HTTP_MAX_URL],
103                ifModified[HTTP_MAX_URL],
104                contentType[HTTP_MAX_URL],
105                authUser[HTTP_MAX_AUTH],
106                authPassword[HTTP_MAX_AUTH];
107} httpReq;
108
109
110typedef struct _httpd_var{
111        char    *name,
112                *value;
113        struct  _httpd_var      *nextValue,
114                                *nextVariable;
115} httpVar;
116
117typedef struct _httpd_content{
118        char    *name;
119        int     type,
120                indexFlag;
121        void    (*function)();
122        char    *data,
123                *path;
124        int     (*preload)();
125        struct  _httpd_content  *next;
126} httpContent;
127
128typedef struct {
129        int             responseLength;
130        httpContent     *content;
131        char            headersSent,
132                        headers[HTTP_MAX_HEADERS],
133                        response[HTTP_MAX_URL],
134                        contentType[HTTP_MAX_URL];
135} httpRes;
136
137
138typedef struct _httpd_dir{
139        char    *name;
140        struct  _httpd_dir *children,
141                        *next;
142        struct  _httpd_content *entries;
143} httpDir;
144
145
146typedef struct ip_acl_s{
147        int     addr;
148        char    len,
149                action;
150        struct  ip_acl_s *next;
151} httpAcl;
152
153typedef struct _httpd_404 {
154        void    (*function)();
155} http404;
156
157typedef struct {
158        int     port,
159                serverSock,
160                clientSock,
161                readBufRemain,
162                startTime;
163        char    clientAddr[HTTP_IP_ADDR_LEN],
164                fileBasePath[HTTP_MAX_URL],
165                readBuf[HTTP_READ_BUF_LEN + 1],
166                *host,
167                *readBufPtr;
168        httpReq request;
169        httpRes response;
170        httpVar *variables;
171        httpDir *content;
172        httpAcl *defaultAcl;
173        http404  *handle404;
174        FILE    *accessLog,
175                *errorLog;
176} httpd;
177
178
179
180/***********************************************************************
181** Function Prototypes
182*/
183
184
185int httpdAddCContent __ANSI_PROTO((httpd*,char*,char*,int,int(*)(),void(*)()));
186int httpdAddFileContent __ANSI_PROTO((httpd*,char*,char*,int,int(*)(),char*));
187int httpdAddStaticContent __ANSI_PROTO((httpd*,char*,char*,int,int(*)(),char*));
188int httpdAddWildcardContent __ANSI_PROTO((httpd*,char*,int(*)(),char*));
189int httpdAddCWildcardContent __ANSI_PROTO((httpd*,char*,int(*)(),void(*)()));
190int httpdAddVariable __ANSI_PROTO((httpd*,char*, char*));
191int httpdGetConnection __ANSI_PROTO((httpd*, struct timeval*));
192int httpdReadRequest __ANSI_PROTO((httpd*));
193int httpdCheckAcl __ANSI_PROTO((httpd*, httpAcl*));
194int httpdAddC404Content __ANSI_PROTO((httpd*,void(*)()));
195
196char *httpdRequestMethodName __ANSI_PROTO((httpd*));
197char *httpdUrlEncode __ANSI_PROTO((char *));
198
199void httpdAddHeader __ANSI_PROTO((httpd*, char*));
200void httpdSetContentType __ANSI_PROTO((httpd*, char*));
201void httpdSetResponse __ANSI_PROTO((httpd*, char*));
202void httpdEndRequest __ANSI_PROTO((httpd*));
203
204httpd *httpdCreate __ANSI_PROTO(());
205void httpdFreeVariables __ANSI_PROTO((httpd*));
206void httpdDumpVariables __ANSI_PROTO((httpd*));
207void httpdOutput __ANSI_PROTO((httpd*, char*));
208void httpdPrintf __ANSI_PROTO((httpd*, char*, ...));
209void httpdProcessRequest __ANSI_PROTO((httpd*));
210void httpdSendHeaders __ANSI_PROTO((httpd*));
211void httpdSetFileBase __ANSI_PROTO((httpd*, char*));
212void httpdSetCookie __ANSI_PROTO((httpd*, char*, char*));
213
214void httpdSetErrorLog __ANSI_PROTO((httpd*, FILE*));
215void httpdSetAccessLog __ANSI_PROTO((httpd*, FILE*));
216void httpdSetDefaultAcl __ANSI_PROTO((httpd*, httpAcl*));
217
218httpVar *httpdGetVariableByName __ANSI_PROTO((httpd*, char*));
219httpVar *httpdGetVariableByPrefix __ANSI_PROTO((httpd*, char*));
220httpVar *httpdGetVariableByPrefixedName __ANSI_PROTO((httpd*, char*, char*));
221httpVar *httpdGetNextVariableByPrefix __ANSI_PROTO((httpVar*, char*));
222
223httpAcl *httpdAddAcl __ANSI_PROTO((httpd*, httpAcl*, char*, int));
224
225
226/***********************************************************************
227** Standard header file footer. 
228*/
229
230#ifdef __cplusplus
231        }
232#endif /* __cplusplus */
233#endif /* file inclusion */
234
235
Note: See TracBrowser for help on using the browser.