source: src/router/httpd/httpd.h @ 17706

Last change on this file since 17706 was 17706, checked in by BrainSlayer, 20 months ago

fix libutils problem

File size: 5.3 KB
Line 
1/*
2 * milli_httpd - pretty small HTTP server
3 *
4 * Copyright 2001-2003, Broadcom Corporation
5 * All Rights Reserved.
6 *
7 * THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
8 * KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
9 * SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
10 * FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
11 *
12 * $Id: httpd.h,v 1.2 2005/11/24 19:38:45 seg Exp $
13 */
14
15#include <cy_conf.h>
16#ifndef _httpd_h_
17#define _httpd_h_
18
19#if defined(DEBUG) && defined(DMALLOC)
20#include <dmalloc.h>
21#endif
22
23#ifdef HAVE_MATRIXSSL
24#define DDWRT
25# include <matrixSsl.h>
26# include <matrixssl_xface.h>
27#endif
28
29#ifdef HAVE_OPENSSL
30#include <ssl.h>
31extern BIO *bio_err;
32#endif
33
34#include <bcmnvram.h>
35
36
37typedef struct {
38        FILE *fp;
39        int userid;
40} webs;
41
42typedef webs *webs_t;
43
44extern char *wfgets(char *buf, int len, webs_t fp);
45extern int wfprintf(webs_t fp, char *fmt, ...);
46extern size_t wfwrite(char *buf, int size, int n, webs_t fp);
47extern size_t wfread(char *buf, int size, int n, webs_t fp);
48extern int wfclose(webs_t fp);
49#ifndef VALIDSOURCE
50#ifndef VISUALSOURCE
51
52extern int wfflush(webs_t fp);
53extern int wfputc(char c, webs_t fp);
54extern int wfputs(char *buf, webs_t fp);
55#endif
56#endif
57#ifdef HAVE_HTTPS
58extern int do_ssl;
59#endif
60/* Basic authorization userid and passwd limit */
61#define AUTH_MAX 64
62
63extern char auth_realm[AUTH_MAX];
64extern void send_authenticate(char *realm);
65
66/* Generic MIME type handler */
67struct mime_handler {
68        char *pattern;
69        char *mime_type;
70        char *extra_header;
71        void (*input) (char *path, webs_t stream, int len, char *boundary);
72        void (*output) (struct mime_handler * handler, char *path,
73                        webs_t stream, char *query);
74        int (*auth) (webs_t wp, char *userid, char *passwd, char *realm,
75                     char *authorisation, int (*auth_check) (char *userid,
76                                                             char *passwd,
77                                                             char *dirname,
78                                                             char
79                                                             *authorisation));
80        unsigned char send_headers;
81};
82
83typedef struct {
84        char *path;             /* Web page URL path */
85        unsigned int size;      /* Size of web page in bytes */
86} websRomPageIndexType;
87
88//extern void setLength(long len);
89
90extern struct mime_handler mime_handlers[];
91
92/* CGI helper functions */
93extern void init_cgi(char *query);
94extern char *get_cgi(char *name);
95extern void set_cgi(char *name, char *value);
96extern int count_cgi();
97
98/* Regular file handler */
99extern void do_file(struct mime_handler *handler, char *path, webs_t stream,
100                    char *query);
101extern void do_file_attach(struct mime_handler *handler, char *path,
102                           webs_t stream, char *query, char *attachment);
103
104/* GoAhead 2.1 compatibility */
105//typedef FILE * webs_t;
106typedef char char_t;
107#define T(s) (s)
108#define __TMPVAR(x) tmpvar ## x
109#define _TMPVAR(x) __TMPVAR(x)
110#define TMPVAR _TMPVAR(__LINE__)
111
112
113#define websDebugWrite(wp, fmt, args...)
114#define websError(wp, code, msg, args...)
115
116#define websHeader(wp) wfputs("<html lang=\"en\">", wp)
117#define websFooter(wp) wfputs("</html>", wp)
118#define websDone(wp, code) wfflush(wp)
119
120#ifndef VALIDSOURCE
121#ifndef VISUALSOURCE
122char *websGetVar(webs_t wp, char *var, char *d);
123#endif
124#endif
125
126struct Webenvironment {
127        void (*Pdo_ej_buffer) (char *buffer, webs_t stream);
128        int (*Phttpd_filter_name) (char *old_name, char *new_name, size_t size,
129                                   int type);
130        char *(*PwebsGetVar) (webs_t wp, char *var, char *d);
131        int (*PwebsWrite) (webs_t wp, char *fmt, ...);
132        struct wl_client_mac *Pwl_client_macs;
133        void (*Pdo_ej) (struct mime_handler * handler, char *path, webs_t stream, char *query); // jimmy, https, 8/4/2003
134        int (*PejArgs) (int argc, char_t ** argv, char_t * fmt, ...);
135        FILE *(*PgetWebsFile) (char *path);
136        int (*Pwfflush) (webs_t fp);
137        int (*Pwfputc) (char c, webs_t fp);
138        int (*Pwfputs) (char *buf, webs_t fp);
139        char *(*PGOZILA_GET) (webs_t wp, char *name);
140        char *(*Plive_translate) (char *tran);
141        void (*Pvalidate_cgi) (webs_t fp);
142        websRomPageIndexType *PwebsRomPageIndex;
143#ifdef HAVE_HTTPS
144        int Pdo_ssl;
145#endif
146};
147
148#define websSetVar(wp, var, value) set_cgi(var, value)
149#define websDefaultHandler(wp, urlPrefix, webDir, arg, url, path, query) ({ do_ej(path, wp,""); fflush(wp); 1; })
150#define websWriteData(wp, buf, nChars) ({ int TMPVAR = wfwrite(buf, 1, nChars, wp); wfflush(wp); TMPVAR; })
151#define websWriteDataNonBlock websWriteData
152#define a_assert(a)
153
154/* GoAhead 2.1 Embedded JavaScript compatibility */
155extern int getWebsFileLen(char *path);
156
157extern char *zencrypt(char *passwd);
158
159extern void do_filtertable(struct mime_handler *handler, char *path,
160                           webs_t stream, char *query);
161extern void do_wds(struct mime_handler *handler, char *path, webs_t stream,
162                   char *query);
163extern void do_wireless_adv(struct mime_handler *handler, char *path,
164                            webs_t stream, char *query);
165#ifndef VISUALSOURCE
166#ifndef VALIDSOURCE
167extern FILE *getWebsFile(char *path);
168extern int ejArgs(int argc, char_t ** argv, char_t * fmt, ...);
169extern void do_ej(struct mime_handler *handler, char *path, webs_t stream,
170                  char *query);
171extern void do_ej_buffer(char *buffer, webs_t stream);
172extern int websWrite(webs_t wp, char *fmt, ...);
173#endif
174#endif
175int do_auth(webs_t wp, char *userid, char *passwd, char *realm,
176            char *authorisation, int (*auth_check) (char *userid, char *passwd,
177                                                    char *dirname,
178                                                    char *authorisation));
179void Initnvramtab(void);
180void *call_ej(char *name, void *handle, webs_t wp, int argc, char_t ** argv);
181
182#endif                          /* _httpd_h_ */
Note: See TracBrowser for help on using the repository browser.