OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [libnetworking/] [rtems_webserver/] [wsIntrn.h] - Blame information for rev 210

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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
 */
128
typedef 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
 */
142
typedef 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
 
156
extern websStatsType websStats;                         /* Web access stats */
157
 
158
/*
159
 *      Error code list
160
 */
161
typedef struct {
162
        int             code;                                                   /* HTTP error code */
163
        char_t  *msg;                                                   /* HTTP error message */
164
} websErrorType;
165
 
166
/*
167
 *      Mime type list
168
 */
169
typedef struct {
170
        char_t  *type;                                                  /* Mime type */
171
        char_t  *ext;                                                   /* File extension */
172
} websMimeType;
173
 
174
/*
175
 *      File information structure.
176
 */
177
typedef 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
 */
186
typedef 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
 
204
extern websRomPageIndexType     websRomPageIndex[];
205
extern websMimeType             websMimeList[];         /* List of mime types */
206
extern sym_fd_t                 websMime;                       /* Set of mime types */
207
extern webs_t*                  webs;                           /* Session list head */
208
extern int                              websMax;                        /* List size */
209
extern char_t                   websHost[64];           /* Name of this host */
210
extern char_t                   websIpaddr[64];         /* IP address of this host */
211
extern char_t                   *websHostUrl;           /* URL for this host */
212
extern int                              websPort;                       /* Port number */
213
 
214
/******************************** Prototypes **********************************/
215
 
216
extern int               websAspOpen();
217
extern void              websAspClose();
218
extern void              websFormOpen();
219
extern void              websFormClose();
220
extern int               websAspWrite(int ejid, webs_t wp, int argc, char_t **argv);
221
extern void      websDefaultClose();
222
extern int               websDefaultHandler(webs_t wp, char_t *urlPrefix,
223
                                        char_t *webDir, int arg, char_t *url, char_t *path,
224
                                        char_t *query);
225
extern int               websFormHandler(webs_t wp, char_t *urlPrefix, char_t *webDir,
226
                                        int arg, char_t *url, char_t *path, char_t *query);
227
extern int               websOpen(int sid);
228
extern void      websResponse(webs_t wp, int code, char_t *msg,
229
                                        char_t *redirect);
230
extern int               websJavaScriptEval(webs_t wp, char_t *script);
231
extern int               websPageReadData(webs_t wp, char *buf, int nBytes);
232
extern int               websPageOpen(webs_t wp, char_t *lpath, char_t *path, int mode, int perm);
233
extern void              websPageClose(webs_t wp);
234
extern void              websPageSeek(webs_t wp, long offset);
235
extern int               websPageStat(webs_t wp, char_t *lpath, char_t *path,
236
                                        websStatType *sbuf);
237
extern int               websPageIsDirectory(char_t *lpath);
238
extern int               websRomOpen();
239
extern void              websRomClose();
240
extern int               websRomPageOpen(webs_t wp, char_t *path, int mode, int perm);
241
extern void      websRomPageClose(int fd);
242
extern int               websRomPageReadData(webs_t wp, char *buf, int len);
243
extern int               websRomPageStat(char_t *path, websStatType *sbuf);
244
extern long              websRomPageSeek(webs_t wp, long offset, int origin);
245
extern void      websSetRequestSocketHandler(webs_t wp, int mask,
246
                                        void (*fn)(webs_t wp));
247
extern int               websSolutionHandler(webs_t wp, char_t *urlPrefix,
248
                                        char_t *webDir, int arg, char_t *url, char_t *path,
249
                                        char_t *query);
250
extern void      websUrlHandlerClose();
251
extern int               websUrlHandlerOpen();
252
extern int               websOpenServer(int port, int retries);
253
extern void      websCloseServer();
254
extern 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
261
extern int               websEmfOpen();
262
extern void      websEmfClose();
263
extern void      websSetEmfEnvironment(webs_t wp);
264
#endif
265
 
266
#endif /* _h_WEBS_INTERNAL */
267
 
268
/******************************************************************************/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.