Added the ability to pass an argument pointer to newly created processes
diff --git a/contiki/apps/about.c b/contiki/apps/about.c
index 3137cf9..e346e53 100644
--- a/contiki/apps/about.c
+++ b/contiki/apps/about.c
@@ -32,7 +32,7 @@
  *
  * This file is part of the Contiki desktop environment
  *
- * $Id: about.c,v 1.7 2003/06/30 20:39:29 adamdunkels Exp $
+ * $Id: about.c,v 1.8 2003/08/24 22:41:31 adamdunkels Exp $
  *
  */
 
@@ -69,9 +69,11 @@
 static ek_id_t id;
 
 /*-----------------------------------------------------------------------------------*/
-LOADER_INIT_FUNC(about_init)
+LOADER_INIT_FUNC(about_init, arg)
 {
   unsigned char width;
+
+  arg_free(arg);
   
   if(id == EK_ID_NONE) {
     id = dispatcher_start(&p);
diff --git a/contiki/apps/calc.c b/contiki/apps/calc.c
index 113e294..14cc7e0 100644
--- a/contiki/apps/calc.c
+++ b/contiki/apps/calc.c
@@ -32,7 +32,7 @@
  *
  * This an example program for the Contiki desktop OS
  *
- * $Id: calc.c,v 1.4 2003/08/20 20:51:31 adamdunkels Exp $
+ * $Id: calc.c,v 1.5 2003/08/24 22:41:31 adamdunkels Exp $
  *
  */
 
@@ -100,9 +100,11 @@
 #define OP_DIV 4
 
 /*-----------------------------------------------------------------------------------*/
-LOADER_INIT_FUNC(calc_init)
+LOADER_INIT_FUNC(calc_init, arg)
 {
   unsigned char i;
+
+  arg_free(arg);
   
   if(id == EK_ID_NONE) {
     id = dispatcher_start(&p);
diff --git a/contiki/apps/email.c b/contiki/apps/email.c
index bf43379..2ac43ec 100644
--- a/contiki/apps/email.c
+++ b/contiki/apps/email.c
@@ -32,7 +32,7 @@
  *
  * This file is part of the Contiki desktop environment for the C64.
  *
- * $Id: email.c,v 1.10 2003/08/12 21:08:51 adamdunkels Exp $
+ * $Id: email.c,v 1.11 2003/08/24 22:41:31 adamdunkels Exp $
  *
  */
 
@@ -157,8 +157,10 @@
   LOADER_UNLOAD();
 }
 /*-----------------------------------------------------------------------------------*/
-LOADER_INIT_FUNC(email_init)
+LOADER_INIT_FUNC(email_init, arg)
 {
+  arg_free(arg);
+  
   if(id == EK_ID_NONE) {
     id = dispatcher_start(&p);
     
diff --git a/contiki/apps/netconf.c b/contiki/apps/netconf.c
index 4b33bc4..1d60376 100644
--- a/contiki/apps/netconf.c
+++ b/contiki/apps/netconf.c
@@ -32,7 +32,7 @@
  *
  * This file is part of the Contiki desktop environment
  *
- * $Id: netconf.c,v 1.9 2003/07/31 23:25:34 adamdunkels Exp $
+ * $Id: netconf.c,v 1.10 2003/08/24 22:41:31 adamdunkels Exp $
  *
  */
 
@@ -95,8 +95,10 @@
 static void makestrings(void);
 
 /*-----------------------------------------------------------------------------------*/
-LOADER_INIT_FUNC(netconf_init)
+LOADER_INIT_FUNC(netconf_init, arg)
 {
+  arg_free(arg);
+    
   if(id == EK_ID_NONE) {
     id = dispatcher_start(&p);
     
diff --git a/contiki/apps/processes.c b/contiki/apps/processes.c
index 24d5997..e7f6248 100644
--- a/contiki/apps/processes.c
+++ b/contiki/apps/processes.c
@@ -32,7 +32,7 @@
  *
  * This file is part of the Contiki desktop environment
  *
- * $Id: processes.c,v 1.7 2003/07/31 23:45:52 adamdunkels Exp $
+ * $Id: processes.c,v 1.8 2003/08/24 22:41:31 adamdunkels Exp $
  *
  */
 
@@ -104,8 +104,10 @@
   CTK_WIDGET_FOCUS(&processwindow, &processupdatebutton);
 }
 /*-----------------------------------------------------------------------------------*/
-LOADER_INIT_FUNC(processes_init)
+LOADER_INIT_FUNC(processes_init, arg)
 {
+  arg_free(arg);
+    
   if(id == EK_ID_NONE) {
     id = dispatcher_start(&p);
     
diff --git a/contiki/apps/program-handler.c b/contiki/apps/program-handler.c
index fafc816..571a960 100644
--- a/contiki/apps/program-handler.c
+++ b/contiki/apps/program-handler.c
@@ -32,7 +32,7 @@
  *
  * This file is part of the Contiki desktop OS
  *
- * $Id: program-handler.c,v 1.18 2003/08/20 20:52:22 adamdunkels Exp $
+ * $Id: program-handler.c,v 1.19 2003/08/24 22:41:31 adamdunkels Exp $
  *
  */
 
@@ -175,41 +175,48 @@
 }
 /*-----------------------------------------------------------------------------------*/
 #ifdef WITH_LOADER_ARCH
-#define NUM_LOADERNAMES 6
+#define NUM_PNARGS 6
 #define NAMELEN 16
-static char loadernames[(NAMELEN + 1) * NUM_LOADERNAMES];
-static char * 
-loadername_copy(char *name)
+struct pnarg {
+  char name[NAMELEN];
+  char *arg;
+};
+static struct pnarg pnargs[NUM_PNARGS];
+static struct pnarg *
+pnarg_copy(char *name, char *arg)
 {
   char i;
-  char *loadernamesptr;
+  struct pnarg *pnargsptr;
 
-  loadernamesptr = loadernames;
+  pnargsptr = pnargs;
   /* Allocate a place in the loadernames table. */
-  for(i = 0; i < NUM_LOADERNAMES; ++i) {
-    if(*loadernamesptr == 0) {
-      strncpy(loadernamesptr, name, NAMELEN);
-      return loadernamesptr;
+  for(i = 0; i < NUM_PNARGS; ++i) {
+    if(*(pnargsptr->name) == 0) {
+      strncpy(pnargsptr->name, name, NAMELEN);
+      pnargsptr->arg = arg;
+      return pnargsptr;
     }
-    loadernamesptr += NAMELEN + 1;
+    ++pnargsptr;
   }
   return NULL;
 }
 
 static void
-loadername_free(char *name)
+pnarg_free(struct pnarg *pn)
 {
-  *name = 0;
+  *(pn->name) = 0;
 }
 #endif /* WITH_LOADER_ARCH */
 /*-----------------------------------------------------------------------------------*/
 void
-program_handler_load(char *name)
+program_handler_load(char *name, char *arg)
 {
 #ifdef WITH_LOADER_ARCH
-  name = loadername_copy(name);
-  if(name != NULL) {
-    dispatcher_emit(loader_signal_display_name, name, id);
+  struct pnarg *pnarg;
+  
+  pnarg = pnarg_copy(name, arg);
+  if(pnarg != NULL) {
+    dispatcher_emit(loader_signal_display_name, pnarg, id);
   } else {
     ctk_label_set_text(&errortype, "Out of memory");
     ctk_dialog_open(&errordialog);
@@ -220,9 +227,9 @@
 }
 
 #ifdef WITH_LOADER_ARCH
-#define RUN(prg, name) program_handler_load(prg)
+#define RUN(prg, name, arg) program_handler_load(prg, arg)
 #else /* WITH_LOADER_ARCH */
-#define RUN(prg, initfunc) initfunc()/*; ctk_desktop_redraw(NULL)*/
+#define RUN(prg, initfunc, arg) initfunc(arg)
 #endif /* WITH_LOADER_ARCH */
 /*-----------------------------------------------------------------------------------*/
 void
@@ -247,7 +254,7 @@
 #ifdef WITH_LOADER_ARCH
     if(data == (ek_data_t)&loadbutton) {
       ctk_window_close(&runwindow);
-      program_handler_load(name);
+      program_handler_load(name, NULL);
     } else if(data == (ek_data_t)&errorokbutton) {
       ctk_dialog_close();
     }
@@ -256,7 +263,7 @@
     for(i = 0; i < CTK_CONF_MAXMENUITEMS; ++i) {    
       if(*dscp != NULL &&
 	 data == (ek_data_t)(*dscp)->icon) {
-	RUN((*dscp)->prgname, (*dscp)->init);
+	RUN((*dscp)->prgname, (*dscp)->init, NULL);
 	break;
       }
       ++dscp;
@@ -266,7 +273,7 @@
 #if WITH_LOADER_ARCH
       dsc = contikidsc[contikimenu.active - 1];
       if(dsc != NULL) {
-	RUN(dsc->prgname, dsc->init);
+	RUN(dsc->prgname, dsc->init, NULL);
       } else if(contikimenu.active == runmenuitem) {
 	ctk_window_open(&runwindow);
 	CTK_WIDGET_FOCUS(&runwindow, &nameentry);
@@ -274,7 +281,8 @@
 #else /* WITH_LOADER_ARCH */
       if(contikidsc[contikimenu.active] != NULL) {
 	RUN(contikidsc[contikimenu.active]->prgname,
-	    contikidsc[contikimenu.active]->init);
+	    contikidsc[contikimenu.active]->init,
+	    NULL);
       }
 #endif /* WITH_LOADER_ARCH */
     }
@@ -282,14 +290,14 @@
   } else if(s == ctk_signal_screensaver_start) {
 #if WITH_LOADER_ARCH
     if(screensaver[0] != 0) {
-      program_handler_load(screensaver);
+      program_handler_load(screensaver, NULL);
     }
 #endif /* WITH_LOADER_ARCH */
 #endif /* CTK_CONF_SCREENSAVER */
   } else if(s == loader_signal_display_name) {
 #if WITH_LOADER_ARCH
     if(displayname == NULL) {
-      ctk_label_set_text(&loadingname, data);
+      ctk_label_set_text(&loadingname, ((struct pnarg *)data)->name);
       ctk_dialog_open(&loadingdialog);
       dispatcher_emit(loader_signal_load, data, id);
       displayname = data;
@@ -303,15 +311,17 @@
     if(displayname == data) {
       ctk_dialog_close();
       displayname = NULL;
-      err = LOADER_LOAD(data);
+      err = LOADER_LOAD(((struct pnarg *)data)->name,
+			((struct pnarg *)data)->arg);
       if(err != LOADER_OK) {
 	errorfilename[0] = '"';
-	strncpy(errorfilename + 1, data, sizeof(errorfilename) - 2);
-	errorfilename[1 + strlen(data)] = '"';
+	strncpy(errorfilename + 1, ((struct pnarg *)data)->name,
+		sizeof(errorfilename) - 2);
+	errorfilename[1 + strlen(((struct pnarg *)data)->name)] = '"';
 	ctk_label_set_text(&errortype, errormsgs[err]);
 	ctk_dialog_open(&errordialog);
       }
-      loadername_free(data);
+      pnarg_free(data);
     } else {
       /* Try again. */
       dispatcher_emit(loader_signal_display_name, data, id);
diff --git a/contiki/apps/program-handler.h b/contiki/apps/program-handler.h
index a297eb6..4a376c6 100644
--- a/contiki/apps/program-handler.h
+++ b/contiki/apps/program-handler.h
@@ -32,7 +32,7 @@
  *
  * This file is part of the Contiki desktop environment for the C64.
  *
- * $Id: program-handler.h,v 1.4 2003/08/09 23:30:37 adamdunkels Exp $
+ * $Id: program-handler.h,v 1.5 2003/08/24 22:41:31 adamdunkels Exp $
  *
  */
 #ifndef __PROGRAM_HANDLER_H__
@@ -41,7 +41,7 @@
 #include "dsc.h"
 
 void program_handler_init(void);
-void program_handler_load(char *name);
+void program_handler_load(char *name, char *arg);
 void program_handler_screensaver(char *name);
 
 void program_handler_add(struct dsc *dsc, char *menuname,
diff --git a/contiki/apps/shell-gui.c b/contiki/apps/shell-gui.c
index a2cd9ec..640691b 100644
--- a/contiki/apps/shell-gui.c
+++ b/contiki/apps/shell-gui.c
@@ -31,7 +31,7 @@
  *
  * This file is part of the Contiki desktop OS.
  *
- * $Id: shell-gui.c,v 1.1 2003/08/21 22:24:29 adamdunkels Exp $
+ * $Id: shell-gui.c,v 1.2 2003/08/24 22:41:31 adamdunkels Exp $
  *
  */
 
@@ -96,8 +96,10 @@
   CTK_WIDGET_REDRAW(&loglabel);
 }
 /*-----------------------------------------------------------------------------------*/
-LOADER_INIT_FUNC(config_init)
+LOADER_INIT_FUNC(config_init, arg)
 {
+  arg_free(arg);
+  
   if(id == EK_ID_NONE) {
     id = dispatcher_start(&p);
     dispatcher_listen(ctk_signal_window_close);
diff --git a/contiki/apps/simpletelnet.c b/contiki/apps/simpletelnet.c
index d62f0cf..8a5c486 100644
--- a/contiki/apps/simpletelnet.c
+++ b/contiki/apps/simpletelnet.c
@@ -32,7 +32,7 @@
  *
  * This file is part of the Contiki desktop environment
  *
- * $Id: simpletelnet.c,v 1.6 2003/08/12 21:09:04 adamdunkels Exp $
+ * $Id: simpletelnet.c,v 1.7 2003/08/24 22:41:31 adamdunkels Exp $
  *
  */
 
@@ -99,7 +99,7 @@
 static ek_id_t id;
 
 /*-----------------------------------------------------------------------------------*/
-LOADER_INIT_FUNC(simpletelnet_init)
+LOADER_INIT_FUNC(simpletelnet_init, arg)
 {
   if(id == EK_ID_NONE) {
     id = dispatcher_start(&p);
diff --git a/contiki/apps/simpletelnet.h b/contiki/apps/simpletelnet.h
index e3d5165..bcd78fe 100644
--- a/contiki/apps/simpletelnet.h
+++ b/contiki/apps/simpletelnet.h
@@ -32,13 +32,12 @@
  *
  * This file is part of the Contiki desktop environment for the C64.
  *
- * $Id: simpletelnet.h,v 1.1 2003/03/19 14:13:33 adamdunkels Exp $
+ * $Id: simpletelnet.h,v 1.2 2003/08/24 22:41:31 adamdunkels Exp $
  *
  */
 #ifndef __SIMPLETELNET_H__
 #define __SIMPLETELNET_H__
 
-void simpletelnet_init(void);
-void simpletelnet_open(void);
+void simpletelnet_init(char *arg);
 
 #endif /* __SIMPLETELNET_H__ */
diff --git a/contiki/apps/telnetd.c b/contiki/apps/telnetd.c
index e38d74a..014e2cc 100644
--- a/contiki/apps/telnetd.c
+++ b/contiki/apps/telnetd.c
@@ -28,7 +28,7 @@
  *
  * This file is part of the Contiki desktop OS.
  *
- * $Id: telnetd.c,v 1.2 2003/08/21 22:31:38 adamdunkels Exp $
+ * $Id: telnetd.c,v 1.3 2003/08/24 22:41:31 adamdunkels Exp $
  *
  */
 
@@ -152,8 +152,10 @@
   }
 }
 /*-----------------------------------------------------------------------------------*/
-LOADER_INIT_FUNC(telnetd_init)
+LOADER_INIT_FUNC(telnetd_init, arg)
 {
+  arg_free(arg);
+  
   if(id == EK_ID_NONE) {
     id = dispatcher_start(&p);
     dispatcher_listen(ctk_signal_window_close);
@@ -212,6 +214,7 @@
        s.buf[s.bufptr] == ISO_nl) {
       s.buf[s.bufptr] = 0;
       petsciiconv_topetscii(s.buf, LINELEN);
+      shell_output(s.buf, "");
       shell_input(s.buf);
       s.bufptr = 0;
     } else {
diff --git a/contiki/apps/vnc.c b/contiki/apps/vnc.c
index 818d219..a1c3534 100644
--- a/contiki/apps/vnc.c
+++ b/contiki/apps/vnc.c
@@ -32,7 +32,7 @@
  *
  * This file is part of the Contiki VNC client
  *
- * $Id: vnc.c,v 1.5 2003/07/31 23:48:42 adamdunkels Exp $
+ * $Id: vnc.c,v 1.6 2003/08/24 22:41:31 adamdunkels Exp $
  *
  */
 
@@ -103,8 +103,10 @@
 static ek_id_t id;
 
 /*-----------------------------------------------------------------------------------*/
-LOADER_INIT_FUNC(vnc_init)
+LOADER_INIT_FUNC(vnc_init, arg)
 {
+  arg_free(arg);
+  
   if(id == EK_ID_NONE) {
     id = dispatcher_start(&p);
 
diff --git a/contiki/apps/vnc.h b/contiki/apps/vnc.h
index 02cfaaa..e47b10f 100644
--- a/contiki/apps/vnc.h
+++ b/contiki/apps/vnc.h
@@ -32,12 +32,12 @@
  *
  * This file is part of the Contiki VNC client.
  *
- * $Id: vnc.h,v 1.1 2003/04/08 19:41:23 adamdunkels Exp $
+ * $Id: vnc.h,v 1.2 2003/08/24 22:41:31 adamdunkels Exp $
  *
  */
 #ifndef __VNC_H__
 #define __VNC_H__
 
-void vnc_init(void);
+void vnc_init(char *arg);
 
 #endif /* __VNC_H__ */
diff --git a/contiki/apps/webserver.c b/contiki/apps/webserver.c
index 9d729d7..dff7ed3 100644
--- a/contiki/apps/webserver.c
+++ b/contiki/apps/webserver.c
@@ -32,7 +32,7 @@
  *
  * This file is part of the Contiki desktop environment for the C64.
  *
- * $Id: webserver.c,v 1.8 2003/08/12 21:09:19 adamdunkels Exp $
+ * $Id: webserver.c,v 1.9 2003/08/24 22:41:31 adamdunkels Exp $
  *
  */
 
@@ -48,6 +48,8 @@
 #include "webserver.h"
 #include "httpd.h"
 
+#include <stdio.h>
+
 /* The main window. */
 static struct ctk_window mainwindow;
 
@@ -69,8 +71,10 @@
 static struct ctk_label loglabel =
 {CTK_LABEL(0, 1, LOG_WIDTH, LOG_HEIGHT, log)};
 /*-----------------------------------------------------------------------------------*/
-LOADER_INIT_FUNC(webserver_init)
+LOADER_INIT_FUNC(webserver_init, arg)
 {
+  arg_free(arg);
+  
   if(id == EK_ID_NONE) {
     id = dispatcher_start(&p);
 
@@ -92,7 +96,6 @@
 static
 DISPATCHER_SIGHANDLER(webserver_sighandler, s, data)
 {
-  unsigned char i;
   DISPATCHER_SIGHANDLER_ARGS(s, data);
   
   if(s == ctk_signal_window_close ||
diff --git a/contiki/apps/webserver.h b/contiki/apps/webserver.h
index 6fb77fd..ca761e6 100644
--- a/contiki/apps/webserver.h
+++ b/contiki/apps/webserver.h
@@ -32,12 +32,12 @@
  *
  * This file is part of the Contiki desktop environment for the C64.
  *
- * $Id: webserver.h,v 1.1 2003/03/19 14:13:33 adamdunkels Exp $
+ * $Id: webserver.h,v 1.2 2003/08/24 22:41:31 adamdunkels Exp $
  *
  */
 #ifndef __WEBSERVER_H__
 #define __WEBSERVER_H__
 
-void webserver_init(void);
+void webserver_init(char *arg);
 
 #endif /* __WEBSERVER_H__ */
diff --git a/contiki/apps/www.c b/contiki/apps/www.c
index 42569ed..24018d6 100644
--- a/contiki/apps/www.c
+++ b/contiki/apps/www.c
@@ -32,7 +32,7 @@
  *
  * This file is part of the Contiki desktop environment
  *
- * $Id: www.c,v 1.18 2003/08/22 19:24:40 adamdunkels Exp $
+ * $Id: www.c,v 1.19 2003/08/24 22:41:31 adamdunkels Exp $
  *
  */
 
@@ -46,6 +46,9 @@
 
 #include "petsciiconv.h"
 
+#include "program-handler.h"
+
+
 #include "loader.h"
 
 #include "www-conf.h"
@@ -223,8 +226,10 @@
  * Initializes and starts the web browser. Called either at startup or
  * to open the browser window.
  */
-LOADER_INIT_FUNC(www_init)
+LOADER_INIT_FUNC(www_init, arg)
 {
+  arg_free(arg);
+  
   if(id == EK_ID_NONE) {
     id = dispatcher_start(&p);
     
@@ -449,6 +454,8 @@
 {
   static struct ctk_widget *w;
   static unsigned char i;
+  static char *argptr;
+  
   DISPATCHER_SIGHANDLER_ARGS(s, data);
 
   
@@ -488,9 +495,13 @@
     } else if(w == (struct ctk_widget *)&wgetnobutton) {
       ctk_dialog_close();
     } else if(w == (struct ctk_widget *)&wgetyesbutton) {
-      ctk_dialog_close();
+      ctk_dialog_close();      
       quit();
-      program_handler_load("wget.prg");
+      argptr = arg_alloc(WWW_CONF_MAX_URLLEN);
+      if(argptr != NULL) {
+	strncpy(argptr, url, WWW_CONF_MAX_URLLEN);
+      } 
+      program_handler_load("wget.prg", argptr);
       
 #if WWW_CONF_FORMS
     } else {
@@ -609,12 +620,12 @@
 {
   x = nextwordptr = 0;
   starty = scrolly;
+  
 #if WWW_CONF_PAGEVIEW
-  if(starty == 0) {
-    scrollend = WWW_CONF_WEBPAGE_HEIGHT - 4;
-  } else {
-    scrollend = starty + WWW_CONF_WEBPAGE_HEIGHT - 4;
+  if(starty > 4) {
+    starty = scrolly - 4;
   }
+  scrollend = starty + WWW_CONF_WEBPAGE_HEIGHT - 4;
 #endif /* WWW_CONF_PAGEVIEW */
   
   nextword[0] = 0;
@@ -797,7 +808,7 @@
       show_statustext(receivingmsgs[count]);
       htmlparser_parse(data, len);
     } else {
-      uip_close();
+      uip_abort();
       ctk_dialog_open(&wgetdialog);
     }
   } else {