From e031e6192efdefe8d3cc24279c63008b4bf0309c Mon Sep 17 00:00:00 2001 From: Emanuele Aliberti Date: Sun, 20 Jan 2002 21:22:29 +0000 Subject: [PATCH] Bare shell for testing the PSX subsystem (not ready yet). svn path=/trunk/; revision=2531 --- posix/apps/baresh/Makefile | 33 +++++++++++++++++++++ posix/apps/baresh/sh.c | 60 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 posix/apps/baresh/Makefile create mode 100644 posix/apps/baresh/sh.c diff --git a/posix/apps/baresh/Makefile b/posix/apps/baresh/Makefile new file mode 100644 index 00000000000..7d811aee163 --- /dev/null +++ b/posix/apps/baresh/Makefile @@ -0,0 +1,33 @@ +# $Id: Makefile,v 1.1 2002/01/20 21:22:29 ea Exp $ +# +# Tu run it in Win32 console mode, undefine __SUBSYSTEM_WINDOWS__ +# and pass "console" in the ld's --subsystem option. +# +# +PATH_TO_TOP=../../../.. + +PATH_TO_PSX_TOP=../.. + +TARGET_NAME=sh + +CFLAGS=-D__SUBSYSTEM_WINDOWS__ + +OBJECTS=$(TARGET_NAME).o + +LIBRARIES=\ + $(PATH_TO_PSX_TOP)/lib/crt0w32.o \ + $(PATH_TO_PSX_TOP)/lib/psxdll/psxdll.a + +$(TARGET_NAME): $(OBJECTS) $(LIBRARIES) + $(CC) \ + $(CFLAGS) \ + $(OBJECTS) \ + $(LIBRARIES)\ + -o $@ \ + -Wl,--subsystem,windows\ + -nostartfiles \ + -nostdlib + +include $(PATH_TO_TOP)/rules.mak + +# EOF diff --git a/posix/apps/baresh/sh.c b/posix/apps/baresh/sh.c new file mode 100644 index 00000000000..bb248c5e317 --- /dev/null +++ b/posix/apps/baresh/sh.c @@ -0,0 +1,60 @@ +/* $Id: sh.c,v 1.1 2002/01/20 21:22:29 ea Exp $ + * + * baresh - Bare Shell for the PSX subsystem. + * Copyright (c) 2002 Emanuele Aliberti + * License: GNU GPL v2 + */ +#include +#include +#include + +#define INPUT_BUFFER_SIZE 128 + +int run=1; + +void cmd_exit(char*buf) +{ + run=0; +} + +void cmd_pwd(char * buf) +{ + char pwd[1024]; + + getcwd(pwd,sizeof pwd); + printf("%s\n",pwd); +} + +void cmd_ls(char*buf) +{ + char pwd[1024]; + DIR * dir; + struct dirent * entry; + + getcwd(pwd,sizeof pwd); + dir=opendir(pwd); + while (NULL!=(entry=readdir(dir))) + { + printf("%s\n",entry->d_name); + } + closedir(dir); +} + +int main(int argc,char*argv[]) +{ + char buf[INPUT_BUFFER_SIZE]; + + while (run) + { + printf("# "); + if (gets(buf)) + { + if (!strcmp("exit",buf)) cmd_exit(buf); + else if (!strcmp("pwd",buf)) cmd_pwd(buf); + else if (!strcmp("ls",buf)) cmd_ls(buf); + else printf("%s: unknown command\n",argv[0]); + } + } + return 0; +} +/* EOF */ -- 2.17.1