source: rtems/cpukit/httpd/wsIntrn.h @ c1cdaa0

4.104.114.84.95
Last change on this file since c1cdaa0 was c1cdaa0, checked in by Joel Sherrill <joel.sherrill@…>, on 10/27/99 at 12:50:33

Patch from Emmanuel Raguet <raguet@…> and Eric Valette
<valette@…> to add a port of the GoAhead? web server
(httpd) to the RTEMS build tree. They have successfully used
this BSP on i386/pc386 and PowerPC/mcp750.

Mark and Joel spoke with Nick Berliner <nickb@…> on
26 Oct 1999 about this port and got verbal approval to include
it in RTEMS distributions.

  • Property mode set to 100644
File size: 7.4 KB
Line 
1/*
2 *      wsIntrn.h -- Internal Go Ahead Web server header
3 *
4 *      Copyright (c) Go Ahead Software Inc., 1992-1999. All Rights Reserved.
5 *
6 *      See the file "license.txt" for information on usage and redistribution
7 */
8
9#ifndef _h_WEBS_INTERNAL
10#define _h_WEBS_INTERNAL 1
11
12/******************************** Description *********************************/
13
14/*
15 *      Internal Go Ahead Web Server header. This defines the Web private APIs
16 *      Include this header when you want to create URL handlers.
17 */
18
19/*********************************** Defines **********************************/
20
21/*
22 *      Define this to enable login of web accesses to a file
23 *              #define WEBS_LOG_SUPPORT 1
24 *
25 *      Define this to enable HTTP/1.1 keep alive support
26 *              #define WEBS_KEEP_ALIVE_SUPPORT 1
27 *
28 *      Define this to enable if-modified-since support
29 *              #define WEBS_IF_MODIFIED_SUPPORT 1
30 *
31 *      Define this to support proxy capability and track local vs remote request
32 *              Note: this is not yet fully implemented.
33 *              #define WEBS_PROXY_SUPPORT 1
34 *
35 *      Define this to support reading pages from ROM
36 *              Note: this is not yet fully implemented.
37 *              #define WEBS_PAGE_ROM 1
38 *
39 *      Define this to enable memory allocation and stack usage tracking
40 *              #define B_STATS 1
41 */
42
43/********************************** Includes **********************************/
44
45#include        <ctype.h>
46#include        <stdlib.h>
47#include        <string.h>
48#include        <stdarg.h>
49
50#if WIN
51        #include        <fcntl.h>
52        #include        <sys/stat.h>
53        #include        <io.h>
54#endif
55
56#if CE
57#if ! UEMF
58        #include        <io.h>
59#endif
60#endif
61
62#if NW
63        #include        <fcntl.h>
64        #include        <sys/stat.h>
65#endif
66
67#if LYNX
68        #include        <fcntl.h>
69        #include        <sys/stat.h>
70        #include        <signal.h>
71        #include        <unistd.h>
72#endif
73
74#if UNIX
75        #include        <fcntl.h>
76        #include        <sys/stat.h>
77        #include        <signal.h>
78        #include        <unistd.h>
79#endif
80
81#if QNX4
82        #include        <fcntl.h>
83        #include        <sys/stat.h>
84        #include        <signal.h>
85        #include        <unistd.h>
86        #include        <unix.h>
87#endif
88
89#if UW
90        #include        <fcntl.h>
91        #include        <sys/stat.h>
92#endif
93
94#if VXW486
95        #include        <vxWorks.h>
96        #include        <fcntl.h>
97        #include        <sys/stat.h>
98#endif
99
100#if UEMF
101        #include        "uemf.h"
102        #include        "ej.h"
103#else
104        #include        "emf/emfInternal.h"
105#endif
106
107#include        "webs.h"
108
109/********************************** Defines ***********************************/
110/*
111 *      Read handler flags and state
112 */
113#define WEBS_BEGIN                              0x1                     /* Beginning state */
114#define WEBS_HEADER                             0x2                     /* Ready to read first line */
115#define WEBS_POST                               0x4                     /* POST without content */
116#define WEBS_POST_CLEN                  0x8                     /* Ready to read content for POST */
117#define WEBS_PROCESSING                 0x10            /* Processing request */
118#define WEBS_KEEP_TIMEOUT               15000           /* Keep-alive timeout (15 secs) */
119#define WEBS_TIMEOUT                    60000           /* General request timeout (60) */
120
121#define PAGE_READ_BUFSIZE               512                     /* bytes read from page files */
122#define MAX_PORT_LEN                    10                      /* max digits in port number */
123
124/*
125 *      URL handler structure. Stores the leading URL path and the handler
126 *      function to call when the URL path is seen.
127 */
128typedef struct {
129        int             (*handler)(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
130                        char_t *url, char_t *path,
131                        char_t *query);                                 /* Callback URL handler function */
132        char_t  *webDir;                                                /* Web directory if required */
133        char_t  *urlPrefix;                                             /* URL leading prefix */
134        int             len;                                                    /* Length of urlPrefix for speed */
135        int             arg;                                                    /* Argument to provide to handler */
136        int             flags;                                                  /* Flags */
137} websUrlHandlerType;
138
139/*
140 *      Webs statistics
141 */
142typedef struct {
143        long                    errors;                                 /* General errors */
144        long                    redirects;
145        long                    net_requests;
146        long                    activeNetRequests;
147        long                    activeBrowserRequests;
148        long                    timeouts;
149        long                    access;                                 /* Access violations */
150        long                    localHits;
151        long                    remoteHits;
152        long                    formHits;
153        long                    handlerHits;
154} websStatsType;
155
156extern websStatsType websStats;                         /* Web access stats */
157
158/*
159 *      Error code list
160 */
161typedef struct {
162        int             code;                                                   /* HTTP error code */
163        char_t  *msg;                                                   /* HTTP error message */
164} websErrorType;
165
166/*
167 *      Mime type list
168 */
169typedef struct {
170        char_t  *type;                                                  /* Mime type */
171        char_t  *ext;                                                   /* File extension */
172} websMimeType;
173
174/*
175 *      File information structure.
176 */
177typedef struct {
178        unsigned long   size;                                   /* File length */
179        int                             isDir;                                  /* Set if directory */
180        time_t                  mtime;                                  /* Modified time */
181} websStatType;
182
183/*
184 *      Compiled Rom Page Index
185 */
186typedef struct {
187        char_t                  *path;                                  /* Web page URL path */
188        unsigned char   *page;                                  /* Web page data */
189        int                             size;                                   /* Size of web page in bytes */
190        int                             pos;                                    /* Current read position */
191} websRomPageIndexType;
192
193/*
194 *      Defines for file open.
195 */
196#ifndef CE
197#define SOCKET_RDONLY   O_RDONLY
198#define SOCKET_BINARY   O_BINARY
199#else /* CE */
200#define SOCKET_RDONLY   0x1
201#define SOCKET_BINARY   0x2
202#endif /* CE */
203
204extern websRomPageIndexType     websRomPageIndex[];
205extern websMimeType             websMimeList[];         /* List of mime types */
206extern sym_fd_t                 websMime;                       /* Set of mime types */
207extern webs_t*                  webs;                           /* Session list head */
208extern int                              websMax;                        /* List size */
209extern char_t                   websHost[64];           /* Name of this host */
210extern char_t                   websIpaddr[64];         /* IP address of this host */
211extern char_t                   *websHostUrl;           /* URL for this host */
212extern int                              websPort;                       /* Port number */
213
214/******************************** Prototypes **********************************/
215
216extern int               websAspOpen();
217extern void              websAspClose();
218extern void              websFormOpen();
219extern void              websFormClose();
220extern int               websAspWrite(int ejid, webs_t wp, int argc, char_t **argv);
221extern void      websDefaultClose();
222extern int               websDefaultHandler(webs_t wp, char_t *urlPrefix,
223                                        char_t *webDir, int arg, char_t *url, char_t *path,
224                                        char_t *query);
225extern int               websFormHandler(webs_t wp, char_t *urlPrefix, char_t *webDir,
226                                        int arg, char_t *url, char_t *path, char_t *query);
227extern int               websOpen(int sid);
228extern void      websResponse(webs_t wp, int code, char_t *msg,
229                                        char_t *redirect);
230extern int               websJavaScriptEval(webs_t wp, char_t *script);
231extern int               websPageReadData(webs_t wp, char *buf, int nBytes);
232extern int               websPageOpen(webs_t wp, char_t *lpath, char_t *path, int mode, int perm);
233extern void              websPageClose(webs_t wp);
234extern void              websPageSeek(webs_t wp, long offset);
235extern int               websPageStat(webs_t wp, char_t *lpath, char_t *path,
236                                        websStatType *sbuf);
237extern int               websPageIsDirectory(char_t *lpath);
238extern int               websRomOpen();
239extern void              websRomClose();
240extern int               websRomPageOpen(webs_t wp, char_t *path, int mode, int perm);
241extern void      websRomPageClose(int fd);
242extern int               websRomPageReadData(webs_t wp, char *buf, int len);
243extern int               websRomPageStat(char_t *path, websStatType *sbuf);
244extern long              websRomPageSeek(webs_t wp, long offset, int origin);
245extern void      websSetRequestSocketHandler(webs_t wp, int mask,
246                                        void (*fn)(webs_t wp));
247extern int               websSolutionHandler(webs_t wp, char_t *urlPrefix,
248                                        char_t *webDir, int arg, char_t *url, char_t *path,
249                                        char_t *query);
250extern void      websUrlHandlerClose();
251extern int               websUrlHandlerOpen();
252extern int               websOpenServer(int port, int retries);
253extern void      websCloseServer();
254extern char_t*   websGetDateString(websStatType* sbuf);
255
256/*
257 *      Prototypes for functions available when running as part of the
258 *      GoAhead Embedded Management Framework (EMF)
259 */
260#if EMF
261extern int               websEmfOpen();
262extern void      websEmfClose();
263extern void      websSetEmfEnvironment(webs_t wp);
264#endif
265
266#endif /* _h_WEBS_INTERNAL */
267
268/******************************************************************************/
Note: See TracBrowser for help on using the repository browser.