Changeset 70d689a in rtems
- Timestamp:
- 08/09/01 22:08:46 (22 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- b6a2d2fa
- Parents:
- bd520203
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/libmisc/ChangeLog
rbd520203 r70d689a 1 2001-08-09 Fernando-Ruiz Casas <correo@fernando-ruiz.com> 2 3 * shell/Makefile.am, shell/README, shell/cmds.c, shell/shell.c, 4 shell/shell.h: Updates. 5 1 6 2001-08-09 Keith Outwater <vac4050@cae597.rsc.raytheon.com> 2 7 -
c/src/libmisc/shell/Makefile.am
rbd520203 r70d689a 10 10 LIB = $(ARCH)/$(LIBNAME).a 11 11 12 C_FILES = cmds.c shell.c pty.c12 C_FILES = cmds.c shell.c 13 13 C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o) 14 14 … … 40 40 .PRECIOUS: $(LIB) 41 41 42 EXTRA_DIST = README shell.c cmds.c pty.cshell.h42 EXTRA_DIST = README shell.c cmds.c shell.h 43 43 44 44 include $(top_srcdir)/../../../automake/local.am -
c/src/libmisc/shell/README
rbd520203 r70d689a 20 20 and enjoy it. 21 21 22 3. If you have tcp/ip inited you can start telnetd daemon. 23 You need register pseudo-terminals driver into device drivers table. 24 16 ptyX termios device terminales are created into /dev/. 25 Calling rtems_initialize_telnetd() starts the daemon. 22 3. Telnetd daemon uses this (browse libnetworking/rtems_telnetd) 26 23 Enjoy it. 27 24 -
c/src/libmisc/shell/cmds.c
rbd520203 r70d689a 335 335 int main_mkdir (int argc, char *argv[]) { 336 336 char *dir; 337 dir=NULL; 338 if (argc>1) dir=argv[1]; 339 if (mkdir(dir,S_IRWXU|S_IRWXG|S_IRWXO)) { 340 printf("mkdir '%s' failed:%s\n",dir,strerror(errno)); 337 int n; 338 n=1; 339 while (n<argc) { 340 dir=argv[n++]; 341 if (mkdir(dir,S_IRWXU|S_IRWXG|S_IRWXO)) { 342 printf("mkdir '%s' failed:%s\n",dir,strerror(errno)); 343 }; 341 344 }; 342 345 return errno; … … 346 349 { 347 350 char *dir; 348 dir=NULL; 349 if (argc>1) dir=argv[1]; 350 if (rmdir(dir)) printf("rmdir '%s' failed:%s\n",dir,strerror(errno)); 351 int n; 352 n=1; 353 while (n<argc) { 354 dir=argv[n++]; 355 if (rmdir(dir)) printf("rmdir '%s' failed:%s\n",dir,strerror(errno)); 356 }; 351 357 return errno; 352 358 } … … 384 390 } 385 391 /*-----------------------------------------------------------*/ 386 /* date - print or set time and date */ 387 388 static int set_time(char *t) 389 { 390 rtems_time_of_day tod; 391 FILE * rtc; 392 int len; 393 394 if ( rtems_clock_get(RTEMS_CLOCK_GET_TOD,&tod) != RTEMS_SUCCESSFUL ) 395 memset( &tod, 0, sizeof(tod) ); 396 397 /* JRS 398 * 399 * This code that was used to parse the command line was taken 400 * from an inappropriate source. It has been removed and needs 401 * to be replaced. 402 */ 403 404 if (!_TOD_Validate(&tod)) { 405 fprintf(stderr, "Invalid date value\n"); 406 } else { 407 rtems_clock_set(&tod); 408 rtems_clock_get(RTEMS_CLOCK_GET_TOD,&tod); 409 rtc=fopen("/dev/rtc","r+"); 410 if (rtc) { 411 fwrite(&tod,sizeof(tod),1,rtc); 412 fclose(rtc); 413 }; 414 }; 415 return 1; 416 } 392 /* date - print time and date */ 417 393 418 394 int main_date(int argc,char *argv[]) 419 395 { 420 396 time_t t; 421 if (argc == 2)422 set_time(argv[1]);423 397 time(&t); 424 398 printf("%s", ctime(&t)); … … 529 503 shell_add_cmd ("logoff","misc","logoff from the system" ,main_logoff); 530 504 shell_alias_cmd("logoff","exit"); 531 shell_add_cmd ("date" ,"misc","date [[MMDDYY]hhmm[ss]]",main_date);505 shell_add_cmd ("date" ,"misc","date" ,main_date); 532 506 shell_add_cmd ("reset","misc","reset the BSP" ,main_reset); 533 507 shell_add_cmd ("alias","misc","alias old new" ,main_alias); -
c/src/libmisc/shell/shell.c
rbd520203 r70d689a 17 17 #endif 18 18 19 #undef __STRICT_ANSI__ /* fileno() */ 19 20 #include <stdio.h> 20 21 … … 30 31 #include <stdlib.h> 31 32 #include <ctype.h> 33 #include <sys/stat.h> 32 34 #include <unistd.h> 33 35 #include <errno.h> … … 223 225 shell_cmd_t * shell_cmd=shell_first_cmd; 224 226 if (argc<2) { 225 printf("help: TOPIC? The topics are\n"); 227 printf("help: ('r' repeat last cmd - 'e' edit last cmd)\n" 228 " TOPIC? The topics are\n"); 226 229 topic=shell_first_topic; 227 230 col=0; … … 276 279 } 277 280 /* ----------------------------------------------- * 278 * TODO: Change to bash readline() better.281 * TODO: Add improvements. History, edit vi or emacs, ... 279 282 * ----------------------------------------------- */ 280 283 int shell_scanline(char * line,int size,FILE * in,FILE * out) { 281 284 int c,col; 282 285 col=0; 286 if (*line) { 287 col=strlen(line); 288 if (out) fprintf(out,"%s",line); 289 }; 290 tcdrain(fileno(in )); 283 291 tcdrain(fileno(out)); 284 292 for (;;) { … … 344 352 } 345 353 354 void write_file(char * name,char * content) { 355 FILE * fd; 356 fd=fopen(name,"w"); 357 if (fd) { 358 fwrite(content,1,strlen(content),fd); 359 fclose(fd); 360 }; 361 } 362 363 void init_issue(void) { 364 static char issue_inited=FALSE; 365 struct stat buf; 366 if (issue_inited) return; 367 issue_inited=TRUE; 368 getpwnam("root"); /* dummy call to init /etc dir */ 369 if (stat("/etc/issue",&buf)) 370 write_file("/etc/issue", 371 "Welcome to @V\\n" 372 "Login into @S(@L)\\n"); 373 if (stat("/etc/issue.net",&buf)) 374 write_file("/etc/issue.net", 375 "Welcome to %v\n" 376 "running on %m\n"); 377 } 378 346 379 int shell_login(FILE * in,FILE * out) { 347 380 FILE * fd; … … 352 385 char pass[128]; 353 386 struct passwd * passwd; 387 init_issue(); 354 388 setuid(0); 355 389 setgid(0); … … 360 394 (current_shell_env->devname[6]!='t')|| 361 395 (current_shell_env->devname[7]!='y')) { 362 cat_file(out,"/etc/issue"); 396 fd=fopen("/etc/issue","r"); 397 if (fd) { 398 while ((c=fgetc(fd))!=EOF) { 399 if (c=='@') { 400 switch(c=fgetc(fd)) { 401 case 'L':fprintf(out,"%s",current_shell_env->devname); 402 break; 403 case 'B':fprintf(out,"0"); 404 break; 405 case 'T': 406 case 'D':time(&t); 407 fprintf(out,"%s",ctime(&t)); 408 break; 409 case 'S':fprintf(out,"RTEMS"); 410 break; 411 case 'V':fprintf(out,"%s\n%s",_RTEMS_version,_Copyright_Notice); 412 break; 413 case '@':fprintf(out,"@"); 414 break; 415 default :fprintf(out,"@%c",c); 416 break; 417 }; 418 } else 419 if (c=='\\') { 420 switch(c=fgetc(fd)) { 421 case '\\':fprintf(out,"\\"); 422 break; 423 case 'b':fprintf(out,"\b"); break; 424 case 'f':fprintf(out,"\f"); break; 425 case 'n':fprintf(out,"\n"); break; 426 case 'r':fprintf(out,"\r"); break; 427 case 's':fprintf(out," "); break; 428 case 't':fprintf(out,"\t"); break; 429 case '@':fprintf(out,"@"); break; 430 }; 431 } else { 432 fputc(c,out); 433 }; 434 }; 435 fclose(fd); 436 } 363 437 } else { 364 438 fd=fopen("/etc/issue.net","r"); … … 398 472 }; 399 473 times=0; 474 strcpy(name,""); 475 strcpy(pass,""); 400 476 for (;;) { 401 477 times++; … … 407 483 if (out) fprintf(out,"\n"); 408 484 if ((passwd=getpwnam(name))) { 409 setuid(passwd->pw_uid); 410 setgid(passwd->pw_gid); 411 rtems_current_user_env->euid= 412 rtems_current_user_env->egid=0; 413 chown(current_shell_env->devname,passwd->pw_uid,0); 414 rtems_current_user_env->euid=passwd->pw_uid; 415 rtems_current_user_env->egid=passwd->pw_gid; 416 if (!strcmp(passwd->pw_passwd,"*")) { 417 /* /etc/shadow */ 418 return 0; 419 } else { 420 /* crypt() */ 421 return 0; 485 if (strcmp(passwd->pw_passwd,"!")) { /* valid user */ 486 setuid(passwd->pw_uid); 487 setgid(passwd->pw_gid); 488 rtems_current_user_env->euid= 489 rtems_current_user_env->egid=0; 490 chown(current_shell_env->devname,passwd->pw_uid,0); 491 rtems_current_user_env->euid=passwd->pw_uid; 492 rtems_current_user_env->egid=passwd->pw_gid; 493 if (!strcmp(passwd->pw_passwd,"*")) { 494 /* /etc/shadow */ 495 return 0; 496 } else { 497 /* crypt() */ 498 return 0; 499 }; 422 500 }; 423 501 }; 424 502 if (out) fprintf(out,"Login incorrect\n"); 503 strcpy(name,""); 504 strcpy(pass,""); 425 505 }; 426 506 return -1; … … 487 567 fprintf(stderr,"shell:unable to open stdout.%s:%s\n",devname,strerror(errno)); 488 568 }; 569 setvbuf(stdout,NULL,_IONBF,0); /* Not buffered*/ 489 570 stderr=fopen(devname,"r+"); 490 571 if (!stderr) { … … 498 579 shell_add_cmd(NULL,NULL,NULL,NULL); /* init the chain list*/ 499 580 do { 581 /* Set again root user and root filesystem, side effect of set_priv..*/ 582 sc=rtems_libio_set_private_env(); 583 if (sc!=RTEMS_SUCCESSFUL) { 584 rtems_error(sc,"rtems_libio_set_private_env():"); 585 rtems_task_delete(RTEMS_SELF); 586 }; 500 587 if (!shell_login(stdin,stdout)) { 501 588 cat_file(stdout,"/etc/motd"); … … 503 590 strcpy(cmd,""); 504 591 printf("\n" 505 "RTEMS SHELL (Ver sion1.0-FRC):%s. "__DATE__". 'help' to list commands.\n",devname);506 chdir("/"); 592 "RTEMS SHELL (Ver.1.0-FRC):%s. "__DATE__". 'help' to list commands.\n",devname); 593 chdir("/"); /* XXX: chdir to getpwent homedir */ 507 594 shell_env->exit_shell=FALSE; 508 595 for (;;) { … … 514 601 if (!shell_scanline(cmd,sizeof(cmd),stdin,stdout)) break; /*EOF*/ 515 602 /* evaluate cmd section */ 516 if (!strcmp(cmd,"r")) { /* repeat last command, forced, not automatic */ 603 if (!strcmp(cmd,"e")) { /* edit last command */ 604 strcpy(cmd,last_cmd); 605 continue; 606 } else 607 if (!strcmp(cmd,"r")) { /* repeat last command */ 517 608 strcpy(cmd,last_cmd); 518 609 } else … … 537 628 /* end exec cmd section */ 538 629 if (shell_env->exit_shell) break; 630 cmd[0]=0; 539 631 }; 540 632 printf("\nGoodbye from RTEMS SHELL :-(\n"); … … 589 681 return rtems_task_start(task_id,shell_shell,(rtems_task_argument) shell_env); 590 682 } 591 /* ----------------------------------------------- */ -
c/src/libmisc/shell/shell.h
rbd520203 r70d689a 1 1 /* 2 * 3 * Instantatiate a new terminal shell. 4 * 5 * Author: 6 * 7 * WORK: fernando.ruiz@ctv.es 8 * HOME: correo@fernando-ruiz.com 9 * 10 * Thanks at: 11 * Chris John 12 * 2 13 * $Id$ 3 14 */ … … 54 65 int shell_scanline(char * line,int size,FILE * in,FILE * out) ; 55 66 void cat_file(FILE * out,char *name); 67 void write_file(char *name,char * content); 56 68 57 69 rtems_status_code shell_init(char * task_name , … … 65 77 * current_shell_env; 66 78 /*--------*/ 67 /* pty.c */68 /*--------*/69 70 char * get_pty(int socket);71 72 73 rtems_device_driver pty_initialize(74 rtems_device_major_number major,75 rtems_device_minor_number minor,76 void *arg);77 rtems_device_driver pty_open(78 rtems_device_major_number major,79 rtems_device_minor_number minor,80 void * arg);81 rtems_device_driver pty_close(82 rtems_device_major_number major,83 rtems_device_minor_number minor,84 void * arg);85 rtems_device_driver pty_read(86 rtems_device_major_number major,87 rtems_device_minor_number minor,88 void * arg);89 rtems_device_driver pty_write(90 rtems_device_major_number major,91 rtems_device_minor_number minor,92 void * arg);93 rtems_device_driver pty_control(94 rtems_device_major_number major,95 rtems_device_minor_number minor,96 void * arg);97 98 99 #define PTY_DRIVER_TABLE_ENTRY \100 { pty_initialize , pty_open , pty_close , \101 pty_read , pty_write , pty_control }102 /*--------*/103 79 /* cmds.c */ 104 80 /*--------*/ -
cpukit/libmisc/ChangeLog
rbd520203 r70d689a 1 2001-08-09 Fernando-Ruiz Casas <correo@fernando-ruiz.com> 2 3 * shell/Makefile.am, shell/README, shell/cmds.c, shell/shell.c, 4 shell/shell.h: Updates. 5 1 6 2001-08-09 Keith Outwater <vac4050@cae597.rsc.raytheon.com> 2 7 -
cpukit/libmisc/shell/Makefile.am
rbd520203 r70d689a 10 10 LIB = $(ARCH)/$(LIBNAME).a 11 11 12 C_FILES = cmds.c shell.c pty.c12 C_FILES = cmds.c shell.c 13 13 C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o) 14 14 … … 40 40 .PRECIOUS: $(LIB) 41 41 42 EXTRA_DIST = README shell.c cmds.c pty.cshell.h42 EXTRA_DIST = README shell.c cmds.c shell.h 43 43 44 44 include $(top_srcdir)/../../../automake/local.am -
cpukit/libmisc/shell/README
rbd520203 r70d689a 20 20 and enjoy it. 21 21 22 3. If you have tcp/ip inited you can start telnetd daemon. 23 You need register pseudo-terminals driver into device drivers table. 24 16 ptyX termios device terminales are created into /dev/. 25 Calling rtems_initialize_telnetd() starts the daemon. 22 3. Telnetd daemon uses this (browse libnetworking/rtems_telnetd) 26 23 Enjoy it. 27 24 -
cpukit/libmisc/shell/cmds.c
rbd520203 r70d689a 335 335 int main_mkdir (int argc, char *argv[]) { 336 336 char *dir; 337 dir=NULL; 338 if (argc>1) dir=argv[1]; 339 if (mkdir(dir,S_IRWXU|S_IRWXG|S_IRWXO)) { 340 printf("mkdir '%s' failed:%s\n",dir,strerror(errno)); 337 int n; 338 n=1; 339 while (n<argc) { 340 dir=argv[n++]; 341 if (mkdir(dir,S_IRWXU|S_IRWXG|S_IRWXO)) { 342 printf("mkdir '%s' failed:%s\n",dir,strerror(errno)); 343 }; 341 344 }; 342 345 return errno; … … 346 349 { 347 350 char *dir; 348 dir=NULL; 349 if (argc>1) dir=argv[1]; 350 if (rmdir(dir)) printf("rmdir '%s' failed:%s\n",dir,strerror(errno)); 351 int n; 352 n=1; 353 while (n<argc) { 354 dir=argv[n++]; 355 if (rmdir(dir)) printf("rmdir '%s' failed:%s\n",dir,strerror(errno)); 356 }; 351 357 return errno; 352 358 } … … 384 390 } 385 391 /*-----------------------------------------------------------*/ 386 /* date - print or set time and date */ 387 388 static int set_time(char *t) 389 { 390 rtems_time_of_day tod; 391 FILE * rtc; 392 int len; 393 394 if ( rtems_clock_get(RTEMS_CLOCK_GET_TOD,&tod) != RTEMS_SUCCESSFUL ) 395 memset( &tod, 0, sizeof(tod) ); 396 397 /* JRS 398 * 399 * This code that was used to parse the command line was taken 400 * from an inappropriate source. It has been removed and needs 401 * to be replaced. 402 */ 403 404 if (!_TOD_Validate(&tod)) { 405 fprintf(stderr, "Invalid date value\n"); 406 } else { 407 rtems_clock_set(&tod); 408 rtems_clock_get(RTEMS_CLOCK_GET_TOD,&tod); 409 rtc=fopen("/dev/rtc","r+"); 410 if (rtc) { 411 fwrite(&tod,sizeof(tod),1,rtc); 412 fclose(rtc); 413 }; 414 }; 415 return 1; 416 } 392 /* date - print time and date */ 417 393 418 394 int main_date(int argc,char *argv[]) 419 395 { 420 396 time_t t; 421 if (argc == 2)422 set_time(argv[1]);423 397 time(&t); 424 398 printf("%s", ctime(&t)); … … 529 503 shell_add_cmd ("logoff","misc","logoff from the system" ,main_logoff); 530 504 shell_alias_cmd("logoff","exit"); 531 shell_add_cmd ("date" ,"misc","date [[MMDDYY]hhmm[ss]]",main_date);505 shell_add_cmd ("date" ,"misc","date" ,main_date); 532 506 shell_add_cmd ("reset","misc","reset the BSP" ,main_reset); 533 507 shell_add_cmd ("alias","misc","alias old new" ,main_alias); -
cpukit/libmisc/shell/shell.c
rbd520203 r70d689a 17 17 #endif 18 18 19 #undef __STRICT_ANSI__ /* fileno() */ 19 20 #include <stdio.h> 20 21 … … 30 31 #include <stdlib.h> 31 32 #include <ctype.h> 33 #include <sys/stat.h> 32 34 #include <unistd.h> 33 35 #include <errno.h> … … 223 225 shell_cmd_t * shell_cmd=shell_first_cmd; 224 226 if (argc<2) { 225 printf("help: TOPIC? The topics are\n"); 227 printf("help: ('r' repeat last cmd - 'e' edit last cmd)\n" 228 " TOPIC? The topics are\n"); 226 229 topic=shell_first_topic; 227 230 col=0; … … 276 279 } 277 280 /* ----------------------------------------------- * 278 * TODO: Change to bash readline() better.281 * TODO: Add improvements. History, edit vi or emacs, ... 279 282 * ----------------------------------------------- */ 280 283 int shell_scanline(char * line,int size,FILE * in,FILE * out) { 281 284 int c,col; 282 285 col=0; 286 if (*line) { 287 col=strlen(line); 288 if (out) fprintf(out,"%s",line); 289 }; 290 tcdrain(fileno(in )); 283 291 tcdrain(fileno(out)); 284 292 for (;;) { … … 344 352 } 345 353 354 void write_file(char * name,char * content) { 355 FILE * fd; 356 fd=fopen(name,"w"); 357 if (fd) { 358 fwrite(content,1,strlen(content),fd); 359 fclose(fd); 360 }; 361 } 362 363 void init_issue(void) { 364 static char issue_inited=FALSE; 365 struct stat buf; 366 if (issue_inited) return; 367 issue_inited=TRUE; 368 getpwnam("root"); /* dummy call to init /etc dir */ 369 if (stat("/etc/issue",&buf)) 370 write_file("/etc/issue", 371 "Welcome to @V\\n" 372 "Login into @S(@L)\\n"); 373 if (stat("/etc/issue.net",&buf)) 374 write_file("/etc/issue.net", 375 "Welcome to %v\n" 376 "running on %m\n"); 377 } 378 346 379 int shell_login(FILE * in,FILE * out) { 347 380 FILE * fd; … … 352 385 char pass[128]; 353 386 struct passwd * passwd; 387 init_issue(); 354 388 setuid(0); 355 389 setgid(0); … … 360 394 (current_shell_env->devname[6]!='t')|| 361 395 (current_shell_env->devname[7]!='y')) { 362 cat_file(out,"/etc/issue"); 396 fd=fopen("/etc/issue","r"); 397 if (fd) { 398 while ((c=fgetc(fd))!=EOF) { 399 if (c=='@') { 400 switch(c=fgetc(fd)) { 401 case 'L':fprintf(out,"%s",current_shell_env->devname); 402 break; 403 case 'B':fprintf(out,"0"); 404 break; 405 case 'T': 406 case 'D':time(&t); 407 fprintf(out,"%s",ctime(&t)); 408 break; 409 case 'S':fprintf(out,"RTEMS"); 410 break; 411 case 'V':fprintf(out,"%s\n%s",_RTEMS_version,_Copyright_Notice); 412 break; 413 case '@':fprintf(out,"@"); 414 break; 415 default :fprintf(out,"@%c",c); 416 break; 417 }; 418 } else 419 if (c=='\\') { 420 switch(c=fgetc(fd)) { 421 case '\\':fprintf(out,"\\"); 422 break; 423 case 'b':fprintf(out,"\b"); break; 424 case 'f':fprintf(out,"\f"); break; 425 case 'n':fprintf(out,"\n"); break; 426 case 'r':fprintf(out,"\r"); break; 427 case 's':fprintf(out," "); break; 428 case 't':fprintf(out,"\t"); break; 429 case '@':fprintf(out,"@"); break; 430 }; 431 } else { 432 fputc(c,out); 433 }; 434 }; 435 fclose(fd); 436 } 363 437 } else { 364 438 fd=fopen("/etc/issue.net","r"); … … 398 472 }; 399 473 times=0; 474 strcpy(name,""); 475 strcpy(pass,""); 400 476 for (;;) { 401 477 times++; … … 407 483 if (out) fprintf(out,"\n"); 408 484 if ((passwd=getpwnam(name))) { 409 setuid(passwd->pw_uid); 410 setgid(passwd->pw_gid); 411 rtems_current_user_env->euid= 412 rtems_current_user_env->egid=0; 413 chown(current_shell_env->devname,passwd->pw_uid,0); 414 rtems_current_user_env->euid=passwd->pw_uid; 415 rtems_current_user_env->egid=passwd->pw_gid; 416 if (!strcmp(passwd->pw_passwd,"*")) { 417 /* /etc/shadow */ 418 return 0; 419 } else { 420 /* crypt() */ 421 return 0; 485 if (strcmp(passwd->pw_passwd,"!")) { /* valid user */ 486 setuid(passwd->pw_uid); 487 setgid(passwd->pw_gid); 488 rtems_current_user_env->euid= 489 rtems_current_user_env->egid=0; 490 chown(current_shell_env->devname,passwd->pw_uid,0); 491 rtems_current_user_env->euid=passwd->pw_uid; 492 rtems_current_user_env->egid=passwd->pw_gid; 493 if (!strcmp(passwd->pw_passwd,"*")) { 494 /* /etc/shadow */ 495 return 0; 496 } else { 497 /* crypt() */ 498 return 0; 499 }; 422 500 }; 423 501 }; 424 502 if (out) fprintf(out,"Login incorrect\n"); 503 strcpy(name,""); 504 strcpy(pass,""); 425 505 }; 426 506 return -1; … … 487 567 fprintf(stderr,"shell:unable to open stdout.%s:%s\n",devname,strerror(errno)); 488 568 }; 569 setvbuf(stdout,NULL,_IONBF,0); /* Not buffered*/ 489 570 stderr=fopen(devname,"r+"); 490 571 if (!stderr) { … … 498 579 shell_add_cmd(NULL,NULL,NULL,NULL); /* init the chain list*/ 499 580 do { 581 /* Set again root user and root filesystem, side effect of set_priv..*/ 582 sc=rtems_libio_set_private_env(); 583 if (sc!=RTEMS_SUCCESSFUL) { 584 rtems_error(sc,"rtems_libio_set_private_env():"); 585 rtems_task_delete(RTEMS_SELF); 586 }; 500 587 if (!shell_login(stdin,stdout)) { 501 588 cat_file(stdout,"/etc/motd"); … … 503 590 strcpy(cmd,""); 504 591 printf("\n" 505 "RTEMS SHELL (Ver sion1.0-FRC):%s. "__DATE__". 'help' to list commands.\n",devname);506 chdir("/"); 592 "RTEMS SHELL (Ver.1.0-FRC):%s. "__DATE__". 'help' to list commands.\n",devname); 593 chdir("/"); /* XXX: chdir to getpwent homedir */ 507 594 shell_env->exit_shell=FALSE; 508 595 for (;;) { … … 514 601 if (!shell_scanline(cmd,sizeof(cmd),stdin,stdout)) break; /*EOF*/ 515 602 /* evaluate cmd section */ 516 if (!strcmp(cmd,"r")) { /* repeat last command, forced, not automatic */ 603 if (!strcmp(cmd,"e")) { /* edit last command */ 604 strcpy(cmd,last_cmd); 605 continue; 606 } else 607 if (!strcmp(cmd,"r")) { /* repeat last command */ 517 608 strcpy(cmd,last_cmd); 518 609 } else … … 537 628 /* end exec cmd section */ 538 629 if (shell_env->exit_shell) break; 630 cmd[0]=0; 539 631 }; 540 632 printf("\nGoodbye from RTEMS SHELL :-(\n"); … … 589 681 return rtems_task_start(task_id,shell_shell,(rtems_task_argument) shell_env); 590 682 } 591 /* ----------------------------------------------- */ -
cpukit/libmisc/shell/shell.h
rbd520203 r70d689a 1 1 /* 2 * 3 * Instantatiate a new terminal shell. 4 * 5 * Author: 6 * 7 * WORK: fernando.ruiz@ctv.es 8 * HOME: correo@fernando-ruiz.com 9 * 10 * Thanks at: 11 * Chris John 12 * 2 13 * $Id$ 3 14 */ … … 54 65 int shell_scanline(char * line,int size,FILE * in,FILE * out) ; 55 66 void cat_file(FILE * out,char *name); 67 void write_file(char *name,char * content); 56 68 57 69 rtems_status_code shell_init(char * task_name , … … 65 77 * current_shell_env; 66 78 /*--------*/ 67 /* pty.c */68 /*--------*/69 70 char * get_pty(int socket);71 72 73 rtems_device_driver pty_initialize(74 rtems_device_major_number major,75 rtems_device_minor_number minor,76 void *arg);77 rtems_device_driver pty_open(78 rtems_device_major_number major,79 rtems_device_minor_number minor,80 void * arg);81 rtems_device_driver pty_close(82 rtems_device_major_number major,83 rtems_device_minor_number minor,84 void * arg);85 rtems_device_driver pty_read(86 rtems_device_major_number major,87 rtems_device_minor_number minor,88 void * arg);89 rtems_device_driver pty_write(90 rtems_device_major_number major,91 rtems_device_minor_number minor,92 void * arg);93 rtems_device_driver pty_control(94 rtems_device_major_number major,95 rtems_device_minor_number minor,96 void * arg);97 98 99 #define PTY_DRIVER_TABLE_ENTRY \100 { pty_initialize , pty_open , pty_close , \101 pty_read , pty_write , pty_control }102 /*--------*/103 79 /* cmds.c */ 104 80 /*--------*/
Note: See TracChangeset
for help on using the changeset viewer.