diff options
author | Ralf Corsepius <ralf.corsepius@rtems.org> | 2002-12-12 03:59:25 +0000 |
---|---|---|
committer | Ralf Corsepius <ralf.corsepius@rtems.org> | 2002-12-12 03:59:25 +0000 |
commit | 7fe03217c8facf2fd90b29c31928e6d090f4e19c (patch) | |
tree | e7dfd9e9146944f1529dc5edab5b25dc4c22cd9f /c/src/libmisc/shell | |
parent | 2002-12-12 Ralf Corsepius <corsepius@faw.uni-ulm.de> (diff) | |
download | rtems-7fe03217c8facf2fd90b29c31928e6d090f4e19c.tar.bz2 |
2002-12-12 Ralf Corsepius <corsepius@faw.uni-ulm.de>
* .cvsignore: Moved to rtems/cpukit/libmisc.
* ChangeLog: Moved to rtems/cpukit/libmisc.
* Makefile.am: Moved to rtems/cpukit/libmisc.
* README: Moved to rtems/cpukit/libmisc.
* configure.ac: Moved to rtems/cpukit/libmisc.
* capture/Makefile.am: Moved to rtems/cpukit/libmisc.
* capture/README: Moved to rtems/cpukit/libmisc.
* capture/capture-cli.c: Moved to rtems/cpukit/libmisc.
* capture/capture-cli.h: Moved to rtems/cpukit/libmisc.
* capture/capture.c: Moved to rtems/cpukit/libmisc.
* capture/capture.h: Moved to rtems/cpukit/libmisc.
* cpuuse/Makefile.am: Moved to rtems/cpukit/libmisc.
* cpuuse/README: Moved to rtems/cpukit/libmisc.
* cpuuse/cpuuse.c: Moved to rtems/cpukit/libmisc.
* cpuuse/cpuuse.h: Moved to rtems/cpukit/libmisc.
* devnull/.cvsignore: Moved to rtems/cpukit/libmisc.
* devnull/Makefile.am: Moved to rtems/cpukit/libmisc.
* devnull/devnull.c: Moved to rtems/cpukit/libmisc.
* devnull/devnull.h: Moved to rtems/cpukit/libmisc.
* dummy/.cvsignore: Moved to rtems/cpukit/libmisc.
* dummy/Makefile.am: Moved to rtems/cpukit/libmisc.
* dummy/README: Moved to rtems/cpukit/libmisc.
* dummy/dummy.c: Moved to rtems/cpukit/libmisc.
* dumpbuf/.cvsignore: Moved to rtems/cpukit/libmisc.
* dumpbuf/Makefile.am: Moved to rtems/cpukit/libmisc.
* dumpbuf/dumpbuf.c: Moved to rtems/cpukit/libmisc.
* dumpbuf/dumpbuf.h: Moved to rtems/cpukit/libmisc.
* monitor/.cvsignore: Moved to rtems/cpukit/libmisc.
* monitor/Makefile.am: Moved to rtems/cpukit/libmisc.
* monitor/README: Moved to rtems/cpukit/libmisc.
* monitor/mon-command.c: Moved to rtems/cpukit/libmisc.
* monitor/mon-config.c: Moved to rtems/cpukit/libmisc.
* monitor/mon-dname.c: Moved to rtems/cpukit/libmisc.
* monitor/mon-driver.c: Moved to rtems/cpukit/libmisc.
* monitor/mon-extension.c: Moved to rtems/cpukit/libmisc.
* monitor/mon-itask.c: Moved to rtems/cpukit/libmisc.
* monitor/mon-manager.c: Moved to rtems/cpukit/libmisc.
* monitor/mon-monitor.c: Moved to rtems/cpukit/libmisc.
* monitor/mon-mpci.c: Moved to rtems/cpukit/libmisc.
* monitor/mon-object.c: Moved to rtems/cpukit/libmisc.
* monitor/mon-prmisc.c: Moved to rtems/cpukit/libmisc.
* monitor/mon-queue.c: Moved to rtems/cpukit/libmisc.
* monitor/mon-server.c: Moved to rtems/cpukit/libmisc.
* monitor/mon-symbols.c: Moved to rtems/cpukit/libmisc.
* monitor/mon-task.c: Moved to rtems/cpukit/libmisc.
* monitor/monitor.h: Moved to rtems/cpukit/libmisc.
* monitor/symbols.h: Moved to rtems/cpukit/libmisc.
* mw-fb/.cvsignore: Moved to rtems/cpukit/libmisc.
* mw-fb/Makefile.am: Moved to rtems/cpukit/libmisc.
* mw-fb/mw_fb.c: Moved to rtems/cpukit/libmisc.
* mw-fb/mw_fb.h: Moved to rtems/cpukit/libmisc.
* mw-fb/mw_uid.c: Moved to rtems/cpukit/libmisc.
* mw-fb/mw_uid.h: Moved to rtems/cpukit/libmisc.
* rtmonuse/.cvsignore: Moved to rtems/cpukit/libmisc.
* rtmonuse/Makefile.am: Moved to rtems/cpukit/libmisc.
* rtmonuse/rtmonuse.c: Moved to rtems/cpukit/libmisc.
* rtmonuse/rtmonuse.h: Moved to rtems/cpukit/libmisc.
* serdbg/.cvsignore: Moved to rtems/cpukit/libmisc.
* serdbg/Makefile.am: Moved to rtems/cpukit/libmisc.
* serdbg/README: Moved to rtems/cpukit/libmisc.
* serdbg/serdbg.c: Moved to rtems/cpukit/libmisc.
* serdbg/serdbg.h: Moved to rtems/cpukit/libmisc.
* serdbg/serdbgcnf.h: Moved to rtems/cpukit/libmisc.
* serdbg/serdbgio.c: Moved to rtems/cpukit/libmisc.
* serdbg/termios_printk.c: Moved to rtems/cpukit/libmisc.
* serdbg/termios_printk.h: Moved to rtems/cpukit/libmisc.
* serdbg/termios_printk_cnf.h: Moved to rtems/cpukit/libmisc.
* shell/.cvsignore: Moved to rtems/cpukit/libmisc.
* shell/Makefile.am: Moved to rtems/cpukit/libmisc.
* shell/README: Moved to rtems/cpukit/libmisc.
* shell/cmds.c: Moved to rtems/cpukit/libmisc.
* shell/shell.c: Moved to rtems/cpukit/libmisc.
* shell/shell.h: Moved to rtems/cpukit/libmisc.
* stackchk/.cvsignore: Moved to rtems/cpukit/libmisc.
* stackchk/Makefile.am: Moved to rtems/cpukit/libmisc.
* stackchk/README: Moved to rtems/cpukit/libmisc.
* stackchk/check.c: Moved to rtems/cpukit/libmisc.
* stackchk/internal.h: Moved to rtems/cpukit/libmisc.
* stackchk/stackchk.h: Moved to rtems/cpukit/libmisc.
* untar/.cvsignore: Moved to rtems/cpukit/libmisc.
* untar/Makefile.am: Moved to rtems/cpukit/libmisc.
* untar/README: Moved to rtems/cpukit/libmisc.
* untar/untar.c: Moved to rtems/cpukit/libmisc.
* untar/untar.h: Moved to rtems/cpukit/libmisc.
* wrapup/.cvsignore: Moved to rtems/cpukit/libmisc.
* wrapup/Makefile.am: Moved to rtems/cpukit/libmisc.
Diffstat (limited to 'c/src/libmisc/shell')
-rw-r--r-- | c/src/libmisc/shell/.cvsignore | 2 | ||||
-rw-r--r-- | c/src/libmisc/shell/Makefile.am | 46 | ||||
-rw-r--r-- | c/src/libmisc/shell/README | 27 | ||||
-rw-r--r-- | c/src/libmisc/shell/cmds.c | 524 | ||||
-rw-r--r-- | c/src/libmisc/shell/shell.c | 682 | ||||
-rw-r--r-- | c/src/libmisc/shell/shell.h | 88 |
6 files changed, 0 insertions, 1369 deletions
diff --git a/c/src/libmisc/shell/.cvsignore b/c/src/libmisc/shell/.cvsignore deleted file mode 100644 index 282522db03..0000000000 --- a/c/src/libmisc/shell/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in diff --git a/c/src/libmisc/shell/Makefile.am b/c/src/libmisc/shell/Makefile.am deleted file mode 100644 index b1ef9c5574..0000000000 --- a/c/src/libmisc/shell/Makefile.am +++ /dev/null @@ -1,46 +0,0 @@ -## -## $Id$ -## - - -include_rtemsdir = $(includedir)/rtems - -LIBNAME = libshell-tmp -LIB = $(ARCH)/$(LIBNAME).a - -C_FILES = cmds.c shell.c -C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.$(OBJEXT)) - -if RTEMS_LIBSHELL -include_rtems_HEADERS = shell.h -endif - -OBJS = $(C_O_FILES) - -include $(top_srcdir)/../../../automake/compile.am -include $(top_srcdir)/../../../automake/lib.am - -$(PROJECT_INCLUDE)/rtems: - @$(mkinstalldirs) $@ -$(PROJECT_INCLUDE)/rtems/%.h: %.h - $(INSTALL_DATA) $< $@ - -# -# (OPTIONAL) Add local stuff here using += -# - -$(LIB): $(OBJS) - $(make-library) - -PREINSTALL_FILES = $(PROJECT_INCLUDE)/rtems \ - $(include_rtems_HEADERS:%=$(PROJECT_INCLUDE)/rtems/%) - -if RTEMS_LIBSHELL -all-local: $(ARCH) $(PREINSTALL_FILES) $(OBJS) $(LIB) -endif - -.PRECIOUS: $(LIB) - -EXTRA_DIST = README shell.c cmds.c shell.h - -include $(top_srcdir)/../../../automake/local.am diff --git a/c/src/libmisc/shell/README b/c/src/libmisc/shell/README deleted file mode 100644 index 9798becc37..0000000000 --- a/c/src/libmisc/shell/README +++ /dev/null @@ -1,27 +0,0 @@ -# -# $Id$ -# - -This directory contains a shell user extension -primary features: - - + create a user shell terminal task. - -This code has not been extensively tested. It is provided as a tool -for RTEMS users to open more shell terminal. -Suggestions and comments are appreciated. - -NOTES: - -1. printf() & getchar() works but you can't use - 0,1,2 like fildes. You need to use fileno(stdin),fileno(stdout),... - -2. You only need a termios dev to start a new session, add your new commands - and enjoy it. - -3. Telnetd daemon uses this (browse libnetworking/rtems_telnetd) - Enjoy it. - -FUTURE: - -1. Adding new commands in cmds.c to give file manegement to shell. diff --git a/c/src/libmisc/shell/cmds.c b/c/src/libmisc/shell/cmds.c deleted file mode 100644 index 4b7cb668f4..0000000000 --- a/c/src/libmisc/shell/cmds.c +++ /dev/null @@ -1,524 +0,0 @@ -/* - * Author: Fernando RUIZ CASAS - * - * Work: fernando.ruiz@ctv.es - * Home: correo@fernando-ruiz.com - * - * This file is inspired in rtems_monitor & Chris John MyRightBoot - * - * But I want to make it more user friendly - * A 'monitor' command is added to adapt the call rtems monitor commands - * at my call procedure - * - * TODO: A lot of improvements of course. - * cp, mv, ... - * hexdump, - * - * More? Say me it, please... - * - * The BSP Specific are not welcome here. - * - * C&S welcome... - * - * $Id$ - */ - -#include <stdio.h> -#include <termios.h> -#include <string.h> -#include <stdlib.h> -#include <ctype.h> -#include <dirent.h> -#include <time.h> -#include <fcntl.h> -#include <unistd.h> -#include <pwd.h> -#include <grp.h> -#include <errno.h> -#include <sys/types.h> -#include <stddef.h> - -#include <rtems.h> -#include <rtems/monitor.h> -#include <rtems/score/tod.h> - -#include <imfs.h> -#include <rtems/shell.h> - -/* ----------------------------------------------- * - - str to int "0xaffe" "0b010010" "0123" "192939" - * ----------------------------------------------- */ -int str2int(char * s) { - int sign=1; - int base=10; - int value=0; - int digit; - if (!s) return 0; - if (*s) { - if (*s=='-') { - sign=-1; - s++; - if (!*s) return 0; - }; - if (*s=='0') { - s++; - switch(*s) { - case 'x': - case 'X':s++; - base=16; - break; - case 'b': - case 'B':s++; - base=2; - break; - default :base=8; - break; - } - }; - while (*s) { - switch(*s) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9':digit=*s-'0'; - break; - case 'A': - case 'B': - case 'C': - case 'D': - case 'E': - case 'F':digit=*s-'A'+10; - break; - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f':digit=*s-'a'+10; - break; - default:return value*sign; - }; - if (digit>base) return value*sign; - value=value*base+digit; - s++; - }; - }; - return value*sign; -} -/*----------------------------------------------------------------------------* - * RAM MEMORY COMMANDS - *----------------------------------------------------------------------------*/ - -#define mdump_adr (current_shell_env->mdump_adr) /* static value */ - -int main_mdump(int argc,char * argv[]) { - unsigned char n,m,max=0; - int adr=mdump_adr; - unsigned char * pb; - if (argc>1) adr=str2int(argv[1]); - if (argc>2) max=str2int(argv[2]); - max/=16; - if (!max) max=20; - for (m=0;m<max;m++) { - printf("0x%08X ",adr); - pb=(unsigned char*) adr; - for (n=0;n<16;n++) - printf("%02X%c",pb[n],n==7?'-':' '); - for (n=0;n<16;n++) { - printf("%c",isprint(pb[n])?pb[n]:'.'); - }; - printf("\n"); - adr+=16; - }; - mdump_adr=adr; - return 0; -} -/*----------------------------------------------------------------------------*/ -int main_mwdump(int argc,char * argv[]) { - unsigned char n,m,max=0; - int adr=mdump_adr; - unsigned short * pw; - if (argc>1) adr=str2int(argv[1]); - if (argc>2) max=str2int(argv[2]); - max/=16; - if (!max) max=20; - for (m=0;m<max;m++) { - printf("0x%08X ",adr); - pw=(unsigned short*) adr; - for (n=0;n<8;n++) - printf("%02X %02X%c",pw[n]/0x100,pw[n]%0x100,n==3?'-':' '); - for (n=0;n<8;n++) { - printf("%c",isprint(pw[n]/0x100)?pw[n]/0x100:'.'); - printf("%c",isprint(pw[n]%0x100)?pw[n]%0x100:'.'); - }; - printf("\n"); - adr+=16; - }; - mdump_adr=adr; - return 0; -} -/*----------------------------------------------------------------------------*/ -int main_medit(int argc,char * argv[]) { - unsigned char * pb; - int n,i; - if (argc<3) { - printf("too few arguments\n"); - return 0; - }; - pb=(unsigned char*)str2int(argv[1]); - i=2; - n=0; - while (i<=argc) { - pb[n++]=str2int(argv[i++])%0x100; - } - mdump_adr=(int)pb; - return main_mdump(0,NULL); -} -/*----------------------------------------------------------------------------*/ -int main_mfill(int argc,char * argv[]) { - int adr; - int size; - unsigned char value; - if (argc<4) { - printf("too few arguments\n"); - return 0; - }; - adr =str2int(argv[1]); - size =str2int(argv[2]); - value=str2int(argv[3])%0x100; - memset((unsigned char*)adr,size,value); - mdump_adr=adr; - return main_mdump(0,NULL); -} -/*----------------------------------------------------------------------------*/ -int main_mmove(int argc,char * argv[]) { - int src; - int dst; - int size; - if (argc<4) { - printf("too few arguments\n"); - return 0; - }; - dst =str2int(argv[1]); - src =str2int(argv[2]); - size =str2int(argv[3]); - memcpy((unsigned char*)dst,(unsigned char*)src,size); - mdump_adr=dst; - return main_mdump(0,NULL); -} -/*----------------------------------------------------------------------------*/ -#ifdef MALLOC_STATS /* /rtems/s/src/lib/libc/malloc.c */ -int main_malloc_dump(int argc,char * argv[]) { - void malloc_dump(void); - malloc_dump(); - return 0; -} -#endif -/*---------------------------------------------------------------------------- - * Reset. Assumes that the watchdog is present. - *----------------------------------------------------------------------------*/ -int main_reset (int argc, char **argv) -{ - rtems_interrupt_level level; - printf ("Waiting for watchdog ... "); - tcdrain(fileno(stdout)); - - rtems_interrupt_disable (level); - for (;;) - ; - return 0; -} -/*---------------------------------------------------------------------------- - * Alias. make an alias - *----------------------------------------------------------------------------*/ -int main_alias (int argc, char **argv) -{ - if (argc<3) { - printf("too few arguments\n"); - return 1; - }; - if (!shell_alias_cmd(argv[1],argv[2])) { - printf("unable to make an alias(%s,%s)\n",argv[1],argv[2]); - }; - return 0; -} -/*-----------------------------------------------------------* - * Directory commands - *-----------------------------------------------------------*/ -int main_ls(int argc, char *argv[]) -{ - char * fname; - DIR *dirp; - struct dirent *dp; - struct stat stat_buf; - struct passwd * pwd; - struct group * grp; - char * user; - char * group; - char sbuf[256]; - char nbuf[1024]; - int n,size; - - fname="."; - if (argc>1) fname=argv[1]; - - if ((dirp = opendir(fname)) == NULL) - { - printf("%s: No such file or directory.\n", fname); - return errno; - } - n=0; - size=0; - while ((dp = readdir(dirp)) != NULL) - { - strcpy(nbuf,fname); - if (nbuf[strlen(nbuf)-1]!='/') strcat(nbuf,"/"); - strcat(nbuf,dp->d_name); /* always the fullpathname. Avoid ftpd problem.*/ - if (stat(nbuf, &stat_buf) == 0) - { /* AWFUL buts works...*/ - strftime(sbuf,sizeof(sbuf)-1,"%b %d %H:%M",gmtime(&stat_buf.st_atime)); - pwd=getpwuid(stat_buf.st_uid); - user=pwd?pwd->pw_name:"nouser"; - grp=getgrgid(stat_buf.st_gid); - group=grp?grp->gr_name:"nogrp"; - printf("%c%c%c%c%c%c%c%c%c%c %3d %6.6s %6.6s %11d %s %s%c\n", - (S_ISLNK(stat_buf.st_mode)?('l'): - (S_ISDIR(stat_buf.st_mode)?('d'):('-'))), - (stat_buf.st_mode & S_IRUSR)?('r'):('-'), - (stat_buf.st_mode & S_IWUSR)?('w'):('-'), - (stat_buf.st_mode & S_IXUSR)?('x'):('-'), - (stat_buf.st_mode & S_IRGRP)?('r'):('-'), - (stat_buf.st_mode & S_IWGRP)?('w'):('-'), - (stat_buf.st_mode & S_IXGRP)?('x'):('-'), - (stat_buf.st_mode & S_IROTH)?('r'):('-'), - (stat_buf.st_mode & S_IWOTH)?('w'):('-'), - (stat_buf.st_mode & S_IXOTH)?('x'):('-'), - (int)stat_buf.st_nlink, - user,group, - (int)stat_buf.st_size, - sbuf, - dp->d_name, - S_ISDIR(stat_buf.st_mode)?'/':' '); - n++; - size+=stat_buf.st_size; - } - } - printf("%d files %d bytes occupied\n",n,size); - closedir(dirp); - return 0; -} -/*-----------------------------------------------------------*/ -int main_pwd (int argc, char *argv[]) { - char dir[1024]; - getcwd(dir,1024); - printf("%s\n",dir); - return 0; -} -/*-----------------------------------------------------------*/ -int main_chdir (int argc, char *argv[]) { - char *dir; - dir="/"; - if (argc>1) dir=argv[1]; - if (chdir(dir)) { - printf("chdir to '%s' failed:%s\n",dir,strerror(errno)); - return errno; - }; - return 0; -} -/*-----------------------------------------------------------*/ -int main_mkdir (int argc, char *argv[]) { - char *dir; - int n; - n=1; - while (n<argc) { - dir=argv[n++]; - if (mkdir(dir,S_IRWXU|S_IRWXG|S_IRWXO)) { - printf("mkdir '%s' failed:%s\n",dir,strerror(errno)); - }; - }; - return errno; -} -/*-----------------------------------------------------------*/ -int main_rmdir (int argc, char *argv[]) -{ - char *dir; - int n; - n=1; - while (n<argc) { - dir=argv[n++]; - if (rmdir(dir)) printf("rmdir '%s' failed:%s\n",dir,strerror(errno)); - }; - return errno; -} -/*-----------------------------------------------------------*/ -int main_chroot(int argc,char * argv[]) { - char * new_root="/"; - if (argc==2) new_root=argv[1]; - if (chroot(new_root)<0) { - printf("error %s:chroot(%s);\n",strerror(errno),new_root); - return -1; - }; - return 0; -} -/*-----------------------------------------------------------*/ -int main_cat (int argc, char *argv[]) -{ - int n; - n=1; - while (n<argc) cat_file(stdout,argv[n++]); - return 0; -} -/*-----------------------------------------------------------*/ -int main_rm (int argc, char *argv[]) -{ - int n; - n=1; - while (n<argc) { - if (unlink(argv[n])) { - printf("error %s:rm %s\n",strerror(errno),argv[n]); - return -1; - }; - n++; - }; - return 0; -} -/*-----------------------------------------------------------*/ -/* date - print time and date */ - -int main_date(int argc,char *argv[]) -{ - time_t t; - time(&t); - printf("%s", ctime(&t)); - return 0; -} -/*-----------------------------------------------------------*/ -int main_logoff(int argc,char *argv[]) -{ - printf("logoff from the system..."); - current_shell_env->exit_shell=TRUE; - return 0; -} -/*-----------------------------------------------------------*/ -int main_tty (int argc,char *argv[]) -{ - printf("%s\n",ttyname(fileno(stdin))); - return 0; -} -/*-----------------------------------------------------------*/ -int main_whoami(int argc,char *argv[]) -{ - struct passwd * pwd; - pwd=getpwuid(getuid()); - printf("%s\n",pwd?pwd->pw_name:"nobody"); - return 0; -} -/*-----------------------------------------------------------*/ -int main_id (int argc,char *argv[]) -{ - struct passwd * pwd; - struct group * grp; - pwd=getpwuid(getuid()); - grp=getgrgid(getgid()); - printf("uid=%d(%s),gid=%d(%s),", - getuid(),pwd?pwd->pw_name:"", - getgid(),grp?grp->gr_name:""); - pwd=getpwuid(geteuid()); - grp=getgrgid(getegid()); - printf("euid=%d(%s),egid=%d(%s)\n", - geteuid(),pwd?pwd->pw_name:"", - getegid(),grp?grp->gr_name:""); - return 0; -} -/*-----------------------------------------------------------*/ -int main_umask(int argc,char *argv[]) -{ - mode_t msk=umask(0); - if (argc == 2) msk=str2int(argv[1]); - umask(msk); - msk=umask(0); - printf("0%o\n",msk); - umask(msk); - return 0; -} -/*-----------------------------------------------------------*/ -int main_chmod(int argc,char *argv[]) -{ - int n; - mode_t mode; - if (argc > 2){ - mode=str2int(argv[1])&0777; - n=2; - while (n<argc) chmod(argv[n++],mode); - }; - return 0; -} -/*-----------------------------------------------------------* - * with this you can call at all the rtems monitor commands. - * Not all work fine but you can show the rtems status and more. - *-----------------------------------------------------------*/ -int main_monitor(int argc,char * argv[]) { - rtems_monitor_command_entry_t *command; - extern rtems_monitor_command_entry_t rtems_monitor_commands[]; - rtems_task_ident(RTEMS_SELF,0,&rtems_monitor_task_id); - rtems_monitor_node = rtems_get_node(rtems_monitor_task_id); - rtems_monitor_default_node = rtems_monitor_node; - if ((command=rtems_monitor_command_lookup(rtems_monitor_commands,argc,argv))) - command->command_function(argc, argv, command->command_arg, 0); - return 0; -} -/*-----------------------------------------------------------*/ -void register_cmds(void) { - rtems_monitor_command_entry_t *command; - extern rtems_monitor_command_entry_t rtems_monitor_commands[]; - /* monitor topic */ - command=rtems_monitor_commands; - while (command) { - if (strcmp("exit",command->command)) /*Exclude EXIT (alias quit)*/ - shell_add_cmd(command->command,"monitor", - command->usage ,main_monitor); - command=command->next; - }; - /* dir[ectories] topic */ - shell_add_cmd ("ls" ,"dir","ls [dir] # list files in the directory" ,main_ls ); - shell_add_cmd ("chdir" ,"dir","chdir [dir] # change the current directory",main_chdir); - shell_add_cmd ("rmdir" ,"dir","rmdir dir # remove directory" ,main_rmdir); - shell_add_cmd ("mkdir" ,"dir","mkdir dir # make a directory" ,main_mkdir); - shell_add_cmd ("pwd" ,"dir","pwd # print work directory" ,main_pwd ); - shell_add_cmd ("chroot","dir","chroot [dir] # change the root directory" ,main_chroot); - shell_add_cmd ("cat" ,"dir","cat n1 [n2 [n3...]]# show the ascii contents",main_cat ); - shell_add_cmd ("rm" ,"dir","rm n1 [n2 [n3...]]# remove files" ,main_rm ); - shell_add_cmd ("chmod" ,"dir","chmod 0777 n1 n2... #change filemode" ,main_chmod); - - shell_alias_cmd("ls" ,"dir"); - shell_alias_cmd("chdir" ,"cd"); - - /* misc. topic */ - shell_add_cmd ("logoff","misc","logoff from the system" ,main_logoff); - shell_alias_cmd("logoff","exit"); - shell_add_cmd ("date" ,"misc","date" ,main_date); - shell_add_cmd ("reset","misc","reset the BSP" ,main_reset); - shell_add_cmd ("alias","misc","alias old new" ,main_alias); - shell_add_cmd ("tty" ,"misc","show ttyname" ,main_tty ); - shell_add_cmd ("whoami","misc","show current user" ,main_whoami); - shell_add_cmd ("id" ,"misc","show uid,gid,euid,egid" ,main_id ); - shell_add_cmd ("umask" ,"misc","umask [new_umask]" ,main_umask ); - - - /* memory topic */ - shell_add_cmd ("mdump","mem" ,"mdump [adr [size]]" ,main_mdump); - shell_add_cmd ("wdump","mem" ,"wdump [adr [size]]" ,main_mwdump); - shell_add_cmd ("medit","mem" ,"medit adr value [value ...]" ,main_medit); - shell_add_cmd ("mfill","mem" ,"mfill adr size value" ,main_mfill); - shell_add_cmd ("mmove","mem" ,"mmove dst src size" ,main_mmove); -#ifdef MALLOC_STATS /* /rtems/s/src/lib/libc/malloc.c */ - shell_add_cmd ("malloc","mem","mem show memory malloc'ed" ,main_mem); -#endif -} -/*-----------------------------------------------------------*/ diff --git a/c/src/libmisc/shell/shell.c b/c/src/libmisc/shell/shell.c deleted file mode 100644 index 4815d517a0..0000000000 --- a/c/src/libmisc/shell/shell.c +++ /dev/null @@ -1,682 +0,0 @@ -/* - * - * Instantatiate a new terminal shell. - * - * Author: - * - * WORK: fernando.ruiz@ctv.es - * HOME: correo@fernando-ruiz.com - * - * Thanks at: - * Chris John - * - * $Id$ - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <stdio.h> -#include <time.h> - -#include <rtems.h> -#include <rtems/error.h> -#include <rtems/libio.h> -#include <rtems/libio_.h> -#include <rtems/system.h> -#include <rtems/shell.h> - -#include <termios.h> -#include <string.h> -#include <stdlib.h> -#include <ctype.h> -#include <sys/stat.h> -#include <unistd.h> -#include <errno.h> -#include <pwd.h> - -/* ----------------------------------------------- * - * This is a stupidity but is cute. - * ----------------------------------------------- */ -rtems_unsigned32 new_rtems_name(char * rtems_name) { - static char b[5]; - sprintf(b,"%-4.4s",rtems_name); - return rtems_build_name(b[0],b[1],b[2],b[3]); -} -/* ************************************************************** - * common linked list of shell commands. - * Because the help report is very long - * I have a topic for each command. - * Help list the topics - * help [topic] list the commands for the topic - * help [command] help for the command - * Can you see help rtems monitor report? - * ************************************************************** */ - -struct shell_topic_tt; -typedef struct shell_topic_tt shell_topic_t; - -struct shell_topic_tt { - char * topic; - shell_topic_t * next; -}; - - -static shell_cmd_t * shell_first_cmd; -static shell_topic_t * shell_first_topic; -/* ----------------------------------------------- * - * Using Chain I can reuse the rtems code. - * I am more comfortable with this, sorry. - * ----------------------------------------------- */ -shell_topic_t * shell_lookup_topic(char * topic) { - shell_topic_t * shell_topic; - shell_topic=shell_first_topic; - while (shell_topic) { - if (!strcmp(shell_topic->topic,topic)) return shell_topic; - shell_topic=shell_topic->next; - }; - return (shell_topic_t *) NULL; -} -/* ----------------------------------------------- */ -shell_topic_t * shell_add_topic(char * topic) { - shell_topic_t * current,*aux; - if (!shell_first_topic) { - aux=malloc(sizeof(shell_topic_t)); - aux->topic=topic; - aux->next=(shell_topic_t*)NULL; - return shell_first_topic=aux; - } else { - current=shell_first_topic; - if (!strcmp(topic,current->topic)) return current; - while (current->next) { - if (!strcmp(topic,current->next->topic)) return current->next; - current=current->next; - }; - aux=malloc(sizeof(shell_topic_t)); - aux->topic=topic; - aux->next=(shell_topic_t*)NULL; - current->next=aux; - return aux; - }; -} -/* ----------------------------------------------- */ -shell_cmd_t * shell_lookup_cmd(char * cmd) { - shell_cmd_t * shell_cmd; - shell_cmd=shell_first_cmd; - while (shell_cmd) { - if (!strcmp(shell_cmd->name,cmd)) return shell_cmd; - shell_cmd=shell_cmd->next; - }; - return (shell_cmd_t *) NULL; -} -/* ----------------------------------------------- */ -shell_cmd_t * shell_add_cmd(char * cmd, - char * topic, - char * usage, - shell_command_t command) { - int shell_help(int argc,char * argv[]); - shell_cmd_t * shell_cmd,*shell_pvt; - if (!shell_first_cmd) { - shell_first_cmd=(shell_cmd_t *) malloc(sizeof(shell_cmd_t)); - shell_first_cmd->name ="help"; - shell_first_cmd->topic ="help"; - shell_first_cmd->usage ="help [topic] # list of usage of commands"; - shell_first_cmd->command=shell_help; - shell_first_cmd->alias =(shell_cmd_t *) NULL; - shell_first_cmd->next =(shell_cmd_t *) NULL; - shell_add_topic(shell_first_cmd->topic); - register_cmds(); - }; - if (!cmd) return (shell_cmd_t *) NULL; - if (!command) return (shell_cmd_t *) NULL; - shell_cmd=(shell_cmd_t *) malloc(sizeof(shell_cmd_t)); - shell_cmd->name =cmd; - shell_cmd->topic =topic; - shell_cmd->usage =usage; - shell_cmd->command=command; - shell_cmd->alias =(shell_cmd_t *) NULL; - shell_cmd->next =(shell_cmd_t *) NULL; - shell_add_topic(shell_cmd->topic); - shell_pvt=shell_first_cmd; - while (shell_pvt->next) shell_pvt=shell_pvt->next; - return shell_pvt->next=shell_cmd; -} -/* ----------------------------------------------- * - * you can make an alias for every command. - * ----------------------------------------------- */ -shell_cmd_t * shell_alias_cmd(char * cmd, char * alias) { - shell_cmd_t * shell_cmd,* shell_aux; - shell_aux=(shell_cmd_t *) NULL; - if (alias) { - if ((shell_aux=shell_lookup_cmd(alias))!=NULL) { - return NULL; - }; - if ((shell_cmd=shell_lookup_cmd(cmd))!=NULL) { - shell_aux=shell_add_cmd(alias,shell_cmd->topic, - shell_cmd->usage,shell_cmd->command); - if (shell_aux) shell_aux->alias=shell_cmd; - }; - }; - return shell_aux; -} -/* ----------------------------------------------- * - * Poor but enough.. - * TODO: Redirection capture. "" evaluate, ... C&S welcome. - * ----------------------------------------------- */ -int shell_make_args(char * cmd, - int * pargc, - char * argv[]) { - int argc=0; - while ((cmd=strtok(cmd," \t\r\n"))!=NULL) { - argv[argc++]=cmd; - cmd=(char*)NULL; - }; - argv[argc]=(char*)NULL; - return *pargc=argc; -} -/* ----------------------------------------------- * - * show the help for one command. - * ----------------------------------------------- */ -int shell_help_cmd(shell_cmd_t * shell_cmd) { - char * pc; - int col,line; - printf("%-10.10s -",shell_cmd->name); - col=12; - line=1; - if (shell_cmd->alias) { - printf("is an <alias> for command '%s'",shell_cmd->alias->name); - } else - if (shell_cmd->usage) { - pc=shell_cmd->usage; - while (*pc) { - switch(*pc) { - case '\r':break; - case '\n':putchar('\n'); - col=0; - break; - default :putchar(*pc); - col++; - break; - }; - pc++; - if(col>78) { /* What daring... 78?*/ - if (*pc) { - putchar('\n'); - col=0; - }; - }; - if (!col && *pc) { - printf(" "); - col=12;line++; - }; - }; - }; - puts(""); - return line; -} -/* ----------------------------------------------- * - * show the help. The first command implemented. - * Can you see the header of routine? Known? - * The same with all the commands.... - * ----------------------------------------------- */ -int shell_help(int argc,char * argv[]) { - int col,line,arg; - shell_topic_t *topic; - shell_cmd_t * shell_cmd=shell_first_cmd; - if (argc<2) { - printf("help: ('r' repeat last cmd - 'e' edit last cmd)\n" - " TOPIC? The topics are\n"); - topic=shell_first_topic; - col=0; - while (topic) { - if (!col){ - col=printf(" %s",topic->topic); - } else { - if ((col+strlen(topic->topic)+2)>78){ - printf("\n"); - col=printf(" %s",topic->topic); - } else { - col+=printf(", %s",topic->topic); - }; - }; - topic=topic->next; - }; - printf("\n"); - return 1; - }; - line=0; - for (arg=1;arg<argc;arg++) { - if (line>16) { - printf("Press any key to continue...");getchar(); - printf("\n"); - line=0; - }; - topic=shell_lookup_topic(argv[arg]); - if (!topic){ - if ((shell_cmd=shell_lookup_cmd(argv[arg]))==NULL) { - printf("help: topic or cmd '%s' not found. Try <help> alone for a list\n",argv[arg]); - line++; - } else { - line+=shell_help_cmd(shell_cmd); - } - continue; - }; - printf("help: list for the topic '%s'\n",argv[arg]); - line++; - while (shell_cmd) { - if (!strcmp(topic->topic,shell_cmd->topic)) - line+=shell_help_cmd(shell_cmd); - if (line>16) { - printf("Press any key to continue...");getchar(); - printf("\n"); - line=0; - }; - shell_cmd=shell_cmd->next; - }; - }; - puts(""); - return 0; -} -/* ----------------------------------------------- * - * TODO: Add improvements. History, edit vi or emacs, ... - * ----------------------------------------------- */ -int shell_scanline(char * line,int size,FILE * in,FILE * out) { - int c,col; - col=0; - if (*line) { - col=strlen(line); - if (out) fprintf(out,"%s",line); - }; - tcdrain(fileno(in )); - if (out) tcdrain(fileno(out)); - for (;;) { - line[col]=0; - c=fgetc(in); - switch (c) { - case 0x04:/*Control-d*/ - if (col) break; - case EOF :return 0; - case '\n':break; - case '\f':if (out) fputc('\f',out); - case 0x03:/*Control-C*/ - line[0]=0; - case '\r':if (out) fputc('\n',out); - return 1; - case 127: - case '\b':if (col) { - if (out) { - fputc('\b',out); - fputc(' ',out); - fputc('\b',out); - }; - col--; - } else { - if (out) fputc('\a',out); - }; - break; - default :if (!iscntrl(c)) { - if (col<size-1) { - line[col++]=c; - if (out) fputc(c,out); - } else { - if (out) fputc('\a',out); - }; - } else { - if (out) - if (c=='\a') fputc('\a',out); - }; - break; - }; - }; -} -/* ----------------------------------------------- * - * - The shell TASK - * Poor but enough.. - * TODO: Redirection. Tty Signals. ENVVARs. Shell language. - * ----------------------------------------------- */ -shell_env_t global_shell_env , - * current_shell_env=&global_shell_env; - -extern char **environ; - -void cat_file(FILE * out,char * name) { - FILE * fd; - int c; - if (out) { - fd=fopen(name,"r"); - if (fd) { - while ((c=fgetc(fd))!=EOF) fputc(c,out); - fclose(fd); - }; - }; -} - -void write_file(char * name,char * content) { - FILE * fd; - fd=fopen(name,"w"); - if (fd) { - fwrite(content,1,strlen(content),fd); - fclose(fd); - }; -} - -void init_issue(void) { - static char issue_inited=FALSE; - struct stat buf; - if (issue_inited) return; - issue_inited=TRUE; - getpwnam("root"); /* dummy call to init /etc dir */ - if (stat("/etc/issue",&buf)) - write_file("/etc/issue", - "Welcome to @V\\n" - "Login into @S(@L)\\n"); - if (stat("/etc/issue.net",&buf)) - write_file("/etc/issue.net", - "Welcome to %v\n" - "running on %m\n"); -} - -int shell_login(FILE * in,FILE * out) { - FILE * fd; - int c; - time_t t; - int times; - char name[128]; - char pass[128]; - struct passwd * passwd; - init_issue(); - setuid(0); - setgid(0); - rtems_current_user_env->euid= - rtems_current_user_env->egid=0; - if (out) { - if((current_shell_env->devname[5]!='p')|| - (current_shell_env->devname[6]!='t')|| - (current_shell_env->devname[7]!='y')) { - fd=fopen("/etc/issue","r"); - if (fd) { - while ((c=fgetc(fd))!=EOF) { - if (c=='@') { - switch(c=fgetc(fd)) { - case 'L':fprintf(out,"%s",current_shell_env->devname); - break; - case 'B':fprintf(out,"0"); - break; - case 'T': - case 'D':time(&t); - fprintf(out,"%s",ctime(&t)); - break; - case 'S':fprintf(out,"RTEMS"); - break; - case 'V':fprintf(out,"%s\n%s",_RTEMS_version,_Copyright_Notice); - break; - case '@':fprintf(out,"@"); - break; - default :fprintf(out,"@%c",c); - break; - }; - } else - if (c=='\\') { - switch(c=fgetc(fd)) { - case '\\':fprintf(out,"\\"); - break; - case 'b':fprintf(out,"\b"); break; - case 'f':fprintf(out,"\f"); break; - case 'n':fprintf(out,"\n"); break; - case 'r':fprintf(out,"\r"); break; - case 's':fprintf(out," "); break; - case 't':fprintf(out,"\t"); break; - case '@':fprintf(out,"@"); break; - }; - } else { - fputc(c,out); - }; - }; - fclose(fd); - } - } else { - fd=fopen("/etc/issue.net","r"); - if (fd) { - while ((c=fgetc(fd))!=EOF) { - if (c=='%') { - switch(c=fgetc(fd)) { - case 't':fprintf(out,"%s",current_shell_env->devname); - break; - case 'h':fprintf(out,"0"); - break; - case 'D':fprintf(out," "); - break; - case 'd':time(&t); - fprintf(out,"%s",ctime(&t)); - break; - case 's':fprintf(out,"RTEMS"); - break; - case 'm':fprintf(out,"(" CPU_NAME "/" CPU_MODEL_NAME ")"); - break; - case 'r':fprintf(out,_RTEMS_version); - break; - case 'v':fprintf(out,"%s\n%s",_RTEMS_version,_Copyright_Notice); - break; - case '%':fprintf(out,"%%"); - break; - default :fprintf(out,"%%%c",c); - break; - }; - } else { - fputc(c,out); - }; - }; - fclose(fd); - } - }; - }; - times=0; - strcpy(name,""); - strcpy(pass,""); - for (;;) { - times++; - if (times>3) break; - if (out) fprintf(out,"\nlogin: "); - if (!shell_scanline(name,sizeof(name),in,out )) break; - if (out) fprintf(out,"Password: "); - if (!shell_scanline(pass,sizeof(pass),in,NULL)) break; - if (out) fprintf(out,"\n"); - if ((passwd=getpwnam(name))) { - if (strcmp(passwd->pw_passwd,"!")) { /* valid user */ - setuid(passwd->pw_uid); - setgid(passwd->pw_gid); - rtems_current_user_env->euid= - rtems_current_user_env->egid=0; - chown(current_shell_env->devname,passwd->pw_uid,0); - rtems_current_user_env->euid=passwd->pw_uid; - rtems_current_user_env->egid=passwd->pw_gid; - if (!strcmp(passwd->pw_passwd,"*")) { - /* /etc/shadow */ - return 0; - } else { - /* crypt() */ - return 0; - }; - }; - }; - if (out) fprintf(out,"Login incorrect\n"); - strcpy(name,""); - strcpy(pass,""); - }; - return -1; -} - -rtems_task shell_shell(rtems_task_argument task_argument) { - - shell_env_t * shell_env =(shell_env_t*) task_argument; - shell_cmd_t * shell_cmd; - - rtems_status_code sc; - - struct termios term; - char * devname; - - char curdir[256]; - char cmd[256]; - char last_cmd[256]; /* to repeat 'r' */ - int argc; - char * argv[128]; - - sc=rtems_task_variable_add(RTEMS_SELF,(void*)¤t_shell_env,free); - if (sc!=RTEMS_SUCCESSFUL) { - rtems_error(sc,"rtems_task_variable_add(current_shell_env):"); - rtems_task_delete(RTEMS_SELF); - }; - - current_shell_env=shell_env; - - sc=rtems_libio_set_private_env(); - if (sc!=RTEMS_SUCCESSFUL) { - rtems_error(sc,"rtems_libio_set_private_env():"); - rtems_task_delete(RTEMS_SELF); - }; - - - devname=shell_env->devname; - setuid(0); - setgid(0); - rtems_current_user_env->euid= - rtems_current_user_env->egid=0; - - stdin =fopen(devname,"r+"); - - if (!stdin) { - fprintf(stderr,"shell:unable to open stdin.%s:%s\n",devname,strerror(errno)); - rtems_task_delete(RTEMS_SELF); - }; - setvbuf(stdin,NULL,_IONBF,0); /* Not buffered*/ - /* make a raw terminal,Linux MANuals */ - if (tcgetattr (fileno(stdin), &term)>=0) { - term.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); - term.c_oflag &= ~OPOST; - term.c_oflag |= (OPOST|ONLCR); /* But with cr+nl on output */ - term.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); - term.c_cflag = CLOCAL | CREAD |(shell_env->tcflag); - term.c_cc[VMIN] = 1; - term.c_cc[VTIME] = 0; - if (tcsetattr (fileno(stdin), TCSADRAIN, &term) < 0) { - fprintf(stderr,"shell:cannot set terminal attributes(%s)\n",devname); - }; - stdout=fopen(devname,"r+"); - if (!stdout) { - fprintf(stderr,"shell:unable to open stdout.%s:%s\n",devname,strerror(errno)); - }; - setvbuf(stdout,NULL,_IONBF,0); /* Not buffered*/ - stderr=fopen(devname,"r+"); - if (!stderr) { - printf("shell:unable to open stderr.%s:%s\n",devname,strerror(errno)); - }; - /* when the future user environment runs ok - * a freopen() reopens the terminals. Now this don't work - * (sorry but you can't use because FILENO_STDIN!=0. Better fileno(stdin)) - */ - }; - shell_add_cmd(NULL,NULL,NULL,NULL); /* init the chain list*/ - do { - /* Set again root user and root filesystem, side effect of set_priv..*/ - sc=rtems_libio_set_private_env(); - if (sc!=RTEMS_SUCCESSFUL) { - rtems_error(sc,"rtems_libio_set_private_env():"); - rtems_task_delete(RTEMS_SELF); - }; - if (!shell_login(stdin,stdout)) { - cat_file(stdout,"/etc/motd"); - strcpy(last_cmd,""); - strcpy(cmd,""); - printf("\n" - "RTEMS SHELL (Ver.1.0-FRC):%s. "__DATE__". 'help' to list commands.\n",devname); - chdir("/"); /* XXX: chdir to getpwent homedir */ - shell_env->exit_shell=FALSE; - for (;;) { - /* Prompt section */ - /* XXX: show_prompt user adjustable */ - getcwd(curdir,sizeof(curdir)); - printf("%s [%s] %c ",shell_env->taskname,curdir,geteuid()?'$':'#'); - /* getcmd section */ - if (!shell_scanline(cmd,sizeof(cmd),stdin,stdout)) break; /*EOF*/ - /* evaluate cmd section */ - if (!strcmp(cmd,"e")) { /* edit last command */ - strcpy(cmd,last_cmd); - continue; - } else - if (!strcmp(cmd,"r")) { /* repeat last command */ - strcpy(cmd,last_cmd); - } else - if (strcmp(cmd,"")) { /* only for get a new prompt */ - strcpy(last_cmd,cmd); - }; - /* exec cmd section */ - /* TODO: - * To avoid user crash catch the signals. - * Open a new stdio files with posibility of redirection * - * Run in a new shell task background. (unix &) - * Resuming. A little bash. - */ - if (shell_make_args(cmd,&argc,argv)) { - if ((shell_cmd=shell_lookup_cmd(argv[0]))!=NULL) { - shell_env->errorlevel=shell_cmd->command(argc,argv); - } else { - printf("shell:%s command not found\n",argv[0]); - shell_env->errorlevel=-1; - }; - }; - /* end exec cmd section */ - if (shell_env->exit_shell) break; - cmd[0]=0; - }; - printf("\nGoodbye from RTEMS SHELL :-(\n"); - }; - } while (shell_env->forever); - fclose(stdin ); - fclose(stdout); - fclose(stderr); - rtems_task_delete(RTEMS_SELF); -} -/* ----------------------------------------------- */ -rtems_status_code shell_init (char * task_name, - rtems_unsigned32 task_stacksize, - rtems_task_priority task_priority, - char * devname, - tcflag_t tcflag, - int forever) { - rtems_id task_id; - rtems_status_code sc; - shell_env_t * shell_env; - sc=rtems_task_create(new_rtems_name(task_name), - task_priority, - task_stacksize?task_stacksize:RTEMS_MINIMUM_STACK_SIZE, - RTEMS_DEFAULT_MODES, - RTEMS_DEFAULT_ATTRIBUTES, - &task_id); - if (sc!=RTEMS_SUCCESSFUL) { - rtems_error(sc,"creating task %s in shell_init()",task_name); - return sc; - }; - shell_env=malloc(sizeof(shell_env_t)); - if (!shell_env) { - rtems_task_delete(task_id); - sc=RTEMS_NO_MEMORY; - rtems_error(sc,"allocating shell_env %s in shell_init()",task_name); - return sc; - }; - if (global_shell_env.magic!=new_rtems_name("SENV")) { - global_shell_env.magic =new_rtems_name("SENV"); - global_shell_env.devname ="/dev/console"; - global_shell_env.taskname ="GLOBAL"; - global_shell_env.tcflag =0; - global_shell_env.exit_shell=0; - global_shell_env.forever =TRUE; - }; - shell_env->magic =global_shell_env.magic; - shell_env->devname =devname; - shell_env->taskname =task_name; - shell_env->tcflag =tcflag; - shell_env->exit_shell=FALSE; - shell_env->forever =forever; - return rtems_task_start(task_id,shell_shell,(rtems_task_argument) shell_env); -} diff --git a/c/src/libmisc/shell/shell.h b/c/src/libmisc/shell/shell.h deleted file mode 100644 index 6c8cbc6771..0000000000 --- a/c/src/libmisc/shell/shell.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * - * Instantatiate a new terminal shell. - * - * Author: - * - * WORK: fernando.ruiz@ctv.es - * HOME: correo@fernando-ruiz.com - * - * Thanks at: - * Chris John - * - * $Id$ - */ - -#ifndef __SHELL_H__ -#define __SHELL_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <rtems.h> -#include <stdio.h> -#include <termios.h> - -typedef int (*shell_command_t)(int argc,char * argv[]); - -struct shell_cmd_tt ; -typedef struct shell_cmd_tt shell_cmd_t; - -struct shell_cmd_tt { - char * name; - char * usage; - char * topic; - shell_command_t command; - shell_cmd_t * alias; - shell_cmd_t * next; -}; - -rtems_unsigned32 new_rtems_name(char * rtems_name); -shell_cmd_t * shell_lookup_cmd(char * cmd); -shell_cmd_t * shell_add_cmd(char * cmd, - char * topic, - char * usage, - shell_command_t command); -shell_cmd_t * shell_alias_cmd(char * cmd, char * alias); - -int shell_make_args(char * cmd, - int * pargc, - char * argv[]); - -typedef struct { - rtems_name magic; /* 'S','E','N','V': Shell Environment */ - char * devname; - char * taskname; - tcflag_t tcflag; - /* user extensions */ - int exit_shell; /* logout */ - int forever ; /* repeat login */ - int errorlevel; - int mdump_adr; -} shell_env_t; - -int shell_scanline(char * line,int size,FILE * in,FILE * out) ; -void cat_file(FILE * out,char *name); -void write_file(char *name,char * content); - -rtems_status_code shell_init(char * task_name , - rtems_unsigned32 task_stacksize,/*0 default*/ - rtems_task_priority task_priority , - char * devname , - tcflag_t tcflag , - int forever ); - -extern shell_env_t global_shell_env, - * current_shell_env; -/*--------*/ -/* cmds.c */ -/*--------*/ -int str2int(char * s); -void register_cmds(void); - -#ifdef __cplusplus -} -#endif - -#endif |