source: rtems/cpukit/httpd/webs.h @ f22ebf0

4.104.114.84.95
Last change on this file since f22ebf0 was a6b4c0df, checked in by Joel Sherrill <joel.sherrill@…>, on 09/01/00 at 10:57:21

2000-08-30 Joel Sherrill <joel@…>

  • Merged version 2.1 of GoAhead? webserver. This update was submitted by Antti P Miettinen <antti.p.miettinen@…>.
  • NOTES, base64.c, ejIntrn.h, emfdb.c, emfdb.h, md5.h, md5c.c, um.c, um.h: New files.
  • wbase64.c: Removed.
  • Makefile.am, asp.c, balloc.c, default.c, ej.h, ejlex.c, ejparse.c, form.c, h.c, handler.c, mime.c, misc.c, ringq.c, rom.c, security.c, socket.c, sym.c, uemf.c, uemf.h, url.c, value.c, webcomp.c, webmain.c, webpage.c, webrom.c, webs.c, webs.h, websuemf.c, wsIntrn.h: Modified.
  • Property mode set to 100644
File size: 9.5 KB
Line 
1/*
2 *      webs.h -- GoAhead Web public header
3 *
4 * Copyright (c) GoAhead Software Inc., 1992-2000. All Rights Reserved.
5 *
6 *      See the file "license.txt" for information on usage and redistribution
7 */
8
9#ifndef _h_WEBS
10#define _h_WEBS 1
11
12/******************************** Description *********************************/
13
14/*
15 *      GoAhead Web Server header. This defines the Web public APIs.
16 *      Include this header for files that contain ASP or Form procedures.
17 *      Include wsIntrn.h when creating URL handlers.
18 */
19
20/********************************* Includes ***********************************/
21
22#include        "ej.h"
23#ifdef WEBS_SSL_SUPPORT
24#include        "websSSL.h"
25#endif
26
27/********************************** Defines ***********************************/
28/*
29 *      By license terms the server software name defined in the following line of
30 *      code must not be modified.
31 */
32#define WEBS_NAME                               T("GoAhead-Webs")
33#define WEBS_VERSION                    T("2.1")
34
35#define WEBS_HEADER_BUFINC              512                     /* Header buffer size */
36#define WEBS_ASP_BUFINC                 512                     /* Asp expansion increment */
37#define WEBS_MAX_PASS                   32                      /* Size of password */
38#define WEBS_BUFSIZE                    1000            /* websWrite max output string */
39#define WEBS_MAX_HEADER                 (5 * 1024)      /* Sanity check header */
40#define WEBS_MAX_URL                    4096            /* Maximum URL size for sanity */
41#define WEBS_SOCKET_BUFSIZ              256                     /* Bytes read from socket */
42
43#define WEBS_HTTP_PORT                  T("httpPort")
44#define CGI_BIN                                 T("cgi-bin")
45
46/*
47 *      Request flags. Also returned by websGetRequestFlags().
48 */
49#define WEBS_LOCAL_PAGE                 0x1                     /* Request for local webs page */
50#define WEBS_KEEP_ALIVE                 0x2                     /* HTTP/1.1 keep alive */
51#define WEBS_DONT_USE_CACHE             0x4                     /* Not implemented cache support */
52#define WEBS_COOKIE                             0x8                     /* Cookie supplied in request */
53#define WEBS_IF_MODIFIED                0x10            /* If-modified-since in request */
54#define WEBS_POST_REQUEST               0x20            /* Post request operation */
55#define WEBS_LOCAL_REQUEST              0x40            /* Request from this system */
56#define WEBS_HOME_PAGE                  0x80            /* Request for the home page */
57#define WEBS_ASP                                0x100           /* ASP request */
58#define WEBS_HEAD_REQUEST               0x200           /* Head request */
59#define WEBS_CLEN                               0x400           /* Request had a content length */
60#define WEBS_FORM                               0x800           /* Request is a form */
61#define WEBS_REQUEST_DONE               0x1000          /* Request complete */
62#define WEBS_POST_DATA                  0x2000          /* Already appended post data */
63#define WEBS_CGI_REQUEST                0x4000          /* cgi-bin request */
64#define WEBS_SECURE                             0x8000          /* connection uses SSL */
65#define WEBS_AUTH_BASIC                 0x10000         /* Basic authentication request */
66#define WEBS_AUTH_DIGEST                0x20000         /* Digest authentication request */
67#define WEBS_HEADER_DONE                0x40000         /* Already output the HTTP header */
68
69/*
70 *      URL handler flags
71 */
72#define WEBS_HANDLER_FIRST      0x1                     /* Process this handler first */
73#define WEBS_HANDLER_LAST       0x2                     /* Process this handler last */
74
75/*
76 *      Per socket connection webs structure
77 */
78typedef struct websRec {
79        ringq_t                 header;                         /* Header dynamic string */
80        time_t                  since;                          /* Parsed if-modified-since time */
81        sym_fd_t                cgiVars;                        /* CGI standard variables */
82        sym_fd_t                cgiQuery;                       /* CGI decoded query string */
83        time_t                  timestamp;                      /* Last transaction with browser */
84        int                             timeout;                        /* Timeout handle */
85        char_t                  ipaddr[32];                     /* Connecting ipaddress */
86        char_t                  type[64];                       /* Mime type */
87        char_t                  *dir;                           /* Directory containing the page */
88        char_t                  *path;                          /* Path name without query */
89        char_t                  *url;                           /* Full request url */
90        char_t                  *host;                          /* Requested host */
91        char_t                  *lpath;                         /* Cache local path name */
92        char_t                  *query;                         /* Request query */
93        char_t                  *decodedQuery;          /* Decoded request query */
94        char_t                  *authType;                      /* Authorization type (Basic/DAA) */
95        char_t                  *password;                      /* Authorization password */
96        char_t                  *userName;                      /* Authorization username */
97        char_t                  *cookie;                        /* Cookie string */
98        char_t                  *userAgent;                     /* User agent (browser) */
99        char_t                  *protocol;                      /* Protocol (normally HTTP) */
100        char_t                  *protoVersion;          /* Protocol version */
101        int                             sid;                            /* Socket id (handler) */
102        int                             listenSid;                      /* Listen Socket id */
103        int                             port;                           /* Request port number */
104        int                             state;                          /* Current state */
105        int                             flags;                          /* Current flags -- see above */
106        int                             code;                           /* Request result code */
107        int                             clen;                           /* Content length */
108        int                             wid;                            /* Index into webs */
109        char_t                  *cgiStdin;                      /* filename for CGI stdin */
110        int                             docfd;                          /* Document file descriptor */
111        int                             numbytes;                       /* Bytes to transfer to browser */
112        int                             written;                        /* Bytes actually transferred */
113        void                    (*writeSocket)(struct websRec *wp);
114#ifdef DIGEST_ACCESS_SUPPORT
115    char_t                      *realm;         /* usually the same as "host" from websRec */
116    char_t                      *nonce;         /* opaque-to-client string sent by server */
117    char_t                      *digest;        /* digest form of user password */
118    char_t                      *uri;           /* URI found in DAA header */
119    char_t                      *opaque;        /* opaque value passed from server */
120    char_t                      *nc;            /* nonce count */
121    char_t                      *cnonce;        /* check nonce */
122    char_t                      *qop;           /* quality operator */
123#endif
124#ifdef WEBS_SSL_SUPPORT
125        websSSL_t               *wsp;           /* SSL data structure */
126#endif
127} websRec;
128
129typedef websRec *webs_t;
130typedef websRec websType;
131
132/******************************** Prototypes **********************************/
133extern int               websAccept(int sid, char *ipaddr, int port, int listenSid);
134extern int               websAspDefine(char_t *name,
135                                        int (*fn)(int ejid, webs_t wp, int argc, char_t **argv));
136extern int               websAspRequest(webs_t wp, char_t *lpath);
137extern void              websCloseListen();
138extern int               websDecode64(char_t *outbuf, char_t *string, int buflen);
139extern void              websDecodeUrl(char_t *token, char_t *decoded, int len);
140extern void      websDone(webs_t wp, int code);
141extern void      websEncode64(char_t *outbuf, char_t *string, int buflen);
142extern void      websError(webs_t wp, int code, char_t *msg, ...);
143extern void      websFooter(webs_t wp);
144extern int               websFormDefine(char_t *name, void (*fn)(webs_t wp,
145                                        char_t *path, char_t *query));
146extern char_t   *websGetDefaultDir();
147extern char_t   *websGetDefaultPage();
148extern char_t   *websGetHostUrl();
149extern char_t   *websGetIpaddrUrl();
150extern char_t   *websGetPassword();
151extern int               websGetPort();
152extern char_t   *websGetPublishDir(char_t *path, char_t **urlPrefix);
153extern char_t   *websGetRealm();
154extern int               websGetRequestBytes(webs_t wp);
155extern char_t   *websGetRequestDir(webs_t wp);
156extern int               websGetRequestFlags(webs_t wp);
157extern char_t   *websGetRequestIpaddr(webs_t wp);
158extern char_t   *websGetRequestLpath(webs_t wp);
159extern char_t   *websGetRequestPath(webs_t wp);
160extern char_t   *websGetRequestPassword(webs_t wp);
161extern char_t   *websGetRequestType(webs_t wp);
162extern int               websGetRequestWritten(webs_t wp);
163extern char_t   *websGetVar(webs_t wp, char_t *var, char_t *def);
164extern int               websCompareVar(webs_t wp, char_t *var, char_t *value);
165extern void      websHeader(webs_t wp);
166extern int               websOpenListen(int port, int retries);
167extern int               websPageOpen(webs_t wp, char_t *lpath, char_t *path,
168                                        int mode, int perm);
169extern void      websPageClose(webs_t wp);
170extern int               websPublish(char_t *urlPrefix, char_t *path);
171extern void              websRedirect(webs_t wp, char_t *url);
172extern void      websSecurityDelete();
173extern int               websSecurityHandler(webs_t wp, char_t *urlPrefix,
174                                        char_t *webDir, int arg, char_t *url, char_t *path,
175                                        char_t *query);
176extern void      websSetDefaultDir(char_t *dir);
177extern void      websSetDefaultPage(char_t *page);
178extern void      websSetEnv(webs_t wp);
179extern void      websSetHost(char_t *host);
180extern void      websSetIpaddr(char_t *ipaddr);
181extern void      websSetPassword(char_t *password);
182extern void      websSetRealm(char_t *realmName);
183extern void      websSetRequestBytes(webs_t wp, int bytes);
184extern void              websSetRequestFlags(webs_t wp, int flags);
185extern void      websSetRequestLpath(webs_t wp, char_t *lpath);
186extern void      websSetRequestPath(webs_t wp, char_t *dir, char_t *path);
187extern char_t   *websGetRequestUserName(webs_t wp);
188extern void      websSetRequestWritten(webs_t wp, int written);
189extern void      websSetVar(webs_t wp, char_t *var, char_t *value);
190extern int               websTestVar(webs_t wp, char_t *var);
191extern void              websTimeoutCancel(webs_t wp);
192extern int               websUrlHandlerDefine(char_t *urlPrefix, char_t *webDir,
193                                        int arg, int (*fn)(webs_t wp, char_t *urlPrefix,
194                                        char_t *webDir, int arg, char_t *url, char_t *path,
195                                        char_t *query), int flags);
196extern int               websUrlHandlerDelete(int (*fn)(webs_t wp, char_t *urlPrefix,
197                                        char_t *webDir, int arg, char_t *url, char_t *path,
198                                        char_t *query));
199extern int               websUrlHandlerRequest(webs_t wp);
200extern int               websUrlParse(char_t *url, char_t **buf, char_t **host,
201                                        char_t **path, char_t **port, char_t **query,
202                                        char_t **proto, char_t **tag, char_t **ext);
203extern char_t   *websUrlType(char_t *webs, char_t *buf, int charCnt);
204extern int               websWrite(webs_t wp, char_t* fmt, ...);
205extern int               websWriteBlock(webs_t wp, char_t *buf, int nChars);
206extern int               websWriteDataNonBlock(webs_t wp, char *buf, int nChars);
207extern int               websValid(webs_t wp);
208extern int               websValidateUrl(webs_t wp, char_t *path);
209extern void             websMarkTime(webs_t wp);
210
211/*
212 *      The following prototypes are used by the SSL patch found in websSSL.c
213 */
214extern int              websAlloc(int sid);
215extern void     websFree(webs_t wp);
216extern void     websTimeout(void *arg, int id);
217extern void     websReadEvent(webs_t wp);
218
219/*
220 *      Prototypes for functions available when running as part of the
221 *      GoAhead Embedded Management Framework (EMF)
222 */
223#if EMF
224extern void      websFormExplain(webs_t wp, char_t *path, char_t *query);
225#endif
226
227#endif /* _h_WEBS */
228
229/******************************************************************************/
Note: See TracBrowser for help on using the repository browser.