From a70fbf1bbfd773da90f8e01dabac1d65ef2d0cf6 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Sun, 21 Jun 2015 21:07:41 +0200 Subject: [PATCH] Reconfigured Telnet server. In order to have the wget command make some sense the write command should be present too. - On the Apple][ reduction of the MTU seems to gain just enough RAM to have the (rather heavy-weight) full-blown C library file I/O working. - On the C128 there's way too little RAM so there's no wget command but only the file commands. - On the CBMs a dummy lseek() was necessary to have the read command link. --- apps/shell/shell-file.c | 28 ++++++------ .../telnet-server/Makefile.apple2enh.defines | 2 +- .../telnet-server/Makefile.atarixl.defines | 2 +- examples/telnet-server/Makefile.c128.defines | 2 +- examples/telnet-server/Makefile.c64.defines | 2 +- examples/telnet-server/telnet-server.c | 11 ++--- platform/c128/Makefile.c128 | 2 +- platform/c128/lib/lseek.c | 43 +++++++++++++++++++ platform/c64/Makefile.c64 | 2 +- platform/c64/lib/lseek.c | 43 +++++++++++++++++++ 10 files changed, 111 insertions(+), 26 deletions(-) create mode 100644 platform/c128/lib/lseek.c create mode 100644 platform/c64/lib/lseek.c diff --git a/apps/shell/shell-file.c b/apps/shell/shell-file.c index 07f6f3d5d..4376c68a3 100644 --- a/apps/shell/shell-file.c +++ b/apps/shell/shell-file.c @@ -51,7 +51,7 @@ PROCESS(shell_ls_process, "ls"); SHELL_COMMAND(ls_command, "ls", - "ls: list files", + "ls : list files", &shell_ls_process); PROCESS(shell_append_process, "append"); SHELL_COMMAND(append_command, @@ -82,19 +82,21 @@ PROCESS_THREAD(shell_ls_process, ev, data) char buf[32]; PROCESS_BEGIN(); - if(cfs_opendir(&dir, "/") != 0) { - shell_output_str(&ls_command, "Cannot open directory", ""); - } else { - totsize = 0; - while(cfs_readdir(&dir, &dirent) == 0) { - totsize += dirent.size; - sprintf(buf, "%lu ", (unsigned long)dirent.size); - /* printf("'%s'\n", dirent.name);*/ - shell_output_str(&ls_command, buf, dirent.name); + if(data != NULL) { + if(cfs_opendir(&dir, data) != 0) { + shell_output_str(&ls_command, "Cannot open directory", ""); + } else { + totsize = 0; + while(cfs_readdir(&dir, &dirent) == 0) { + totsize += dirent.size; + sprintf(buf, "%lu ", (unsigned long)dirent.size); + /* printf("'%s'\n", dirent.name);*/ + shell_output_str(&ls_command, buf, dirent.name); + } + cfs_closedir(&dir); + sprintf(buf, "%lu", (unsigned long)totsize); + shell_output_str(&ls_command, "Total size: ", buf); } - cfs_closedir(&dir); - sprintf(buf, "%lu", (unsigned long)totsize); - shell_output_str(&ls_command, "Total size: ", buf); } PROCESS_END(); } diff --git a/examples/telnet-server/Makefile.apple2enh.defines b/examples/telnet-server/Makefile.apple2enh.defines index 3dbfd3e2f..c11112c3c 100644 --- a/examples/telnet-server/Makefile.apple2enh.defines +++ b/examples/telnet-server/Makefile.apple2enh.defines @@ -1 +1 @@ -DEFINES = WITH_LOGGING,WITH_CLIENT,WITH_DNS,WITH_PFS +DEFINES = CONNECTIONS=3,WITH_LOGGING,WITH_CLIENT,WITH_DNS,MTU_SIZE=1000 diff --git a/examples/telnet-server/Makefile.atarixl.defines b/examples/telnet-server/Makefile.atarixl.defines index 405794c09..bcd39d550 100644 --- a/examples/telnet-server/Makefile.atarixl.defines +++ b/examples/telnet-server/Makefile.atarixl.defines @@ -1 +1 @@ -DEFINES = WITH_LOGGING,WITH_CLIENT,WITH_DNS +DEFINES = CONNECTIONS=3,WITH_LOGGING,WITH_CLIENT,WITH_DNS diff --git a/examples/telnet-server/Makefile.c128.defines b/examples/telnet-server/Makefile.c128.defines index 84c86ef72..5e74716aa 100644 --- a/examples/telnet-server/Makefile.c128.defines +++ b/examples/telnet-server/Makefile.c128.defines @@ -1 +1 @@ -DEFINES = WITH_LOGGING,WITH_CLIENT,WITH_DNS,WITH_PFS,CONNECTIONS=2,MTU_SIZE=500 +DEFINES = WITH_LOGGING diff --git a/examples/telnet-server/Makefile.c64.defines b/examples/telnet-server/Makefile.c64.defines index 3dbfd3e2f..bcd39d550 100644 --- a/examples/telnet-server/Makefile.c64.defines +++ b/examples/telnet-server/Makefile.c64.defines @@ -1 +1 @@ -DEFINES = WITH_LOGGING,WITH_CLIENT,WITH_DNS,WITH_PFS +DEFINES = CONNECTIONS=3,WITH_LOGGING,WITH_CLIENT,WITH_DNS diff --git a/examples/telnet-server/telnet-server.c b/examples/telnet-server/telnet-server.c index a0862886e..0164d2744 100644 --- a/examples/telnet-server/telnet-server.c +++ b/examples/telnet-server/telnet-server.c @@ -48,21 +48,18 @@ PROCESS_THREAD(shell_init_process, ev, data) { PROCESS_BEGIN(); -#ifdef __CC65__ - shell_ps_init(); - shell_netstat_init(); - shell_wget_init(); - shell_memdebug_init(); -#else /* __CC65__ */ shell_file_init(); +#ifndef __CC65__ shell_httpd_init(); shell_irc_init(); shell_ps_init(); shell_run_init(); shell_text_init(); shell_time_init(); +#endif /* !__CC65__ */ +#ifndef __C128__ shell_wget_init(); -#endif /* __CC65__ */ +#endif /* !__C128__ */ PROCESS_END(); } diff --git a/platform/c128/Makefile.c128 b/platform/c128/Makefile.c128 index 6b73ff04c..b186fac60 100644 --- a/platform/c128/Makefile.c128 +++ b/platform/c128/Makefile.c128 @@ -31,7 +31,7 @@ # Author: Oliver Schmidt # -CONTIKI_TARGET_SOURCEFILES += pfs.S pfs_write.S +CONTIKI_TARGET_SOURCEFILES += lseek.c pfs.S pfs_write.S CONTIKI_CPU = $(CONTIKI)/cpu/6502 include $(CONTIKI_CPU)/Makefile.6502 diff --git a/platform/c128/lib/lseek.c b/platform/c128/lib/lseek.c new file mode 100644 index 000000000..d79f9e529 --- /dev/null +++ b/platform/c128/lib/lseek.c @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2007, 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 Contiki operating system. + * + * Author: Oliver Schmidt + * + */ + +#include + +/*-----------------------------------------------------------------------------------*/ +off_t +__fastcall__ lseek(int fd, off_t offset, int whence) +{ + return (off_t)-1; +} +/*-----------------------------------------------------------------------------------*/ diff --git a/platform/c64/Makefile.c64 b/platform/c64/Makefile.c64 index ddc94d586..ed548463b 100644 --- a/platform/c64/Makefile.c64 +++ b/platform/c64/Makefile.c64 @@ -31,7 +31,7 @@ # Author: Oliver Schmidt # -CONTIKI_TARGET_SOURCEFILES += pfs.S pfs_write.S +CONTIKI_TARGET_SOURCEFILES += lseek.c pfs.S pfs_write.S CONTIKI_CPU = $(CONTIKI)/cpu/6502 include $(CONTIKI_CPU)/Makefile.6502 diff --git a/platform/c64/lib/lseek.c b/platform/c64/lib/lseek.c new file mode 100644 index 000000000..d79f9e529 --- /dev/null +++ b/platform/c64/lib/lseek.c @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2007, 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 Contiki operating system. + * + * Author: Oliver Schmidt + * + */ + +#include + +/*-----------------------------------------------------------------------------------*/ +off_t +__fastcall__ lseek(int fd, off_t offset, int whence) +{ + return (off_t)-1; +} +/*-----------------------------------------------------------------------------------*/