home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_200 / 200_01 / shell.sci < prev    next >
Text File  |  1979-12-31  |  3KB  |  97 lines

  1. #
  2. # Small C Interpreter command shell
  3. #
  4. char _nr, _nc, _ro, _co, *_cp, *_el, _mhz;
  5.  
  6. putchar(c){return sys(c,2,1);}
  7. getchar(){return sys(1,2);}
  8. puts(b){return sys(b,2,3);}
  9. putd(n){return printf("%d\n",n);}
  10. putx(n){return printf("%x\n",n);}
  11. puto(n){return printf("%o\n",n);}
  12. gets(b){return sys(b,80,1,4);}
  13. fputc(c,u){return sys(c,u,1);}
  14. fgetc(u){return sys(u,2);}
  15. fputs(b,u){return sys(b,u,3);}
  16. fgets(b,n,u){return sys(b,n,u,4);}
  17. sprintf(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9){sys(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,5);}
  18. printf(a0,a1,a2,a3,a4,a5,a6,a7,a8)
  19. {char b[128];sys(b,a0,a1,a2,a3,a4,a5,a6,a7,a8,5);puts(b);}
  20. sscanf(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9){sys(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,6);}
  21. scanf(a0,a1,a2,a3,a4,a5,a6,a7,a8)
  22. {char b[128];gets(b);sys(b,a0,a1,a2,a3,a4,a5,a6,a7,a8,6);}
  23. atoi(b){int v;sys(b,"%d",&v,6);return v;}
  24. fopen(f,m){return sys(f,m,7);}
  25. fread(s,l,u){return sys(s,l,u,8);}
  26. fwrite(s,l,u){return sys(s,l,u,9);}
  27. fclose(u){return sys(u,10);}
  28. fseek(u,o,w){return sys(u,o,w,11);}
  29. ftell(u){return sys(u,12);}
  30. bdos(a,b){return sys(a,b,13);}
  31. system(s){return sys(s,14);}
  32. exit(){sys(15);}
  33. strcmp(s,t){return sys(s,t,20);}
  34. strncmp(s,t,n){return sys(s,t,n,20);}
  35. strcpy(s,t){return sys(s,t,21);}
  36. strncpy(s,t,n){return sys(s,t,n,21);}
  37. strlen(s){return sys(s,22);}
  38. malloc(n){return sys(n,23);}
  39. free(p){sys(p,24);}
  40. debug(n){sys(n,28);}
  41. check(n){sys(1,n,28);}
  42. dirscan(p,f){return sys(p,f,29);}
  43. int86(i,e,r){return sys(i,e,r,30);}
  44. memleft(){return sys(31);}
  45.  
  46. entry
  47. main()
  48. {
  49.    int f, t;
  50.    char buf[24];
  51.    char line[81];
  52.    char program[ memleft()-1024 ];
  53.  
  54.    puts(sys(0));
  55.    puts("\nSCI Shell V1.5 20Oct86 Copyright (C) 1986 Bob Brodt\n");
  56.    *program='Z';
  57.    _mhz=12; 
  58.  
  59.    _nr=25; _nc=80;
  60.    _ro=_co=1;
  61.    _cp="\033[%d;%dH";
  62.    _el="\033[0K";
  63.  
  64.    for(;;) {
  65.       puts("shell> ");
  66.       line[5]=0;
  67.       if(gets(line)) {
  68.          if (!strncmp(line,"edit",4))
  69.             sys(atoi(line+4),program,19);
  70.          else if (!strncmp(line,"list",4)) {
  71.             f=1;
  72.             t=32765;
  73.             if(line[4])
  74.                sscanf(line+4,"%d %d",&f,&t);
  75.             sys(program,f,t,27);
  76.          }
  77.          else if (!strncmp(line,"save",4))
  78.             sys(line+5,program,26);
  79.          else if (!strncmp(line,"load",4))
  80.             sys(line+5,program,25);
  81.          else if (!strncmp(line,"exit",4))
  82.             return;
  83.          else if (!strncmp(line,"dir",3)) {
  84.             if ( !line[3] )
  85.                strcpy(line+4,"*.*");
  86.             if ( dirscan(line+4,buf) ) {
  87.                printf("%s\n",buf);
  88.                while(dirscan(0,buf))
  89.                   printf("%s\n",buf);
  90.             }
  91.          }
  92.          else
  93.             printf("\n%d\n",sys(line,program,16));
  94.       }
  95.    }
  96. }
  97.