diff options
Diffstat (limited to 'contrib/help/help.c')
-rw-r--r-- | contrib/help/help.c | 421 |
1 files changed, 0 insertions, 421 deletions
diff --git a/contrib/help/help.c b/contrib/help/help.c deleted file mode 100644 index 86e5f1f0..00000000 --- a/contrib/help/help.c +++ /dev/null | |||
@@ -1,421 +0,0 @@ | |||
1 | #include "web_server.h" | ||
2 | |||
3 | #include <string.h> | ||
4 | #include <signal.h> | ||
5 | #include <stdlib.h> | ||
6 | #include <math.h> | ||
7 | |||
8 | #include "info.h" | ||
9 | #include "functions.h" | ||
10 | #include "examples.h" | ||
11 | #include "security.h" | ||
12 | |||
13 | struct web_server server; | ||
14 | |||
15 | |||
16 | #ifdef WIN32 | ||
17 | #include <windows.h> | ||
18 | #endif | ||
19 | |||
20 | |||
21 | int PORT=81; | ||
22 | |||
23 | |||
24 | void teste1() { | ||
25 | printf("Content-type: text/html\r\n\r\n"); | ||
26 | printf("here's location:<BR>\n"); | ||
27 | printf("%s\r\n",ClientInfo->Header("Location")); | ||
28 | printf("NOTHING=%s\n<BR>",ClientInfo->Conf("[PERSONAL_CONF]","NOTHING")); | ||
29 | printf("IP=%s\n<BR>",ClientInfo->Conf("[PERSONAL_CONF]","IP")); | ||
30 | printf("MOST=%s\n<BR>",ClientInfo->Conf("[PERSONAL_CONF]","MOST")); | ||
31 | printf("IP=%s\n<BR>",ClientInfo->Conf("[LIBWEBSERVER]","IP")); | ||
32 | printf("Connection: %s\n",ClientInfo->Header("Connection")); | ||
33 | }; | ||
34 | |||
35 | void varteste() { | ||
36 | web_client_setvar("bg",ClientInfo->Conf("PAGE_1","background")); | ||
37 | web_client_setvar("pata","#00FF00"); | ||
38 | printf("Content-type: text/html\r\n\r\n"); | ||
39 | printf("<HR>\n"); | ||
40 | printf("$;pata;=\"$pata;\""); | ||
41 | printf("<B><$pata;BODY bgcolor=\"$pata;\"></B> $ (prototipe 0.5.1)<BR>\n"); | ||
42 | printf("Luis Figueiredo$pata;coninhas\r\n"); | ||
43 | |||
44 | }; | ||
45 | |||
46 | void teste() { | ||
47 | int i=0; | ||
48 | |||
49 | web_client_setcookie("caos","teste da noia",NULL,NULL,NULL,0); | ||
50 | |||
51 | printf("content-type: text/html\r\n\r\n"); | ||
52 | printf("hal is \"%s\" hallo is \"%s\"<BR>\n",ClientInfo->Post("hal"),ClientInfo->Post("hallo")); | ||
53 | printf("hal is \"%s\" hallo is \"%s\"<BR>\n",ClientInfo->Post("hal"),ClientInfo->Post("hallo")); | ||
54 | printf("<form method=post>\n"); | ||
55 | printf("<input type=text name=hal value='%s'>\n",ClientInfo->Cookie("stdio")); | ||
56 | web_client_setcookie("teste",ClientInfo->Post("hallo"),"+1m",NULL,NULL,0); | ||
57 | printf("<input type=text name=hallo value='%s'>\n",ClientInfo->Cookie("teste")); | ||
58 | printf("<input type=submit name=send value='POST'>\n"); | ||
59 | printf("</form>\n"); | ||
60 | |||
61 | printf("<form method=query>\n"); | ||
62 | for (i=0;i<5;i++) { | ||
63 | printf("<input type=checkbox name=teste value='%d'>%d<BR>\n",i,i); | ||
64 | }; | ||
65 | printf("<input type=submit name=send1 value='SEND'>\n"); | ||
66 | printf("</form>\n"); | ||
67 | printf("You choose: "); | ||
68 | printf("%d numbers: \n",ClientInfo->Query("#teste")); | ||
69 | for(i=0;i<(int)ClientInfo->Query("#teste");i++){ | ||
70 | printf("%s,",ClientInfo->Query("teste")); | ||
71 | }; | ||
72 | web_client_setcookie("quatro","ratata","+1m","/","127.0.0.1",0); | ||
73 | printf("...<BR>"); | ||
74 | printf("<form method=post>\n"); | ||
75 | for (i=0;i<5;i++) { | ||
76 | printf("<input type=checkbox name=teste value='%d'>post %d<BR>\n",i,i); | ||
77 | }; | ||
78 | printf("<input type=submit name=send1 value='SEND'>\n"); | ||
79 | printf("</form>\n"); | ||
80 | printf("You choose: "); | ||
81 | web_client_setcookie("tres","ratata","+1m",NULL,NULL,0); | ||
82 | printf("%d numbers: ",ClientInfo->Post("#teste")); | ||
83 | for (i=0;i<(int)ClientInfo->Post("#teste");i++) { | ||
84 | printf("%s,",ClientInfo->Post("teste")); | ||
85 | }; | ||
86 | printf("...<BR>"); | ||
87 | web_client_deletecookie("cinco"); | ||
88 | printf("<form method=query>\n"); | ||
89 | printf("<input type=submit name=test value='pipi'><BR>\n"); | ||
90 | printf("</form>\n"); | ||
91 | printf("The value of test is '%s'<BR>\n",ClientInfo->Query("test")); | ||
92 | printf("The value of test is '%s'<BR>\n",ClientInfo->Query("test")); | ||
93 | printf("The value of test is '%s'<BR>\n",ClientInfo->Query("test")); | ||
94 | printf("ClientInfo->Cookie(\"teste\")='%s'<BR>\n",ClientInfo->Cookie("teste")); | ||
95 | printf("ClientInfo->Cookie(\"stdio\")='%s'<BR>\n",ClientInfo->Cookie("stdio")); | ||
96 | printf("ClientInfo->Cookie(\"merdinha\")='%s'<BR>\n",ClientInfo->Cookie("merdinha")); | ||
97 | printf("ClientInfo->Cookie(\"activo\")='%s'<BR>\n",ClientInfo->Cookie("activo")); | ||
98 | printf("ClientInfo->Cookie(\"caos\")='%s'<BR>\n",ClientInfo->Cookie("caos")); | ||
99 | printf("ClientInfo->Cookie(\"caos\")='%s'<BR>\n",ClientInfo->Cookie("caos")); | ||
100 | printf("Method is %s\n<BR>",ClientInfo->method); | ||
101 | printf("Inetaddr=%s\n<BR>",ClientInfo->inetname); | ||
102 | |||
103 | for(i=0;i<10;i++) { | ||
104 | printf("<BR>ClientInfo->Post(\"teste\")='%s'\n",ClientInfo->Post("teste")); | ||
105 | }; | ||
106 | printf("<BR>ClientInfo->Cookie(NULL)=\"%s\"<BR>",ClientInfo->Cookie(NULL)); | ||
107 | printf("<BR>ClientInfo->Post(NULL)=\"%s\"<BR>",ClientInfo->Post(NULL)); | ||
108 | printf("<BR>ClientInfo->Query(NULL)=\"%s\"<BR>",ClientInfo->Query(NULL)); | ||
109 | printf("<BR>ClientInfo->Query(\"teste 0\")=\"%s\"<BR>",ClientInfo->Query("teste 0")); | ||
110 | printf("<PRE>ClientInfo->Header(NULL)=\"%s\"</PRE>\r\n",ClientInfo->Header(NULL)); | ||
111 | |||
112 | }; | ||
113 | |||
114 | |||
115 | void links() { | ||
116 | printf("[<a href='/'>main</a>] [<a href='/?help=info'>info</a>] [<a href='/?help=functions'>functions</a>] [<a href='/?help=examples'>examples</a>] [<a href='/?help=security'>security</a>] [<a href='/?help=Authors'>authors</a>] "); | ||
117 | }; | ||
118 | |||
119 | void startpage(char *topic) { | ||
120 | printf("Content-type: text/html\r\n\r\n"); | ||
121 | printf("<HTML>\n<body bgcolor='EFEFFF'>\n<CENTER>\n<TABLE><TR><TD align=center>\n<a href='http://libwebserver.sourceforge.net'><img border=0 src='/libwebserver.gif'></a>\n</TD><TR><TR><TD align=center>\n<font face='Verdana'><B>HELP<BR>(%s)</B></font>\n</TD></TR></TABLE>\n</CENTER>\n",topic); | ||
122 | links(); | ||
123 | printf("<HR><BR>\n"); | ||
124 | }; | ||
125 | void endpage() { | ||
126 | printf("<HR>"); | ||
127 | links(); | ||
128 | printf("<p align=right> <small> by Luis Figueiredo (<a href='mailto:stdio@netc.pt'>stdio@netc.pt</a>) (%s)</BODY></HTML>\n",_libwebserver_version); | ||
129 | }; | ||
130 | |||
131 | |||
132 | |||
133 | |||
134 | |||
135 | |||
136 | |||
137 | |||
138 | |||
139 | //Johannes E. Schindelin // new on 0.4.0 | ||
140 | void hello_world() { | ||
141 | startpage("hello world example"); | ||
142 | printf("Hello, World!\r\n"); | ||
143 | endpage(); | ||
144 | } | ||
145 | // | ||
146 | |||
147 | |||
148 | // NEW on 0.4.1 | ||
149 | void checkbox() { | ||
150 | int i=0; | ||
151 | char *txt[]={"one","two","three","four","five"}; | ||
152 | startpage("checkbox example"); | ||
153 | printf("<form method=query>\n"); | ||
154 | for(i=0;i<5;i++) { | ||
155 | printf("<input type=checkbox name=number value='%s'\n> %s<BR>",txt[i],txt[i]); | ||
156 | }; | ||
157 | printf("<input type=submit name=send value=' SEND '>\n"); | ||
158 | printf("</form>\n"); | ||
159 | printf("You have choosen <font color='FF0000'>%d</font> numbers: \n",ClientInfo->Query("#number")); | ||
160 | for(i=0;i<(int)ClientInfo->Query("#number");i++) { | ||
161 | printf("<b>%s</b>,\n",ClientInfo->Query("number")); | ||
162 | }; | ||
163 | printf("...<BR>"); | ||
164 | endpage(); | ||
165 | }; | ||
166 | |||
167 | |||
168 | |||
169 | // NEW on 0.4.0 | ||
170 | void cookie() { | ||
171 | if(strlen(ClientInfo->Post("user"))) | ||
172 | web_client_setcookie("username",ClientInfo->Post("user"),"+15M",NULL,NULL,0); | ||
173 | startpage("Cookie example"); | ||
174 | printf("<form method='POST'>\n"); | ||
175 | printf("<input type=text name='user' value='%s'>\r\n<BR>",ClientInfo->Cookie("username")); | ||
176 | printf("<input type=submit name='send' value=' GO! '><BR>\r\n"); | ||
177 | printf("</form>\n"); | ||
178 | endpage(); | ||
179 | }; | ||
180 | // | ||
181 | |||
182 | void logfile() { | ||
183 | startpage("logfile"); | ||
184 | printf("<PRE>\n"); | ||
185 | web_client_addfile(server.logfile); | ||
186 | printf("</PRE>\n"); | ||
187 | endpage(); | ||
188 | }; | ||
189 | |||
190 | struct image { | ||
191 | char *data; | ||
192 | size_t size; | ||
193 | } image={NULL,0}; | ||
194 | |||
195 | |||
196 | void imageout() { | ||
197 | if(strlen(ClientInfo->Query("img"))) { | ||
198 | if(image.data!=NULL) { | ||
199 | printf("Content-type: image/jpeg\r\n\r\n"); | ||
200 | fwrite(image.data,image.size,1,stdout); | ||
201 | }; | ||
202 | return; | ||
203 | }; | ||
204 | |||
205 | startpage("Image example"); | ||
206 | printf("<form action='/image' method='POST' enctype='multipart/form-data'>\n"); | ||
207 | printf("<input type=file name=image><BR>\n"); | ||
208 | printf("<input type=submit name='GOO' value='See'>\n"); | ||
209 | printf("</form>\n"); | ||
210 | if(strlen(ClientInfo->MultiPart("image").data)) { | ||
211 | printf("%s<BR><img src='/image?img=%s.jpg'>\n",ClientInfo->MultiPart("image").filename,ClientInfo->MultiPart("image").filename); | ||
212 | free(image.data); | ||
213 | image.data=malloc(ClientInfo->MultiPart("image").size+1); | ||
214 | memcpy(image.data,ClientInfo->MultiPart("image").data,ClientInfo->MultiPart("image").size); | ||
215 | image.size=ClientInfo->MultiPart("image").size; | ||
216 | }else { | ||
217 | free(image.data); | ||
218 | image.data=NULL; | ||
219 | }; | ||
220 | endpage(); | ||
221 | }; | ||
222 | |||
223 | #define GIFSIDE 320 | ||
224 | char gifdata[GIFSIDE*GIFSIDE]; | ||
225 | void outgif() { | ||
226 | float i; | ||
227 | int x,y,xc,yc; | ||
228 | char color; | ||
229 | web_client_gifsetpalette("EGA"); | ||
230 | if(*ClientInfo->Query("img")!=0) { | ||
231 | printf("Content-type: image/gif\r\n\r\n"); | ||
232 | if(!strcmp(ClientInfo->Query("img"),"circle")) { | ||
233 | xc=atoi(ClientInfo->Query("x"))%GIFSIDE; | ||
234 | yc=atoi(ClientInfo->Query("y"))%GIFSIDE; | ||
235 | color=(char)(rand()%15)+1; | ||
236 | for(i=0;i<6.28;i+=(float)0.01) { | ||
237 | x=(int)((GIFSIDE+xc+cos(i)*10))%GIFSIDE; // Johannes E. Schindelin bugfix | ||
238 | y=(int)((GIFSIDE+yc+sin(i)*10))%GIFSIDE; // Johannes E. Schindelin bugfix | ||
239 | gifdata[x+(y*GIFSIDE)]=color; | ||
240 | }; | ||
241 | }; | ||
242 | web_client_gifoutput(gifdata,GIFSIDE,GIFSIDE,0); | ||
243 | }; | ||
244 | startpage("Gif example"); | ||
245 | printf("<center>Generated a circle (click inside the image)<BR>\n"); | ||
246 | printf("Pressed x=%s,y=%s<BR>\n",ClientInfo->Query("x"),ClientInfo->Query("y")); | ||
247 | printf("<form><input type=image border=0 src='/gif?img=circle&x=%s&y=%s'></form></CENTER>\n",ClientInfo->Query("x"),ClientInfo->Query("y")); | ||
248 | endpage(); | ||
249 | }; | ||
250 | |||
251 | |||
252 | void urlauthenticate() { | ||
253 | if(!strlen(ClientInfo->user) || !strlen(ClientInfo->pass) && | ||
254 | strcmp(ClientInfo->user,"username") || strcmp(ClientInfo->pass,"password")) { // you can read things from a auth file | ||
255 | web_client_HTTPdirective("HTTP/1.1 401 Authorization Required\r\n" | ||
256 | "WWW-Authenticate: Basic realm=\"This site info\""); | ||
257 | startpage("Authenticate example"); | ||
258 | printf("<CENTER><font color='FF0000'>Access denied</font></CENTER>\n"); | ||
259 | endpage(); | ||
260 | return; | ||
261 | } | ||
262 | startpage("Authenticate example"); | ||
263 | printf("You entered in your area\n"); | ||
264 | endpage(); | ||
265 | }; | ||
266 | |||
267 | |||
268 | void help() { | ||
269 | // info | ||
270 | // engine // removed (read the source) | ||
271 | // functions help | ||
272 | // functionall examples | ||
273 | // security | ||
274 | // regards | ||
275 | // authors | ||
276 | if(!strlen(ClientInfo->Query("help"))) { | ||
277 | startpage("Table of contents"); | ||
278 | printf("<B>\n"); | ||
279 | printf("<ol>\n"); | ||
280 | printf("<li><a href='/?help=info'>libwebserver info</a></li>\n"); | ||
281 | printf("<ul><li><a href='/?help=info#what'>What's libwebserver for?</a></li></ul>\n"); | ||
282 | printf("<ul><li><a href='/?help=info#who'>Who's supposed to use libwebserver?</a></li></ul>\n"); // Johannes E. Schindelin spellcheck | ||
283 | printf("<ul><li><a href='/?help=info#when'>When am i supposed to use libwebserver?</a></li></ul>\n"); // Johannes E. Schindelin spellcheck | ||
284 | printf("<ul><li><a href='/?help=info#server_scripts'>Is there support for server scripts such as .php .cgi .asp?</a></li></ul>\n"); // Johannes E. Schindelin spellcheck | ||
285 | printf("<li><a href='/?help=functions'>libwebserver functions</a></li>\n"); | ||
286 | printf("<ul><li><a href='/?help=functions#web_server_init'>web_server_init()</a></li></ul>\n"); | ||
287 | printf("<ul><li><a href='/?help=functions#web_server_addhandler'>web_server_addhandler()</a></li></ul>\n"); | ||
288 | printf("<ul><li><a href='/?help=functions#web_server_aliasdir'>web_server_aliasdir()</a><small>(new)</small></li></ul>\n"); | ||
289 | printf("<ul><li><a href='/?help=functions#web_server_run'>web_server_run()</a></li></ul>\n"); | ||
290 | printf("<ul><li><a href='/?help=functions#web_server_getconf'>web_server_getconf()</a></li></ul>\n"); | ||
291 | printf("<ul><li><a href='/?help=functions#web_server_useSSLcert'>web_server_useSSLcert()</a></li></ul>\n"); | ||
292 | printf("<ul><li><a href='/?help=functions#web_server_useMIMEfile'>web_server_useMIMEfile()</a><small>(new)</small></li></ul>\n"); | ||
293 | printf("<ul><li><a href='/?help=functions#web_client_addstream'>web_client_addstream() </a><small><small>(obsolet, no longer in use in 0.3.4) use web_client_addfile instead</small></small></li></ul>\n"); | ||
294 | printf("<ul><li><a href='/?help=functions#web_client_addfile'>web_client_addfile()</a></li></ul>\n"); | ||
295 | printf("<ul><li><a href='/?help=functions#web_client_gifoutput'>web_client_gifoutput()</a><small>(changed)</small></li></ul>\n"); | ||
296 | printf("<ul><li><a href='/?help=functions#web_client_gifsetpalette'>web_client_gifsetpalette()</a><small>(new)</small></li></ul>\n"); | ||
297 | printf("<ul><li><a href='/?help=functions#web_client_setcookie'>web_client_setcookie()</a></li></ul>\n"); | ||
298 | printf("<ul><li><a href='/?help=functions#web_client_deletecookie'>web_client_deletecookie()</a></li></ul>\n"); | ||
299 | printf("<ul><li><a href='/?help=functions#web_client_setvar'>web_client_setvar()</a></li></ul>\n"); | ||
300 | printf("<ul><li><a href='/?help=functions#web_client_getvar'>web_client_getvar()</a></li></ul>\n"); | ||
301 | printf("<ul><li><a href='/?help=functions#web_client_delvar'>web_client_delvar()</a></li></ul>\n"); | ||
302 | printf("<ul><li><a href='/?help=functions#web_client_HTTPdirective'>web_client_HTTPdirective()</a></li></ul>\n"); | ||
303 | printf("<ul><li><a href='/?help=functions#web_client_contenttype'>web_client_contenttype()</a><small>(new)</small></li></ul>\n"); | ||
304 | printf("<ul><li><a href='/?help=functions#web_log'>web_log()</a></li></ul>\n"); | ||
305 | printf("<ul><li><a href='/?help=functions#ClientInfo'>ClientInfo</a></li></ul>\n"); | ||
306 | printf("<ul><li><a href='/?help=functions#configfile'>The config file</a></li></ul>\n"); | ||
307 | printf("<li><a href='/?help=examples'>libwebserver examples</a></li>\n"); | ||
308 | printf("<ul><li><a href='/?help=examples#helloworld'>Hello, World!</a></li></ul>\n"); | ||
309 | printf("<ul><li><a href='/?help=examples#logfile'>Show's log file</a></li></ul>\n"); | ||
310 | printf("<ul><li><a href='/?help=examples#imageup'>Image Uploader</a></li></ul>\n"); | ||
311 | printf("<ul><li><a href='/?help=examples#auth'>Authentication</a></li></ul>\n"); | ||
312 | printf("<ul><li><a href='/?help=examples#ssl'>Openssl for (https)</a></li></ul>\n"); | ||
313 | printf("<ul><li><a href='/?help=examples#outgif'>Gif generator</a><small>Changed</small></li></ul>\n"); | ||
314 | printf("<ul><li><a href='/?help=examples#cookie'>Cookies</a></li></ul>\n"); | ||
315 | printf("<ul><li><a href='/?help=examples#checkbox'>checkbox</a></li></ul>\n"); | ||
316 | printf("<ul><li><a href='/?help=examples#confexample'>Config example</a></li></ul>\n"); | ||
317 | printf("<ul><li><a href='/brokenlink'>Broken link</a></li></ul>\n"); | ||
318 | printf("<ul><li><a href='/fs/'>aliasdir</a></li></ul>\n"); | ||
319 | printf("<li><a href='/?help=security'>libwebserver security</a></li>\n"); | ||
320 | printf("<ul><li><a href='/?help=security#safe'>It is safe to use?</a></li></ul>\n"); // Johannes E. Schindelin spellcheck | ||
321 | printf("<ul><li><a href='/?help=security#certificate'>How do I create my own certificate?</a></li></ul>\n"); // Johannes E. Schindelin made | ||
322 | printf("<ul><li><a href='/?help=security#racecondition'>Avoid race condition problems</a></li></ul>\n"); // Johannes E. Schindelin made | ||
323 | |||
324 | printf("<li><a href='/?help=Authors'>Authors</a></li>\n"); | ||
325 | printf("</ol>\n"); | ||
326 | printf("</B>\n"); | ||
327 | endpage(); | ||
328 | return; | ||
329 | }; | ||
330 | |||
331 | startpage(ClientInfo->Query("help")); | ||
332 | if(!strcmp(ClientInfo->Query("help"),"info")) { | ||
333 | fwrite(info,sizeof(info),1,stdout); | ||
334 | //web_client_addfile("help.html/info.html"); | ||
335 | }; | ||
336 | if(!strcmp(ClientInfo->Query("help"),"security")) { | ||
337 | fwrite(security,sizeof(security),1,stdout); | ||
338 | //web_client_addfile("help.html/security.html"); | ||
339 | }; | ||
340 | if(!strcmp(ClientInfo->Query("help"),"functions")) { | ||
341 | fwrite(functions,sizeof(functions),1,stdout); | ||
342 | //web_client_addfile("help.html/functions.html"); | ||
343 | }; | ||
344 | if(!strcmp(ClientInfo->Query("help"),"examples")) { | ||
345 | fwrite(examples,sizeof(examples),1,stdout); | ||
346 | //web_client_addfile("help.html/examples.html"); | ||
347 | }; | ||
348 | if(!strcmp(ClientInfo->Query("help"),"Authors")) { | ||
349 | printf("Luis Figueiredo (<a href='mailto:stdio@netc.pt'>stdio@netc.pt</a>) - Main programmer, designer<BR><BR>\n"); | ||
350 | printf("People who contributed:<BR>\n"); | ||
351 | printf("<UL>Joćo Luis Marques (<a href='mailto:Lamego@PTLink.net'>Lamego@PTLink.net</a>)<BR>\n"); | ||
352 | printf("<UL>minor bug reported (redirectors, stdout)</UL></UL>\n"); | ||
353 | printf("<UL>'oddsock' (<a href='mailto:oddsock@oddsock.org'>oddsock@oddsock.org</a>)<BR>\n"); | ||
354 | printf("<UL>Licensing tip, and minor bug reported (segv in querystring)</UL></UL>\n"); | ||
355 | printf("<UL>Rocco Carbone (<a href='mailto:rocco@tecsiel.it'>rocco@tecsiel.it</a>)<BR>\n"); | ||
356 | printf("<UL>Return code for web_server_run tip</UL></UL>\n"); | ||
357 | printf("<UL>Johannes E. Schindelin (<a href='mailto:Johannes.Schindelin@gmx.de'>Johannes.Schindelin@gmx.de</a>)<BR>\n"); | ||
358 | printf("<UL>Spell checking, Makefile portability, and security 'How do I create my own certificate?'<BR>\n"); | ||
359 | printf("bugfixes, example 'hello world!'</UL></UL>\n"); | ||
360 | printf("<UL>Richard Offer (<a href='mailto:offer@sgi.com'>offer@sgi.com</a>)<BR>\n"); | ||
361 | printf("<UL>checkboxes, (multiple variables) tip</UL></UL>\n"); | ||
362 | printf("<UL>Sven Anders (<a href='mailto:anders@anduras.de'>anders@anduras.de</a>)<BR>\n"); | ||
363 | printf("<UL>Created a new web_client_setcookie()(i made some changes)</UL></UL>\n"); | ||
364 | printf("<UL>Hilobok Andrew (<a href='mailto:han@km.if.ua'>han@km.if.ua</a>)<BR>\n"); | ||
365 | printf("<UL>FreeBSD portability</UL></UL>\n"); | ||
366 | }; | ||
367 | endpage(); | ||
368 | }; | ||
369 | |||
370 | |||
371 | |||
372 | void confexample() { | ||
373 | startpage("confexample"); | ||
374 | printf("<PRE>\n"); | ||
375 | web_client_addfile(server.conffile); | ||
376 | printf("</PRE>\n"); | ||
377 | printf("ClientInfo->Conf(\"PERSONAL_CONF\",\"PORT\")->%s<BR>\n",ClientInfo->Conf("PERSONAL_CONF","PORT")); | ||
378 | printf("ClientInfo->Conf(\"PERSONAL_CONF\",\"IP\")->%s<BR>\n",ClientInfo->Conf("PERSONAL_CONF","IP")); | ||
379 | printf("ClientInfo->Conf(\"LIBWEBSERVER\",\"PORT\")->%s<BR>\n",ClientInfo->Conf("LIBWEBSERVER","PORT")); | ||
380 | endpage(); | ||
381 | |||
382 | }; | ||
383 | |||
384 | |||
385 | |||
386 | |||
387 | |||
388 | int main() { | ||
389 | |||
390 | #ifdef DEBUG | ||
391 | //FILE *err=freopen("debug.log","w",stderr); | ||
392 | #endif // DEBUG | ||
393 | |||
394 | memset(gifdata,0,GIFSIDE*GIFSIDE); | ||
395 | while(!web_server_init(&server,PORT,"help.cfg",WS_USEEXTCONF|WS_USELEN))PORT++; | ||
396 | web_server_useMIMEfile(&server,"mime.types"); | ||
397 | |||
398 | //web_server_addhandler(&server,"* /",skip,0); | ||
399 | web_server_addhandler(&server,"* /",help,0); | ||
400 | web_server_addhandler(&server,"* /teste",teste,WS_LOCAL); | ||
401 | web_server_addhandler(&server,"* /varteste",varteste,WS_DYNVAR|WS_USELEN); | ||
402 | web_server_addhandler(&server,"* /teste1",teste1,WS_LOCAL); | ||
403 | web_server_addhandler(&server,"* /hello",hello_world,0); | ||
404 | web_server_addhandler(&server,"* /log",logfile,WS_USELEN); // turn off global flag | ||
405 | web_server_addhandler(&server,"* /image",imageout,0); | ||
406 | web_server_addhandler(&server,"* /gif",outgif,0); | ||
407 | web_server_addhandler(&server,"* /auth",urlauthenticate,0); | ||
408 | web_server_addhandler(&server,"* /cookie",cookie,0); | ||
409 | web_server_addhandler(&server,"* /checkbox",checkbox,0); | ||
410 | web_server_addhandler(&server,"* /confexample",confexample,0); | ||
411 | |||
412 | web_server_aliasdir(&server,"fs","/",0); | ||
413 | _tmpnameprefix="lws"; | ||
414 | printf("http://localhost:%d\n",server.port); | ||
415 | //putenv("TEMP=c:\\temp"); | ||
416 | for(;;) { | ||
417 | web_server_run(&server); | ||
418 | }; | ||
419 | |||
420 | |||
421 | }; | ||