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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 30 unneback
/*
2
 *      webs.h -- Go Ahead Web public 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
10
#define _h_WEBS 1
11
 
12
/******************************** Description *********************************/
13
 
14
/*
15
 *      Go Ahead 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
 
24
/********************************** Defines ***********************************/
25
 
26
#define WEBS_HEADER_BUFINC              512                     /* Header buffer size */
27
#define WEBS_ASP_BUFINC                 512                     /* Asp expansion increment */
28
#define WEBS_MAX_PASS                   32                      /* Size of password */
29
#define WEBS_BUFSIZE                    1000            /* websWrite max output string */
30
#define WEBS_MAX_HEADER                 (5 * 1024)      /* Sanity check header */
31
#define WEBS_MAX_URL                    4096            /* Maximum URL size for sanity */
32
#define WEBS_SOCKET_BUFSIZ              256                     /* Bytes read from socket */
33
 
34
/*
35
 *      Request flags. Also returned by websGetRequestFlags().
36
 */
37
#define WEBS_LOCAL_PAGE                 0x1                     /* Request for local webs page */ 
38
#define WEBS_KEEP_ALIVE                 0x2                     /* HTTP/1.1 keep alive */
39
#define WEBS_DONT_USE_CACHE             0x4                     /* Not implemented cache support */
40
#define WEBS_COOKIE                             0x8                     /* Cookie supplied in request */
41
#define WEBS_IF_MODIFIED                0x10            /* If-modified-since in request */
42
#define WEBS_POST_REQUEST               0x20            /* Post request operation */
43
#define WEBS_LOCAL_REQUEST              0x40            /* Request from this system */
44
#define WEBS_HOME_PAGE                  0x80            /* Request for the home page */ 
45
#define WEBS_ASP                                0x100           /* ASP request */ 
46
#define WEBS_HEAD_REQUEST               0x200           /* Head request */
47
#define WEBS_CLEN                               0x400           /* Request had a content length */
48
#define WEBS_FORM                               0x800           /* Request is a form */
49
#define WEBS_REQUEST_DONE               0x1000          /* Request complete */
50
#define WEBS_POST_DATA                  0x2000          /* Already appended post data */
51
#define WEBS_HEADER_DONE                0x40000         /* Already output the HTTP header */
52
 
53
/*
54
 *      URL handler flags
55
 */
56
#define WEBS_HANDLER_FIRST      0x1                     /* Process this handler first */
57
#define WEBS_HANDLER_LAST       0x2                     /* Process this handler last */
58
 
59
/*
60
 *      Per socket connection webs structure
61
 */
62
typedef struct websRec {
63
        ringq_t                 header;                         /* Header dynamic string */
64
        time_t                  since;                          /* Parsed if-modified-since time */
65
        sym_fd_t                cgiVars;                        /* CGI standard variables */
66
        sym_fd_t                cgiQuery;                       /* CGI decoded query string */
67
        time_t                  timestamp;                      /* Last transaction with browser */
68
        void*                   timeout;                        /* Timeout handle */
69
        char_t                  ipaddr[32];                     /* Connecting ipaddress */
70
        char_t                  type[64];                       /* Mime type */
71
        char_t*                 dir;                            /* Directory containing the page */
72
        char_t*                 path;                           /* Path name without query */
73
        char_t*                 url;                            /* Full request url */
74
        char_t*                 host;                           /* Requested host */
75
        char_t*                 lpath;                          /* Cache local path name */
76
        char_t*                 query;                          /* Request query */
77
        char_t*                 decodedQuery;           /* Decoded request query */
78
        char_t*                 password;                       /* Authorization password */
79
        char_t*                 userName;                       /* Authorization username */
80
        char_t*                 cookie;                         /* Cookie string */
81
        char_t*                 userAgent;                      /* User agent (browser) */
82
        int                             sid;                            /* Socket id (handler) */
83
        int                             port;                           /* Request port number */
84
        int                             state;                          /* Current state */
85
        int                             flags;                          /* Current flags -- see above */
86
        int                             code;                           /* Request result code */
87
        int                             clen;                           /* Content length */
88
        int                             wid;                            /* Index into webs */
89
        int                             docfd;                          /* Document file descriptor */
90
        int                             numbytes;                               /* Bytes to transfer to browser */
91
        int                             written;                        /* Bytes actually transferred */
92
        void                    (*writeSocket)(struct websRec *wp);
93
} websRec;
94
 
95
typedef websRec *webs_t;
96
typedef websRec websType;
97
 
98
/******************************** Prototypes **********************************/
99
 
100
extern int               websAspDefine(char_t *name,
101
                                        int (*fn)(int ejid, webs_t wp, int argc, char_t **argv));
102
extern int               websAspRequest(webs_t wp, char_t *lpath);
103
extern void              websCloseListen();
104
extern int               websDecode64(char_t *outbuf, char_t *string, int buflen);
105
extern void              websDecodeUrl(char_t *token, char_t *decoded, int len);
106
extern void      websDone(webs_t wp, int code);
107
extern void      websEncode64(char_t *outbuf, char_t *string, int buflen);
108
extern void      websError(webs_t wp, int code, char_t *msg, ...);
109
extern void      websFooter(webs_t wp);
110
extern int               websFormDefine(char_t *name, void (*fn)(webs_t wp,
111
                                        char_t *path, char_t *query));
112
extern char_t   *websGetDefaultDir();
113
extern char_t   *websGetDefaultPage();
114
extern char_t   *websGetHostUrl();
115
extern char_t   *websGetPassword();
116
extern int               websGetPort();
117
extern char_t   *websGetPublishDir(char_t *path, char_t **urlPrefix);
118
extern int               websGetRequestBytes(webs_t wp);
119
extern char_t   *websGetRequestDir(webs_t wp);
120
extern int               websGetRequestFlags(webs_t wp);
121
extern char_t   *websGetRequestIpaddr(webs_t wp);
122
extern char_t   *websGetRequestLpath(webs_t wp);
123
extern char_t   *websGetRequestPath(webs_t wp);
124
extern char_t   *websGetRequestPassword(webs_t wp);
125
extern char_t   *websGetRequestType(webs_t wp);
126
extern int               websGetRequestWritten(webs_t wp);
127
extern char_t   *websGetVar(webs_t wp, char_t *var, char_t *def);
128
extern void      websHeader(webs_t wp);
129
extern int               websOpenListen(int port, int retries);
130
extern int               websPageOpen(webs_t wp, char_t *lpath, char_t *path,
131
                                        int mode, int perm);
132
extern void      websPageClose(webs_t wp);
133
extern int               websPublish(char_t *urlPrefix, char_t *path);
134
extern void              websRedirect(webs_t wp, char_t *url);
135
extern void      websSecurityDelete();
136
extern int               websSecurityHandler(webs_t wp, char_t *urlPrefix,
137
                                        char_t *webDir, int arg, char_t *url, char_t *path,
138
                                        char_t *query);
139
extern void      websSetDefaultDir(char_t *dir);
140
extern void      websSetDefaultPage(char_t *page);
141
extern void      websSetEnv(webs_t wp);
142
extern void      websSetHost(char_t *host);
143
extern void      websSetIpaddr(char_t *ipaddr);
144
extern void      websSetPassword(char_t *password);
145
extern void      websSetRequestBytes(webs_t wp, int bytes);
146
extern void              websSetRequestFlags(webs_t wp, int flags);
147
extern void      websSetRequestLpath(webs_t wp, char_t *lpath);
148
extern void      websSetRequestPath(webs_t wp, char_t *dir, char_t *path);
149
extern char_t   *websGetRequestUserName(webs_t wp);
150
extern void      websSetRequestWritten(webs_t wp, int written);
151
extern void      websSetVar(webs_t wp, char_t *var, char_t *value);
152
extern int               websTestVar(webs_t wp, char_t *var);
153
extern int               websUrlHandlerDefine(char_t *urlPrefix, char_t *webDir,
154
                                        int arg, int (*fn)(webs_t wp, char_t *urlPrefix,
155
                                        char_t *webDir, int arg, char_t *url, char_t *path,
156
                                        char_t *query), int flags);
157
extern int               websUrlHandlerDelete(int (*fn)(webs_t wp, char_t *urlPrefix,
158
                                        char_t *webDir, int arg, char_t *url, char_t *path,
159
                                        char_t *query));
160
extern int               websUrlHandlerRequest(webs_t wp);
161
extern int               websUrlParse(char_t *url, char_t **buf, char_t **host,
162
                                        char_t **path, char_t **port, char_t **query,
163
                                        char_t **proto, char_t **tag, char_t **ext);
164
extern char_t   *websUrlType(char_t *webs, char_t *buf, int charCnt);
165
extern int               websWrite(webs_t wp, char_t* fmt, ...);
166
extern int               websWriteBlock(webs_t wp, char_t *buf, int nChars);
167
extern int               websWriteBlockData(webs_t wp, char *buf, int nChars);
168
extern int               websValid(webs_t wp);
169
extern int               websValidateUrl(webs_t wp, char_t *path);
170
extern int               websCloseFileHandle(webs_t wp);
171
 
172
/*
173
 *      Prototypes for functions available when running as part of the
174
 *      GoAhead Embedded Management Framework (EMF)
175
 */
176
#if EMF
177
extern void      websFormExplain(webs_t wp, char_t *path, char_t *query);
178
#endif
179
 
180
#endif /* _h_WEBS */
181
 
182
/******************************************************************************/

powered by: WebSVN 2.1.0

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