blob: f5f185829a2e3f8691cc2eba122cdac3227a9502 [file] [log] [blame]
adamdunkelsca9ddcb2003-03-19 14:13:31 +00001/*
2 * Copyright (c) 2002, Adam Dunkels.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following
12 * disclaimer in the documentation and/or other materials provided
13 * with the distribution.
adamdunkels06f897e2004-06-06 05:59:20 +000014 * 3. The name of the author may not be used to endorse or promote
adamdunkelsca9ddcb2003-03-19 14:13:31 +000015 * products derived from this software without specific prior
16 * written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * This file is part of the Contiki desktop environment
31 *
oliverschmidt10f4b8d2005-02-07 23:13:00 +000032 * $Id: www.c,v 1.28 2005/02/07 23:13:01 oliverschmidt Exp $
adamdunkelsca9ddcb2003-03-19 14:13:31 +000033 *
34 */
35
adamdunkelsdb300d22004-02-24 09:57:49 +000036#include <string.h>
adamdunkelsca9ddcb2003-03-19 14:13:31 +000037
adamdunkelsf2f8cb22004-07-04 11:35:07 +000038#include "ek.h"
adamdunkelsca9ddcb2003-03-19 14:13:31 +000039#include "ctk.h"
adamdunkelsca9ddcb2003-03-19 14:13:31 +000040#include "webclient.h"
41#include "htmlparser.h"
42#include "http-strings.h"
43#include "resolv.h"
44
45#include "petsciiconv.h"
46
adamdunkels8bb5cca2003-08-24 22:41:31 +000047#include "program-handler.h"
48
adamdunkelsdb300d22004-02-24 09:57:49 +000049#include "uiplib.h"
adamdunkels8bb5cca2003-08-24 22:41:31 +000050
adamdunkelsf2f8cb22004-07-04 11:35:07 +000051#include "tcpip.h"
52
adamdunkels8af703e2003-04-08 11:50:20 +000053#include "loader.h"
54
adamdunkelsca9ddcb2003-03-19 14:13:31 +000055#include "www-conf.h"
56
adamdunkels30c449e2003-07-31 23:12:05 +000057#if 1
adamdunkelsca9ddcb2003-03-19 14:13:31 +000058#define PRINTF(x)
59#else
60#include <stdio.h>
61#define PRINTF(x) printf x
62#endif
63
64
65/* The array that holds the current URL. */
66static char url[WWW_CONF_MAX_URLLEN + 1];
67static char tmpurl[WWW_CONF_MAX_URLLEN + 1];
68
69/* The array that holds the web page text. */
adamdunkels89c1f4e2003-08-09 13:33:25 +000070static char webpage[WWW_CONF_WEBPAGE_WIDTH *
71 WWW_CONF_WEBPAGE_HEIGHT + 1];
adamdunkelsca9ddcb2003-03-19 14:13:31 +000072
adamdunkels269d7be2004-09-03 09:55:22 +000073
adamdunkelsca9ddcb2003-03-19 14:13:31 +000074/* The CTK widgets for the main window. */
75static struct ctk_window mainwindow;
76
77static struct ctk_button backbutton =
78 {CTK_BUTTON(0, 0, 4, "Back")};
79static struct ctk_button downbutton =
80 {CTK_BUTTON(10, 0, 4, "Down")};
81static struct ctk_button stopbutton =
adamdunkels89c1f4e2003-08-09 13:33:25 +000082 {CTK_BUTTON(WWW_CONF_WEBPAGE_WIDTH - 16, 0, 4, "Stop")};
adamdunkelsca9ddcb2003-03-19 14:13:31 +000083static struct ctk_button gobutton =
adamdunkels89c1f4e2003-08-09 13:33:25 +000084 {CTK_BUTTON(WWW_CONF_WEBPAGE_WIDTH - 4, 0, 2, "Go")};
adamdunkelsca9ddcb2003-03-19 14:13:31 +000085
86static struct ctk_separator sep1 =
adamdunkels89c1f4e2003-08-09 13:33:25 +000087 {CTK_SEPARATOR(0, 2, WWW_CONF_WEBPAGE_WIDTH)};
adamdunkelsca9ddcb2003-03-19 14:13:31 +000088
89static char editurl[WWW_CONF_MAX_URLLEN + 1];
90static struct ctk_textentry urlentry =
adamdunkels89c1f4e2003-08-09 13:33:25 +000091 {CTK_TEXTENTRY(0, 1, WWW_CONF_WEBPAGE_WIDTH - 2,
92 1, editurl, WWW_CONF_MAX_URLLEN)};
adamdunkelsca9ddcb2003-03-19 14:13:31 +000093static struct ctk_label webpagelabel =
adamdunkels89c1f4e2003-08-09 13:33:25 +000094 {CTK_LABEL(0, 3, WWW_CONF_WEBPAGE_WIDTH,
95 WWW_CONF_WEBPAGE_HEIGHT, webpage)};
adamdunkelsca9ddcb2003-03-19 14:13:31 +000096
adamdunkels89c1f4e2003-08-09 13:33:25 +000097static char statustexturl[WWW_CONF_WEBPAGE_WIDTH];
adamdunkelsca9ddcb2003-03-19 14:13:31 +000098static struct ctk_label statustext =
adamdunkels89c1f4e2003-08-09 13:33:25 +000099 {CTK_LABEL(0, WWW_CONF_WEBPAGE_HEIGHT + 4,
100 WWW_CONF_WEBPAGE_WIDTH, 1, "")};
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000101static struct ctk_separator sep2 =
adamdunkels89c1f4e2003-08-09 13:33:25 +0000102 {CTK_SEPARATOR(0, WWW_CONF_WEBPAGE_HEIGHT + 3,
103 WWW_CONF_WEBPAGE_WIDTH)};
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000104
adamdunkelsf6eea752003-08-22 19:24:40 +0000105static struct ctk_window wgetdialog;
106static struct ctk_label wgetlabel1 =
adamdunkels77b7a692003-08-29 20:36:23 +0000107 {CTK_LABEL(1, 1, 34, 1, "This web page cannot be displayed.")};
adamdunkelsf6eea752003-08-22 19:24:40 +0000108static struct ctk_label wgetlabel2 =
adamdunkels77b7a692003-08-29 20:36:23 +0000109 {CTK_LABEL(1, 3, 35, 1, "Would you like to download instead?")};
adamdunkelsf6eea752003-08-22 19:24:40 +0000110static struct ctk_button wgetnobutton =
adamdunkels77b7a692003-08-29 20:36:23 +0000111 {CTK_BUTTON(1, 5, 6, "Cancel")};
adamdunkelsf6eea752003-08-22 19:24:40 +0000112static struct ctk_button wgetyesbutton =
adamdunkels77b7a692003-08-29 20:36:23 +0000113 {CTK_BUTTON(11, 5, 24, "Close browser & download")};
adamdunkelsf6eea752003-08-22 19:24:40 +0000114
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000115/* The char arrays that hold the history of visited URLs. */
adamdunkels17e84a32003-04-02 09:54:39 +0000116static char history[WWW_CONF_HISTORY_SIZE][WWW_CONF_MAX_URLLEN];
oliverschmidt10f4b8d2005-02-07 23:13:00 +0000117static char history_last;
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000118
119
120/* The CTK widget definitions for the hyperlinks and the char arrays
121 that hold the link URLs. */
122struct formattribs {
123 char formaction[WWW_CONF_MAX_FORMACTIONLEN];
124 char formname[WWW_CONF_MAX_FORMNAMELEN];
125#define FORMINPUTTYPE_SUBMITBUTTON 1
126#define FORMINPUTTYPE_INPUTFIELD 2
127 unsigned char inputtype;
128 char inputname[WWW_CONF_MAX_INPUTNAMELEN];
129 char *inputvalue;
130};
131
132union pagewidgetattrib {
133 char url[WWW_CONF_MAX_URLLEN];
adamdunkelsd59dadf2003-08-15 18:48:35 +0000134#if WWW_CONF_FORMS
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000135 struct formattribs form;
adamdunkelsd59dadf2003-08-15 18:48:35 +0000136#endif /* WWW_CONF_FORMS */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000137};
adamdunkels17e84a32003-04-02 09:54:39 +0000138static struct ctk_widget pagewidgets[WWW_CONF_MAX_NUMPAGEWIDGETS];
139static union pagewidgetattrib pagewidgetattribs[WWW_CONF_MAX_NUMPAGEWIDGETS];
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000140static unsigned char pagewidgetptr;
141
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000142#if WWW_CONF_RENDERSTATE
143static unsigned char renderstate;
144#endif /* WWW_CONF_RENDERSTATE */
145
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000146#define ISO_nl 0x0a
147#define ISO_space 0x20
148#define ISO_ampersand 0x26
149#define ISO_plus 0x2b
150#define ISO_slash 0x2f
151#define ISO_eq 0x3d
152#define ISO_questionmark 0x3f
153
154/* The state of the rendering code. */
adamdunkels269d7be2004-09-03 09:55:22 +0000155static char *webpageptr;
156static unsigned char x, y;
157static unsigned char loading;
158static unsigned short firsty, pagey;
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000159
160static unsigned char count;
161static char receivingmsgs[4][23] = {
162 "Receiving web page ...",
163 "Receiving web page. ..",
164 "Receiving web page.. .",
165 "Receiving web page... "
166};
167
168
adamdunkelsf2f8cb22004-07-04 11:35:07 +0000169EK_EVENTHANDLER(www_eventhandler, ev, data);
170EK_PROCESS(p, "Web browser", EK_PRIO_NORMAL,
171 www_eventhandler, NULL, NULL);
172static ek_id_t id = EK_ID_NONE;
173
174/*static DISPATCHER_SIGHANDLER(www_sighandler, s, data);
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000175static struct dispatcher_proc p =
adamdunkels78c03dc2003-04-09 13:45:05 +0000176 {DISPATCHER_PROC("Web browser", NULL, www_sighandler, webclient_appcall)};
adamdunkelsf2f8cb22004-07-04 11:35:07 +0000177 static ek_id_t id;*/
178
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000179
180
181static void formsubmit(struct formattribs *attribs);
182/*-----------------------------------------------------------------------------------*/
183/* make_window()
184 *
185 * Creates the web browser's window.
186 */
187static void
188make_window(void)
189{
190
191 CTK_WIDGET_ADD(&mainwindow, &backbutton);
192 CTK_WIDGET_ADD(&mainwindow, &downbutton);
193 CTK_WIDGET_ADD(&mainwindow, &stopbutton);
194 CTK_WIDGET_ADD(&mainwindow, &gobutton);
195 CTK_WIDGET_ADD(&mainwindow, &urlentry);
196 CTK_WIDGET_ADD(&mainwindow, &sep1);
197 CTK_WIDGET_ADD(&mainwindow, &webpagelabel);
adamdunkelsf2f8cb22004-07-04 11:35:07 +0000198 CTK_WIDGET_SET_FLAG(&webpagelabel, CTK_WIDGET_FLAG_MONOSPACE);
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000199 CTK_WIDGET_ADD(&mainwindow, &sep2);
200 CTK_WIDGET_ADD(&mainwindow, &statustext);
201
202 CTK_WIDGET_FOCUS(&mainwindow, &stopbutton);
203
204 pagewidgetptr = 0;
205}
206/*-----------------------------------------------------------------------------------*/
207/* redraw_window():
208 *
209 * Convenience function that calls upon CTK to redraw the browser
210 * window. */
211static void
212redraw_window(void)
213{
214 ctk_window_redraw(&mainwindow);
215}
216/*-----------------------------------------------------------------------------------*/
217/* www_init();
218 *
219 * Initializes and starts the web browser. Called either at startup or
220 * to open the browser window.
221 */
adamdunkels8bb5cca2003-08-24 22:41:31 +0000222LOADER_INIT_FUNC(www_init, arg)
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000223{
adamdunkels8bb5cca2003-08-24 22:41:31 +0000224 arg_free(arg);
225
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000226 if(id == EK_ID_NONE) {
adamdunkelsf2f8cb22004-07-04 11:35:07 +0000227 /* id = dispatcher_start(&p);*/
228 id = ek_start(&p);
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000229
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000230 }
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000231}
232/*-----------------------------------------------------------------------------------*/
233static void
234clear_page(void)
235{
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000236 ctk_window_clear(&mainwindow);
237 make_window();
adamdunkels269d7be2004-09-03 09:55:22 +0000238 redraw_window();
adamdunkels17e84a32003-04-02 09:54:39 +0000239 memset(webpage, 0, WWW_CONF_WEBPAGE_WIDTH * WWW_CONF_WEBPAGE_HEIGHT);
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000240}
241/*-----------------------------------------------------------------------------------*/
242static void
243show_url(void)
244{
245 memcpy(editurl, url, WWW_CONF_MAX_URLLEN);
246 strncpy(editurl, "http://", 7);
247 petsciiconv_topetscii(editurl + 7, WWW_CONF_MAX_URLLEN - 7);
248 CTK_WIDGET_REDRAW(&urlentry);
249}
adamdunkels269d7be2004-09-03 09:55:22 +0000250static void
251start_loading(void)
252{
253 loading = 1;
254 x = y = 0;
255 pagey = 0;
256 webpageptr = webpage;
257
258 clear_page();
259}
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000260/*-----------------------------------------------------------------------------------*/
261static void
262show_statustext(char *text)
263{
264 ctk_label_set_text(&statustext, text);
265 CTK_WIDGET_REDRAW(&statustext);
266}
267/*-----------------------------------------------------------------------------------*/
268/* open_url():
269 *
270 * Called when the URL present in the global "url" variable should be
271 * opened. It will call the hostname resolver as well as the HTTP
272 * client requester.
273 */
274static void
275open_url(void)
276{
277 unsigned char i;
278 static char host[32];
279 char *file;
280 register char *urlptr;
adamdunkels75c276c2003-09-04 19:35:32 +0000281 static u16_t addr[2];
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000282
283 /* Trim off any spaces in the end of the url. */
284 urlptr = url + strlen(url) - 1;
285 while(*urlptr == ' ' && urlptr > url) {
286 *urlptr = 0;
287 --urlptr;
288 }
289
290 /* Don't even try to go further if the URL is empty. */
291 if(urlptr == url) {
292 return;
293 }
294
295 /* See if the URL starts with http://, otherwise prepend it. */
296 if(strncmp(url, http_http, 7) != 0) {
297 while(urlptr >= url) {
298 *(urlptr + 7) = *urlptr;
299 --urlptr;
300 }
301 strncpy(url, http_http, 7);
302 }
303
304 /* Find host part of the URL. */
305 urlptr = &url[7];
306 for(i = 0; i < sizeof(host); ++i) {
307 if(*urlptr == 0 ||
308 *urlptr == '/' ||
309 *urlptr == ' ' ||
310 *urlptr == ':') {
311 host[i] = 0;
312 break;
313 }
314 host[i] = *urlptr;
315 ++urlptr;
316 }
317
318 /* XXX: Here we should find the port part of the URL, but this isn't
319 currently done because of laziness from the programmer's side
320 :-) */
321
322 /* Find file part of the URL. */
323 while(*urlptr != '/' && *urlptr != 0) {
324 ++urlptr;
325 }
326 if(*urlptr == '/') {
327 file = urlptr;
328 } else {
329 file = "/";
330 }
331
332 /* Try to lookup the hostname. If it fails, we initiate a hostname
333 lookup and print out an informative message on the statusbar. */
adamdunkelsdb300d22004-02-24 09:57:49 +0000334 if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {
adamdunkels75c276c2003-09-04 19:35:32 +0000335 if(resolv_lookup(host) == NULL) {
336 resolv_query(host);
337 show_statustext("Resolving host...");
338 return;
339 }
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000340 }
341
342 /* The hostname we present in the hostname table, so we send out the
343 initial GET request. */
344 if(webclient_get(host, 80, file) == 0) {
345 show_statustext("Out of memory error.");
346 } else {
347 show_statustext("Connecting...");
348 }
349 redraw_window();
350}
351/*-----------------------------------------------------------------------------------*/
352/* open_link(link):
353 *
354 * Will format a link from the current web pages so that it suits the
355 * open_url() function and finally call it to open the requested URL.
356 */
357static void
358open_link(char *link)
359{
360 char *urlptr;
361
362 if(strncmp(link, http_http, 7) == 0) {
363 /* The link starts with http://. We just copy the contents of the
364 link into the url string and jump away. */
365 strncpy(url, link, WWW_CONF_MAX_URLLEN);
366 } else if(*link == ISO_slash &&
367 *(link + 1) == ISO_slash) {
368 /* The link starts with //, so we'll copy it into the url
369 variable, starting after the http (which already is present in
370 the url variable since we were able to open the web page on
371 which this link was found in the first place). */
372 strncpy(&url[5], link, WWW_CONF_MAX_URLLEN);
373 } else if(*link == ISO_slash) {
374 /* The link starts with a slash, so it is a non-relative link
375 within the same web site. We find the start of the filename of
376 the current URL and paste the contents of this link there, and
377 head off to the new URL. */
378 for(urlptr = &url[7];
379 *urlptr != 0 && *urlptr != ISO_slash;
380 ++urlptr);
381 strncpy(urlptr, link, WWW_CONF_MAX_URLLEN - (urlptr - url));
382 } else {
383 /* A fully relative link is found. We find the last slash in the
384 current URL and paste the link there. */
385
386 /* XXX: we should really parse any ../ in the link as well. */
387 for(urlptr = url + strlen(url);
388 urlptr != url && *urlptr != ISO_slash;
389 --urlptr);
390 ++urlptr;
391 strncpy(urlptr, link, WWW_CONF_MAX_URLLEN - (urlptr - url));
392 }
393
394 /* Open the URL. */
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000395 show_url();
396 open_url();
adamdunkels269d7be2004-09-03 09:55:22 +0000397
398
399 start_loading();
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000400}
401/*-----------------------------------------------------------------------------------*/
402/* log_back():
403 *
404 * Copies the current URL from the url variable and into the log for
405 * the back button.
406 */
407static void
408log_back(void)
409{
adamdunkels89c1f4e2003-08-09 13:33:25 +0000410 if(strncmp(url, history[(int)history_last], WWW_CONF_MAX_URLLEN) != 0) {
411 memcpy(history[(int)history_last], url, WWW_CONF_MAX_URLLEN);
412 ++history_last;
413 if(history_last >= WWW_CONF_HISTORY_SIZE) {
414 history_last = 0;
415 }
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000416 }
417}
418/*-----------------------------------------------------------------------------------*/
adamdunkelsf6eea752003-08-22 19:24:40 +0000419static void
420quit(void)
421{
422 ctk_window_close(&mainwindow);
adamdunkelsf2f8cb22004-07-04 11:35:07 +0000423 ek_exit();
adamdunkelsf6eea752003-08-22 19:24:40 +0000424 id = EK_ID_NONE;
425 LOADER_UNLOAD();
426}
427/*-----------------------------------------------------------------------------------*/
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000428/* www_dispatcher():
429 *
430 * The program's signal dispatcher function. Is called by the ek
431 * dispatcher whenever a signal arrives.
432 */
adamdunkelsf2f8cb22004-07-04 11:35:07 +0000433/*static
434 DISPATCHER_SIGHANDLER(www_sighandler, s, data)*/
435EK_EVENTHANDLER(www_eventhandler, ev, data)
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000436{
437 static struct ctk_widget *w;
438 static unsigned char i;
adamdunkels8bb5cca2003-08-24 22:41:31 +0000439 static char *argptr;
440
adamdunkelsf2f8cb22004-07-04 11:35:07 +0000441 /* DISPATCHER_SIGHANDLER_ARGS(s, data);*/
442 EK_EVENTHANDLER_ARGS(ev, data);
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000443
444
445 w = (struct ctk_widget *)data;
adamdunkelsf2f8cb22004-07-04 11:35:07 +0000446
447 if(ev == tcpip_event) {
448 webclient_appcall(data);
449 } else if(ev == EK_EVENT_INIT) {
450 /* Create the main window. */
451 memset(webpage, 0, sizeof(webpage));
452 ctk_window_new(&mainwindow, WWW_CONF_WEBPAGE_WIDTH,
453 WWW_CONF_WEBPAGE_HEIGHT+5, "Web browser");
454 make_window();
455#ifdef WWW_CONF_HOMEPAGE
456 strncpy(editurl, WWW_CONF_HOMEPAGE, sizeof(editurl));
457#endif /* WWW_CONF_HOMEPAGE */
458 CTK_WIDGET_FOCUS(&mainwindow, &urlentry);
459
460 /* Create download dialog.*/
461 ctk_dialog_new(&wgetdialog, 38, 7);
462 CTK_WIDGET_ADD(&wgetdialog, &wgetlabel1);
463 CTK_WIDGET_ADD(&wgetdialog, &wgetlabel2);
464 CTK_WIDGET_ADD(&wgetdialog, &wgetnobutton);
465 CTK_WIDGET_ADD(&wgetdialog, &wgetyesbutton);
466
467 ctk_window_open(&mainwindow);
468
469 } else if(ev == ctk_signal_widget_activate) {
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000470 if(w == (struct ctk_widget *)&backbutton) {
adamdunkels269d7be2004-09-03 09:55:22 +0000471 firsty = 0;
472 start_loading();
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000473
474 --history_last;
adamdunkels17e84a32003-04-02 09:54:39 +0000475 if(history_last > WWW_CONF_HISTORY_SIZE) {
476 history_last = WWW_CONF_HISTORY_SIZE - 1;
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000477 }
adamdunkels30c449e2003-07-31 23:12:05 +0000478 memcpy(url, history[(int)history_last], WWW_CONF_MAX_URLLEN);
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000479 open_url();
480 CTK_WIDGET_FOCUS(&mainwindow, &backbutton);
481 } else if(w == (struct ctk_widget *)&downbutton) {
adamdunkels269d7be2004-09-03 09:55:22 +0000482 firsty = pagey + WWW_CONF_WEBPAGE_HEIGHT - 4;
483 start_loading();
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000484 open_url();
485 CTK_WIDGET_FOCUS(&mainwindow, &downbutton);
adamdunkels328e5352003-08-20 20:54:46 +0000486 } else if(w == (struct ctk_widget *)&gobutton ||
487 w == (struct ctk_widget *)&urlentry) {
adamdunkels269d7be2004-09-03 09:55:22 +0000488 start_loading();
489 firsty = 0;
adamdunkels30c449e2003-07-31 23:12:05 +0000490
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000491 log_back();
492 memcpy(url, editurl, WWW_CONF_MAX_URLLEN);
493 petsciiconv_toascii(url, WWW_CONF_MAX_URLLEN);
494 open_url();
495 CTK_WIDGET_FOCUS(&mainwindow, &gobutton);
496 } else if(w == (struct ctk_widget *)&stopbutton) {
adamdunkels269d7be2004-09-03 09:55:22 +0000497 loading = 0;
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000498 webclient_close();
adamdunkelsf6eea752003-08-22 19:24:40 +0000499 } else if(w == (struct ctk_widget *)&wgetnobutton) {
500 ctk_dialog_close();
501 } else if(w == (struct ctk_widget *)&wgetyesbutton) {
adamdunkels8bb5cca2003-08-24 22:41:31 +0000502 ctk_dialog_close();
adamdunkelsf6eea752003-08-22 19:24:40 +0000503 quit();
adamdunkels8bb5cca2003-08-24 22:41:31 +0000504 argptr = arg_alloc(WWW_CONF_MAX_URLLEN);
505 if(argptr != NULL) {
506 strncpy(argptr, url, WWW_CONF_MAX_URLLEN);
507 }
508 program_handler_load("wget.prg", argptr);
adamdunkelsf6eea752003-08-22 19:24:40 +0000509
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000510#if WWW_CONF_FORMS
511 } else {
512 /* Check form buttons */
513 for(i = 0; i < pagewidgetptr; ++i) {
514 if(&pagewidgets[i] == w) {
515 formsubmit(&pagewidgetattribs[i].form);
516 /* show_statustext(pagewidgetattribs[i].form.formaction);*/
517 /* PRINTF(("Formaction %s formname %s inputname %s\n",
518 pagewidgetattribs[i].form.formaction,
519 pagewidgetattribs[i].form.formname,
520 pagewidgetattribs[i].form.inputname));*/
521 break;
522 }
523 }
524#endif /* WWW_CONF_FORMS */
525 }
adamdunkelsf2f8cb22004-07-04 11:35:07 +0000526 } else if(ev == ctk_signal_hyperlink_activate) {
adamdunkels269d7be2004-09-03 09:55:22 +0000527 firsty = 0;
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000528 log_back();
529 open_link(w->widget.hyperlink.url);
530 CTK_WIDGET_FOCUS(&mainwindow, &stopbutton);
adamdunkelsf6eea752003-08-22 19:24:40 +0000531 /* ctk_window_open(&mainwindow);*/
adamdunkelsf2f8cb22004-07-04 11:35:07 +0000532 } else if(ev == ctk_signal_hyperlink_hover) {
adamdunkels89c1f4e2003-08-09 13:33:25 +0000533 if(CTK_WIDGET_TYPE((struct ctk_widget *)data) ==
534 CTK_WIDGET_HYPERLINK) {
adamdunkelsc4bf5ca2003-04-18 00:20:22 +0000535 strncpy(statustexturl, w->widget.hyperlink.url,
536 sizeof(statustexturl));
537 petsciiconv_topetscii(statustexturl, sizeof(statustexturl));
538 show_statustext(statustexturl);
539 }
adamdunkelsf2f8cb22004-07-04 11:35:07 +0000540 } else if(ev == resolv_event_found) {
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000541 /* Either found a hostname, or not. */
542 if((char *)data != NULL &&
543 resolv_lookup((char *)data) != NULL) {
544 open_url();
545 } else {
546 show_statustext("Host not found.");
547 }
adamdunkelsf2f8cb22004-07-04 11:35:07 +0000548 } else if(ev == ctk_signal_window_close ||
549 ev == EK_EVENT_REQUEST_EXIT) {
adamdunkelsf6eea752003-08-22 19:24:40 +0000550 quit();
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000551 }
552}
553/*-----------------------------------------------------------------------------------*/
554/* set_url():
555 *
556 * Constructs an URL from the arguments and puts it into the global
557 * "url" variable and the visible "editurl" (which is shown in the URL
558 * text entry widget in the browser window).
559 */
560static void
561set_url(char *host, u16_t port, char *file)
562{
563 char *urlptr;
564
565 memset(url, 0, WWW_CONF_MAX_URLLEN);
566
567 if(strncmp(file, http_http, 7) == 0) {
568 strncpy(url, file, sizeof(url));
569 } else {
570 strncpy(url, http_http, 7);
571 urlptr = url + 7;
572 strcpy(urlptr, host);
573 urlptr += strlen(host);
574 strcpy(urlptr, file);
575 }
576
577 show_url();
578}
579/*-----------------------------------------------------------------------------------*/
580/* webclient_aborted():
581 *
582 * Callback function. Called from the webclient when the HTTP
583 * connection was abruptly aborted.
584 */
585void
586webclient_aborted(void)
587{
588 show_statustext("Connection reset by peer");
589}
590/*-----------------------------------------------------------------------------------*/
591/* webclient_timedout():
592 *
593 * Callback function. Called from the webclient when the HTTP
594 * connection timed out.
595 */
596void
597webclient_timedout(void)
598{
599 show_statustext("Connection timed out");
600}
601/*-----------------------------------------------------------------------------------*/
602/* webclient_closed():
603 *
604 * Callback function. Called from the webclient when the HTTP
605 * connection was closed after a request from the "webclient_close()"
606 * function. .
607 */
608void
609webclient_closed(void)
610{
611 show_statustext("Stopped.");
adamdunkels17e84a32003-04-02 09:54:39 +0000612 petsciiconv_topetscii(&webpage[(WWW_CONF_WEBPAGE_HEIGHT - 1) *
613 WWW_CONF_WEBPAGE_WIDTH], WWW_CONF_WEBPAGE_WIDTH);
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000614 redraw_window();
615}
616/*-----------------------------------------------------------------------------------*/
617/* webclient_closed():
618 *
619 * Callback function. Called from the webclient when the HTTP
620 * connection is connected.
621 */
622void
623webclient_connected(void)
624{
adamdunkels269d7be2004-09-03 09:55:22 +0000625 start_loading();
626
627 clear_page();
adamdunkels30c449e2003-07-31 23:12:05 +0000628
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000629 show_statustext("Request sent...");
630 set_url(webclient_hostname(), webclient_port(), webclient_filename());
631
632#if WWW_CONF_RENDERSTATE
633 renderstate = HTMLPARSER_RENDERSTATE_NONE;
634#endif /* WWW_CONF_RENDERSTATE */
635 htmlparser_init();
636}
637/*-----------------------------------------------------------------------------------*/
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000638/* webclient_datahandler():
639 *
640 * Callback function. Called from the webclient module when HTTP data
641 * has arrived.
642 */
643void
644webclient_datahandler(char *data, u16_t len)
645{
646 if(len > 0) {
adamdunkelsf6eea752003-08-22 19:24:40 +0000647 if(strcmp(webclient_mimetype(), http_texthtml) == 0) {
648 count = (count + 1) & 3;
649 show_statustext(receivingmsgs[count]);
650 htmlparser_parse(data, len);
adamdunkels269d7be2004-09-03 09:55:22 +0000651 redraw_window();
adamdunkelsf6eea752003-08-22 19:24:40 +0000652 } else {
adamdunkels8bb5cca2003-08-24 22:41:31 +0000653 uip_abort();
adamdunkelsf6eea752003-08-22 19:24:40 +0000654 ctk_dialog_open(&wgetdialog);
655 }
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000656 } else {
657 /* Clear remaining parts of page. */
adamdunkels269d7be2004-09-03 09:55:22 +0000658 loading = 0;
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000659 }
660
661 if(data == NULL) {
adamdunkels269d7be2004-09-03 09:55:22 +0000662 loading = 0;
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000663 show_statustext("Done.");
adamdunkels17e84a32003-04-02 09:54:39 +0000664 petsciiconv_topetscii(&webpage[(WWW_CONF_WEBPAGE_HEIGHT - 1) *
665 WWW_CONF_WEBPAGE_WIDTH], WWW_CONF_WEBPAGE_WIDTH);
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000666 redraw_window();
667 }
668}
669/*-----------------------------------------------------------------------------------*/
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000670static void *
adamdunkels269d7be2004-09-03 09:55:22 +0000671add_pagewidget(char *text, unsigned char len, unsigned char type,
672 unsigned char border)
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000673{
adamdunkelsd59dadf2003-08-15 18:48:35 +0000674 register struct ctk_widget *lptr;
adamdunkels269d7be2004-09-03 09:55:22 +0000675 register unsigned char *wptr;
676 static unsigned char maxwidth;
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000677 static void *dataptr;
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000678
adamdunkels269d7be2004-09-03 09:55:22 +0000679 if(!loading) {
680 return NULL;
681 }
682
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000683 if(len + border == 0) {
684 return NULL;
685 }
686
adamdunkels17e84a32003-04-02 09:54:39 +0000687 maxwidth = WWW_CONF_WEBPAGE_WIDTH - (1 + 2 * border);
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000688
689 /* If the text of the link is too long so that it does not fit into
690 the width of the current window, counting from the current x
691 coordinate, we first try to jump to the next line. */
692 if(len + x > maxwidth) {
adamdunkels269d7be2004-09-03 09:55:22 +0000693 htmlparser_newline();
694 if(!loading) {
695 return NULL;
696 }
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000697 }
698
699 /* If the text of the link still is too long, we just chop it off!
700 XXX: this is not really the right thing to do, we should probably
adamdunkels269d7be2004-09-03 09:55:22 +0000701 either make a link into a multiline link, or add multiple
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000702 buttons. But this will do for now. */
703 if(len > maxwidth) {
704 text[maxwidth] = 0;
705 len = maxwidth;
706 }
707
708 dataptr = NULL;
709
adamdunkels269d7be2004-09-03 09:55:22 +0000710 if(firsty == pagey) {
711 wptr = webpageptr;
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000712 /* To save memory, we'll copy the widget text to the web page
713 drawing area and reference it from there. */
adamdunkels269d7be2004-09-03 09:55:22 +0000714 wptr[0] = 0;
715 wptr += border;
716 memcpy(wptr, text, len);
717 wptr[len] = 0;
718 wptr[len + border] = ' ';
adamdunkels17e84a32003-04-02 09:54:39 +0000719 if(pagewidgetptr < WWW_CONF_MAX_NUMPAGEWIDGETS) {
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000720 dataptr = &pagewidgetattribs[pagewidgetptr];
721 lptr = &pagewidgets[pagewidgetptr];
722
723 switch(type) {
724 case CTK_WIDGET_HYPERLINK:
725 CTK_HYPERLINK_NEW((struct ctk_hyperlink *)lptr, x,
adamdunkels269d7be2004-09-03 09:55:22 +0000726 y + 3, len,
727 wptr, dataptr);
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000728 break;
729 case CTK_WIDGET_BUTTON:
730 CTK_BUTTON_NEW((struct ctk_button *)lptr, x,
adamdunkels269d7be2004-09-03 09:55:22 +0000731 y + 3, len,
732 wptr);
733 ((struct formattribs *)dataptr)->inputvalue = wptr;
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000734 break;
735 case CTK_WIDGET_TEXTENTRY:
adamdunkels269d7be2004-09-03 09:55:22 +0000736 CTK_TEXTENTRY_NEW((struct ctk_textentry *)lptr, x,
737 y + 3, len, 1,
738 wptr, len);
739 ((struct formattribs *)dataptr)->inputvalue = wptr;
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000740 break;
741 }
adamdunkelsf2f8cb22004-07-04 11:35:07 +0000742 CTK_WIDGET_SET_FLAG(lptr, CTK_WIDGET_FLAG_MONOSPACE);
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000743 CTK_WIDGET_ADD(&mainwindow, lptr);
744
745 ++pagewidgetptr;
746 }
747 }
748 /* Increase the x coordinate with the length of the link text plus
749 the extra space behind it and the CTK button markers. */
adamdunkels269d7be2004-09-03 09:55:22 +0000750 len = len + 1 + 2 * border;
751 x += len;
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000752
adamdunkels269d7be2004-09-03 09:55:22 +0000753 if(firsty == pagey) {
754 webpageptr += len;
755 }
756
757 if(x == WWW_CONF_WEBPAGE_WIDTH) {
758 htmlparser_newline();
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000759 }
760
761 return dataptr;
762}
763/*-----------------------------------------------------------------------------------*/
adamdunkels269d7be2004-09-03 09:55:22 +0000764#if WWW_CONF_RENDERSTATE
765static void
766centerline(char *wptr)
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000767{
adamdunkels269d7be2004-09-03 09:55:22 +0000768 unsigned char spaces, i;
769 char *cptr;
770 register struct ctk_widget *linksptr;
771
oliverschmidtd11555c2005-01-30 20:22:17 +0000772 cptr = wptr + WWW_CONF_WEBPAGE_WIDTH;
adamdunkels269d7be2004-09-03 09:55:22 +0000773 for(spaces = 0; spaces < WWW_CONF_WEBPAGE_WIDTH; ++spaces) {
oliverschmidtd11555c2005-01-30 20:22:17 +0000774 if(*--cptr != 0) {
adamdunkels269d7be2004-09-03 09:55:22 +0000775 break;
776 }
777 }
778
oliverschmidtd11555c2005-01-30 20:22:17 +0000779 spaces /= 2;
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000780
oliverschmidtd11555c2005-01-30 20:22:17 +0000781 while(cptr >= wptr) {
782 *(cptr + spaces) = *cptr;
783 --cptr;
784 }
785
adamdunkels269d7be2004-09-03 09:55:22 +0000786 memset(wptr, ' ', spaces);
787
788 linksptr = pagewidgets;
789
790 for(i = 0; i < pagewidgetptr; ++i) {
791 if(CTK_WIDGET_YPOS(linksptr) == y + 2) {
792 linksptr->x += spaces;
793 linksptr->widget.hyperlink.text += spaces;
794 }
795 ++linksptr;
796 }
797}
798#endif /* WWW_CONF_RENDERSTATE */
799/*-----------------------------------------------------------------------------------*/
800void
801htmlparser_newline(void)
802{
803 char *wptr;
804
805 if(pagey < firsty) {
806 ++pagey;
807 x = 0;
808 return;
809 }
810
oliverschmidt453510a2005-01-21 14:25:27 +0000811 if(!loading) {
812 return;
813 }
814
adamdunkels269d7be2004-09-03 09:55:22 +0000815 webpageptr += (WWW_CONF_WEBPAGE_WIDTH - x);
816 ++y;
817 x = 0;
818
819 wptr = webpageptr - WWW_CONF_WEBPAGE_WIDTH;
820 petsciiconv_topetscii(wptr,
821 WWW_CONF_WEBPAGE_WIDTH);
822#if WWW_CONF_RENDERSTATE
823 if(renderstate & HTMLPARSER_RENDERSTATE_CENTER) {
824 centerline(wptr);
825 }
826#endif /* WWW_CONF_RENDERSTATE */
827
828 if(y == WWW_CONF_WEBPAGE_HEIGHT) {
829 loading = 0;
830 webclient_close();
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000831 }
832}
833/*-----------------------------------------------------------------------------------*/
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000834void
adamdunkels269d7be2004-09-03 09:55:22 +0000835htmlparser_word(char *word, unsigned char wordlen)
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000836{
adamdunkels269d7be2004-09-03 09:55:22 +0000837
838 if(loading) {
839 if(wordlen + 1 > WWW_CONF_WEBPAGE_WIDTH - x) {
840 htmlparser_newline();
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000841 }
adamdunkels269d7be2004-09-03 09:55:22 +0000842
843 if(loading) {
844 if(pagey == firsty) {
845 memcpy(webpageptr, word, wordlen);
846 webpageptr += wordlen;
847 *webpageptr = ' ';
848 ++webpageptr;
849 }
850 x += wordlen + 1;
851 if(x == WWW_CONF_WEBPAGE_WIDTH) {
852 htmlparser_newline();
853 }
854 }
855 }
856}
857/*-----------------------------------------------------------------------------------*/
858void
859htmlparser_link(char *text, unsigned char textlen, char *url)
860{
861 static unsigned char *linkurlptr;
862
863 linkurlptr = add_pagewidget(text, textlen, CTK_WIDGET_HYPERLINK, 0);
864 if(linkurlptr != NULL &&
865 strlen(url) < WWW_CONF_MAX_URLLEN) {
866 strcpy(linkurlptr, url);
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000867 }
868}
869/*-----------------------------------------------------------------------------------*/
870#if WWW_CONF_RENDERSTATE
871void
872htmlparser_renderstate(unsigned char s)
873{
874 if((s & HTMLPARSER_RENDERSTATE_STATUSMASK) ==
875 HTMLPARSER_RENDERSTATE_BEGIN) {
876 renderstate |= s & ~HTMLPARSER_RENDERSTATE_STATUSMASK;
877 } else {
878 renderstate &= ~(s & ~HTMLPARSER_RENDERSTATE_STATUSMASK);
879 }
880}
881#endif /* WWW_CONF_RENDERSTATE */
882
883#if WWW_CONF_FORMS
884/*-----------------------------------------------------------------------------------*/
885void
886htmlparser_submitbutton(char *text, char *name,
887 char *formname, char *formaction)
888{
889 register struct formattribs *form;
adamdunkels269d7be2004-09-03 09:55:22 +0000890
891 form = add_pagewidget(text, strlen(text), CTK_WIDGET_BUTTON, 1);
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000892 if(form != NULL) {
893 strncpy(form->formaction, formaction, WWW_CONF_MAX_FORMACTIONLEN);
894 strncpy(form->formname, formname, WWW_CONF_MAX_FORMNAMELEN);
895 strncpy(form->inputname, name, WWW_CONF_MAX_INPUTNAMELEN);
896 form->inputtype = FORMINPUTTYPE_SUBMITBUTTON;
897 }
adamdunkels30c449e2003-07-31 23:12:05 +0000898
899
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000900}
901/*-----------------------------------------------------------------------------------*/
902void
903htmlparser_inputfield(char *text, char *name,
904 char *formname, char *formaction)
905{
906 register struct formattribs *form;
adamdunkels269d7be2004-09-03 09:55:22 +0000907
908 form = add_pagewidget(text, strlen(text), CTK_WIDGET_TEXTENTRY, 1);
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000909 if(form != NULL) {
910 strncpy(form->formaction, formaction, WWW_CONF_MAX_FORMACTIONLEN);
911 strncpy(form->formname, formname, WWW_CONF_MAX_FORMNAMELEN);
912 strncpy(form->inputname, name, WWW_CONF_MAX_INPUTNAMELEN);
913 form->inputtype = FORMINPUTTYPE_INPUTFIELD;
914 }
915}
916/*-----------------------------------------------------------------------------------*/
917static void
918formsubmit(struct formattribs *attribs)
919{
920 unsigned char i, j;
adamdunkels1a23b5b2003-08-05 13:50:02 +0000921 register char *urlptr, *valueptr;
922 register struct formattribs *faptr;
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000923
924 urlptr = &tmpurl[0];
925
926 strncpy(urlptr, attribs->formaction, WWW_CONF_MAX_URLLEN);
927 tmpurl[WWW_CONF_MAX_URLLEN] = 0;
928 urlptr += strlen(urlptr);
929 *urlptr = ISO_questionmark;
930 ++urlptr;
931
932
933 /* Construct an URL by finding all input field forms with the same
934 formname as the current submit button, and add the submit button
935 URL stuff as well. */
936 for(i = 0; i < pagewidgetptr; ++i) {
937 if(urlptr - &tmpurl[0] >= WWW_CONF_MAX_URLLEN) {
938 break;
939 }
940
941 faptr = &pagewidgetattribs[i].form;
942
943 if(strcmp(attribs->formaction, faptr->formaction) == 0 &&
944 strcmp(attribs->formname, faptr->formname) == 0 &&
945 (faptr->inputtype == FORMINPUTTYPE_INPUTFIELD ||
946 faptr == attribs)) {
947
948 /* Copy the name of the input field into the URL and append a
949 questionmark. */
950 strncpy(urlptr, faptr->inputname, WWW_CONF_MAX_URLLEN - strlen(tmpurl));
951 tmpurl[WWW_CONF_MAX_URLLEN] = 0;
952 urlptr += strlen(urlptr);
953 *urlptr = ISO_eq;
954 ++urlptr;
955
956 /* Convert and copy the contents of the input field to the URL
957 and append an ampersand. */
958 valueptr = pagewidgets[i].widget.textentry.text;
959 petsciiconv_toascii(valueptr, WWW_CONF_MAX_INPUTVALUELEN);
960 for(j = 0; j < WWW_CONF_MAX_INPUTVALUELEN; ++j) {
961 if(urlptr - &tmpurl[0] >= WWW_CONF_MAX_URLLEN) {
962 break;
963 }
964 *urlptr = *valueptr;
965 if(*urlptr == ISO_space) {
966 *urlptr = ISO_plus;
967 }
968 if(*urlptr == 0) {
969 break;
970 }
971 ++urlptr;
972 ++valueptr;
973 }
974
975 *urlptr = ISO_ampersand;
976 ++urlptr;
977 }
978 }
979 --urlptr;
980 *urlptr = 0;
adamdunkels89c1f4e2003-08-09 13:33:25 +0000981 log_back();
adamdunkelsca9ddcb2003-03-19 14:13:31 +0000982 open_link(tmpurl);
983}
984/*-----------------------------------------------------------------------------------*/
985#endif /* WWW_CONF_FORMS */