Initial revision
diff --git a/contiki-cpc/apps/blueround-dsc.c b/contiki-cpc/apps/blueround-dsc.c
new file mode 100644
index 0000000..f2d245b
--- /dev/null
+++ b/contiki-cpc/apps/blueround-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: blueround-dsc.c,v 1.1 2006/04/17 15:18:15 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon blueround_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(blueround_dsc,
+    "Blueround CTK theme",
+    "blueround.prg",
+    blueround_init,
+    &blueround_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char blueroundicon_bitmap[3*3*8] = {
+  0xfe,0xf8,0xe0,0xc0,0xc0,0x80,0x80,0x00,
+  0x00,0x55,0xaa,0x00,0xaa,0x00,0x00,0x00,
+  0x7f,0x1f,0x07,0x03,0x03,0x01,0x01,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x80,0x80,0xc0,0xc0,0xe0,0xf8,0xfe,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x01,0x01,0x03,0x03,0x07,0x1f,0x7f
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char blueroundicon_textmap[9] = {
+  '(', '=', ')',
+  '|', 'o', '|',
+  '(', '-', ')'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon blueround_icon =
+  {CTK_ICON("Blueround", blueroundicon_bitmap, blueroundicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/cgterm-dsc.c b/contiki-cpc/apps/cgterm-dsc.c
new file mode 100644
index 0000000..acba8ba
--- /dev/null
+++ b/contiki-cpc/apps/cgterm-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: cgterm-dsc.c,v 1.1 2006/04/17 15:18:15 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(cgterm_dsc,
+    "Program for connecting to C64 Telnet BBSes",
+    "cgterm.prg",
+    cgterm_init,
+    &icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char cgtermicon_bitmap[3*3*8] = {
+  0x00, 0x7e, 0x40, 0x73, 0x46, 0x4c, 0x18, 0x13,
+  0x00, 0x00, 0xff, 0x81, 0x34, 0xc9, 0x00, 0xb6,
+  0x00, 0x7e, 0x02, 0xce, 0x72, 0x32, 0x18, 0x48,
+
+  0x30, 0x27, 0x24, 0x20, 0x37, 0x24, 0x20, 0x33,
+  0x00, 0x7b, 0x42, 0x00, 0x7b, 0x42, 0x00, 0x3b,
+  0x0c, 0x24, 0x24, 0x04, 0xa4, 0x24, 0x04, 0x4c,
+
+  0x12, 0x19, 0x4c, 0x46, 0x63, 0x40, 0x7c, 0x00,
+  0x22, 0x91, 0x00, 0xc4, 0x81, 0xff, 0x00, 0x00,
+  0x08, 0x18, 0x32, 0x62, 0xc6, 0x02, 0x3e, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char cgtermicon_textmap[9] = {
+  'T', 'e', 'l',
+  'n', 'e', 't',
+  'B', 'B', 'S'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon icon =
+  {CTK_ICON("C/G terminal", cgtermicon_bitmap, cgtermicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/cgterm.c b/contiki-cpc/apps/cgterm.c
new file mode 100644
index 0000000..fa85a40
--- /dev/null
+++ b/contiki-cpc/apps/cgterm.c
@@ -0,0 +1,243 @@
+#include "contiki.h"
+#include "socket.h"
+#include "ctk-draw.h"
+
+#include <cbm.h>
+#include <c64.h>
+#include <string.h>
+
+static struct {
+  struct socket sout, sin;
+  struct pt inpt, outpt;
+  char outputbuf[200];
+  char inputbuf[200];
+  unsigned short len;
+} s;
+
+#define CURSOR_ON()  *(char *)0xcc = 0
+#define CURSOR_OFF() *(char *)0xcc = 1
+static void ctkmode(void);
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(send(void))
+{
+  SOCKET_BEGIN(&s.sout);
+  
+  SOCKET_SEND(&s.sout, s.outputbuf, s.len);
+  SOCKET_END(&s.sout);    
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(handle_output(void))
+{
+  ctk_arch_key_t c;
+  char *ptr;
+  
+  PT_BEGIN(&s.outpt);
+  
+  while(1) {
+    PT_WAIT_UNTIL(&s.outpt, (ctk_mode_get() == CTK_MODE_EXTERNAL) &&
+		  kbhit());
+
+
+    ptr = s.outputbuf;
+    s.len = 0;    
+    while(kbhit() && s.len < sizeof(s.outputbuf)) {
+      c = cgetc();
+      *ptr = c;
+      ++ptr;
+      ++s.len;   
+    }
+
+    PT_WAIT_THREAD(&s.outpt, send());
+  }
+  PT_END(&s.outpt);      
+}
+/*---------------------------------------------------------------------------*/
+static
+PT_THREAD(handle_input(void))
+{
+  unsigned short i;
+  char *ptr;
+  char next;
+  
+  next = 1; 
+  PT_BEGIN(&s.inpt);
+  
+  while(1) {
+    /* Wait until data arrives. */
+    next = 0;
+    PT_WAIT_UNTIL(&s.inpt, next && uip_newdata());
+
+    CURSOR_OFF();
+    /* Print it out on the screen. */
+    ptr = (char *)uip_appdata;
+    for(i = 0; i < uip_len; ++i) {
+      cbm_k_bsout(*ptr);
+      ++ptr;
+    }
+    CURSOR_ON();
+  }  
+  PT_END(&s.inpt);
+}
+/*---------------------------------------------------------------------------*/
+static void
+appcall(void *state)
+{
+  if(uip_closed() || uip_aborted() || uip_timedout()) {
+    ctkmode();
+  } else if(uip_connected()) {
+  } else {
+    handle_input();
+    handle_output();   
+  }
+}
+/*---------------------------------------------------------------------------*/
+static struct uip_conn *
+connect(u16_t *host, u16_t port)
+{
+  SOCKET_INIT(&s.sin, s.inputbuf, sizeof(s.inputbuf));
+  SOCKET_INIT(&s.sout, s.inputbuf, sizeof(s.inputbuf));
+  PT_INIT(&s.inpt);
+  PT_INIT(&s.outpt);
+  return tcp_connect(host, htons(port), NULL);
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler);
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_PROCESS(p, "C/G terminal", EK_PRIO_NORMAL,
+	   eventhandler, pollhandler, NULL);
+static ek_id_t id = EK_ID_NONE;
+static struct uip_conn *conn;
+static u16_t serveraddr[2];
+static u16_t serverport;
+/*---------------------------------------------------------------------------*/
+static struct ctk_window window;
+static struct ctk_label hostlabel =
+  {CTK_LABEL(0, 0, 4, 1, "Host")};
+static char host[32];
+static struct ctk_textentry hostentry =
+  {CTK_TEXTENTRY(5, 0, 20, 1, host, sizeof(host) - 1)};
+static struct ctk_label portlabel =
+  {CTK_LABEL(27, 0, 4, 1, "Port")};
+static char port[7];
+static struct ctk_textentry portentry =
+  {CTK_TEXTENTRY(32, 0, 4, 1, port, sizeof(port) - 1)};
+static struct ctk_button connectbutton =
+  {CTK_BUTTON(0, 2, 7, "Connect")};
+static struct ctk_button switchbutton =
+  {CTK_BUTTON(30, 2, 6, "Switch")};
+static struct ctk_label helplabel =
+  {CTK_LABEL(0, 4, 37, 1, "RUN/STOP to return from terminal view")};
+/*---------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(cgterm_init, arg)
+{
+  arg_free(arg);
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*---------------------------------------------------------------------------*/
+static void
+ctkmode(void)
+{
+  ctk_mode_set(CTK_MODE_NORMAL);
+  ctk_draw_init();
+  ctk_desktop_redraw(NULL);
+}
+/*---------------------------------------------------------------------------*/
+static void
+textmode(void)
+{
+  ctk_mode_set(CTK_MODE_EXTERNAL);
+  
+  VIC.ctrl1 = 0x1b;  /* $D011 */
+  VIC.addr  = 0x17;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  CIA2.pra  = 0x03;  /* $DD00 */
+  
+  VIC.bordercolor = 0x00; /* $D020 */
+  VIC.bgcolor0 = 0x00; /* $D021 */
+
+  CURSOR_ON();
+}     
+/*---------------------------------------------------------------------------*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  u16_t *ipaddr;
+  char *cptr;
+    
+  if(ev == tcpip_event) {
+    appcall(data);
+  } else if(ev == EK_EVENT_INIT) {
+    ctk_window_new(&window, 38, 5, "C/G term");
+    CTK_WIDGET_ADD(&window, &hostlabel);
+    CTK_WIDGET_ADD(&window, &hostentry);
+    CTK_WIDGET_ADD(&window, &portlabel);
+    CTK_WIDGET_ADD(&window, &portentry);
+    CTK_WIDGET_ADD(&window, &connectbutton);
+    CTK_WIDGET_ADD(&window, &switchbutton);
+    CTK_WIDGET_ADD(&window, &helplabel);
+    ctk_window_open(&window);
+  } else if(ev == ctk_signal_widget_activate) {
+
+    if(data == (ek_data_t)&switchbutton) {
+      textmode();
+    } else if(data == (ek_data_t)&connectbutton) {
+      serverport = 0;
+      for(cptr = port; *cptr != ' ' && *cptr != 0; ++cptr) {
+	if(*cptr < '0' || *cptr > '9') {
+	  return;
+	}
+	serverport = 10 * serverport + *cptr - '0';
+      }
+
+      ipaddr = serveraddr;
+      if(uiplib_ipaddrconv(host, (u8_t *)serveraddr) == 0) {
+	ipaddr = resolv_lookup(host);
+	if(ipaddr == NULL) {
+	  resolv_query(host);
+	} else {
+	  uip_ipaddr_copy(serveraddr, ipaddr);
+	}
+      }
+      if(ipaddr != NULL) {      
+	conn = connect(serveraddr, serverport);
+	if(conn != NULL) {
+	  memset((char *)0x0400, 0x20, 40*25);
+	  memset((char *)0xd800, 0x01, 40*25);
+	  textmode();
+	}
+      }
+    }
+  } else if(ev == resolv_event_found) {
+    ipaddr = resolv_lookup(host);
+    if(ipaddr != NULL) {
+      uip_ipaddr_copy(serveraddr, ipaddr);
+      
+      conn = connect(serveraddr, serverport);
+      if(conn != NULL) {
+	memset((char *)0x0400, 0x20, 40*25);
+	memset((char *)0xd800, 0x01, 40*25);
+	textmode();
+      }
+    }
+  } else if(ev == EK_EVENT_REQUEST_EXIT ||
+	    ev == ctk_signal_window_close) {
+    ctk_window_close(&window);
+    ek_exit();
+    LOADER_UNLOAD();
+  } 
+}
+/*---------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+  if(ctk_mode_get() == CTK_MODE_EXTERNAL) {
+    if(CIA1.prb == 0x7f) {
+      ctkmode();
+    } else if(kbhit() && conn != NULL) {
+      tcpip_poll_tcp(conn);
+    }
+  }
+}
+/*---------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/config.c b/contiki-cpc/apps/config.c
new file mode 100644
index 0000000..9fb37fe
--- /dev/null
+++ b/contiki-cpc/apps/config.c
@@ -0,0 +1,248 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS.
+ *
+ * $Id: config.c,v 1.1 2006/04/17 15:18:15 kthacker Exp $
+ *
+ */
+
+#include "program-handler.h"
+#include "loader.h"
+#include "cfs.h"
+#include "uip.h"
+#include "uiplib.h"
+#include "uip_arp.h"
+#include "resolv.h"
+
+
+struct ptentry {
+  char c;
+  char * (* pfunc)(char *str);
+};
+
+/*-----------------------------------------------------------------------------------*/
+static char *
+parse(char *str, struct ptentry *t)
+{
+  struct ptentry *p;
+
+  /* Loop over the parse table entries in t in order to find one that
+     matches the first character in str. */
+  for(p = t; p->c != 0; ++p) {
+    if(*str == p->c) {
+      /* Skip rest of the characters up to the first space. */
+      while(*str != ' ') {
+	++str;
+      }
+
+      /* Skip all spaces.*/
+      while(*str == ' ') {
+	++str;
+      }
+
+      /* Call parse table entry function and return. */
+      return p->pfunc(str);
+    }
+  }
+
+  /* Did not find matching entry in parse table. We just call the
+     default handler supplied by the caller and return. */
+  return p->pfunc(str);
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+skipnewline(char *str)
+{
+  /* Skip all characters until the newline. */
+  while(*str != '\n') {
+    ++str;
+  }
+
+  /* Return a pointer to the first character after the newline. */
+  return str + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+nullterminate(char *str)
+{
+  char *nt;
+
+  /* Nullterminate string. Start with finding newline character. */
+  for(nt = str; *nt != '\r' &&
+	*nt != '\n'; ++nt);
+
+  /* Replace newline with a null char. */
+  *nt = 0;
+
+  /* Remove trailing spaces. */
+  while(nt > str && *(nt - 1) == ' ') {
+    *(nt - 1) = 0;
+    --nt;
+  }
+  
+  /* Return pointer to null char. */
+  return nt;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loadfile(char *str)
+{
+  char *nt;
+
+  nt = nullterminate(str);
+  
+  /* Call loader function. */
+  program_handler_load(str, NULL);
+
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+screensaverconf(char *str)
+{
+  char *nt;
+  
+  nt = nullterminate(str);
+  program_handler_screensaver(str);
+
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static u16_t addr[2];
+static char *
+ipaddrconf(char *str)
+{
+  char *nt;
+  
+  nt = nullterminate(str);
+
+
+//  if(uiplib_ipaddrconv(str, (unsigned char *)addr)) {
+//    uip_sethostaddr(addr);
+//  }
+
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+netmaskconf(char *str)
+{
+  char *nt;
+  
+  nt = nullterminate(str);
+//  if(uiplib_ipaddrconv(str, (unsigned char *)addr)) {
+//    uip_setnetmask(addr);
+//  }
+
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+drconf(char *str)
+{
+  char *nt;
+  
+  nt = nullterminate(str);
+//  if(uiplib_ipaddrconv(str, (unsigned char *)addr)) {
+//    uip_setdraddr(addr);
+//  }
+
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+dnsconf(char *str)
+{
+  char *nt;
+  
+  nt = nullterminate(str);
+//  if(uiplib_ipaddrconv(str, (unsigned char *)addr)) {
+//    resolv_conf(addr);
+//  }
+
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+const static struct ptentry configparsetab[] =
+  {{'n', loadfile},
+   {'t', loadfile},
+   {'c', loadfile},   
+   {'s', screensaverconf},   
+   {'i', ipaddrconf},
+   {'m', netmaskconf},
+   {'r', drconf},
+   {'d', dnsconf},
+   {'#', skipnewline},
+
+   /* Default action */
+   {0, skipnewline}};
+static void
+configscript(void)
+{
+  static char line[40], *lineptr;
+  /*  static struct c64_fs_file f;*/
+  int f;
+
+  if((f = cfs_open("config.cfg", 0)) == -1) {
+    return;
+  }
+
+  line[0] = ' ';
+  while(line[0] != '.' &&
+	line[0] != 0) {
+    lineptr = line;
+    do {
+      if(cfs_read(f, lineptr, 1) != 1) {
+	cfs_close(f);
+	return;
+      }
+      ++lineptr;
+    } while(*(lineptr - 1) != '\n' &&
+	    *(lineptr - 1) != '\r');
+
+    *lineptr = 0;
+
+    if(line[0] != '.' &&
+       line[0] != 0) {
+      parse(line, configparsetab);
+    }
+    
+  }
+  cfs_close(f);
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(config_init, arg)
+{
+  arg_free(arg);
+  program_handler_screensaver(NULL);  
+  configscript();
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/configedit-dsc.c b/contiki-cpc/apps/configedit-dsc.c
new file mode 100644
index 0000000..fcb9250
--- /dev/null
+++ b/contiki-cpc/apps/configedit-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: configedit-dsc.c,v 1.1 2006/04/17 15:18:15 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern const struct ctk_icon configedit_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(configedit_dsc,
+    "Edit Contiki configuration",
+    "confedit.prg",
+    configedit_init,
+    &configedit_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static const unsigned char tcpipconficon_bitmap[3*3*8] = {
+  0x00, 0x79, 0x43, 0x73, 0x47, 0x77, 0x47, 0x6f,
+  0x00, 0xfe, 0xfe, 0xfc, 0xfc, 0xfc, 0xf8, 0xfb,
+  0x00, 0x16, 0x02, 0x00, 0x02, 0x00, 0x00, 0xc2,
+
+  0x48, 0x4c, 0x5f, 0x5f, 0x1f, 0x3f, 0x3f, 0x03,
+  0x79, 0xf0, 0xf0, 0xf0, 0xe0, 0xe0, 0xfe, 0xfc,
+  0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+
+  0x77, 0x47, 0x70, 0x43, 0x79, 0x41, 0x7c, 0x00,
+  0xfc, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xf7, 0x00,
+  0x00, 0x80, 0x00, 0x00, 0x00, 0x84, 0xf0, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static const char tcpipconficon_textmap[9] = {
+  'C', 'F', 'G',
+  ' ', ' ', ' ',
+  'C', 'F', 'G'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+const struct ctk_icon configedit_icon =
+  {CTK_ICON("Configuration", tcpipconficon_bitmap, tcpipconficon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/configedit-dsc.h b/contiki-cpc/apps/configedit-dsc.h
new file mode 100644
index 0000000..368b45c
--- /dev/null
+++ b/contiki-cpc/apps/configedit-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: configedit-dsc.h,v 1.1 2006/04/17 15:18:15 kthacker Exp $
+ *
+ */
+#ifndef __CONFIGEDIT_DSC_H__
+#define __CONFIGEDIT_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(configedit_dsc);
+
+#endif /* __CONFIGEDIT_DSC_H__ */
diff --git a/contiki-cpc/apps/configedit.c b/contiki-cpc/apps/configedit.c
new file mode 100644
index 0000000..5d43f72
--- /dev/null
+++ b/contiki-cpc/apps/configedit.c
@@ -0,0 +1,491 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: configedit.c,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ *
+ */
+
+#include "contiki.h"
+
+#include "ctk-draw-service.h"
+#include "packet-service.h"
+
+#include "uip.h"
+#include "uip_arp.h"
+#include "resolv.h"
+#include "ctk.h"
+#include "ctk-draw.h"
+
+#include "program-handler.h"
+
+#include "cfs.h"
+
+//#include "cfs-init.h"
+#include "cfs-cpc.h"
+
+#include "loader.h"
+
+#include "log.h"
+
+
+#include <stdio.h>
+
+#include <string.h>
+
+/* TCP/IP configuration window. */
+static struct ctk_window window;
+
+#define LABELMAXWIDTH 12
+
+const static struct ctk_label cfslabel =
+  {CTK_LABEL(0, 1, LABELMAXWIDTH, 1, "Disk driver")};
+static char cfs[25];
+static struct ctk_textentry cfstextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 1, 16, 1, cfs, 24)};
+
+const static struct ctk_label themelabel =
+  {CTK_LABEL(0, 3, LABELMAXWIDTH, 1, "CTK theme")};
+static char theme[25];
+static struct ctk_textentry themetextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 3, 16, 1, theme, 24)};
+
+const static struct ctk_label driverlabel =
+  {CTK_LABEL(0, 5, LABELMAXWIDTH, 1, "Net driver")};
+static char driver[25];
+static struct ctk_textentry drivertextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 5, 16, 1, driver, 24)};
+
+const static struct ctk_label screensaverlabel =
+  {CTK_LABEL(0, 7, LABELMAXWIDTH, 1, "Screensaver")};
+static char screensaver[25];
+struct ctk_textentry screensavertextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 7, 16, 1, screensaver, 24)};
+
+
+const static struct ctk_label ipaddrlabel =
+  {CTK_LABEL(0, 9, LABELMAXWIDTH, 1, "IP address")};
+static char ipaddr[25];
+struct ctk_textentry ipaddrtextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 9, 16, 1, ipaddr, 24)};
+const static struct ctk_label netmasklabel =
+  {CTK_LABEL(0, 11, LABELMAXWIDTH, 1, "Netmask")};
+static char netmask[25];
+static struct ctk_textentry netmasktextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 11, 16, 1, netmask, 24)};
+const static struct ctk_label gatewaylabel =
+  {CTK_LABEL(0, 13, LABELMAXWIDTH, 1, "Gateway")};
+static char gateway[25];
+static struct ctk_textentry gatewaytextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 13, 16, 1, gateway, 24)};
+const static struct ctk_label dnsserverlabel =
+  {CTK_LABEL(0, 15, LABELMAXWIDTH, 1, "DNS server")};
+static char dnsserver[25];
+static struct ctk_textentry dnsservertextentry =
+  {CTK_TEXTENTRY(LABELMAXWIDTH + 1, 15, 16, 1, dnsserver, 24)};
+
+const static struct ctk_button savebutton =
+  {CTK_BUTTON(0, 17, 12, "Save & close")};
+const static struct ctk_button cancelbutton =
+  {CTK_BUTTON(24, 17, 6, "Cancel")};
+
+/*static DISPATCHER_SIGHANDLER(configedit_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Config editor", NULL, configedit_sighandler, NULL)};
+  static ek_id_t id;*/
+
+EK_EVENTHANDLER(configedit_eventhandler, ev, data);
+EK_PROCESS(p, "Config editor", EK_PRIO_NORMAL,
+	   configedit_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+
+/*-----------------------------------------------------------------------------------*/
+struct ptentry {
+  char c;
+  char * (* pfunc)(char *str);
+};
+
+/*-----------------------------------------------------------------------------------*/
+static char *
+parse(char *str, struct ptentry *t)
+{
+  struct ptentry *p;
+
+  /* Loop over the parse table entries in t in order to find one that
+     matches the first character in str. */
+  for(p = t; p->c != 0; ++p) {
+    if(*str == p->c) {
+      /* Skip rest of the characters up to the first space. */
+      while(*str != ' ') {
+	++str;
+      }
+
+      /* Skip all spaces.*/
+      while(*str == ' ') {
+	++str;
+      }
+
+      /* Call parse table entry function and return. */
+      return p->pfunc(str);
+    }
+  }
+
+  /* Did not find matching entry in parse table. We just call the
+     default handler supplied by the caller and return. */
+  return p->pfunc(str);
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+skipnewline(char *str)
+{
+  /* Skip all characters until the newline. */
+  while(*str != '\n') {
+    ++str;
+  }
+
+  /* Return a pointer to the first character after the newline. */
+  return str + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+nullterminate(char *str)
+{
+  char *nt;
+
+  /* Nullterminate string. Start with finding newline character. */
+  for(nt = str; *nt != '\r' &&
+	*nt != '\n'; ++nt);
+
+  /* Replace newline with a null char. */
+  *nt = 0;
+
+  /* Remove trailing spaces. */
+  while(nt > str && *(nt - 1) == ' ') {
+    *(nt - 1) = 0;
+    --nt;
+  }
+    
+  /* Return pointer to null char. */
+  return nt;
+}
+/*-----------------------------------------------------------------------------------*/
+static char * __fastcall__
+copystr(char *dst, char *src, int len)
+{
+  char *nt = nullterminate(src);
+  strncpy(dst, src, len);
+  return nt + 1;
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loaddriver(char *str)
+{
+  return copystr(driver, str, sizeof(driver));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loadtheme(char *str)
+{
+  return copystr(theme, str, sizeof(theme));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loadcfs(char *str)
+{
+  return copystr(cfs, str, sizeof(cfs));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+loadscreensaver(char *str)
+{
+  return copystr(screensaver, str, sizeof(screensaver));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+ipaddrconf(char *str)
+{
+  return copystr(ipaddr, str, sizeof(ipaddr));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+netmaskconf(char *str)
+{
+  return copystr(netmask, str, sizeof(netmask));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+drconf(char *str)
+{
+  return copystr(gateway, str, sizeof(gateway));
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+dnsconf(char *str)
+{
+  return copystr(dnsserver, str, sizeof(dnsserver));
+}
+/*-----------------------------------------------------------------------------------*/
+const static struct ptentry initparsetab[] =
+  {{'n', loaddriver},
+   {'t', loadtheme},
+   {'c', loadcfs},
+   {'s', loadscreensaver},
+   {'i', ipaddrconf},
+   {'m', netmaskconf},
+   {'r', drconf},
+   {'d', dnsconf},
+   {'#', skipnewline},
+
+   /* Default action */
+   {0, skipnewline}};
+static void
+initscript(void)
+{
+  char line[40], *lineptr;
+  /*  struct c64_fs_file f;*/
+  int f;
+
+  if((f = cfs_open("config.cfg", 0)) == -1) {
+    return;
+  }
+  line[0] = ' ';
+  while(line[0] != '.' &&
+	line[0] != 0) {
+    lineptr = line;
+    do {
+      if(cfs_read(f, lineptr, 1) != 1) {
+	cfs_close(f);
+	return;
+      }
+      ++lineptr;
+    } while(*(lineptr - 1) != '\n' &&
+	    *(lineptr - 1) != '\r');
+
+    *lineptr = 0;
+
+    if(line[0] != '.' &&
+       line[0] != 0) {
+      parse(line, initparsetab);
+    }
+    
+  }
+  cfs_close(f);
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+static int makeline(char *line, char c, char *str)
+{
+  int len;
+
+  len = strlen(str);
+  
+  line[0] = c;
+  line[1] = ' ';
+  strcpy(&line[2], str);
+  line[2 + len] = '\n';
+  line[3 + len] = 0;
+  return len + 3;
+}
+
+#if 0
+struct scriptvar
+{
+ const char *var;
+ char chr;
+};
+
+cstatic struct scriptvar scriptvars[]=
+{
+{cfs,'c'},
+
+
+};
+#endif
+
+
+/*-----------------------------------------------------------------------------------*/
+static void
+savescript(void)
+{
+  char line[40];
+  /*  struct c64_fs_file f;*/
+  int f;
+  
+  f = cfs_open("@:config.cfg", CFS_WRITE);
+  if(f == -1) {
+    log_message("Could not open config.cfg", "");
+    return;
+  }
+  if(cfs[0] != 0) {
+	int len = makeline(line, 'c',cfs);
+	cfs_write(f, line, len);
+//    cfs_write(f, line, makeline(line, 'c', cfs));
+  }
+  if(theme[0] != 0) {
+	int len = makeline(line, 't',theme);
+	cfs_write(f, line, len);
+//    cfs_write(f, line, makeline(line, 't', theme));
+  }
+  if(driver[0] != 0) {
+	int len = makeline(line, 'n',driver);
+	cfs_write(f, line, len);
+//    cfs_write(f, line, makeline(line, 'n', driver));
+  }
+  if(ipaddr[0] != 0) {
+	int len = makeline(line, 'i',ipaddr);
+	cfs_write(f, line, len);
+//    cfs_write(f, line, makeline(line, 'i', ipaddr));
+  }
+  if(netmask[0] != 0) {
+	int len = makeline(line, 'm',netmask);
+	cfs_write(f, line, len);
+//    cfs_write(f, line, makeline(line, 'm', netmask));
+  }
+  if(gateway[0] != 0) {
+	int len = makeline(line, 'r',gateway);
+	cfs_write(f, line, len);
+//    cfs_write(f, line, makeline(line, 'r', gateway));
+  }
+  if(dnsserver[0] != 0) {
+	int len = makeline(line, 'd',dnsserver);
+	cfs_write(f, line, len);
+//    cfs_write(f, line, makeline(line, 'd', dnsserver));
+  }
+  
+  if(screensaver[0] != 0) {
+	int len = makeline(line, 's',screensaver);
+	cfs_write(f, line, len);
+//    cfs_write(f, line, makeline(line, 's', screensaver));
+  }
+  
+  strcpy(line, ".\n\0\n\n\n");
+  cfs_write(f, line, strlen(line));
+  
+  cfs_close(f);
+  
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(configedit_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }    
+}
+/*-----------------------------------------------------------------------------------*/
+
+/*-----------------------------------------------------------------------------------*/
+static void
+configedit_quit(void)
+{
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+quit_services(void)
+{
+  cfs_cpc_init(NULL);
+  ctk_draw_quit();  
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(configedit_eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    /* Create window. */
+    ctk_window_new(&window, 32, 18, "Config editor");
+
+    CTK_WIDGET_ADD(&window, &cfslabel);  
+    CTK_WIDGET_ADD(&window, &cfstextentry);
+    CTK_TEXTENTRY_CLEAR(&cfstextentry);
+
+    CTK_WIDGET_ADD(&window, &themelabel);  
+    CTK_WIDGET_ADD(&window, &themetextentry);
+    CTK_TEXTENTRY_CLEAR(&themetextentry);
+    
+    CTK_WIDGET_ADD(&window, &driverlabel);  
+    CTK_WIDGET_ADD(&window, &drivertextentry);
+    CTK_TEXTENTRY_CLEAR(&drivertextentry);
+
+    CTK_WIDGET_ADD(&window, &screensaverlabel);
+    CTK_WIDGET_ADD(&window, &screensavertextentry);
+    CTK_TEXTENTRY_CLEAR(&screensavertextentry);
+
+    CTK_WIDGET_ADD(&window, &ipaddrlabel);  
+    CTK_WIDGET_ADD(&window, &ipaddrtextentry);
+    CTK_TEXTENTRY_CLEAR(&ipaddrtextentry);
+
+    CTK_WIDGET_ADD(&window, &netmasklabel);
+    CTK_WIDGET_ADD(&window, &netmasktextentry);
+    CTK_TEXTENTRY_CLEAR(&netmasktextentry);
+
+    CTK_WIDGET_ADD(&window, &gatewaylabel);
+    CTK_WIDGET_ADD(&window, &gatewaytextentry);
+    CTK_TEXTENTRY_CLEAR(&gatewaytextentry);
+
+    CTK_WIDGET_ADD(&window, &dnsserverlabel);
+    CTK_WIDGET_ADD(&window, &dnsservertextentry);
+    CTK_TEXTENTRY_CLEAR(&dnsservertextentry);
+
+
+    CTK_WIDGET_ADD(&window, &savebutton);
+    CTK_WIDGET_ADD(&window, &cancelbutton);    
+    
+    CTK_WIDGET_FOCUS(&window, &cfstextentry);  
+
+    /* Fill the configuration strings with values from the current
+       configuration */
+    initscript();
+    
+    ctk_window_open(&window);
+
+  } else if(ev == ctk_signal_button_activate) {   
+    if(data == (ek_data_t)&savebutton) {
+      savescript();
+      quit_services();
+      ctk_window_close(&window);
+      configedit_quit();
+      program_handler_load("config.prg", NULL);
+    } else if(data == (ek_data_t)&cancelbutton) {
+      ctk_window_close(&window);
+      configedit_quit();
+    }
+  } else if(ev == ctk_signal_window_close ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    ctk_window_close(&window);
+    configedit_quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/default-dsc.c b/contiki-cpc/apps/default-dsc.c
new file mode 100644
index 0000000..96507ec
--- /dev/null
+++ b/contiki-cpc/apps/default-dsc.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: default-dsc.c,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon default_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(default_dsc,
+    "Default CTK theme",
+    "default.prg",
+    default_init,
+    &default_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char defaulticon_bitmap[3*3*8] = {
+  0xff,0xff,0xc0,0xcf,0xc0,0xc3,0xc0,0xc0,
+  0xff,0xff,0x00,0xff,0x00,0xff,0x00,0x00,
+  0xff,0xfc,0x00,0xf0,0x00,0xc0,0x00,0x00,
+  0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,0x0b,
+  0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x80,0x00,
+  0x00,0x00,0x00,0x00,0xff,0x00,0xff,0xff,
+  0x0b,0x0b,0x0b,0x0b,0xfb,0x03,0xff,0xff  
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char defaulticon_textmap[9] = {
+  '+', '=', '+',
+  '|', 'D', '|',
+  '+', '-', '+'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon default_icon =
+  {CTK_ICON("Default", defaulticon_bitmap, defaulticon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/directory-dsc.c b/contiki-cpc/apps/directory-dsc.c
new file mode 100644
index 0000000..d4d1944
--- /dev/null
+++ b/contiki-cpc/apps/directory-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: directory-dsc.c,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern const struct ctk_icon directory_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(directory_dsc,
+    "Directory reader",
+    "dir.prg",
+    directory_init,
+    &directory_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static const unsigned char directoryicon_bitmap[3*3*8] = {
+  0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
+  0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
+  0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
+
+  0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
+  0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
+  0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
+
+  0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
+  0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
+  0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static const char directoryicon_textmap[9] = {
+  '+', '-', '+',
+  '|', 'o', '|',
+  '+', '-', '+'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+const struct ctk_icon directory_icon =
+  {CTK_ICON("Directory", directoryicon_bitmap, directoryicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/directory-dsc.h b/contiki-cpc/apps/directory-dsc.h
new file mode 100644
index 0000000..da154fe
--- /dev/null
+++ b/contiki-cpc/apps/directory-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: directory-dsc.h,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ *
+ */
+#ifndef __DIRECTORY_DSC_H__
+#define __DIRECTORY_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(directory_dsc);
+
+#endif /* __DIRECTORY_DSC_H__ */
diff --git a/contiki-cpc/apps/enabler-dsc.c b/contiki-cpc/apps/enabler-dsc.c
new file mode 100644
index 0000000..0051476
--- /dev/null
+++ b/contiki-cpc/apps/enabler-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: enabler-dsc.c,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon enabler_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(enabler_dsc,
+    "Colorless grayish CTK theme",
+    "enabler.prg",
+    enabler_init,
+    &enabler_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char enablericon_bitmap[3*3*8] = {
+  0xff,0xff,0xff,0xfc,0xf0,0xf0,0xe0,0xe0,
+  0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
+  0xff,0xff,0xff,0x3f,0x0f,0x0f,0x07,0x07,
+
+  0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,0xe0,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
+
+  0xe0,0xe0,0xf0,0xf0,0xfc,0xff,0xff,0xff,
+  0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,
+  0x07,0x07,0x0f,0x0f,0x3f,0xff,0xff,0xff
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char enablericon_textmap[9] = {
+  '(', '=', ')',
+  '|', 'o', '|',
+  '(', '-', ')'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon enabler_icon =
+  {CTK_ICON("Enabler", enablericon_bitmap, enablericon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/http-user-agent-string b/contiki-cpc/apps/http-user-agent-string
new file mode 100644
index 0000000..1b3104c
--- /dev/null
+++ b/contiki-cpc/apps/http-user-agent-string
@@ -0,0 +1 @@
+http_user_agent_fields "Connection: close\r\nUser-Agent: Contiki/1.1-rc0 (Commodore 64; http://dunkels.com/adam/contiki/)\r\n\r\n"
diff --git a/contiki-cpc/apps/http-user-agent-string.c b/contiki-cpc/apps/http-user-agent-string.c
new file mode 100644
index 0000000..d4e1bc9
--- /dev/null
+++ b/contiki-cpc/apps/http-user-agent-string.c
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: http-user-agent-string.c,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ */
+char http_user_agent_fields[100] = 
+/* "Connection: close\r\nUser-Agent: Contiki/1.1-rc0 (Commodore 64; http://dunkels.com/adam/contiki/)\r\n\r\n" */
+{0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x63, 0x6c, 0x6f, 0x73, 0x65, 0xd, 0xa, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x31, 0x2e, 0x31, 0x2d, 0x72, 0x63, 0x30, 0x20, 0x28, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x64, 0x6f, 0x72, 0x65, 0x20, 0x36, 0x34, 0x3b, 0x20, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0xd, 0xa, };
diff --git a/contiki-cpc/apps/http-user-agent-string.h b/contiki-cpc/apps/http-user-agent-string.h
new file mode 100644
index 0000000..402af57
--- /dev/null
+++ b/contiki-cpc/apps/http-user-agent-string.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: http-user-agent-string.h,v 1.1 2006/04/17 15:18:16 kthacker Exp $
+ */
+extern char http_user_agent_fields[100];
diff --git a/contiki-cpc/apps/httpd-cgi.c b/contiki-cpc/apps/httpd-cgi.c
new file mode 100644
index 0000000..53c04a8
--- /dev/null
+++ b/contiki-cpc/apps/httpd-cgi.c
@@ -0,0 +1,279 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd-cgi.c,v 1.1 2006/04/17 15:18:17 kthacker Exp $
+ *
+ */
+
+/*
+ * This file includes functions that are called by the web server
+ * scripts. The functions takes no argument, and the return value is
+ * interpreted as follows. A zero means that the function did not
+ * complete and should be invoked for the next packet as well. A
+ * non-zero value indicates that the function has completed and that
+ * the web server should move along to the next script line.
+ *
+ */
+
+#include "uip.h"
+#include "httpd.h"
+#include "httpd-cgi.h"
+#include "httpd-fs.h"
+
+#include "petsciiconv.h"
+
+#ifdef __CBM__
+#include <cbm.h>
+#include <c64.h>
+#endif /* __CBM__ */
+
+#include <stdio.h>
+#include <string.h>
+
+static u8_t file_stats(void);
+static u8_t tcp_stats(void);
+static u8_t processes(void);
+
+static u8_t d64output(void);
+static u8_t diroutput(void);
+
+httpd_cgifunction httpd_cgitab[] = {
+  NULL,
+  tcp_stats,     /* CGI function "b" */
+  processes,     /* CGI function "c" */
+
+  d64output,     /* CGI function "d" */
+};
+
+static const char closed[] =   /*  "CLOSED",*/
+{0x43, 0x4c, 0x4f, 0x53, 0x45, 0x44, 0};
+static const char syn_rcvd[] = /*  "SYN-RCVD",*/
+{0x53, 0x59, 0x4e, 0x2d, 0x52, 0x43, 0x56, 
+ 0x44,  0};
+static const char syn_sent[] = /*  "SYN-SENT",*/
+{0x53, 0x59, 0x4e, 0x2d, 0x53, 0x45, 0x4e, 
+ 0x54,  0};
+static const char established[] = /*  "ESTABLISHED",*/
+{0x45, 0x53, 0x54, 0x41, 0x42, 0x4c, 0x49, 0x53, 0x48, 
+ 0x45, 0x44, 0};
+static const char fin_wait_1[] = /*  "FIN-WAIT-1",*/
+{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, 
+ 0x54, 0x2d, 0x31, 0};
+static const char fin_wait_2[] = /*  "FIN-WAIT-2",*/
+{0x46, 0x49, 0x4e, 0x2d, 0x57, 0x41, 0x49, 
+ 0x54, 0x2d, 0x32, 0};
+static const char closing[] = /*  "CLOSING",*/
+{0x43, 0x4c, 0x4f, 0x53, 0x49, 
+ 0x4e, 0x47, 0};
+static const char time_wait[] = /*  "TIME-WAIT,"*/
+{0x54, 0x49, 0x4d, 0x45, 0x2d, 0x57, 0x41, 
+ 0x49, 0x54, 0};
+static const char last_ack[] = /*  "LAST-ACK"*/
+{0x4c, 0x41, 0x53, 0x54, 0x2d, 0x41, 0x43, 
+ 0x4b, 0};
+
+static const char *states[] = {
+  closed,
+  syn_rcvd,
+  syn_sent,
+  established,
+  fin_wait_1,
+  fin_wait_2,
+  closing,
+  time_wait,
+  last_ack};
+  
+
+/*-----------------------------------------------------------------------------------*/
+#if 0
+static u8_t
+file_stats(void)
+{
+  /* We use sprintf() to print the number of file accesses to a
+     particular file (given as an argument to the function in the
+     script). We then use uip_send() to actually send the data. */
+  if(uip_acked()) {
+    return 1;
+  }
+  uip_send(uip_appdata, sprintf((char *)uip_appdata, "%5u", httpd_fs_count(&hs->script[4])));
+  return 0;
+}
+#endif /* 0 */
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+tcp_stats(void)
+{
+  register struct uip_conn *conn;  
+
+  if(uip_acked()) {
+    /* If the previously sent data has been acknowledged, we move
+       forward one connection. */
+    if(++hs->count == UIP_CONNS) {
+      /* If all connections has been printed out, we are done and
+	 return 1. */
+      return 1;
+    }
+  }
+
+  conn = &uip_conns[hs->count];
+  while((conn->tcpstateflags & TS_MASK) == CLOSED) {
+    if(++hs->count == UIP_CONNS) {
+      /* If all connections has been printed out, we are done and
+	 return 1. */
+      return 1;
+    }
+    conn = &uip_conns[hs->count];
+  }
+
+  uip_send(uip_appdata, sprintf((char *)uip_appdata,
+				"<tr><td>%d</td><td>%u.%u.%u.%u:%u</td><td>%s</td><td>%u</td><td>%u</td><td>%c %c</td></tr>\r\n",
+				htons(conn->lport),
+				htons(conn->ripaddr[0]) >> 8,
+				htons(conn->ripaddr[0]) & 0xff,
+				htons(conn->ripaddr[1]) >> 8,
+				htons(conn->ripaddr[1]) & 0xff,
+				htons(conn->rport),
+				states[conn->tcpstateflags & TS_MASK],
+				conn->nrtx,
+				conn->timer,
+				(uip_outstanding(conn))? '*':' ',
+				(uip_stopped(conn))? '!':' '));
+
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+processes(void)
+{
+  u8_t i;
+  register struct dispatcher_proc *p;
+  char name[40];
+
+  p = DISPATCHER_PROCS();
+  for(i = 0; i < hs->count; ++i) {
+    if(p != NULL) {
+      p = p->next;
+    }
+  }
+
+  if(uip_acked()) {
+    /* If the previously sent data has been acknowledged, we move
+       forward one connection. */
+    ++hs->count;
+    if(p != NULL) {
+      p = p->next;
+    }
+    if(p == NULL) {
+      /* If all processes have been printed out, we are done and
+	 return 1. */
+      return 1;
+    }
+  }
+
+  strncpy(name, p->name, 40);
+  petsciiconv_toascii(name, 40);
+  uip_send(uip_appdata,
+	   sprintf((char *)uip_appdata,
+		   "<tr align=\"center\"><td>%3d</td><td>%s</td><td>0x%04x</td><td>0x%04x</td><td>0x%04x</td></tr>\r\n",
+		   p->id, name,
+		   p->idle, p->signalhandler, p->uiphandler));
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+struct drv_state {
+  u8_t track;
+  u8_t sect;
+};
+
+static struct drv_state ds;
+
+
+#include "c64-dio.h"
+
+static void
+read_sector(void)
+{
+  c64_dio_read_block(ds.track, ds.sect, uip_appdata);
+}
+
+static u8_t
+next_sector(void)
+{
+  ++ds.sect;
+  if(ds.track < 18) {
+    if(ds.sect == 21) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  } else if(ds.track < 25) {
+    if(ds.sect == 19) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  } else if(ds.track < 31) {
+    if(ds.sect == 18) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  } else if(ds.track < 36) {
+    if(ds.sect == 17) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  }
+
+  if(ds.track == 36) {
+    return 1;
+  }
+  return 0;
+}
+
+static u8_t
+d64output(void)
+{
+  if(hs->count == 0) {
+    ds.track = 1;
+    ds.sect = 0;
+    /*    c64_dio_init(8);*/
+  }
+  
+  if(uip_acked()) {
+    ++hs->count;
+    if(next_sector()) {
+      return 1;
+    }
+  }
+
+  read_sector();
+  uip_send(uip_appdata, 256);
+  return 0;
+}
+
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/httpd-fs.h b/contiki-cpc/apps/httpd-fs.h
new file mode 100644
index 0000000..d641ba2
--- /dev/null
+++ b/contiki-cpc/apps/httpd-fs.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2001, Swedish Institute of Computer Science.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the lwIP TCP/IP stack.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: httpd-fs.h,v 1.1 2006/04/17 15:18:17 kthacker Exp $
+ */
+#ifndef __HTTPD_FS_H__
+#define __HTTPD_FS_H__
+
+#include "uip.h"
+
+#define HTTPD_FS_STATISTICS 0
+
+struct httpd_fs_file {
+  char *data;
+  int len;
+};
+
+/* file must be allocated by caller and will be filled in
+   by the function. */
+int httpd_fs_open(const char *name, struct httpd_fs_file *file);
+
+#ifdef HTTPD_FS_STATISTICS
+#if HTTPD_FS_STATISTICS == 1  
+u16_t httpd_fs_count(char *name);
+#endif /* HTTPD_FS_STATISTICS */
+#endif /* HTTPD_FS_STATISTICS */
+
+void httpd_fs_init(void);
+
+#endif /* __HTTPD_FS_H__ */
diff --git a/contiki-cpc/apps/httpd-fsdata.c b/contiki-cpc/apps/httpd-fsdata.c
new file mode 100644
index 0000000..e0175d0
--- /dev/null
+++ b/contiki-cpc/apps/httpd-fsdata.c
@@ -0,0 +1,406 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: httpd-fsdata.c,v 1.1 2006/04/17 15:18:18 kthacker Exp $
+ */
+static const char data_cgi_processes[] = {
+	/* /cgi/processes */
+	0x2f, 0x63, 0x67, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0,
+	0x69, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 
+	0x68, 0x74, 0x6d, 0x6c, 0xa, 0x74, 0x20, 0x3c, 0x68, 0x31, 
+	0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 0x70, 0x72, 
+	0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 0x2f, 0x68, 
+	0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 0x74, 0x61, 0x62, 
+	0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 
+	0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, 0x74, 0x20, 0x3c, 
+	0x74, 0x72, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x49, 0x44, 0x3c, 
+	0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x4e, 0x61, 
+	0x6d, 0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 
+	0x3e, 0x49, 0x64, 0x6c, 0x65, 0x20, 0x68, 0x61, 0x6e, 0x64, 
+	0x6c, 0x65, 0x72, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 
+	0x68, 0x3e, 0x53, 0x69, 0x67, 0x6e, 0x61, 0x6c, 0x20, 0x68, 
+	0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x3c, 0x2f, 0x74, 0x68, 
+	0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x54, 0x43, 0x50, 0x2f, 0x49, 
+	0x50, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x65, 0x72, 0x3c, 
+	0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 0x3e, 0xa, 
+	0x63, 0x20, 0x63, 0xa, 0x74, 0x20, 0x3c, 0x2f, 0x74, 0x61, 
+	0x62, 0x6c, 0x65, 0x3e, 0xa, 0x69, 0x20, 0x2f, 0x66, 0x6f, 
+	0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 
+	0xa, 0x2e, };
+
+static const char data_cgi_tcp[] = {
+	/* /cgi/tcp */
+	0x2f, 0x63, 0x67, 0x69, 0x2f, 0x74, 0x63, 0x70, 0,
+	0x69, 0x20, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 
+	0x68, 0x74, 0x6d, 0x6c, 0xa, 0x74, 0x20, 0x3c, 0x68, 0x31, 
+	0x3e, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x63, 
+	0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 
+	0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0x3c, 
+	0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 
+	0x68, 0x3d, 0x22, 0x31, 0x30, 0x30, 0x25, 0x22, 0x3e, 0xa, 
+	0x74, 0x20, 0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 
+	0x52, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x3c, 0x2f, 0x74, 0x68, 
+	0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x53, 0x74, 0x61, 0x74, 0x65, 
+	0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x52, 
+	0x65, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x6d, 0x69, 0x73, 0x73, 
+	0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 
+	0x74, 0x68, 0x3e, 0x54, 0x69, 0x6d, 0x65, 0x72, 0x3c, 0x2f, 
+	0x74, 0x68, 0x3e, 0x3c, 0x74, 0x68, 0x3e, 0x46, 0x6c, 0x61, 
+	0x67, 0x73, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 0x3c, 0x2f, 0x74, 
+	0x72, 0x3e, 0xa, 0x63, 0x20, 0x62, 0xa, 0x74, 0x20, 0x3c, 
+	0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0xa, 0x69, 0x20, 
+	0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 
+	0x61, 0x69, 0x6e, 0xa, 0x2e, };
+
+static const char data_cgi_d64[] = {
+	/* /cgi/d64 */
+	0x2f, 0x63, 0x67, 0x69, 0x2f, 0x64, 0x36, 0x34, 0,
+	0x69, 0x20, 0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x68, 
+	0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 
+	0x6e, 0xa, 0x63, 0x20, 0x64, 0xa, 0x2e, 0xa, };
+
+static const char data_index_html[] = {
+	/* /index.html */
+	0x2f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 
+	0xd, 0xa, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 
+	0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74, 
+	0x6c, 0x65, 0x3e, 0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 
+	0x74, 0x69, 0x6b, 0x69, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 
+	0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 0x3c, 0x2f, 0x74, 0x69, 
+	0x74, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 
+	0x3e, 0xa, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 
+	0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 
+	0x74, 0x65, 0x22, 0x3e, 0xa, 0x3c, 0x74, 0x61, 0x62, 0x6c, 
+	0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 0x31, 
+	0x30, 0x30, 0x25, 0x22, 0x20, 0x62, 0x6f, 0x72, 0x64, 0x65, 
+	0x72, 0x3d, 0x22, 0x30, 0x22, 0x3e, 0xa, 0x3c, 0x74, 0x72, 
+	0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 0x20, 
+	0x73, 0x72, 0x63, 0x3d, 0x22, 0x63, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2e, 0x70, 0x6e, 0x67, 0x22, 0x3e, 0x3c, 0x2f, 
+	0x74, 0x64, 0x3e, 0xa, 0x3c, 0x74, 0x64, 0x20, 0x61, 0x6c, 
+	0x69, 0x67, 0x6e, 0x3d, 0x22, 0x63, 0x65, 0x6e, 0x74, 0x65, 
+	0x72, 0x22, 0x3e, 0x3c, 0x68, 0x31, 0x3e, 0x57, 0x65, 0x6c, 
+	0x63, 0x6f, 0x6d, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x74, 0x68, 
+	0x65, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20, 
+	0x77, 0x65, 0x62, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 
+	0x21, 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 
+	0x3e, 0xa, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x69, 0x6d, 0x67, 
+	0x20, 0x73, 0x72, 0x63, 0x3d, 0x22, 0x77, 0x65, 0x62, 0x73, 
+	0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x70, 0x6e, 0x67, 0x22, 
+	0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 0x72, 
+	0x3e, 0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0x3c, 
+	0x62, 0x72, 0x3e, 0xa, 0x3c, 0x62, 0x3e, 0x3c, 0x63, 0x65, 
+	0x6e, 0x74, 0x65, 0x72, 0x3e, 0x54, 0x68, 0x65, 0x73, 0x65, 
+	0x20, 0x77, 0x65, 0x62, 0x20, 0x70, 0x61, 0x67, 0x65, 0x73, 
+	0x20, 0x61, 0x72, 0x65, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 
+	0x64, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x79, 0x6f, 0x75, 
+	0x72, 0x20, 0x43, 0x36, 0x34, 0x21, 0x3c, 0x2f, 0x63, 0x65, 
+	0x6e, 0x74, 0x65, 0x72, 0x3e, 0x3c, 0x2f, 0x62, 0x3e, 0xa, 
+	0x3c, 0x75, 0x6c, 0x3e, 0x3c, 0x6c, 0x69, 0x3e, 0x3c, 0x61, 
+	0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x38, 0x2f, 
+	0x22, 0x3e, 0x44, 0x69, 0x73, 0x6b, 0x20, 0x64, 0x69, 0x72, 
+	0x65, 0x63, 0x74, 0x6f, 0x72, 0x79, 0x3c, 0x2f, 0x61, 0x3e, 
+	0x3c, 0x62, 0x72, 0x3e, 0xa, 0x3c, 0x6c, 0x69, 0x3e, 0x3c, 
+	0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 
+	0x67, 0x69, 0x2f, 0x64, 0x36, 0x34, 0x22, 0x3e, 0x44, 0x6f, 
+	0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x20, 0x65, 0x6e, 0x74, 
+	0x69, 0x72, 0x65, 0x20, 0x64, 0x69, 0x73, 0x6b, 0x20, 0x69, 
+	0x6e, 0x20, 0x61, 0x73, 0x20, 0x61, 0x20, 0x44, 0x36, 0x34, 
+	0x20, 0x66, 0x69, 0x6c, 0x65, 0x3c, 0x2f, 0x61, 0x3e, 0x2e, 
+	0x3c, 0x62, 0x72, 0x3e, 0xa, 0x3c, 0x6c, 0x69, 0x3e, 0x3c, 
+	0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 
+	0x67, 0x69, 0x2f, 0x74, 0x63, 0x70, 0x22, 0x3e, 0x43, 0x75, 
+	0x72, 0x72, 0x65, 0x6e, 0x74, 0x20, 0x6e, 0x65, 0x74, 0x77, 
+	0x6f, 0x72, 0x6b, 0x20, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 
+	0x74, 0x69, 0x6f, 0x6e, 0x73, 0x3c, 0x2f, 0x61, 0x3e, 0x3c, 
+	0x62, 0x72, 0x3e, 0xa, 0x3c, 0x6c, 0x69, 0x3e, 0x3c, 0x61, 
+	0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x2f, 0x63, 0x67, 
+	0x69, 0x2f, 0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 
+	0x73, 0x22, 0x3e, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, 
+	0x70, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x65, 0x73, 0x3c, 
+	0x2f, 0x61, 0x3e, 0x3c, 0x62, 0x72, 0x3e, 0xa, 0x3c, 0x2f, 
+	0x75, 0x6c, 0x3e, 0xa, 0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 
+	0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20, 0x68, 0x6f, 0x6d, 0x65, 
+	0x70, 0x61, 0x67, 0x65, 0x3a, 0x20, 0x3c, 0x61, 0x20, 0x68, 
+	0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 
+	0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 
+	0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 
+	0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x22, 0x3e, 0x3c, 
+	0x74, 0x74, 0x3e, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 
+	0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 
+	0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 
+	0x74, 0x69, 0x6b, 0x69, 0x2f, 0x3c, 0x2f, 0x74, 0x74, 0x3e, 
+	0x3c, 0x2f, 0x61, 0x3e, 0x2e, 0xa, 0x3c, 0x2f, 0x62, 0x6f, 
+	0x64, 0x79, 0x3e, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 
+};
+
+static const char data_404_html[] = {
+	/* /404.html */
+	0x2f, 0x34, 0x30, 0x34, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 
+	0xd, 0xa, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 
+	0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 0x6f, 
+	0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 0x65, 
+	0x22, 0x3e, 0x3c, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 
+	0x3c, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 
+	0x74, 0x68, 0x3d, 0x22, 0x36, 0x30, 0x30, 0x22, 0x20, 0x62, 
+	0x6f, 0x72, 0x64, 0x65, 0x72, 0x3d, 0x22, 0x30, 0x22, 0x3e, 
+	0x3c, 0x74, 0x72, 0x3e, 0x3c, 0x74, 0x64, 0x3e, 0x3c, 0x68, 
+	0x31, 0x3e, 0x34, 0x30, 0x34, 0x20, 0x2d, 0x20, 0x66, 0x69, 
+	0x6c, 0x65, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x66, 0x6f, 0x75, 
+	0x6e, 0x64, 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x3c, 0x2f, 0x74, 
+	0x72, 0x3e, 0x3c, 0x2f, 0x74, 0x64, 0x3e, 0x3c, 0x2f, 0x74, 
+	0x61, 0x62, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x63, 0x65, 0x6e, 
+	0x74, 0x65, 0x72, 0x3e, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 
+	0x3e, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e, };
+
+static const char data_header_html[] = {
+	/* /header.html */
+	0x2f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 
+	0xd, 0xa, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 
+	0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74, 
+	0x6c, 0x65, 0x3e, 0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 
+	0x74, 0x69, 0x6b, 0x69, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 
+	0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 0x3c, 0x2f, 0x74, 0x69, 
+	0x74, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 
+	0x3e, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 0x63, 
+	0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 0x74, 
+	0x65, 0x22, 0x3e, 0xa, };
+
+static const char data_footer_plain[] = {
+	/* /footer.plain */
+	0x2f, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0,
+	0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 
+	0x69, 0x20, 0x68, 0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65, 
+	0x3a, 0x20, 0x3c, 0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 
+	0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x75, 
+	0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 
+	0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x22, 0x3e, 0x3c, 0x74, 0x74, 0x3e, 0x68, 
+	0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 
+	0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 
+	0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 
+	0x2f, 0x3c, 0x2f, 0x74, 0x74, 0x3e, 0x3c, 0x2f, 0x61, 0x3e, 
+	0x2e, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c, 0x2f, 
+	0x68, 0x74, 0x6d, 0x6c, 0x3e, };
+
+static const char data_webserver_png[] = {
+	/* /webserver.png */
+	0x2f, 0x77, 0x65, 0x62, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x70, 0x6e, 0x67, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 
+	0xd, 0xa, 0xd, 0xa, 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 
+	0x1a, 0xa, 00, 00, 00, 0xd, 0x49, 0x48, 0x44, 0x52, 
+	00, 00, 00, 0x18, 00, 00, 00, 0x18, 0x1, 00, 
+	00, 00, 00, 0xc8, 0xc, 00, 0x55, 00, 00, 00, 
+	0x2, 0x62, 0x4b, 0x47, 0x44, 00, 0x1, 0xdd, 0x8a, 0x13, 
+	0xa4, 00, 00, 00, 0x5d, 0x49, 0x44, 0x41, 0x54, 0x78, 
+	0xda, 0x1d, 0xc8, 0x21, 0xa, 0x80, 0x30, 00, 0x46, 0xe1, 
+	0xa7, 0xc7, 0x34, 0x78, 0x93, 0x89, 0xb, 0x1e, 0x43, 0x96, 
+	0x8c, 0x62, 0x14, 0x19, 0x6e, 0xc1, 0xe8, 0x19, 0x96, 0x97, 
+	0x8c, 0x6, 0xc3, 0xf8, 0x45, 0xc3, 0x83, 0x8f, 0x87, 0x24, 
+	0x7a, 0x2a, 0xe2, 0x54, 0x8, 0x32, 0x78, 0x25, 0x56, 0x5d, 
+	0xc4, 0xa3, 0xb0, 0x74, 0xf7, 0xff, 0x9c, 0x1e, 0x76, 0xed, 
+	0x8c, 0x79, 0xfb, 0xfb, 0xec, 0xf2, 0x43, 0xc8, 0x86, 0xa5, 
+	0xb9, 0x89, 0x67, 0x61, 0x3d, 0x2e, 0xfc, 0x9c, 0x8, 0x83, 
+	0x21, 0xda, 0x82, 0x6d, 0x2d, 0xaa, 0xf5, 0x2, 0x33, 0x91, 
+	0x35, 0x61, 0x3a, 0xe8, 0xa4, 0x34, 00, 00, 00, 00, 
+	0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, };
+
+static const char data_contiki_png[] = {
+	/* /contiki.png */
+	0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2e, 0x70, 0x6e, 0x67, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x2f, 0x70, 0x6e, 0x67, 
+	0xd, 0xa, 0xd, 0xa, 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 
+	0x1a, 0xa, 00, 00, 00, 0xd, 0x49, 0x48, 0x44, 0x52, 
+	00, 00, 00, 0x18, 00, 00, 00, 0x18, 0x8, 0x2, 
+	00, 00, 00, 0x6f, 0x15, 0xaa, 0xaf, 00, 00, 00, 
+	0x9, 0x70, 0x48, 0x59, 0x73, 00, 00, 0x1c, 0x1f, 00, 
+	00, 0x1c, 0x1f, 0x1, 0x60, 0xfd, 0x4, 0xda, 00, 00, 
+	00, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xd3, 0x3, 0x9, 
+	0x16, 0x4, 0xd, 0x60, 0xa0, 0x97, 00, 00, 00, 00, 
+	0xad, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0xad, 0x94, 0x41, 
+	0xe, 0xc5, 0x20, 0x8, 0x44, 0x9d, 0x1f, 0xee, 0x7f, 0xe5, 
+	0xf9, 0xb, 0x13, 0x6a, 0x1, 0x29, 0xa5, 0xb2, 0x53, 0xca, 
+	0xf0, 0x9c, 0x40, 0x41, 0x72, 0x1c, 0x89, 0x23, 0x42, 0x24, 
+	0xc5, 0xcb, 0x1, 0x48, 0x1a, 0xf8, 0xec, 0xbc, 0x91, 0xe4, 
+	0xa3, 0x79, 0x34, 0x9d, 0x67, 0xd6, 0xcb, 0x5d, 0x42, 0x3e, 
+	0x97, 0xbc, 0x9a, 0x24, 00, 00, 0xfa, 0x8d, 0x98, 0x74, 
+	0x8, 0x12, 0xa, 0x4d, 0xad, 0x8b, 0x43, 0xcf, 0x3d, 0xd7, 
+	0xb5, 0x36, 0xf0, 0xa8, 0x1e, 0x81, 0x47, 0xf3, 0xaa, 0x1, 
+	0xa5, 0xf, 0xb2, 0x66, 0x37, 0x84, 0x6e, 0x44, 0x3d, 0x9c, 
+	0x35, 0x3a, 0x44, 0x61, 0xcb, 0x26, 0x91, 0xef, 0xfa, 0x82, 
+	0x28, 0x9f, 0xb2, 0x77, 0x44, 0x49, 0xb3, 0xd2, 0x1c, 0x55, 
+	0x26, 0x5e, 0x54, 0x42, 0x17, 0xf2, 0x91, 0x25, 0xdc, 0x6a, 
+	0x49, 0xa, 0x4c, 0x99, 0x3f, 0xae, 0xeb, 0x26, 0xeb, 0xd5, 
+	0xe, 0xaa, 0x32, 0x19, 0xd6, 0x23, 0x6f, 0x47, 0x71, 0x2c, 
+	0x7e, 0xa6, 0x40, 0xb7, 0x59, 0x23, 0xa1, 0xdb, 0x7a, 0xb4, 
+	0xfb, 0xfb, 0x25, 0x5a, 0xb6, 0xf8, 0x63, 0x90, 0xc4, 0x11, 
+	0xa1, 0x31, 0xc6, 0x1f, 0x2c, 0x64, 0x9c, 0x21, 0xc5, 0x1a, 
+	0x66, 0x5d, 00, 00, 00, 00, 0x49, 0x45, 0x4e, 0x44, 
+	0xae, 0x42, 0x60, 0x82, };
+
+static const char data_binaryheader_plain[] = {
+	/* /binaryheader.plain */
+	0x2f, 0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 
+	0x6f, 0x6e, 0x2f, 0x6f, 0x63, 0x74, 0x65, 0x74, 0x2d, 0x73, 
+	0x74, 0x72, 0x65, 0x61, 0x6d, 0xd, 0xa, 0xd, 0xa, };
+
+static const char data_dirheader_html[] = {
+	/* /dirheader.html */
+	0x2f, 0x64, 0x69, 0x72, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e, 0x68, 0x74, 0x6d, 0x6c, 0,
+	0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x30, 0x20, 0x32, 
+	0x30, 0x30, 0x20, 0x4f, 0x4b, 0xd, 0xa, 0x53, 0x65, 0x72, 
+	0x76, 0x65, 0x72, 0x3a, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 
+	0x6b, 0x69, 0x2f, 0x70, 0x72, 0x65, 0x2d, 0x31, 0x2e, 0x31, 
+	0x20, 0x28, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 
+	0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 
+	0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 
+	0x69, 0x6b, 0x69, 0x2f, 0x29, 0xd, 0xa, 0x43, 0x6f, 0x6e, 
+	0x74, 0x65, 0x6e, 0x74, 0x2d, 0x74, 0x79, 0x70, 0x65, 0x3a, 
+	0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 
+	0xd, 0xa, 0xd, 0xa, 0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 
+	0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x3c, 0x74, 0x69, 0x74, 
+	0x6c, 0x65, 0x3e, 0x54, 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 
+	0x74, 0x69, 0x6b, 0x69, 0x20, 0x77, 0x65, 0x62, 0x20, 0x73, 
+	0x65, 0x72, 0x76, 0x65, 0x72, 0x21, 0x3c, 0x2f, 0x74, 0x69, 
+	0x74, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 
+	0x3e, 0xa, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x62, 0x67, 
+	0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3d, 0x22, 0x77, 0x68, 0x69, 
+	0x74, 0x65, 0x22, 0x3e, 0xa, 0x3c, 0x63, 0x65, 0x6e, 0x74, 
+	0x65, 0x72, 0x3e, 0x3c, 0x68, 0x31, 0x3e, 0x46, 0x69, 0x6c, 
+	0x65, 0x73, 0x20, 0x6f, 0x6e, 0x20, 0x64, 0x69, 0x73, 0x6b, 
+	0x3c, 0x2f, 0x68, 0x31, 0x3e, 0xa, 0x3c, 0x74, 0x61, 0x62, 
+	0x6c, 0x65, 0x20, 0x77, 0x69, 0x64, 0x74, 0x68, 0x3d, 0x22, 
+	0x31, 0x30, 0x30, 0x25, 0x22, 0x20, 0x62, 0x6f, 0x72, 0x64, 
+	0x65, 0x72, 0x3d, 0x22, 0x30, 0x22, 0x3e, 0x3c, 0x74, 0x68, 
+	0x3e, 0x46, 0x69, 0x6c, 0x65, 0x3c, 0x2f, 0x74, 0x68, 0x3e, 
+	0x3c, 0x74, 0x68, 0x3e, 0x53, 0x69, 0x7a, 0x65, 0x20, 0x28, 
+	0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x29, 0x3c, 0x2f, 0x74, 
+	0x68, 0x3e, };
+
+static const char data_dirfooter_plain[] = {
+	/* /dirfooter.plain */
+	0x2f, 0x64, 0x69, 0x72, 0x66, 0x6f, 0x6f, 0x74, 0x65, 0x72, 0x2e, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0,
+	0x3c, 0x2f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0x3c, 0x2f, 
+	0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x3e, 0x54, 0x68, 0x65, 
+	0x20, 0x43, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x20, 0x68, 
+	0x6f, 0x6d, 0x65, 0x70, 0x61, 0x67, 0x65, 0x3a, 0x20, 0x3c, 
+	0x61, 0x20, 0x68, 0x72, 0x65, 0x66, 0x3d, 0x22, 0x68, 0x74, 
+	0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 
+	0x6c, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 
+	0x6d, 0x2f, 0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 
+	0x22, 0x3e, 0x3c, 0x74, 0x74, 0x3e, 0x68, 0x74, 0x74, 0x70, 
+	0x3a, 0x2f, 0x2f, 0x64, 0x75, 0x6e, 0x6b, 0x65, 0x6c, 0x73, 
+	0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x64, 0x61, 0x6d, 0x2f, 
+	0x63, 0x6f, 0x6e, 0x74, 0x69, 0x6b, 0x69, 0x2f, 0x3c, 0x2f, 
+	0x74, 0x74, 0x3e, 0x3c, 0x2f, 0x61, 0x3e, 0x2e, 0x3c, 0x2f, 
+	0x62, 0x6f, 0x64, 0x79, 0x3e, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 
+	0x6c, 0x3e, };
+
+const struct httpd_fsdata_file file_cgi_processes[] = {{NULL, data_cgi_processes, data_cgi_processes + 15, sizeof(data_cgi_processes) - 15}};
+
+const struct httpd_fsdata_file file_cgi_tcp[] = {{file_cgi_processes, data_cgi_tcp, data_cgi_tcp + 9, sizeof(data_cgi_tcp) - 9}};
+
+const struct httpd_fsdata_file file_cgi_d64[] = {{file_cgi_tcp, data_cgi_d64, data_cgi_d64 + 9, sizeof(data_cgi_d64) - 9}};
+
+const struct httpd_fsdata_file file_index_html[] = {{file_cgi_d64, data_index_html, data_index_html + 12, sizeof(data_index_html) - 12}};
+
+const struct httpd_fsdata_file file_404_html[] = {{file_index_html, data_404_html, data_404_html + 10, sizeof(data_404_html) - 10}};
+
+const struct httpd_fsdata_file file_header_html[] = {{file_404_html, data_header_html, data_header_html + 13, sizeof(data_header_html) - 13}};
+
+const struct httpd_fsdata_file file_footer_plain[] = {{file_header_html, data_footer_plain, data_footer_plain + 14, sizeof(data_footer_plain) - 14}};
+
+const struct httpd_fsdata_file file_webserver_png[] = {{file_footer_plain, data_webserver_png, data_webserver_png + 15, sizeof(data_webserver_png) - 15}};
+
+const struct httpd_fsdata_file file_contiki_png[] = {{file_webserver_png, data_contiki_png, data_contiki_png + 13, sizeof(data_contiki_png) - 13}};
+
+const struct httpd_fsdata_file file_binaryheader_plain[] = {{file_contiki_png, data_binaryheader_plain, data_binaryheader_plain + 20, sizeof(data_binaryheader_plain) - 20}};
+
+const struct httpd_fsdata_file file_dirheader_html[] = {{file_binaryheader_plain, data_dirheader_html, data_dirheader_html + 16, sizeof(data_dirheader_html) - 16}};
+
+const struct httpd_fsdata_file file_dirfooter_plain[] = {{file_dirheader_html, data_dirfooter_plain, data_dirfooter_plain + 17, sizeof(data_dirfooter_plain) - 17}};
+
+#define HTTPD_FS_ROOT file_dirfooter_plain
+
+#define HTTPD_FS_NUMFILES 12
\ No newline at end of file
diff --git a/contiki-cpc/apps/httpd.c b/contiki-cpc/apps/httpd.c
new file mode 100644
index 0000000..9726200
--- /dev/null
+++ b/contiki-cpc/apps/httpd.c
@@ -0,0 +1,411 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd.c,v 1.1 2006/04/17 15:18:18 kthacker Exp $
+ *
+ */
+
+
+#include "uip.h"
+
+#include "http-strings.h"
+
+#include "httpd.h"
+#include "httpd-fs.h"
+#include "httpd-fsdata.h"
+#include "httpd-cgi.h"
+
+#include "tcpip.h"
+
+#include <stdio.h>
+
+/* The HTTP server states: */
+#define STATE_DEALLOCATED       0
+#define STATE_INITIAL           1
+#define STATE_GET               2
+#define STATE_HEADERS           3
+#define STATE_SEND_HEADERS      4
+#define STATE_SEND_CONTENT_TYPE 5
+#define STATE_SEND_DATA         6
+
+#define ISO_nl                  0x0a
+#define ISO_space               0x20
+#define ISO_slash               0x2f
+
+#ifdef DEBUG
+#include <stdio.h>
+#define PRINT(x) printf("%s", x)
+#define PRINTLN(x) printf("%s\n", x)
+#else /* DEBUG */
+#define PRINT(x)
+#define PRINTLN(x)
+#endif /* DEBUG */
+
+
+#define HTTPD_CONF_NUMCONNS 4
+static struct httpd_state conns[HTTPD_CONF_NUMCONNS];
+u8_t i;
+
+struct http_filetype {
+  const char *ext;
+  unsigned char extlen;
+  const char *type;
+  unsigned char typelen;
+};
+
+static struct http_filetype filetypes[] = {
+  {http_html, sizeof(http_html) - 1,
+   http_content_type_html, sizeof(http_content_type_html) - 1},
+  {http_htm, sizeof(http_htm) - 1,
+   http_content_type_html, sizeof(http_content_type_html) - 1},
+  {http_css, sizeof(http_css) - 1,
+   http_content_type_css, sizeof(http_content_type_css) - 1},
+  {http_png, sizeof(http_png) - 1,
+   http_content_type_png, sizeof(http_content_type_png) - 1},
+  {http_gif, sizeof(http_gif) - 1,
+   http_content_type_gif, sizeof(http_content_type_gif) - 1},
+  {http_jpg, sizeof(http_jpg) - 1,
+   http_content_type_jpg, sizeof(http_content_type_jpg) - 1},
+  {http_txt, sizeof(http_txt) - 1,
+   http_content_type_text, sizeof(http_content_type_text) - 1},
+  {http_text, sizeof(http_text) - 1,
+   http_content_type_text, sizeof(http_content_type_text) - 1},  
+  {NULL, 0, NULL, 0}
+};
+#define NUMFILETYPES (sizeof(filetypes) / sizeof(struct http_filetype))
+/*-----------------------------------------------------------------------------*/
+static struct httpd_state *
+alloc_state(void)
+{
+  
+  for(i = 0; i < HTTPD_CONF_NUMCONNS; ++i) {
+    if(conns[i].state == STATE_DEALLOCATED) {
+      return &conns[i];
+    }
+  }
+
+  /* We are overloaded! XXX: we'll just kick all other connections! */
+  for(i = 0; i < HTTPD_CONF_NUMCONNS; ++i) {
+    conns[i].state = STATE_DEALLOCATED;
+  }
+  
+  return NULL;
+}
+/*-----------------------------------------------------------------------------*/
+static void
+dealloc_state(struct httpd_state *s)
+{
+  s->state = STATE_DEALLOCATED;
+}
+/*-----------------------------------------------------------------------------*/
+void
+httpd_init(void)
+{
+  httpd_fs_init();
+  
+  /* Listen to port 80. */
+  tcp_listen(HTONS(80));
+
+  for(i = 0; i < HTTPD_CONF_NUMCONNS; ++i) {
+    conns[i].state = STATE_DEALLOCATED;
+  }
+}
+/*-----------------------------------------------------------------------------*/
+/**
+ * \internal
+ * Buffer an amount of data from the incoming uIP data.
+ *
+ * \param buf A pointer to the buffer.
+ * \param len The length of data to buffer.
+ *
+ * \return Zero if the function wasn't able to buffer to buffer all
+ * data, non-zero otherwise.
+ */
+/*-----------------------------------------------------------------------------*/
+static unsigned char
+buffer(CC_REGISTER_ARG struct httpd_buffer *buf, int len, u8_t c)
+{
+  while(buf->ptr < len &&
+	uip_len > 0) {
+    buf->buf[buf->ptr] = *uip_appdata;
+    ++uip_appdata;
+    --uip_len;
+
+    if(buf->buf[buf->ptr] == c) {
+      return 1;
+    }
+    ++buf->ptr;
+  }
+  return (buf->ptr == len);
+}
+/*-----------------------------------------------------------------------------*/
+static void
+buffer_reset(struct httpd_buffer *buf)
+{
+  buf->ptr = 0;
+}
+/*-----------------------------------------------------------------------------*/
+static void
+newdata(CC_REGISTER_ARG struct httpd_state *hs)
+{
+  int i;
+  struct http_filetype *filetype;
+    
+  while(uip_len > 0) {
+    switch(hs->state) {
+      
+    case STATE_INITIAL:
+      /* This is the first data that we receive, so we check if we can
+	 identify the "GET" request. We call the buffer() function to
+	 try to buffer 4 bytes of data from the incoming data stream. If
+	 the function isn't able to buffer enough data, we return and
+	 will try again next time around. */
+      hs->buf.buf = hs->getbuffer;
+      if(buffer(&(hs->buf), 4, ISO_space)) {
+	if(strncmp(http_get, hs->buf.buf, 4) == 0) {
+	  hs->state = STATE_GET;
+	  buffer_reset(&(hs->buf));
+	} else {
+	  uip_abort();
+	  return;
+	}
+      }
+      break;
+    
+    case STATE_GET:
+      /* We will read one byte at a time from the GET request until we
+	 find a en end of the line (\n\r). The GET request is remembered
+	 in the httpd state since we might need to look at it later. */
+      hs->buf.buf = hs->getbuffer;
+      if(buffer(&(hs->buf), sizeof(hs->getbuffer), ISO_nl)) {
+	hs->state = STATE_HEADERS;
+	hs->getlen = hs->buf.ptr - 1;
+	/* Null-terminate GET request string. */
+	hs->getbuffer[hs->getlen] = 0;
+
+	/* If there is a space character in the get request, we find
+	   it and null terminate the string there. */
+	for(i = 0; i < hs->getlen; ++i) {
+	  if(hs->getbuffer[i] == ISO_space) {
+	    hs->getbuffer[i] = 0;
+	    hs->getlen = i;
+	    break;
+	  }
+	}
+	buffer_reset(&(hs->buf));	
+      }
+      break;
+
+    case STATE_HEADERS:
+      hs->buf.buf = hs->hdrbuffer;
+      if(buffer(&(hs->buf), sizeof(hs->hdrbuffer), '\n')) {
+	if(hs->buf.ptr == 1) {
+	  hs->state = STATE_SEND_HEADERS;
+	  if(httpd_fs_open(hs->getbuffer, &hs->file)) {
+	    hs->count = sizeof(http_header_200) - 1;
+	    hs->dataptr = (char *)http_header_200;
+	    hs->contenttype = http_content_type_binary;
+	    hs->contentlen = sizeof(http_content_type_binary) - 1;
+	    for(filetype = filetypes;
+		filetype->ext != NULL;
+		++filetype) {
+	      if(strncmp(filetype->ext,
+			 hs->getbuffer + (hs->getlen - filetype->extlen),
+			 filetype->extlen) == 0) {
+		hs->contenttype = filetype->type;
+		hs->contentlen = filetype->typelen;
+		break;
+	      }
+	    }
+
+	  } else if(hs->getbuffer[0] == ISO_slash &&
+	      hs->getbuffer[1] == 0) {
+	    hs->count = sizeof(http_header_200) - 1;
+	    hs->dataptr = (char *)http_header_200;
+	    hs->contenttype = http_content_type_html;
+	    hs->contentlen = sizeof(http_content_type_html) - 1;
+	    httpd_fs_open(http_index_html, &hs->file);
+	  } else {
+	    hs->count = sizeof(http_header_404) - 1;
+	    hs->dataptr = (char *)http_header_404;
+	    hs->contenttype = http_content_type_html;
+	    hs->contentlen = sizeof(http_content_type_html) - 1;
+	    httpd_fs_open(http_404_html, &hs->file);
+	  }
+	} else {
+	  buffer_reset(&(hs->buf));
+	}
+      }
+      break;
+
+    default:
+      uip_len = 0;
+      break;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------*/
+static void
+acked(CC_REGISTER_ARG struct httpd_state *hs)
+{
+  hs->poll = 0;
+
+  
+  switch(hs->state) {
+
+  case STATE_SEND_HEADERS:
+    if(hs->count >= uip_mss()) {
+      hs->count -= uip_mss();
+      hs->dataptr += uip_mss();
+    } else {
+      hs->count = 0;
+    }	
+    if(hs->count == 0) {
+      hs->state = STATE_SEND_CONTENT_TYPE;
+      hs->count = hs->contentlen;
+      hs->dataptr = (char *)hs->contenttype;
+    }
+    break;
+    
+  case STATE_SEND_CONTENT_TYPE:
+    if(hs->count >= uip_mss()) {
+      hs->count -= uip_mss();
+      hs->dataptr += uip_mss();
+    } else {
+      hs->count = 0;
+    }	
+    if(hs->count == 0) {
+      hs->state = STATE_SEND_DATA;
+      hs->count = hs->file.len;
+      hs->dataptr = hs->file.data;
+    }
+    break;
+    
+  case STATE_SEND_DATA:
+    if(hs->count >= uip_mss()) {
+      hs->count -= uip_mss();
+      hs->dataptr += uip_mss();
+    } else {
+      hs->count = 0;
+    }	
+    if(hs->count == 0) {
+      uip_close();
+      dealloc_state(hs);
+    }
+    break;
+  }
+}
+/*-----------------------------------------------------------------------------*/
+static void
+senddata(CC_REGISTER_ARG struct httpd_state *hs)
+{
+  if(hs->state == STATE_SEND_HEADERS ||
+     hs->state == STATE_SEND_CONTENT_TYPE ||
+     hs->state == STATE_SEND_DATA) {
+    uip_send(hs->dataptr,
+	     hs->count > uip_mss()? uip_mss(): hs->count);
+  }
+}
+/*-----------------------------------------------------------------------------*/
+void
+httpd_appcall(void *state)
+{
+  register struct httpd_state *hs;
+
+  hs = (struct httpd_state *)(state);
+
+
+  if(uip_connected()) {
+    /* Since we've just been connected, the state pointer should be
+       NULL and we need to allocate a new state object. If we have run
+       out of memory for state objects, we'll have to abort the
+       connection and return. */
+    if(hs == NULL) {
+      hs = alloc_state();
+      if(hs == NULL) {
+	uip_close();
+	return;
+      }
+      tcp_markconn(uip_conn, (void *)hs);
+    }
+    /* Since we have just been connected with the remote host, we
+       reset the state for this connection. The ->count variable
+       contains the amount of data that is yet to be sent to the
+       remote host, and the ->state is set to HTTP_NOGET to signal
+       that we haven't received any HTTP GET request for this
+       connection yet. */
+    hs->state = STATE_INITIAL;
+    hs->count = 0;
+    hs->poll = 0;
+    buffer_reset(&(hs->buf));
+    return;
+  }
+
+  if(uip_closed() ||
+     uip_aborted() ||
+     uip_timedout()) {
+    if(hs != NULL) {
+      dealloc_state(hs);
+    }
+    return;
+  } else if(uip_poll()) {
+    /* If we are polled ten times, we abort the connection. This is
+       because we don't want connections lingering indefinately in
+       the system. */
+    if(hs != NULL) {
+      if(hs->state == STATE_DEALLOCATED) {
+	uip_abort();
+      } else if(hs->poll++ >= 100) {
+	uip_abort();
+	dealloc_state(hs);
+      }
+    }
+    return;
+  }
+  
+  if(uip_acked()) {
+    acked(hs);
+  }
+  
+  if(uip_newdata()) {
+    newdata(hs);
+  }
+  
+  if(uip_rexmit() ||
+     uip_newdata() ||
+     uip_acked()) {
+    senddata(hs);
+  } else if(uip_poll()) {    
+    senddata(hs);
+  }
+
+
+}
+/*-----------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/httpd.h b/contiki-cpc/apps/httpd.h
new file mode 100644
index 0000000..08abced
--- /dev/null
+++ b/contiki-cpc/apps/httpd.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2001, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the uIP TCP/IP stack.
+ *
+ * $Id: httpd.h,v 1.1 2006/04/17 15:18:18 kthacker Exp $
+ *
+ */
+
+#ifndef __HTTPD_H__
+#define __HTTPD_H__
+
+#include "ek.h"
+
+#include "httpd-fs.h"
+
+void httpd_init(void);
+/*DISPATCHER_UIPCALL(httpd_appcall, state);*/
+void httpd_appcall(void *state);
+
+struct httpd_buffer {
+  u8_t *buf;
+  int ptr;
+};
+
+struct httpd_state {
+  u8_t state; 
+  u16_t count;
+  u8_t poll;
+  char *dataptr;
+  struct httpd_fs_file file;
+
+  const char *contenttype;
+  int contentlen;
+  
+  char *script;
+
+  struct httpd_buffer buf;
+
+  int getlen;
+  u8_t getbuffer[100];
+  u8_t hdrbuffer[100];
+  
+  /*
+  union {
+    struct c64_fs_dir d;
+    struct c64_fs_file f;
+    } f;*/
+};
+
+extern struct httpd_state *hs;
+
+void webserver_log_file(u16_t *requester, char *file);
+
+#endif /* __HTTPD_H__ */
diff --git a/contiki-cpc/apps/makefsdata b/contiki-cpc/apps/makefsdata
new file mode 100644
index 0000000..83bbc5b
--- /dev/null
+++ b/contiki-cpc/apps/makefsdata
@@ -0,0 +1,92 @@
+#!/usr/bin/perl
+
+open(OUTPUT, "> httpd-fsdata.c");
+
+chdir("httpd-fs");
+open(FILES, "find . -type f |");
+
+
+while($file = <FILES>) {
+
+    # Do not include files in CVS directories nor backup files.
+    if($file =~ /(CVS|~)/) {
+    	next;
+    }
+    
+    chop($file);
+    
+    open(HEADER, "> /tmp/header") || die $!;
+    print(HEADER "HTTP/1.0 200 OK\r\n");
+    print(HEADER "Server: Contiki/pre-1.1 (http://dunkels.com/adam/contiki/)\r\n");
+    if($file =~ /\.html$/) {
+	print(HEADER "Content-type: text/html\r\n");
+    } elsif($file =~ /\.gif$/) {
+	print(HEADER "Content-type: image/gif\r\n");
+    } elsif($file =~ /\.png$/) {
+	print(HEADER "Content-type: image/png\r\n");
+    } elsif($file =~ /\.jpg$/) {
+	print(HEADER "Content-type: image/jpeg\r\n");
+    } elsif($file =~ /\.css$/) {
+	print(HEADER "Content-type: text/css\r\n");
+    } else {
+	print(HEADER "Content-type: text/plain\r\n");
+    }
+    print(HEADER "\r\n");
+    close(HEADER);
+
+    unless($file =~ /\.plain$/ || $file =~ /cgi/) {
+	system("cat /tmp/header $file > /tmp/file");
+    } else {
+	system("cp $file /tmp/file");
+    }
+    
+    open(FILE, "/tmp/file");
+    unlink("/tmp/file");
+    unlink("/tmp/header");
+
+    $file =~ s/\.//;
+    $fvar = $file;
+    $fvar =~ s-/-_-g;
+    $fvar =~ s-\.-_-g;
+    print(OUTPUT "static const char data".$fvar."[] = {\n");
+    print(OUTPUT "\t/* $file */\n\t");
+    for($j = 0; $j < length($file); $j++) {
+	printf(OUTPUT "%#02x, ", unpack("C", substr($file, $j, 1)));
+    }
+    printf(OUTPUT "0,\n");
+    
+    
+    $i = 0;        
+    while(read(FILE, $data, 1)) {
+        if($i == 0) {
+            print(OUTPUT "\t");
+        }
+        printf(OUTPUT "%#02x, ", unpack("C", $data));
+        $i++;
+        if($i == 10) {
+            print(OUTPUT "\n");
+            $i = 0;
+        }
+    }
+    print(OUTPUT "};\n\n");
+    close(FILE);
+    push(@fvars, $fvar);
+    push(@files, $file);
+}
+
+for($i = 0; $i < @fvars; $i++) {
+    $file = $files[$i];
+    $fvar = $fvars[$i];
+
+    if($i == 0) {
+        $prevfile = "NULL";
+    } else {
+        $prevfile = "file" . $fvars[$i - 1];
+    }
+    print(OUTPUT "const struct httpd_fsdata_file file".$fvar."[] = {{$prevfile, data$fvar, ");
+    print(OUTPUT "data$fvar + ". (length($file) + 1) .", ");
+    print(OUTPUT "sizeof(data$fvar) - ". (length($file) + 1) ."}};\n\n");
+}
+
+print(OUTPUT "#define HTTPD_FS_ROOT file$fvars[$i - 1]\n\n");
+print(OUTPUT "#define HTTPD_FS_NUMFILES $i");
diff --git a/contiki-cpc/apps/makestrings b/contiki-cpc/apps/makestrings
new file mode 100644
index 0000000..e6e8470
--- /dev/null
+++ b/contiki-cpc/apps/makestrings
@@ -0,0 +1,39 @@
+#!/usr/bin/perl
+
+
+sub stringify {
+  my $name = shift(@_);
+  open(OUTPUTC, "> $name.c");
+  open(OUTPUTH, "> $name.h");
+  
+  open(FILE, "$name");
+  
+  while(<FILE>) {
+    if(/(.+) "(.+)"/) {
+      $var = $1;
+      $data = $2;
+      
+      $datan = $data;
+      $datan =~ s/\\r/\r/g;
+      $datan =~ s/\\n/\n/g;
+      $datan =~ s/\\0/\0/g;
+      
+      printf(OUTPUTC "char $var\[%d] = \n", length($datan) + 1);
+      printf(OUTPUTC "/* \"$data\" */\n");
+      printf(OUTPUTC "{");
+      for($j = 0; $j < length($datan); $j++) {
+	printf(OUTPUTC "%#02x, ", unpack("C", substr($datan, $j, 1)));
+      }
+      printf(OUTPUTC "};\n");
+      
+      printf(OUTPUTH "extern char $var\[%d];\n", length($datan) + 1);
+      
+    }
+  }
+  close(OUTPUTC);
+  close(OUTPUTH);
+}
+stringify("http-user-agent-string");
+
+exit 0;
+
diff --git a/contiki-cpc/apps/memstat-dsc.c b/contiki-cpc/apps/memstat-dsc.c
new file mode 100644
index 0000000..be3e3bf
--- /dev/null
+++ b/contiki-cpc/apps/memstat-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: memstat-dsc.c,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern const struct ctk_icon memstat_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(memstat_dsc,
+    "Memory statistics",
+    "memstat.prg",
+    memstat_init,
+    &memstat_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static const unsigned char memstaticon_bitmap[3*3*8] = {
+  0x00, 0x7f, 0x43, 0x4c, 0x58, 0x53, 0x60, 0x6f,
+  0x00, 0xff, 0x00, 0x7e, 0x00, 0xff, 0x00, 0xff,
+  0x00, 0xfe, 0xc2, 0x32, 0x1a, 0xca, 0x06, 0xf6,
+
+  0x40, 0x5f, 0x40, 0x5f, 0x40, 0x5f, 0x40, 0x4f,
+  0x00, 0xff, 0x00, 0xff, 0x00, 0xfc, 0x01, 0xf3,
+  0x02, 0xfa, 0x02, 0x82, 0x3e, 0xfe, 0xfe, 0xfe,
+
+  0x60, 0x67, 0x50, 0x59, 0x4c, 0x43, 0x7f, 0x00,
+  0x07, 0xe7, 0x0f, 0xef, 0x0f, 0x0f, 0xff, 0x00,
+  0x8e, 0x06, 0x06, 0x06, 0x8e, 0xfe, 0xfe, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static const char memstaticon_textmap[9] = {
+  '0', '0', '1',
+  '0', '1', '0',
+  '1', '0', '1'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+const struct ctk_icon memstat_icon =
+  {CTK_ICON("Memory stats", memstaticon_bitmap, memstaticon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/memstat-dsc.h b/contiki-cpc/apps/memstat-dsc.h
new file mode 100644
index 0000000..356c6cc
--- /dev/null
+++ b/contiki-cpc/apps/memstat-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: memstat-dsc.h,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ *
+ */
+#ifndef __MEMSTAT_DSC_H__
+#define __MEMSTAT_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(memstat_dsc);
+
+#endif /* __MEMSTAT_DSC_H__ */
diff --git a/contiki-cpc/apps/memstat.c b/contiki-cpc/apps/memstat.c
new file mode 100644
index 0000000..0b8f8b0
--- /dev/null
+++ b/contiki-cpc/apps/memstat.c
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: memstat.c,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ *
+ */
+
+#include <stdlib.h>
+
+#include "ctk.h"
+#include "ek.h"
+#include "loader.h"
+
+static struct ctk_window window;
+static struct ctk_label freemsg =
+  {CTK_LABEL(2, 0, 12, 1, "Free memory:")};
+static char freemem[6];
+static struct ctk_label freenum =
+  {CTK_LABEL(18, 0, 5, 1, freemem)};
+
+static struct ctk_label lblockmsg =
+  {CTK_LABEL(2, 2, 14, 1, "Largest block:")};
+static char lblock[6];
+static struct ctk_label lblocknum =
+  {CTK_LABEL(18, 2, 5, 1, lblock)};
+
+const static struct ctk_button updatebutton =
+  {CTK_BUTTON(0, 4, 6, "Update")};
+const static struct ctk_button closebutton =
+  {CTK_BUTTON(17, 4, 5, "Close")};
+
+/*static DISPATCHER_SIGHANDLER(memstat_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Memory statistics", NULL, memstat_sighandler, NULL)};
+  static ek_id_t id;*/
+EK_EVENTHANDLER(memstat_eventhandler, ev, data);
+EK_PROCESS(p, "Memory statistics", EK_PRIO_NORMAL,
+	   memstat_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+static void
+update(void)
+{
+  int mem;
+
+  mem = _heapmemavail();
+  freemem[0] = (mem/10000) % 10 + '0';
+  freemem[1] = (mem/1000) % 10 + '0';
+  freemem[2] = (mem/100) % 10 + '0';
+  freemem[3] = (mem/10) % 10 + '0';
+  freemem[4] = (mem) % 10 + '0';
+
+  mem = _heapmaxavail();
+  lblock[0] = (mem/10000) % 10 + '0';
+  lblock[1] = (mem/1000) % 10 + '0';
+  lblock[2] = (mem/100) % 10 + '0';
+  lblock[3] = (mem/10) % 10 + '0';
+  lblock[4] = (mem) % 10 + '0';
+
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(memstat_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+    
+  } else {
+    ctk_window_open(&window);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+quit(void)
+{
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(memstat_eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    ctk_window_new(&window, 24, 5, "Memory stats");
+    /*    ctk_window_move(&window, 0, 1);*/
+
+    CTK_WIDGET_ADD(&window, &freemsg);
+    CTK_WIDGET_ADD(&window, &freenum);
+
+    CTK_WIDGET_ADD(&window, &lblockmsg);
+    CTK_WIDGET_ADD(&window, &lblocknum);
+
+    CTK_WIDGET_ADD(&window, &updatebutton);
+    CTK_WIDGET_ADD(&window, &closebutton);
+
+    CTK_WIDGET_FOCUS(&window, &updatebutton);
+    
+    update();
+    
+    ctk_window_open(&window);
+    
+  } else if(ev == ctk_signal_button_activate) {
+    if(data == (ek_data_t)&updatebutton) {
+      update();
+      ctk_window_redraw(&window);
+    } else if(data == (ek_data_t)&closebutton) {
+      ctk_window_close(&window);
+      quit();
+    }
+  } else if((ev == ctk_signal_window_close &&
+	    data == (ek_data_t)&window) ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/mtest.c b/contiki-cpc/apps/mtest.c
new file mode 100644
index 0000000..173092c
--- /dev/null
+++ b/contiki-cpc/apps/mtest.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. Neither the name of the Institute nor the names of its contributors 
+ *    may be used to endorse or promote products derived from this software 
+ *    without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
+ * SUCH DAMAGE. 
+ *
+ * This file is part of the Contiki operating system.
+ * 
+ * Author: Adam Dunkels <adam@sics.se>
+ *
+ * $Id: mtest.c,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ */
+#include "mt.h"
+
+MTP(t, p, "Test thread");
+/*--------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+static void
+test(void *data)
+{
+  while(1) {
+    asm("inc $d020");
+  }
+}
+#pragma optimize(pop)
+/*--------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(mtest_init, arg)
+{
+  arg_free(arg);
+  mtp_start(&t, test, NULL);
+}
+/*--------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/plasma-dsc.c b/contiki-cpc/apps/plasma-dsc.c
new file mode 100644
index 0000000..945215b
--- /dev/null
+++ b/contiki-cpc/apps/plasma-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: plasma-dsc.c,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon plasma_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(plasma_dsc,
+    "Screensaver with a plasma",
+    "plasma.sav",
+    plasma_init,
+    &plasma_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char plasmaicon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char plasmaicon_textmap[9] = {
+  '.', ' ', '.',
+  'o', ' ', 'o',
+  'O', ' ', 'O'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon plasma_icon =
+  {CTK_ICON("Plasma", plasmaicon_bitmap, plasmaicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/plasma.c b/contiki-cpc/apps/plasma.c
new file mode 100644
index 0000000..d4bc8f6
--- /dev/null
+++ b/contiki-cpc/apps/plasma.c
@@ -0,0 +1,254 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: plasma.c,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ *
+ */
+
+#include <stdlib.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-mouse.h"
+#include "ek.h"
+#include "loader.h"
+
+static unsigned char sinetab1[256] = {
+  128, 131, 134, 137, 140, 143, 146, 149, 
+  152, 156, 159, 162, 165, 168, 171, 174, 
+  176, 179, 182, 185, 188, 191, 193, 196, 
+  199, 201, 204, 206, 209, 211, 213, 216, 
+  218, 220, 222, 224, 226, 228, 230, 232, 
+  234, 236, 237, 239, 240, 242, 243, 245, 
+  246, 247, 248, 249, 250, 251, 252, 252, 
+  253, 254, 254, 255, 255, 255, 255, 255, 
+  255, 255, 255, 255, 255, 255, 254, 254, 
+  253, 252, 252, 251, 250, 249, 248, 247, 
+  246, 245, 243, 242, 240, 239, 237, 236, 
+  234, 232, 230, 228, 226, 224, 222, 220, 
+  218, 216, 213, 211, 209, 206, 204, 201, 
+  199, 196, 193, 191, 188, 185, 182, 179, 
+  176, 174, 171, 168, 165, 162, 159, 156, 
+  152, 149, 146, 143, 140, 137, 134, 131, 
+  128, 124, 121, 118, 115, 112, 109, 106, 
+  103, 99, 96, 93, 90, 87, 84, 81, 
+  79, 76, 73, 70, 67, 64, 62, 59, 
+  56, 54, 51, 49, 46, 44, 42, 39, 
+  37, 35, 33, 31, 29, 27, 25, 23, 
+  21, 19, 18, 16, 15, 13, 12, 10, 
+  9, 8, 7, 6, 5, 4, 3, 3, 
+  2, 1, 1, 0, 0, 0, 0, 0, 
+  0, 0, 0, 0, 0, 0, 1, 1, 
+  2, 3, 3, 4, 5, 6, 7, 8, 
+  9, 10, 12, 13, 15, 16, 18, 19, 
+  21, 23, 25, 27, 29, 31, 33, 35, 
+  37, 39, 42, 44, 46, 49, 51, 54, 
+  56, 59, 62, 64, 67, 70, 73, 76, 
+  78, 81, 84, 87, 90, 93, 96, 99, 
+  103, 106, 109, 112, 115, 118, 121, 124,
+};
+
+static unsigned char sinetab2[256];
+static unsigned char sinetab3[256];
+
+static unsigned char colortab[256];
+
+static unsigned char colors[16] =
+  {
+    0x00, 0x06, 0x0b, 0x04,
+    0x0a, 0x0f, 0x07, 0x01,
+    0x07, 0x0f, 0x0a, 0x08,
+    0x02, 0x09, 0x00, 0x00,
+  };
+
+#define XSIZE 24
+#define YSIZE 25
+
+static unsigned char xplasma[XSIZE], yplasma[YSIZE];
+static unsigned char xcnt, ycnt;
+static unsigned char xcnt01, xcnt02, xcnt1, xcnt2;
+static unsigned char ycnt01, ycnt02, ycnt1, ycnt2;
+
+static unsigned char xadd01 = 0xfe;
+static unsigned char yadd01 = 0x05;
+static unsigned char xadd02 = 0x01;
+static unsigned char yadd02 = 0xfb;
+
+static unsigned char xadd1 = 0x04;
+static unsigned char yadd1 = 0x02;
+static unsigned char xadd2 = 0xfc;
+static unsigned char yadd2 = 0xf9;
+
+static unsigned char xadd = 0x03;
+static unsigned char yadd = 0xfe;
+
+static unsigned char movcnt;
+static unsigned char movadd = 0xfb;
+
+/*static DISPATCHER_SIGHANDLER(sighandler, s, data);
+static void idle(void);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Plasma screensaver", idle,
+		   sighandler,
+		   NULL)};
+		   static ek_id_t id;*/
+EK_EVENTHANDLER(eventhandler, ev, data);
+EK_POLLHANDLER(pollhandler);
+EK_PROCESS(p, "Plasma screensaver", EK_PRIO_LOWEST,
+	   eventhandler, pollhandler, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+static void
+quit(void)
+{
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+scrninit(void)
+{
+  unsigned char *ptr, *cptr;
+  static int i;
+  
+  /* Make sine tables */
+  for(i = 0; i < 256; ++i) {
+    sinetab2[(unsigned char)i] = sinetab1[(unsigned char)i] / 2;
+    sinetab3[(unsigned char)i] = sinetab1[(unsigned char)i] / 4;    
+  }
+    
+  /* Make color table */
+  for(i = 0; i < 256; ++i) {
+    colortab[(unsigned char)i] = colors[(unsigned char)i / 16];
+  }
+    
+  
+  /* Fill screen with inverted spaces. */
+  cptr = COLOR_RAM;
+  for(ptr = (unsigned char *)0x0400;
+      ptr != (unsigned char *)0x07e8;
+      ++ptr) {
+    *ptr = 0xa0;
+    *cptr++ = 0x00;
+  }
+  
+  VIC.ctrl1 = 0x1b;  /* $D011 */
+  VIC.addr  = 0x17;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  VIC.bordercolor = 0x00; /* $D020 */
+  VIC.bgcolor0 = 0x00; /* $D021 */  
+  CIA2.pra  = 0x03;  /* $DD00 */
+
+}
+/*-----------------------------------------------------------------------------------*/
+EK_POLLHANDLER(pollhandler)
+{
+  static unsigned char i, x, y;
+  register unsigned char *cptr;
+  
+  if(ctk_mode_get() == CTK_MODE_SCREENSAVER) {
+
+
+    xcnt1 = xcnt01;
+    xcnt2 = xcnt02;
+    
+    for(i = 0; i < XSIZE; ++i) {
+      xplasma[i] = sinetab1[xcnt1] + sinetab2[xcnt2];
+      xcnt1 += xadd1;
+      xcnt2 += xadd2;
+    }
+
+    ycnt1 = ycnt01;
+    ycnt2 = ycnt02;
+    
+    for(i = 0; i < YSIZE; ++i) {
+      yplasma[i] = sinetab1[ycnt1] + sinetab3[ycnt2];
+      ycnt1 += yadd1;
+      ycnt2 += yadd2;
+    }
+
+    xcnt01 += xadd01;
+    xcnt02 += xadd02;
+    ycnt01 += yadd01;
+    ycnt02 += yadd02;
+
+    
+    yadd02 = sinetab3[ycnt] / 4;
+    xadd02 = sinetab3[xcnt] / 4;
+
+    ycnt += yadd;
+    xcnt += xadd;
+
+    movcnt += movadd;
+    cptr = (unsigned char *)(0xd800 + sinetab1[movcnt]/16);
+    for(y = 0; y < YSIZE; ++y) {
+      for(x = 0; x < XSIZE; ++x) {
+	*cptr = colortab[(xplasma[x] + yplasma[y]) & 0xff];
+	++cptr;
+      }
+      cptr += 40 - XSIZE;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/*static
+  DISPATCHER_SIGHANDLER(sighandler, s, data)*/
+EK_EVENTHANDLER(eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    ctk_mode_set(CTK_MODE_SCREENSAVER);
+    ctk_mouse_hide();
+   
+    scrninit();
+
+  } else if(ev == ctk_signal_screensaver_stop ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    ctk_draw_init();
+    ctk_desktop_redraw(NULL);
+    /*    ctk_mode_set(CTK_MODE_NORMAL);*/
+    quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(plasma_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+ 
diff --git a/contiki-cpc/apps/ravenpine-dsc.c b/contiki-cpc/apps/ravenpine-dsc.c
new file mode 100644
index 0000000..cd2cea8
--- /dev/null
+++ b/contiki-cpc/apps/ravenpine-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ravenpine-dsc.c,v 1.1 2006/04/17 15:18:19 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon ravenpine_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(ravenpine_dsc,
+    "Terminal green CTK theme",
+    "ravenpine.prg",
+    ravenpine_init,
+    &ravenpine_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char ravenpineicon_bitmap[3*3*8] = {
+  0x00,0x3f,0x6a,0x40,0x60,0x40,0x60,0x40,
+  0x00,0xff,0xaa,0x00,0x00,0x00,0x00,0x00,
+  0x00,0xf0,0x20,0x00,0x00,0x00,0x00,0x00,
+
+  0x60,0x40,0x60,0x40,0x60,0x40,0x60,0x40,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+
+  0x60,0x40,0x40,0x40,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,
+  0x02,0x02,0x02,0x02,0x02,0x06,0xfc,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char ravenpineicon_textmap[9] = {
+  '(', '=', ')',
+  '|', 'o', '|',
+  '(', '-', ')'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon ravenpine_icon =
+  {CTK_ICON("Ravenpine", ravenpineicon_bitmap, ravenpineicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/shell.c b/contiki-cpc/apps/shell.c
new file mode 100644
index 0000000..1575708
--- /dev/null
+++ b/contiki-cpc/apps/shell.c
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above copyright 
+ *    notice, this list of conditions and the following disclaimer in the 
+ *    documentation and/or other materials provided with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop OS.
+ *
+ * $Id: shell.c,v 1.1 2006/04/17 15:18:20 kthacker Exp $
+ *
+ */
+
+#include "program-handler.h"
+#include "loader.h"
+#include "cfs.h"
+#include "uip.h"
+#include "uip_arp.h"
+#include "resolv.h"
+
+#include "shell.h"
+
+#include <string.h>
+
+static char showingdir = 0;
+static struct cfs_dir dir;
+static unsigned int totsize;
+
+struct ptentry {
+  char c;
+  void (* pfunc)(char *str);
+};
+
+/*-----------------------------------------------------------------------------------*/
+static void
+parse(CC_REGISTER_ARG char *str, struct ptentry *t)
+{
+  CC_REGISTER_ARG struct ptentry *p;
+  char *sstr;
+
+  sstr = str;
+  
+  /* Loop over the parse table entries in t in order to find one that
+     matches the first character in str. */
+  for(p = t; p->c != 0; ++p) {
+    if(*str == p->c) {
+      /* Skip rest of the characters up to the first space. */
+      while(*str != ' ') {
+	++str;
+      }
+
+      /* Skip all spaces.*/
+      while(*str == ' ') {
+	++str;
+      }
+
+      /* Call parse table entry function and return. */
+      p->pfunc(str);
+      return;
+    }
+  }
+
+  /* Did not find matching entry in parse table. We just call the
+     default handler supplied by the caller and return. */
+  p->pfunc(str);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+inttostr(CC_REGISTER_ARG char *str, unsigned int i)
+{
+  str[0] = '0' + i / 100;
+  if(str[0] == '0') {
+    str[0] = ' ';
+  }
+  str[1] = '0' + (i / 10) % 10;
+  if(str[0] == ' ' && str[1] == '0') {
+    str[1] = ' ';
+  }
+  str[2] = '0' + i % 10;
+  str[3] = ' ';
+  str[4] = 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+processes(char *str)
+{
+  static char idstr[5];
+  struct ek_proc *p;
+
+  shell_output("Processes:", "");
+  /* Step through each possible process ID and see if there is a
+     matching process. */
+  for(p = EK_PROCS(); p != NULL; p = p->next) {
+    inttostr(idstr, p->id);
+    shell_output(idstr, (char *)p->name);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static char *
+nullterminate(char *str)
+{
+  char *nt;
+
+  /* Nullterminate string. Start with finding newline character. */
+  for(nt = str; *nt != '\r' &&
+	*nt != '\n'; ++nt);
+
+  /* Replace newline with a null char. */
+  *nt = 0;
+
+  /* Remove trailing spaces. */
+  while(nt > str && *(nt - 1) == ' ') {
+    *(nt - 1) = 0;
+    --nt;
+  }
+  
+  /* Return pointer to null char. */
+  return nt;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+runfile(char *str)
+{
+  nullterminate(str);
+
+  if(strlen(str) > 0) {
+    /* Call loader function. */
+    program_handler_load(str, NULL);
+    shell_output("Starting program ", str);  
+  } else {
+    shell_output("Must supply a program name", "");  
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+execfile(char *str)
+{
+  runfile(str);
+  shell_quit(NULL);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+killproc(char *str)
+{
+  char procnum, j, c;
+  char procstr[5];
+
+  nullterminate(str);
+  
+  procnum = 0;
+  
+  for(j = 0; j < 4; ++j) {
+    c = str[j];
+    if(c >= '0' && c <= '9') {
+      procnum = procnum * 10 + (str[j] - '0');
+    } else {
+      break;
+    }
+  }
+  if(procnum != 0) {
+    inttostr(procstr, procnum);
+    shell_output("Killing process ", procstr);
+    ek_post(procnum, EK_EVENT_REQUEST_EXIT, NULL);
+  } else {
+    shell_output("Invalid process number", "");
+  }
+  
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+help(char *str)
+{
+  shell_output("Available commands:", "");
+  shell_output("run  - start program", "");
+  shell_output("exec - start program & exit shell", "");  
+  shell_output("ps   - show processes", "");
+  shell_output("kill - kill process", "");
+  shell_output("ls   - display directory", "");
+  shell_output("quit - quit shell", "");
+  shell_output("?    - show this help", "");      
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+directory(char *str)
+{
+  if(cfs_opendir(&dir, "/") != 0) {
+    shell_output("Cannot open directory", "");
+    showingdir = 0;
+  } else {
+    shell_output("Disk directory:", "");
+    showingdir = 1;
+    totsize = 0;
+    ek_post(EK_PROC_ID(EK_CURRENT()), EK_EVENT_CONTINUE, NULL);
+  }
+  
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+none(char *str)
+{
+}
+/*-----------------------------------------------------------------------------------*/
+static struct ptentry configparsetab[] =
+  {{'e', execfile},
+   {'r', runfile},
+   {'k', killproc},   
+   {'p', processes},
+   {'l', directory},
+   {'q', shell_quit},
+   {'?', help},
+
+   /* Default action */
+   {0, none}};
+/*-----------------------------------------------------------------------------------*/
+void
+shell_init(void)
+{
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_start(void)
+{
+  showingdir = 0;
+  shell_output("Contiki command shell", "");
+  shell_output("Type '?' and return for help", "");  
+  shell_prompt("contiki-c64> "); 
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_input(char *cmd)
+{
+  if(showingdir != 0) {
+    showingdir = 0;
+    shell_output("Directory stopped", "");
+    cfs_closedir(&dir);
+  }
+  parse(cmd, configparsetab);
+  if(showingdir == 0) {
+    shell_prompt("contiki-c64> ");
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+shell_eventhandler(ek_event_t ev, ek_data_t data)
+{
+  static struct cfs_dirent dirent;
+  static char size[10];
+
+  if(ev == EK_EVENT_CONTINUE) {
+    if(showingdir != 0) {
+      if(cfs_readdir(&dir, &dirent) != 0) {
+	cfs_closedir(&dir);
+	showingdir = 0;
+	inttostr(size, totsize);
+	shell_output("Total number of blocks: ", size);
+	shell_prompt("contiki-c64> ");
+      } else {
+	totsize += dirent.size;
+	inttostr(size, dirent.size);
+	shell_output(size, dirent.name);
+	ek_post(EK_PROC_ID(EK_CURRENT()), EK_EVENT_CONTINUE, NULL);
+      }
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/springlight-dsc.c b/contiki-cpc/apps/springlight-dsc.c
new file mode 100644
index 0000000..d9fed23
--- /dev/null
+++ b/contiki-cpc/apps/springlight-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: springlight-dsc.c,v 1.1 2006/04/17 15:18:20 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon springlight_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(springlight_dsc,
+    "Spring green CTK theme",
+    "springlight.prg",
+    springlight_init,
+    &springlight_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char springlighticon_bitmap[3*3*8] = {
+  0x00,0x3f,0x6a,0x40,0x60,0x40,0x60,0x40,
+  0x00,0xff,0xaa,0x00,0x00,0x00,0x00,0x00,
+  0x00,0xf0,0x20,0x00,0x00,0x00,0x00,0x00,
+
+  0x60,0x40,0x60,0x40,0x60,0x40,0x60,0x40,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
+
+  0x60,0x40,0x40,0x40,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,
+  0x02,0x02,0x02,0x02,0x02,0x06,0xfc,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char springlighticon_textmap[9] = {
+  '(', '=', ')',
+  '|', 'o', '|',
+  '(', '-', ')'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon springlight_icon =
+  {CTK_ICON("Springlight", springlighticon_bitmap, springlighticon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/ssfire-dsc.c b/contiki-cpc/apps/ssfire-dsc.c
new file mode 100644
index 0000000..51a3578
--- /dev/null
+++ b/contiki-cpc/apps/ssfire-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ssfire-dsc.c,v 1.1 2006/04/17 15:18:20 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern struct ctk_icon ssfire_icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(ssfire_dsc,
+    "Screensaver with two fires",
+    "ssfire.sav",
+    ssfire_init,
+    &ssfire_icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static unsigned char ssfireicon_bitmap[3*3*8] = {
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static char ssfireicon_textmap[9] = {
+  '.', ' ', '.',
+  'o', ' ', 'o',
+  'O', ' ', 'O'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+static struct ctk_icon ssfire_icon =
+  {CTK_ICON("Fire", ssfireicon_bitmap, ssfireicon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/ssfire.c b/contiki-cpc/apps/ssfire.c
new file mode 100644
index 0000000..ed03af2
--- /dev/null
+++ b/contiki-cpc/apps/ssfire.c
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2002-2004, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: ssfire.c,v 1.1 2006/04/17 15:18:20 kthacker Exp $
+ *
+ */
+
+#include <stdlib.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "ctk-mouse.h"
+#include "ek.h"
+#include "loader.h"
+
+
+/*static DISPATCHER_SIGHANDLER(ssfire_sighandler, s, data);
+static void ssfire_idle(void);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Fire screensaver", ssfire_idle,
+		   ssfire_sighandler,
+		   NULL)};
+		   static ek_id_t id;*/
+
+EK_EVENTHANDLER(ssfire_eventhandler, ev, data);
+EK_POLLHANDLER(ssfire_pollhandler);
+EK_PROCESS(p, "Fire screensaver", EK_PRIO_LOWEST,
+	   ssfire_eventhandler, ssfire_pollhandler, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+static unsigned char flames[8*17];
+
+
+static const unsigned char flamecolors[16] =
+  {COLOR_BLACK,  COLOR_BLACK, COLOR_BLACK,
+   COLOR_RED,    COLOR_LIGHTRED,   COLOR_YELLOW, COLOR_WHITE,
+   COLOR_WHITE,  COLOR_WHITE, COLOR_WHITE,    COLOR_WHITE,
+   COLOR_WHITE,  COLOR_WHITE, COLOR_WHITE,    COLOR_WHITE,
+   COLOR_WHITE};
+   
+
+static void fire_init(void);
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(ssfire_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+fire_quit(void)
+{
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+fire_init(void)
+{
+  unsigned char *ptr, *cptr;
+  
+  /* Fill screen with inverted spaces. */
+  cptr = COLOR_RAM;
+  for(ptr = (unsigned char *)0x0400;
+      ptr != (unsigned char *)0x07e8;
+      ++ptr) {
+    *ptr = 0xa0;
+    *cptr++ = 0x00;
+  }
+
+  SID.v3.freq = 0xffff;
+  SID.v3.ctrl = 0x80;
+  SID.amp = 0;  
+
+  VIC.ctrl1 = 0x1b;  /* $D011 */
+  VIC.addr  = 0x17;  /* $D018 */
+  VIC.ctrl2 = 0xc8;  /* $D016 */
+  VIC.bordercolor = 0x00; /* $D020 */
+  VIC.bgcolor0 = 0x00; /* $D021 */  
+  CIA2.pra  = 0x03;  /* $DD00 */
+
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(ssfire_eventhandler, ev, data)
+{
+  EK_EVENTHANDLER_ARGS(ev, data);
+  
+  if(ev == EK_EVENT_INIT) {
+    ctk_mode_set(CTK_MODE_SCREENSAVER);
+    ctk_mouse_hide();
+    fire_init();
+  } else if(ev == ctk_signal_screensaver_stop ||
+	    ev == EK_EVENT_REQUEST_EXIT) {
+    fire_quit();
+    ctk_draw_init();
+    ctk_desktop_redraw(NULL);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static unsigned char *flameptr, *colorptr1, *colorptr2;
+static unsigned char x, y;
+
+#pragma optimize(push, off)
+EK_POLLHANDLER(ssfire_pollhandler)
+{
+
+  if(ctk_mode_get() == CTK_MODE_SCREENSAVER) {
+  
+    /* Calculate new flames. */
+    asm("ldx #0");
+    asm("loop:");
+    asm("lda _flames+7,x");
+    asm("clc");
+    asm("adc _flames+8,x");
+    asm("adc _flames+9,x");
+    asm("adc _flames+16,x");
+    asm("lsr");
+    asm("lsr");
+    asm("sta _flames,x");
+    asm("inx");
+    asm("cpx #(8*15)");
+    asm("bne loop");
+
+    /* Fill last line with pseudo-random data from noise generator on
+       voice 3. */
+    asm("ldx #$05");
+    asm("loop2:");
+    asm("ldy #$20");
+    asm("delay:");
+    asm("dey");
+    asm("bne delay");
+    asm("lda $d41b");
+    asm("and #$0f");
+    asm("sta _flames+8*15+1,x");
+    asm("dex");
+    asm("bpl loop2");
+
+    /* Display flames on screen. */  
+    flameptr = flames;
+    colorptr1 = COLOR_RAM + 40*10;
+    colorptr2 = colorptr1 + 0x20;
+    for(y = 0; y < 15; ++y) {
+      for(x = 0; x < 8; ++x) {
+	colorptr1[x] = colorptr2[x] = flamecolors[flameptr[x]];
+      }
+      colorptr1 += 0x28;
+      colorptr2 += 0x28;
+      flameptr += 8;
+    }
+  
+  }
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+
diff --git a/contiki-cpc/apps/themeloader.c b/contiki-cpc/apps/themeloader.c
new file mode 100644
index 0000000..7c00afa
--- /dev/null
+++ b/contiki-cpc/apps/themeloader.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: themeloader.c,v 1.1 2006/04/17 15:18:20 kthacker Exp $
+ *
+ */
+
+#include <string.h>
+
+#include "loader.h"
+#include "ctk-draw.h"
+#include "ctk-hires-theme.h"
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(themeloader_init, arg)
+{
+  arg_free(arg);
+  
+  memcpy(ctk_hires_theme_ptr, &ctk_hires_theme,
+	 sizeof(struct ctk_hires_theme));
+  ctk_draw_init();
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/unused/directory.c b/contiki-cpc/apps/unused/directory.c
new file mode 100644
index 0000000..d00245c
--- /dev/null
+++ b/contiki-cpc/apps/unused/directory.c
@@ -0,0 +1,280 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. All advertising materials mentioning features or use of this
+ *    software must display the following acknowledgement:
+ *        This product includes software developed by Adam Dunkels. 
+ * 4. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: directory.c,v 1.1 2006/04/17 15:18:26 kthacker Exp $
+ *
+ */
+
+#include <stdlib.h>
+//#include <cbm.h>
+#include <string.h>
+
+#include "ctk.h"
+#include "ctk-draw.h"
+#include "dispatcher.h"
+#include "loader.h"
+
+#include "program-handler.h"
+
+#define MAX_NUMFILES 40
+#define WIDTH 36
+#define HEIGHT 22
+
+static struct dsc *dscs[MAX_NUMFILES];
+static char filenames[MAX_NUMFILES][16];
+static unsigned char numfiles, morestart;
+
+static struct ctk_window window;
+
+static struct ctk_label description =
+  {CTK_LABEL(0, HEIGHT - 1, WIDTH, 1, "")};
+
+static char autoexit = 1;
+const static struct ctk_button autoexitbutton =
+  {CTK_BUTTON(0, 20, 9, "Auto-exit")};
+const static char autoexiton[] = "is On ";
+const static char autoexitoff[] = "is Off";
+static struct ctk_label autoexitlabel =
+  {CTK_LABEL(12, 20, 6, 1, autoexiton)};
+
+const static struct ctk_button morebutton =
+  {CTK_BUTTON(0, 20, 4, "More")};
+
+const static struct ctk_button backbutton =
+  {CTK_BUTTON(0, 20, 4, "Back")};
+
+const static struct ctk_button reloadbutton =
+  {CTK_BUTTON(30, 20, 6, "Reload")};
+
+static DISPATCHER_SIGHANDLER(directory_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Directory browser", NULL, directory_sighandler, NULL)};
+static ek_id_t id;
+
+static unsigned char width, height;
+
+/*-----------------------------------------------------------------------------------*/
+//static struct cbm_dirent dirent;
+/*-----------------------------------------------------------------------------------*/
+static void
+show_statustext(char *text)
+{
+  ctk_label_set_text(&description, text);
+  CTK_WIDGET_REDRAW(&description);
+}
+/*-----------------------------------------------------------------------------------*/
+#define LFN 9
+static void
+loaddirectory(void)
+{
+#if 0
+  unsigned char i, j;
+  
+  if(cbm_opendir(LFN, 8) != 0) {
+    show_statustext("Cannot open directory");
+  } else {
+    i = 0;
+    while(cbm_readdir(LFN, &dirent) == 0) {
+      if(strcmp(&dirent.name[strlen(dirent.name) - 4], ".dsc") == 0) {	
+	strncpy(filenames[i], dirent.name, 16);
+	++i;
+	if(i == MAX_NUMFILES) {
+	  break;
+	}
+      }
+    }
+    cbm_closedir(LFN);
+
+    numfiles = i;
+
+    j = 0;
+    for(i = 0; i < numfiles; ++i) {
+      dscs[j] = LOADER_LOAD_DSC(filenames[i]);
+      if(dscs[j] != NULL) {
+	++j;
+      }
+    }
+    show_statustext("Directory loaded");
+  }
+#endif
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+makewindow(unsigned char i)
+{
+  unsigned char x, y;
+
+  ctk_window_clear(&window);
+  CTK_WIDGET_SET_YPOS(&description, height - 3);
+  CTK_WIDGET_SET_WIDTH(&description, width);
+  CTK_WIDGET_ADD(&window, &description);
+
+  morestart = i;
+  
+  x = 0; y = 1;
+  for(; dscs[i] != NULL; ++i) {
+
+    if(x + strlen(dscs[i]->icon->title) >= width) {
+      y += 5;
+      x = 0;
+      if(y >= height - 2 - 4) {
+	morestart = i;
+	break;
+      }
+    }
+    CTK_WIDGET_SET_XPOS(dscs[i]->icon, x);
+    CTK_WIDGET_SET_YPOS(dscs[i]->icon, y);
+    CTK_WIDGET_ADD(&window, dscs[i]->icon);
+
+    x += strlen(dscs[i]->icon->title) + 1;
+  }
+  CTK_WIDGET_SET_YPOS(&autoexitbutton, height - 2);
+  CTK_WIDGET_ADD(&window, &autoexitbutton);
+  CTK_WIDGET_SET_YPOS(&autoexitlabel, height - 2);
+  CTK_WIDGET_ADD(&window, &autoexitlabel);
+
+  if(i != morestart) {
+    CTK_WIDGET_SET_YPOS(&backbutton, height - 1);
+    CTK_WIDGET_ADD(&window, &backbutton);
+  } else {
+    CTK_WIDGET_SET_YPOS(&morebutton, height - 1);
+    CTK_WIDGET_ADD(&window, &morebutton);
+  }
+  CTK_WIDGET_SET_XPOS(&reloadbutton, width - 8);
+  CTK_WIDGET_SET_YPOS(&reloadbutton, height - 1);
+  CTK_WIDGET_ADD(&window, &reloadbutton);    
+}
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(directory_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = dispatcher_start(&p);
+
+    width = ctk_draw_width() - 4;
+    height = ctk_draw_height() - 4;
+    
+    ctk_window_new(&window, width, height, "Directory");
+
+    loaddirectory();
+    makewindow(0);
+    
+    dispatcher_listen(ctk_signal_widget_activate);
+    dispatcher_listen(ctk_signal_widget_select);
+    dispatcher_listen(ctk_signal_window_close);
+  }
+  ctk_window_open(&window);
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+quit(void)
+{
+  unsigned char i;
+
+  ctk_window_close(&window);
+  for(i = 0; dscs[i] != NULL; ++i) {
+    LOADER_UNLOAD_DSC(dscs[i]);
+  }
+  dispatcher_exit(&p);
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+static
+DISPATCHER_SIGHANDLER(directory_sighandler, s, data)
+{
+  unsigned char i;
+  DISPATCHER_SIGHANDLER_ARGS(s, data);
+  
+  if(s == ctk_signal_widget_activate) {
+    if(data == (ek_data_t)&reloadbutton) {
+      for(i = 0; dscs[i] != NULL; ++i) {
+	LOADER_UNLOAD_DSC(dscs[i]);
+      }     
+      loaddirectory();
+      makewindow(0);
+      ctk_window_open(&window);
+    } else if(data == (ek_data_t)&morebutton) {
+      makewindow(morestart);
+      ctk_window_open(&window);
+    } else if(data == (ek_data_t)&backbutton) {
+      makewindow(0);
+      ctk_window_open(&window);
+    } else if(data == (ek_data_t)&autoexitbutton) {
+      autoexit = 1 - autoexit;
+      if(autoexit == 1) {
+	ctk_label_set_text(&autoexitlabel, autoexiton);
+      } else {
+	ctk_label_set_text(&autoexitlabel, autoexitoff);
+      }
+      CTK_WIDGET_REDRAW(&autoexitlabel);
+    } else {
+      for(i = 0; dscs[i] != NULL; ++i) {
+	if(data == (ek_data_t)(dscs[i]->icon)) {
+	  program_handler_load(dscs[i]->prgname);
+	  if(autoexit) {
+	    ctk_window_close(&window);
+	    quit();
+	  }
+	  break;
+	}
+      }
+    }
+  } else if(s == ctk_signal_widget_select) {
+    if(data == (ek_data_t)&reloadbutton) {
+      show_statustext("Reload directory");
+    } else if(data == (ek_data_t)&morebutton) {
+      show_statustext("Show more files");
+    } else if(data == (ek_data_t)&backbutton) {
+      show_statustext("Show first files");
+    } else if(data == (ek_data_t)&autoexitbutton) {
+      show_statustext("Exit when loading program");
+    } else {
+      for(i = 0; dscs[i] != NULL; ++i) {
+	if(data == (ek_data_t)(dscs[i]->icon)) {
+	  show_statustext(dscs[i]->description);
+	  break;
+	}
+      }
+    }
+  } else if(s == ctk_signal_window_close &&
+	    data == (ek_data_t)&window) {
+    quit();
+  } else if(s == dispatcher_signal_quit) {
+    ctk_window_close(&window);
+    quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/vnc-draw-asm.S b/contiki-cpc/apps/vnc-draw-asm.S
new file mode 100644
index 0000000..7522a43
--- /dev/null
+++ b/contiki-cpc/apps/vnc-draw-asm.S
@@ -0,0 +1,16 @@
+
+;---------------------------------------------------------------------       
+	.importzp       ptr1, ptr2, ptr3, ptr4, sreg
+	.importzp	sp
+
+	.import		_vnc_draw_datalen
+	.import		_vnc_draw_dataptr
+	.import		_vnc_draw_bitmapptr	
+	.import		_vnc_draw_x
+	.import		_vnc_draw_y
+;---------------------------------------------------------------------
+.bss
+;---------------------------------------------------------------------
+.data
+;---------------------------------------------------------------------
+.code
diff --git a/contiki-cpc/apps/vnc-draw-asm.h b/contiki-cpc/apps/vnc-draw-asm.h
new file mode 100644
index 0000000..b786fa9
--- /dev/null
+++ b/contiki-cpc/apps/vnc-draw-asm.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki VNC client
+ *
+ * $Id: vnc-draw-asm.h,v 1.1 2006/04/17 15:18:20 kthacker Exp $
+ *
+ */
+#ifndef __VNC_DRAW_ASM_H__
+#define __VNC_DRAW_ASM_H__
+
+#include "vnc-draw.h"
+
+void vnc_draw_asm_pixelline(void);
+
+#endif /* __VNC_DRAW_ASM_H__ */
diff --git a/contiki-cpc/apps/vnc-draw.c b/contiki-cpc/apps/vnc-draw.c
new file mode 100644
index 0000000..78520ea
--- /dev/null
+++ b/contiki-cpc/apps/vnc-draw.c
@@ -0,0 +1,689 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki VNC client
+ *
+ * $Id: vnc-draw.c,v 1.1 2006/04/17 15:18:21 kthacker Exp $
+ *
+ */
+
+
+
+#include "vnc-draw.h"
+#include "vnc-draw-asm.h"
+
+#include "vnc-conf.h"
+
+
+static unsigned char conv[256];
+
+const static unsigned char oratab[8] =
+  { 0x80, 0x40, 0x20, 0x10,
+    0x08, 0x04, 0x02, 0x01 };
+const static unsigned char andtab[8] =
+  { 0x7f, 0xbf, 0xdf, 0xef,
+    0xf7, 0xfb, 0xfd, 0xfe };
+
+static u8_t *bitmapptrtab[VNC_CONF_VIEWPORT_HEIGHT];
+
+static unsigned short viewport_x,
+  viewport_y, viewport_w, viewport_h;
+
+u8_t vnc_draw_bitmap[(VNC_CONF_VIEWPORT_WIDTH / 8) *
+		     VNC_CONF_VIEWPORT_HEIGHT];
+
+
+
+u16_t vnc_draw_x;
+u16_t vnc_draw_y;
+u8_t *vnc_draw_dataptr;
+u8_t *vnc_draw_bitmapptr;
+u16_t vnc_draw_datalen;
+
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_draw_pixel(u16_t x, u8_t y, u8_t c)
+{
+  u8_t o, a;
+  
+  vnc_draw_bitmapptr = bitmapptrtab[y] + (x & 0x1f8);  
+  
+  if(c) {
+    o = oratab[x & 7];
+    *vnc_draw_bitmapptr = *vnc_draw_bitmapptr | o;
+  } else {
+    a = andtab[x & 7];
+    *vnc_draw_bitmapptr = *vnc_draw_bitmapptr & a;
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_draw_pixelline(u16_t x, u16_t y, u8_t *data, u16_t datalen)
+{
+  u8_t o, a;
+  register u8_t *bitmapptr;
+  
+  vnc_draw_x = x - viewport_x;
+  vnc_draw_y = y - viewport_y;
+
+  /*  if(vnc_draw_y & 1) {
+    return;
+  } else {
+    vnc_draw_y /= 2;
+    }*/
+
+  
+  
+  if(vnc_draw_y >= VNC_CONF_VIEWPORT_HEIGHT ||
+     vnc_draw_x >= VNC_CONF_VIEWPORT_WIDTH) {
+    return;
+  }
+
+  vnc_draw_datalen = datalen;
+  
+  if(vnc_draw_datalen + vnc_draw_x >= VNC_CONF_VIEWPORT_WIDTH) {
+    vnc_draw_datalen = VNC_CONF_VIEWPORT_WIDTH - vnc_draw_x;
+    if(vnc_draw_datalen == 0) {
+      return;
+    }
+  }
+  
+  vnc_draw_dataptr = data;
+
+  /*  vnc_draw_bitmapptr = bitmaptab[vnc_draw_y] +
+      (vnc_draw_x & 0x1f8);*/
+
+  for(; vnc_draw_datalen > 0; --vnc_draw_datalen) {
+    /*    vnc_draw_pixel(vnc_draw_x, vnc_draw_y,
+	  conv[*vnc_draw_dataptr]);*/
+
+    bitmapptr = bitmapptrtab[vnc_draw_y] + (vnc_draw_x & 0x1f8);  
+    
+    if(conv[*vnc_draw_dataptr]) {
+      o = oratab[vnc_draw_x & 7];
+      *bitmapptr = *bitmapptr | o;
+    } else {
+      a = andtab[vnc_draw_x & 7];
+      *bitmapptr = *bitmapptr & a;
+    }
+    ++vnc_draw_dataptr;
+    ++vnc_draw_x;
+  }  
+}
+/*-----------------------------------------------------------------------------------*/
+void
+vnc_draw_init(void)
+{
+  unsigned int tmp;
+  unsigned int i;
+  unsigned short ptr;
+
+
+  /* Create color conversion table. */
+  for(i = 0; i < 256; ++i) {
+    if(((i & 0xc0) > 0xc0) ||
+       ((i & 0x38) > 0x18) ||
+       ((i & 0x07) > 0x03)) {
+      conv[i] = 0;
+    } else {
+      conv[i] = 1;
+    }
+  }
+
+  memset(vnc_draw_bitmap, 0, sizeof(vnc_draw_bitmap));
+  
+  for(i = 0; i < VNC_CONF_VIEWPORT_HEIGHT; ++i) {
+    bitmapptrtab[i] = (u8_t *)((u16_t)vnc_draw_bitmap +
+			       ((i & 0xfff8)/8) * VNC_CONF_VIEWPORT_WIDTH +
+			       (i & 7));
+  }
+
+  viewport_x = 0;
+  viewport_y = 0;
+
+  viewport_w = VNC_CONF_VIEWPORT_WIDTH;
+  viewport_h = VNC_CONF_VIEWPORT_HEIGHT;
+  
+  return;
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+vnc_draw_viewport_x(void)
+{
+  return viewport_x;
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+vnc_draw_viewport_y(void)
+{
+  return viewport_y;
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+vnc_draw_viewport_w(void)
+{
+  return viewport_w;
+}
+/*-----------------------------------------------------------------------------------*/
+u16_t
+vnc_draw_viewport_h(void)
+{
+  return viewport_h;
+}
+/*-----------------------------------------------------------------------------------*/
+#if 0
+signed short
+c64_mouse_x(void)
+{
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+signed short
+c64_mouse_y(void)
+{
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+u8_t
+c64_mouse_buttons(void)
+{
+  return firebutton;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+c64_set_mouse_x(unsigned short x)
+{
+  joyx = x;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+c64_set_mouse_y(unsigned short y)
+{
+  joyy = y;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+c64_set_viewport_x(unsigned short x)
+{
+  viewport_x = x;
+}
+/*-----------------------------------------------------------------------------------*/
+void
+c64_set_viewport_y(unsigned short y)
+{
+  viewport_y = y;
+}
+/*-----------------------------------------------------------------------------------*/
+
+#endif /* 0 */
+#if 0
+#pragma optimize(push, off)
+void
+c64_scroll_up(unsigned char c)
+{
+  asm("lda $f7");
+  asm("pha");
+  asm("lda $f8");
+  asm("pha");
+  asm("lda $f9");
+  asm("pha");
+  asm("lda $fa");
+  asm("pha");
+  asm("lda $fb");
+  asm("pha");
+  asm("lda $fc");
+  asm("pha");
+  asm("lda $fd");
+  asm("pha");
+  asm("lda $fe");
+  asm("pha");
+
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$35");
+  asm("sta $01");
+  
+  asm("lda #$80");
+  asm("sta $f7");
+  asm("lda #$a2");
+  asm("sta $f8");
+  asm("lda #$00");
+  asm("sta $f9");
+  asm("lda #$a0");
+  asm("sta $fa");
+
+  asm("lda #$80");
+  asm("sta $fb");
+  asm("lda #$e2");
+  asm("sta $fc");
+  asm("lda #$00");
+  asm("sta $fd");
+  asm("lda #$e0");
+  asm("sta $fe");
+
+  asm("ldy #0");
+  asm("loop:");
+  asm("lda ($f7),y");
+  asm("sta ($f9),y");
+  asm("lda ($fb),y");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("bne loop");
+
+  asm("inc $f8");
+  asm("inc $fa");
+  asm("inc $fc");
+  asm("inc $fe");
+
+  asm("lda $fc");
+  asm("cmp #$00");
+  asm("bne loop");
+
+  asm("ldy #0");
+  asm("lda #0");
+  asm("sta $fe00,y");
+  asm("sta $be00,y");
+  asm("sta $fcc0,y");
+  asm("sta $bcc0,y");
+  asm("iny");
+  asm("bne *-13");
+  asm("sta $ff00,y");
+  asm("sta $bf00,y");
+  asm("sta $fdc0,y");
+  asm("sta $bdc0,y");
+  asm("iny");
+  asm("cpy #$40");
+  asm("bne *-15");
+  
+
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("sta $fe");
+  asm("pla");
+  asm("sta $fd");
+  asm("pla");
+  asm("sta $fc");
+  asm("pla");
+  asm("sta $fb");
+  asm("pla");
+  asm("sta $fa");
+  asm("pla");
+  asm("sta $f9");
+  asm("pla");
+  asm("sta $f8");
+  asm("pla");
+  asm("sta $f7");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+c64_scroll_down(unsigned char c)
+{
+  asm("lda $f7");
+  asm("pha");
+  asm("lda $f8");
+  asm("pha");
+  asm("lda $f9");
+  asm("pha");
+  asm("lda $fa");
+  asm("pha");
+  asm("lda $fb");
+  asm("pha");
+  asm("lda $fc");
+  asm("pha");
+  asm("lda $fd");
+  asm("pha");
+  asm("lda $fe");
+  asm("pha");
+
+
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$35");
+  asm("sta $01");
+  
+  asm("lda #$c0");
+  asm("sta $fb");
+  asm("lda #$fb");
+  asm("sta $fc");
+  asm("lda #$40");
+  asm("sta $fd");
+  asm("lda #$fe");
+  asm("sta $fe");
+
+  asm("lda #$c0");
+  asm("sta $f7");
+  asm("lda #$bb");
+  asm("sta $f8");
+  asm("lda #$40");
+  asm("sta $f9");
+  asm("lda #$be");
+  asm("sta $fa");
+
+
+  asm("ldy #0");
+  asm("loop:");
+  asm("lda ($fb),y");
+  asm("sta ($fd),y");
+  asm("lda ($f7),y");
+  asm("sta ($f9),y");
+  asm("iny");
+  asm("bne loop");
+
+  asm("dec $f8");
+  asm("dec $fa");
+  asm("dec $fc");
+  asm("dec $fe");
+
+
+  asm("lda $fe");
+  asm("cmp #$df");
+  asm("bne loop");
+
+  asm("ldy #0");
+  asm("lda #0");
+  asm("sta $e000,y");
+  asm("sta $a000,y");
+  asm("sta $e140,y");
+  asm("sta $a140,y");
+  asm("iny");
+  asm("bne *-13");
+  asm("sta $e100,y");
+  asm("sta $a100,y");
+  asm("sta $e240,y");
+  asm("sta $a240,y");
+  asm("iny");
+  asm("cpy #$40");
+  asm("bne *-15");
+  
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("sta $fe");
+  asm("pla");
+  asm("sta $fd");
+  asm("pla");
+  asm("sta $fc");
+  asm("pla");
+  asm("sta $fb");
+  asm("pla");
+  asm("sta $fa");
+  asm("pla");
+  asm("sta $f9");
+  asm("pla");
+  asm("sta $f8");
+  asm("pla");
+  asm("sta $f7");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+c64_scroll_right(unsigned char c)
+{
+  asm("lda $f7");
+  asm("pha");
+  asm("lda $f8");
+  asm("pha");
+  asm("lda $f9");
+  asm("pha");
+  asm("lda $fa");
+  asm("pha");
+  asm("lda $fb");
+  asm("pha");
+  asm("lda $fc");
+  asm("pha");
+  asm("lda $fd");
+  asm("pha");
+  asm("lda $fe");
+  asm("pha");
+
+
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$35");
+  asm("sta $01");
+
+  asm("lda #$00");
+  asm("sta $f7");
+  asm("lda #$a0");
+  asm("sta $f8");
+  asm("lda #$10");
+  asm("sta $f9");
+  asm("lda #$a0");
+  asm("sta $fa");
+
+  asm("lda #$00");
+  asm("sta $fb");
+  asm("lda #$e0");
+  asm("sta $fc");
+  asm("lda #$10");
+  asm("sta $fd");
+  asm("lda #$e0");
+  asm("sta $fe");
+
+  asm("ldx #0");
+  
+  asm("loop3:");
+  
+  asm("ldy #$ff");
+  asm("loop:");
+  asm("lda ($f7),y");
+  asm("sta ($f9),y");
+  asm("lda ($fb),y");
+  asm("sta ($fd),y");
+  asm("dey");
+  asm("cpy #$ff");
+  asm("bne loop");
+  
+  asm("inc $f8");
+  asm("inc $fa");
+  asm("inc $fc");
+  asm("inc $fe");
+
+  asm("ldy #$30");
+  asm("loop2:");
+  asm("lda ($f7),y");
+  asm("sta ($f9),y");
+  asm("lda ($fb),y");
+  asm("sta ($fd),y");
+  asm("dey");
+  asm("cpy #$ff");
+  asm("bne loop2");
+
+  asm("lda $f7");
+  asm("clc");
+  asm("adc #$40");
+  asm("sta $f7");
+  asm("sta $fb");
+  asm("bcc :+");
+  asm("inc $f8");
+  asm("inc $fc");
+  asm(":");
+  
+  asm("lda $f9");
+  asm("clc");
+  asm("adc #$40");
+  asm("sta $f9");
+  asm("sta $fd");
+  asm("bcc :+");
+  asm("inc $fa");
+  asm("inc $fe");
+  asm(":");
+  
+
+  
+  asm("inx");
+  asm("cpx #24");
+  asm("bne loop3");
+
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("sta $fe");
+  asm("pla");
+  asm("sta $fd");
+  asm("pla");
+  asm("sta $fc");
+  asm("pla");
+  asm("sta $fb");
+  asm("pla");
+  asm("sta $fa");
+  asm("pla");
+  asm("sta $f9");
+  asm("pla");
+  asm("sta $f8");
+  asm("pla");
+  asm("sta $f7");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+#pragma optimize(push, off)
+void
+c64_scroll_left(unsigned char c)
+{
+  asm("lda $f7");
+  asm("pha");
+  asm("lda $f8");
+  asm("pha");
+  asm("lda $f9");
+  asm("pha");
+  asm("lda $fa");
+  asm("pha");
+  asm("lda $fb");
+  asm("pha");
+  asm("lda $fc");
+  asm("pha");
+  asm("lda $fd");
+  asm("pha");
+  asm("lda $fe");
+  asm("pha");
+
+
+  asm("lda $01");
+  asm("pha");
+  asm("lda #$35");
+  asm("sta $01");
+
+  asm("lda #$10");
+  asm("sta $f7");
+  asm("lda #$a0");
+  asm("sta $f8");
+  asm("lda #$00");
+  asm("sta $f9");
+  asm("lda #$a0");
+  asm("sta $fa");
+
+  asm("lda #$10");
+  asm("sta $fb");
+  asm("lda #$e0");
+  asm("sta $fc");
+  asm("lda #$00");
+  asm("sta $fd");
+  asm("lda #$e0");
+  asm("sta $fe");
+
+  asm("ldx #0");
+  asm("loop3:");
+  asm("ldy #0");
+  asm("loop:");
+  asm("lda ($f7),y");
+  asm("sta ($f9),y");
+  asm("lda ($fb),y");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("bne loop");
+  
+  asm("inc $f8");
+  asm("inc $fa");
+  asm("inc $fc");
+  asm("inc $fe");
+
+  asm("ldy #0");
+  asm("loop2:");
+  asm("lda ($f7),y");
+  asm("sta ($f9),y");
+  asm("lda ($fb),y");
+  asm("sta ($fd),y");
+  asm("iny");
+  asm("cpy #$30");
+  asm("bne loop2");
+
+  asm("lda $f7");
+  asm("clc");
+  asm("adc #$40");
+  asm("sta $f7");
+  asm("sta $fb");
+  asm("bcc :+");
+  asm("inc $f8");
+  asm("inc $fc");
+  asm(":");
+  
+  asm("lda $f9");
+  asm("clc");
+  asm("adc #$40");
+  asm("sta $f9");
+  asm("sta $fd");
+  asm("bcc :+");
+  asm("inc $fa");
+  asm("inc $fe");
+  asm(":");
+  
+
+  asm("inx");
+  asm("cpx #24");
+  asm("bne loop3");
+
+  asm("pla");
+  asm("sta $01");
+  asm("pla");
+  asm("sta $fe");
+  asm("pla");
+  asm("sta $fd");
+  asm("pla");
+  asm("sta $fc");
+  asm("pla");
+  asm("sta $fb");
+  asm("pla");
+  asm("sta $fa");
+  asm("pla");
+  asm("sta $f9");
+  asm("pla");
+  asm("sta $f8");
+  asm("pla");
+  asm("sta $f7");
+}
+#pragma optimize(pop)
+/*-----------------------------------------------------------------------------------*/
+
+
+
+#endif /* 0 */
diff --git a/contiki-cpc/apps/welcome.c b/contiki-cpc/apps/welcome.c
new file mode 100644
index 0000000..709da3d
--- /dev/null
+++ b/contiki-cpc/apps/welcome.c
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: welcome.c,v 1.1 2006/04/17 15:18:21 kthacker Exp $
+ *
+ */
+
+#include "contiki.h"
+#include <string.h>
+
+
+static struct ctk_window welcomedialog;
+const static struct ctk_label welcomelabel1 =
+  {CTK_LABEL(1, 1, 30, 1, "Welcome to " CONTIKI_VERSION_STRING "!")};
+const static struct ctk_label welcomelabel2 =
+  {CTK_LABEL(2, 4, 28, 1, "F1     - open menus")};
+const static struct ctk_label welcomelabel3 =
+  {CTK_LABEL(2, 6, 28, 1, "F3     - cycle windows")};
+const static struct ctk_label welcomelabel4 =
+  {CTK_LABEL(2, 8, 28, 1, "F7     - select up")};
+const static struct ctk_label welcomelabel5 =
+  {CTK_LABEL(2, 10, 28, 1, "F4     - select down")};
+const static struct ctk_label welcomelabel6 =
+  {CTK_LABEL(2, 12, 28, 1, "Return - activate selected")};
+const static struct ctk_label welcomelabel7 =
+  {CTK_LABEL(3, 15, 25, 1, "Press any key to continue")};
+
+
+EK_EVENTHANDLER(welcome_eventhandler, ev, data);
+
+EK_PROCESS(p, "Welcome", EK_PRIO_NORMAL, welcome_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/*-----------------------------------------------------------------------------------*/
+LOADER_INIT_FUNC(welcome_init, arg)
+{
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+welcome_quit(void)
+{
+  ctk_dialog_close();
+  ek_exit();
+  id = EK_ID_NONE;
+  LOADER_UNLOAD();
+}
+/*-----------------------------------------------------------------------------------*/
+/*static DISPATCHER_SIGHANDLER(welcome_sighandler, s, data)*/
+EK_EVENTHANDLER(welcome_eventhandler, ev, data)
+{
+  unsigned char width;
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    width = ctk_desktop_width(NULL);
+    
+    if(width > 34) {
+      ctk_dialog_new(&welcomedialog, 32, 17);
+    } else {
+      ctk_dialog_new(&welcomedialog, width - 2, 17);
+    }
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel1);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel2);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel3);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel4);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel5);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel6);
+    CTK_WIDGET_ADD(&welcomedialog, &welcomelabel7);    
+    
+    ctk_dialog_open(&welcomedialog);
+    
+  } else if(ev == EK_EVENT_REQUEST_EXIT ||
+	    ev == ctk_signal_keypress) {
+    welcome_quit();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/wget-dsc.c b/contiki-cpc/apps/wget-dsc.c
new file mode 100644
index 0000000..0e0f12d
--- /dev/null
+++ b/contiki-cpc/apps/wget-dsc.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: wget-dsc.c,v 1.1 2006/04/17 15:18:21 kthacker Exp $
+ *
+ */
+
+#include "dsc.h"
+
+extern const struct ctk_icon icon;
+/*-----------------------------------------------------------------------------------*/
+DSC(wget_dsc,
+    "Downloads files or D64 disks from the web",
+    "wget.prg",
+    wget_init,
+    &icon);
+/*-----------------------------------------------------------------------------------*/
+#if CTK_CONF_ICON_BITMAPS
+static const unsigned char wgeticon_bitmap[3*3*8] = {
+  0x00, 0x7e, 0x40, 0x73, 0x46, 0x4c, 0x18, 0x13,
+  0x00, 0x00, 0xff, 0x81, 0x34, 0xc9, 0x00, 0xb6,
+  0x00, 0x7e, 0x02, 0xce, 0x72, 0x32, 0x18, 0x48,
+
+  0x30, 0x27, 0x24, 0x20, 0x37, 0x24, 0x20, 0x33,
+  0x00, 0x7b, 0x42, 0x00, 0x7b, 0x42, 0x00, 0x3b,
+  0x0c, 0x24, 0x24, 0x04, 0xa4, 0x24, 0x04, 0x4c,
+
+  0x12, 0x19, 0x4c, 0x46, 0x63, 0x40, 0x7c, 0x00,
+  0x22, 0x91, 0x00, 0xc4, 0x81, 0xff, 0x00, 0x00,
+  0x08, 0x18, 0x32, 0x62, 0xc6, 0x02, 0x3e, 0x00
+};
+#endif /* CTK_CONF_ICON_BITMAPS */
+
+#if CTK_CONF_ICON_TEXTMAPS
+static const char wgeticon_textmap[9] = {
+  'w', 'e', 'b',
+  'p', 'r', 'g',
+  'd', '6', '4'
+};
+#endif /* CTK_CONF_ICON_TEXTMAPS */
+
+const struct ctk_icon icon =
+  {CTK_ICON("Web downloader", wgeticon_bitmap, wgeticon_textmap)};
+/*-----------------------------------------------------------------------------------*/
diff --git a/contiki-cpc/apps/wget-dsc.h b/contiki-cpc/apps/wget-dsc.h
new file mode 100644
index 0000000..1b13211
--- /dev/null
+++ b/contiki-cpc/apps/wget-dsc.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2003, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: wget-dsc.h,v 1.1 2006/04/17 15:18:23 kthacker Exp $
+ *
+ */
+#ifndef __WGET_DSC_H__
+#define __WGET_DSC_H__
+
+#include "dsc.h"
+
+DSC_HEADER(wget_dsc);
+
+#endif /* __WGET_DSC_H__ */
diff --git a/contiki-cpc/apps/wget.c b/contiki-cpc/apps/wget.c
new file mode 100644
index 0000000..20b403e
--- /dev/null
+++ b/contiki-cpc/apps/wget.c
@@ -0,0 +1,545 @@
+/*
+ * Copyright (c) 2002, Adam Dunkels.
+ * All rights reserved. 
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met: 
+ * 1. Redistributions of source code must retain the above copyright 
+ *    notice, this list of conditions and the following disclaimer. 
+ * 2. Redistributions in binary form must reproduce the above
+ *    copyright notice, this list of conditions and the following
+ *    disclaimer in the documentation and/or other materials provided
+ *    with the distribution. 
+ * 3. The name of the author may not be used to endorse or promote
+ *    products derived from this software without specific prior
+ *    written permission.  
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
+ *
+ * This file is part of the Contiki desktop environment
+ *
+ * $Id: wget.c,v 1.1 2006/04/17 15:18:24 kthacker Exp $
+ *
+ */
+
+
+#include "ctk.h"
+#include "ek.h"
+#include "webclient.h"
+#include "resolv.h"
+#include "petsciiconv.h"
+#include "uiplib.h"
+#include "loader.h"
+
+#include "contiki.h"
+
+#include "program-handler.h"
+
+#include <c64.h>
+#include <cbm.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+
+#include "c64-dio.h"
+
+#define USE_KERNAL 0
+
+static struct ctk_window window;
+
+static struct ctk_label urllabel =
+  {CTK_LABEL(0, 1, 4, 1, "URL:")};
+static char url[80];
+static char urledit[80];
+struct ctk_textentry urltextentry =
+  {CTK_TEXTENTRY(5, 1, 29, 1, urledit, 78)};
+
+
+static struct ctk_label savefilenamelabel =
+  {CTK_LABEL(0, 3, 14, 1, "Save filename:")};
+static char savefilename[40];
+static struct ctk_textentry savefilenametextentry =
+  {CTK_TEXTENTRY(15, 3, 19, 1, savefilename, 38)};
+
+static struct ctk_button filebutton =
+  {CTK_BUTTON(0, 5, 13, "Download file")};
+
+static struct ctk_button d64button =
+  {CTK_BUTTON(17, 5, 18, "Download D64 disk")};
+
+static struct ctk_label statustext =
+  {CTK_LABEL(0, 7, 36, 1, "")};
+static char statusmsg[40];
+
+static struct ctk_window d64dialog;
+static struct ctk_label overwritelabel =
+  {CTK_LABEL(0, 1, 36, 1, "This will overwrite the entire disk!")};
+static struct ctk_label makesurelabel1 =
+  {CTK_LABEL(7, 3, 22, 1, "Make sure you have the")};
+static struct ctk_label makesurelabel2 =
+  {CTK_LABEL(6, 4, 24, 1, "right disk in the drive!")};
+static struct ctk_button overwritebutton =
+  {CTK_BUTTON(2, 6, 14, "Overwrite disk")};
+static struct ctk_button cancelbutton =
+  {CTK_BUTTON(26, 6, 6, "Cancel")};
+
+/*static DISPATCHER_SIGHANDLER(wget_sighandler, s, data);
+static struct dispatcher_proc p =
+  {DISPATCHER_PROC("Web downloader", NULL, wget_sighandler, webclient_appcall)};
+  static ek_id_t id;*/
+
+EK_EVENTHANDLER(wget_eventhandler, ev, data);
+EK_PROCESS(p, "Web downloader", EK_PRIO_NORMAL,
+	   wget_eventhandler, NULL, NULL);
+static ek_id_t id = EK_ID_NONE;
+
+/* State */
+
+#define DLOAD_NONE 0
+#define DLOAD_FILE 1
+#define DLOAD_D64  2
+static u8_t dload_state;
+static unsigned long dload_bytes;
+
+
+
+struct drv_state {
+  u8_t track;
+  u8_t sect;
+};
+
+static struct drv_state ds;
+
+static char buffer[256];
+static u16_t bufferptr;
+
+/*-----------------------------------------------------------------------------------*/
+/* wget_init();
+ *
+ * Initializes and starts the web browser. Called either at startup or
+ * to open the browser window.
+ */
+LOADER_INIT_FUNC(wget_init, arg)
+{
+  if(arg != NULL) {
+    strncpy(url, arg, sizeof(url));
+    strncpy(urledit, arg, sizeof(urledit));
+    petsciiconv_topetscii(urledit, sizeof(urledit));
+  } else {
+#ifdef WGET_CONF_URL
+    strncpy(url, WGET_CONF_URL, sizeof(url));
+    strncpy(urledit, WGET_CONF_URL, sizeof(urledit));
+#endif /* WGET_CONF_URL  */
+  }
+  arg_free(arg);
+  
+  if(id == EK_ID_NONE) {
+    id = ek_start(&p);
+
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+show_statustext(char *text)
+{
+  ctk_label_set_text(&statustext, text);
+  CTK_WIDGET_REDRAW(&statustext);
+}
+/*-----------------------------------------------------------------------------------*/
+/* open_url():
+ *
+ * Called when the URL present in the global "url" variable should be
+ * opened. It will call the hostname resolver as well as the HTTP
+ * client requester.
+ */
+static void
+start_get(void)
+{
+  u16_t addr[2];
+  unsigned char i;
+  static char host[32];
+  char *file;
+  register char *urlptr;
+  unsigned short port;
+
+  /* Trim off any spaces in the end of the url. */
+  urlptr = url + strlen(url) - 1;
+  while(*urlptr == ' ' && urlptr > url) {
+    *urlptr = 0;
+    --urlptr;
+  }
+
+  /* Don't even try to go further if the URL is empty. */
+  if(urlptr == url) {
+    return;
+  }
+
+  /* See if the URL starts with http://, otherwise prepend it. */
+  if(strncmp(url, http_http, 7) != 0) {
+    while(urlptr >= url) {
+      *(urlptr + 7) = *urlptr;
+      --urlptr;
+    }
+    strncpy(url, http_http, 7);
+  } 
+
+  /* Find host part of the URL. */
+  urlptr = &url[7];  
+  for(i = 0; i < sizeof(host); ++i) {
+    if(*urlptr == 0 ||
+       *urlptr == '/' ||
+       *urlptr == ' ' ||
+       *urlptr == ':') {
+      host[i] = 0;
+      break;
+    }
+    host[i] = *urlptr;
+    ++urlptr;
+  }
+
+  /* XXX: Here we should find the port part of the URL, but this isn't
+     currently done because of laziness from the programmer's side
+     :-) */
+  
+  /* Find file part of the URL. */
+  while(*urlptr != '/' && *urlptr != 0) {
+    ++urlptr;
+  }
+  if(*urlptr == '/') {
+    file = urlptr;
+  } else {
+    file = "/";
+  }
+      
+  
+  /* First check if the host is an IP address. */
+  if(uiplib_ipaddrconv(host, (unsigned char *)addr) == 0) {    
+    
+    /* Try to lookup the hostname. If it fails, we initiate a hostname
+       lookup and print out an informative message on the
+       statusbar. */
+    if(resolv_lookup(host) == NULL) {
+      resolv_query(host);
+      show_statustext("Resolving host...");
+      return;
+    }
+  }
+
+  /* The hostname we present in the hostname table, so we send out the
+     initial GET request. */
+  if(webclient_get(host, 80, file) == 0) {
+    show_statustext("Out of memory error.");
+  } else {
+    show_statustext("Connecting...");
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+EK_EVENTHANDLER(wget_eventhandler, ev, data)
+{
+  int ret;
+  static unsigned char i;
+  EK_EVENTHANDLER_ARGS(ev, data);
+
+  if(ev == EK_EVENT_INIT) {
+    /* Create the main window. */
+    ctk_window_new(&window, 36, 8, "Web downloader");
+
+    
+    CTK_WIDGET_ADD(&window, &urllabel);
+    CTK_WIDGET_ADD(&window, &urltextentry);
+    
+    CTK_WIDGET_ADD(&window, &savefilenamelabel);
+    CTK_WIDGET_ADD(&window, &savefilenametextentry);
+
+    /*    CTK_WIDGET_ADD(&window, &filebutton);*/
+
+    CTK_WIDGET_ADD(&window, &d64button);
+
+    CTK_WIDGET_ADD(&window, &statustext);
+
+    dload_state = DLOAD_NONE;
+      
+    memset(savefilename, 0, sizeof(savefilename));
+    memset(url, 0, sizeof(url));
+
+    ctk_dialog_new(&d64dialog, 36, 8);
+    CTK_WIDGET_ADD(&d64dialog, &overwritelabel);
+    CTK_WIDGET_ADD(&d64dialog, &makesurelabel1);
+    CTK_WIDGET_ADD(&d64dialog, &makesurelabel2);
+    CTK_WIDGET_ADD(&d64dialog, &overwritebutton);
+    CTK_WIDGET_ADD(&d64dialog, &cancelbutton);
+    
+    
+    ctk_window_open(&window);
+  } else if(ev == tcpip_event) {
+    webclient_appcall(data);
+  } else if(ev == ctk_signal_button_activate) {
+    if(data == (void *)&filebutton) {
+      /*      ret = cbm_open(2, 8, 2, savefilename);
+	      if(ret == -1) {*/
+	sprintf(statusmsg, "Open error with '%s'", savefilename);
+	show_statustext(statusmsg);
+	/*      } else {
+	strncpy(url, urledit, sizeof(url));
+	petsciiconv_toascii(url, sizeof(url));
+	start_get();
+	dload_bytes = 0;
+	dload_state = DLOAD_FILE;
+	}*/
+    } else if(data == (void *)&d64button) {
+      ctk_dialog_open(&d64dialog);
+    } else if(data == (void *)&cancelbutton) {
+      ctk_dialog_close();
+    } else if(data == (void *)&overwritebutton) {
+      ctk_dialog_close();
+
+      /* Turn of screensaver. */
+      program_handler_screensaver(NULL);
+      
+      strncpy(url, urledit, sizeof(url));
+      petsciiconv_toascii(url, sizeof(url));
+      start_get();
+      dload_bytes = 0;
+      dload_state = DLOAD_D64;
+      ds.track = 1;
+      ds.sect = 0;
+      bufferptr = 0;
+#if USE_KERNAL
+#else
+      c64_dio_init(_curunit);
+#endif
+      
+      /*      c64_dio_init(8);*/
+    }
+  } else if(ev == ctk_signal_hyperlink_activate) {
+    if(dload_state == DLOAD_NONE) {
+      /*      open_link(w->widget.hyperlink.url);*/
+      strncpy(urledit,
+	      ((struct ctk_widget *)data)->widget.hyperlink.url, sizeof(urledit));
+      petsciiconv_topetscii(urledit, sizeof(urledit));
+      CTK_WIDGET_REDRAW(&urltextentry);
+      CTK_WIDGET_FOCUS(&window, &urltextentry);
+    }
+  } else if(ev == resolv_event_found) {
+    /* Either found a hostname, or not. */
+    if((char *)data != NULL &&
+       resolv_lookup((char *)data) != NULL) {
+      start_get();
+    } else {
+      show_statustext("Host not found.");
+    }
+  } else if(ev == ctk_signal_window_close) {
+    ek_exit();
+    id = EK_ID_NONE;
+    LOADER_UNLOAD();
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_aborted():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection was abruptly aborted.
+ */
+void
+webclient_aborted(void)
+{
+  show_statustext("Connection reset by peer");
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_timedout():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection timed out.
+ */
+void
+webclient_timedout(void)
+{
+  show_statustext("Connection timed out");
+  if(dload_state == DLOAD_FILE) {
+    cbm_close(2);
+  }
+
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_closed():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection was closed after a request from the "webclient_close()"
+ * function. .
+ */
+void
+webclient_closed(void)
+{  
+  show_statustext("Done.");
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_closed():
+ *
+ * Callback function. Called from the webclient when the HTTP
+ * connection is connected.
+ */
+void
+webclient_connected(void)
+{    
+  show_statustext("Request sent...");
+}
+/*-----------------------------------------------------------------------------------*/
+static u8_t
+next_sector(void)
+{
+  ++ds.sect;
+  if(ds.track < 18) {
+    if(ds.sect == 21) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  } else if(ds.track < 25) {
+    if(ds.sect == 19) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  } else if(ds.track < 31) {
+    if(ds.sect == 18) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  } else if(ds.track < 36) {
+    if(ds.sect == 17) {
+      ++ds.track;
+      ds.sect = 0;
+    }
+  }
+
+  if(ds.track == 36) {
+    return 1;
+  }
+  return 0;
+}
+/*-----------------------------------------------------------------------------------*/
+static void
+x_open(u8_t f, u8_t d, u8_t cmd, u8_t *fname)
+{
+  u8_t ret;
+  
+  ret = cbm_open(f, d, cmd, fname);
+  if(ret != 0) {
+    /*    printf("open: error %d\n", ret);*/
+    /*    ctk_label_set_text(&statuslabel, "Open err");
+	  CTK_WIDGET_REDRAW(&statuslabel);*/
+    show_statustext("Open error");
+  }
+  
+}
+static void
+write_sector(u8_t device, u8_t track, u8_t sect, void *mem)
+{
+  u16_t ret;
+  static u8_t cmd[32];
+  
+  x_open(15, device, 15, NULL);
+  x_open(2, device, 2, "#");
+
+  ret = cbm_write(2, mem, 256);
+  
+  sprintf(cmd, "u2: 2 0 %d %d", track, sect);  
+  cbm_write(15, cmd, strlen(cmd));
+  /*  printf("%s\n", cmd);*/
+    
+
+  /*  ret = 0;*/
+  if(ret == -1) {
+    sprintf(statusmsg, "Write error at %d:%d", track, sect);
+    show_statustext(statusmsg);
+  } else {
+    sprintf(statusmsg, "Wrote %d bytes to %d:%d", ret, track, sect);
+    show_statustext(statusmsg);
+  }
+  /*  printf("write: wrote %d bytes\n", ret);*/
+
+  cbm_close(2);
+  cbm_close(15);
+}
+
+static void
+write_buffer(void)
+{
+#if USE_KERNAL
+  write_sector(8, ds.track, ds.sect, buffer);
+#else
+  c64_dio_write_block(ds.track, ds.sect, buffer);
+#endif
+  if(next_sector() != 0) {
+    dload_state = DLOAD_NONE;
+  }
+}
+static void
+handle_d64_data(char *data, u16_t len)
+{
+  u16_t bufferlen;
+
+  while(dload_state == DLOAD_D64 &&
+	len > 0) {
+    bufferlen = sizeof(buffer) - bufferptr;
+    if(len < bufferlen) {
+      bufferlen = len;
+    }
+    
+    memcpy(&buffer[bufferptr], data, bufferlen);
+
+    data += bufferlen;
+    bufferptr += bufferlen;
+    len -= bufferlen;
+    
+    if(bufferptr == sizeof(buffer)) {
+      write_buffer();
+      bufferptr = 0;
+    }
+  }
+}
+/*-----------------------------------------------------------------------------------*/
+/* webclient_datahandler():   
+ *
+ * Callback function. Called from the webclient module when HTTP data
+ * has arrived.
+ */
+void
+webclient_datahandler(char *data, u16_t len)
+{
+  int ret;
+  
+  if(len > 0) {
+    dload_bytes += len;    
+    sprintf(statusmsg, "Downloading (%lu bytes)", dload_bytes);
+    show_statustext(statusmsg);
+    if(dload_state == DLOAD_D64) {
+      handle_d64_data(data, len);
+    } else if(dload_state == DLOAD_FILE) {      
+      ret = cbm_write(2, data, len);       
+      if(ret != len) {
+	sprintf(statusmsg, "Wrote only %d bytes", ret);
+	  show_statustext(statusmsg);	  
+      }
+    }
+  }
+  
+  if(data == NULL) {
+    if(dload_state == DLOAD_FILE) {
+      cbm_close(2);
+    }
+    dload_state = DLOAD_NONE;
+    sprintf(statusmsg, "Finished downloading %lu bytes", dload_bytes);
+    show_statustext(statusmsg);
+  }
+}
+/*-----------------------------------------------------------------------------------*/