Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator) (01/16/90)
Submitted-by: PERUGIA@ICNUCEVM.CNUCE.CNR.IT (Carlo & Cesare) Posting-number: Volume 90, Issue 014 Archive-name: unix/cshell-4.00a/part01 Shell provides a convient AmigaDos alternative command interface. All its commands are internal and thus does not rely on the c: commands for any functionality. New to 4.00A: - This version is called 4.00A because it is not 100% compatible with previous versions. We choose to accept this in order to better support the new ARP.library 1.3. - External commands are searched in a different order than before; Shell path is now searched AFTER current directory, AmigaDOS path and C:. - ARP pattern matching has been implemented (in part for line arg expanding, fully for search -w). - Internal changes for various optimizations. - Search command has been improved in several ways. - New commands: basename, tackon. - New options: if -v, resident -d, fornum -v -s, dir -n. - Fixed bugs with dir (some dirs remained locked), foreach -v, htype (blanks were treated as binary), info (for devices > 32M). - rback command now works ok (run, however, doesn't). - Oh, I forgot: it also has an AREXX port... And you don't even have to get AREXX to use it. See new commands rxsend, rxrec #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 4)." # Contents: comm3.c globals.c main.c makefile rawconsole.c run.c set.c # shell.h shellfunctions.h # Wrapped by tadguy@xanth on Mon Jan 15 11:28:07 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'comm3.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'comm3.c'\" else echo shar: Extracting \"'comm3.c'\" \(12209 characters\) sed "s/^X//" >'comm3.c' <<'END_OF_FILE' X/* X * COMM3.C X * X * Version 4.00A by Carlo Borreo & Cesare Dieni 13-Jan-90 X * X */ X Xdo_assign() { Xswitch(ac) { X case 1: assignlist(); X break; X case 2: doassign(av[1], NULL); X break; X case 3: doassign(av[1], av[2]); X break; X default: ierror(NULL, 500); X break; X } Xreturn 0; X} X Xchar *assign_errors[4]={ X "", X "Name %s is not valid\n", X "Weird error\n", X "Can't cancel %s\n" X }; X Xdoassign(log, phy) Xchar *log, *phy; X{ Xint last=strlen(log) - 1; X Xif (log[last] != ':') fprintf(stderr, "Bad name %s\n", log); Xelse { X log[last] = 0; X fprintf(stderr,assign_errors[Assign(log, phy)],phy); X } X} X Xassignlist() X{ Xstruct DirectoryEntry *de_head=NULL, *de; Xchar buf[256]; XBPTR lock; Xint ctr=0; X XAddDADevs(&de_head, DLF_DEVICES | DLF_VOLUMES | DLF_DIRS); Xprintf("Devices:\n"); Xfor (de=de_head; de && de->de_Type==DLX_DEVICE; de=de->de_Next) { X printf("%-8s",de->de_Name); X if (ctr++ == 5) { ctr=0; printf("\n"); } X } Xprintf("\n\nVolumes:\n"); Xfor ( ; X de && (de->de_Type==DLX_VOLUME || de->de_Type==DLX_UNMOUNTED); X de=de->de_Next X ) X printf( "%-16s %s\n", X de->de_Name, X de->de_Type == DLX_VOLUME ? "[Mounted]" : "" X ); Xprintf("\nDirectories:\n"); Xfor (; de && de->de_Type==DLX_ASSIGN; de=de->de_Next) { X if (lock=Lock(de->de_Name, ACCESS_READ)) { X PathName(lock, buf, 256L); X UnLock(lock); X } X else X strcpy(buf,"Unexisting lock"); X printf("%-20s%s\n",de->de_Name,buf); X } XFreeDAList(&de_head); X} X Xdo_join() X{ XBPTR sou, dest; Xchar *buffer; Xunsigned int i; Xlong n; Xchar *namedest=av[--ac]; X Xget_opt("r", &i); Xif (options==0 && exists(namedest)) { ierror(namedest,203); return 20; } Xif ( (buffer=malloc(8192)) == NULL ) { ierror(NULL,103); return 20; } Xif ( (dest=Open(namedest, MODE_NEWFILE)) == NULL ) X { pError(namedest); goto fail1; } Xfor (i=1; i<ac; i++) { X if ( (sou=Open(av[i], MODE_OLDFILE)) == NULL ) pError(av[i]); X else X while( (n=Read(sou, buffer, 8192L)) > 0 ) X if (Write(dest, buffer, n) != n) X { pError(namedest); Close(sou); goto fail2; } X Close(sou); X } Xfail2: X Close(dest); Xfail1: X free(buffer); X return 0; X} X X#define BUFDIM 512L X#define MAXSTR 256 X Xint minstr; X Xstrings_in_file(s) Xchar *s; X{ Xchar c; Xchar readbuf[BUFDIM+1], strbuf[MAXSTR+1]; Xregister unsigned int i, strctr=0; XBPTR fh; Xint out, n; X Xif ( fh=Open(s, MODE_OLDFILE) ) { X fprintf(stderr, "Strings in %s (len>=%d):\n",s,minstr); X while ( (n=(int)Read(fh, readbuf, BUFDIM)) > 0 && !CHECKBREAK() ) X for (i=0; i<n; i++) { X c=readbuf[i]; X if (c<0x20 || c>0x7f) { X out=(strctr>=minstr); X if (!out) strctr=0; X } X else { X strbuf[strctr++]=c; X out=(strctr>=BUFDIM); X } X if (out) { X strbuf[strctr]='\0'; X puts(strbuf); X strctr=0; X } X } X Close(fh); X } Xelse pError(s); X} X Xdo_strings() X{ Xminstr=myatoi(av[--ac],1,255); Xall_args("r", strings_in_file, 0); Xreturn 0; X} X XBPTR myfile[MAXMYFILES]; X Xdo_open() X{ Xlong mode; Xunsigned int n; X Xswitch (toupper(av[2][0])) { X case 'R': mode=MODE_OLDFILE; break; X case 'W': mode=MODE_NEWFILE; break; X default : ierror(NULL,500); return; X } Xn=(unsigned int)myatoi(av[3],0,MAXMYFILES-1); if (atoierr) return 20; Xif (myfile[n]) myclose(n); Xmyfile[n]=Open(av[1],mode); Xreturn (myfile[n]==NULL); X} X Xdo_close() X{ Xregister unsigned int i; Xint n; X Xif (ac==1) X for (i=1; i<MAXMYFILES; i++) X myclose(i); Xfor (i=1; i<ac; i++) { X n=myatoi(av[i],0,MAXMYFILES-1); if (atoierr) return 20; X myclose(n); X } Xreturn 0; X} X Xmyclose(n) X{ Xif (myfile[n]) { Close(myfile[n]); myfile[n]=NULL; } X} X Xdo_fileslist() X{ Xregister unsigned short i; Xint flag=0; X Xprintf("Open files:"); Xfor (i=0; i<MAXMYFILES; i++) X if (myfile[i]) { printf(" %d",i); flag=1; } Xif (!flag) printf(" None!"); Xprintf("\n"); Xreturn 0; X} X XBPTR extOpen(name,mode) Xchar *name; Xlong mode; X{ Xif (name[0]=='.') return myfile[atoi(name+1)]; Xreturn Open(name,mode); X} X XextClose(fh) XBPTR fh; X{ Xregister unsigned short i; X Xfor (i=0; i<MAXMYFILES; i++) X if (myfile[i]==fh) return; XClose(fh); X} X Xdo_basename() X{ Xset_var(LEVEL_SET, av[1], BaseName(av[2])); Xreturn 0; X} X Xdo_tackon() X{ Xchar buf[256]; X Xstrcpy(buf, av[2]); XTackOn(buf, av[3]); Xset_var(LEVEL_SET, av[1], buf); Xreturn 0; X} X Xdo_resident() X{ Xunsigned int i; Xregister struct ResidentProgramNode *p; Xchar buf[256]; X Xget_opt("ard", &i); Xif (options==0 && ac>1) options=1; Xswitch (options) { X case 0: X ObtainSemaphore (& (ArpBase->ResPrgProtection) ); X if (p=ArpBase->ResidentPrgList) { X printf("Name Users Access\n"); X for (; p; p=p->rpn_Next) X printf("%-17s%5ld%6ld\n", X p->rpn_Name-2, (long)p->rpn_Usage, (long)p->rpn_AccessCnt); X } X else printf("No resident program(s)\n"); X ReleaseSemaphore(& (ArpBase->ResPrgProtection) ); X break; X case 1: X for (; i<ac; i++) X if (loadres(av[i])) X printf("OK! %s is now resident\n", BaseName(av[i])); X else pError(av[i]); X break; X case 2: X for (; i<ac; i++) X if (RemResidentPrg(av[i])) ierror(av[i],202); X else printf("Removed %s\n",av[i]); X break; X case 4: X for (; i<ac; i++) { X sprintf(buf,"res_%s",av[i]); X Setenv(buf,"1"); X } X break; X default: X ierror(NULL,500); X break; X } Xreturn 0; X} X Xint loadres(s) Xchar *s; X{ XBPTR seg; X Xif (seg=(BPTR)LoadPrg(s)) AddResidentPrg(seg,BaseName(s)); Xreturn (seg != NULL); X} X Xstruct ProcessControlBlock pcb={ X 4000, /* pcb_StackSize */ X 0, /* pcb_Pri */ X }; X/* remaining field are NULL */ X Xdo_truerun(avline, backflag) Xchar *avline; X{ Xchar name[200]; Xchar *FindIt(); X Xif (backflag) { X pcb.pcb_Control=NULL; X pcb.pcb_Input=pcb.pcb_Output=Open("NIL:",MODE_OLDFILE); X } Xelse { X pcb.pcb_Control=NULL; X pcb.pcb_Input=pcb.pcb_Output =NULL; X } Xif (FindIt(av[1], "", name)) X ASyncRun(name,next_word(next_word(avline)),&pcb); Xelse X ierror(av[1],205); Xreturn 0; X} X Xint exists(name) Xchar *name; X{ XBPTR lock; X Xif (lock=Lock(name,ACCESS_READ)) { X UnLock(lock); X return 1; X } Xreturn 0; X} X Xdo_aset() X{ XSetenv(av[1],av[2]); Xreturn 0; X} X X#define HTYPELINE 16L X Xhtype_a_file(s) Xchar *s; X{ XBPTR fh; Xlong n, filesize=0; Xchar buf[HTYPELINE+1]; Xregister unsigned short i; X Xif ( (fh=Open(s,MODE_OLDFILE))==NULL ) { pError(s); return 20; } Xwhile ( (n=Read(fh,buf,HTYPELINE))>0 && !dobreak()) { X printf("%06lx: ",filesize); X filesize+=n; X for (i=0; i<n; i++) { X printf( (i&3) ? "%02x" : " %02x",(int)(unsigned char)buf[i]); X if (buf[i]<0x20) buf[i]='.'; X } X for ( ; i<HTYPELINE; i++) { X printf( (i&3) ? " " : " "); X buf[i]=' '; X } X buf[i]=0; X printf(" %s\n",buf); X } XClose(fh); Xreturn 0; X} X Xdo_htype() X{ Xall_args("", htype_a_file, 0); Xreturn 0; X} X Xdo_stack() X{ Xlong n; X Xif (ac>1) { X n=Atol(av[1]); X if (!IoErr()) Mycli->cli_DefaultStack=(long)(n >> 2L); X } Xelse printf("current stack size is %ld bytes\n", X (long)Mycli->cli_DefaultStack << 2L); Xreturn 0; X} X Xdo_fault() X{ Xstruct PERROR *p; Xregister unsigned int i; Xint n; X Xfor (i=1; i<ac; i++) { X n=myatoi(av[i],0,32767); X if (!atoierr) { X for (p=Perror; p->errnum && p->errnum!=n; p++); X if (p->errnum) X printf("Fault %d: %s\n",n,p->errstr); X else X printf("Fault %d not recognized\n",n); X } X } Xreturn 0; X} X Xstruct rpncommand { X char *str; X int parsin, parsout; X }; X Xstruct rpncommand rpn[]={ X "+", 2, 1, X "-", 2, 1, X "*", 2, 1, X "/", 2, 1, X "%", 2, 1, X "&", 2, 1, X "|", 2, 1, X "~", 1, 1, X ">", 2, 1, X "<", 2, 1, X "==", 2, 1, X "!", 1, 1, X "DUP", 1, 2, X "DROP", 1, 0, X "SWAP", 2, 2, X "HELP", 0, 0, X NULL, 0, 1, /* this looks for a number */ X}; X Xdo_rpn(garbage,ifflag) /* ifflag!=0 if called from if */ Xchar *garbage; X{ Xregister long n0, n1; Xlong t; Xunsigned int i, j; Xint sp=0; Xlong stack[100]; Xstruct rpncommand *temp; X Xi=1; Xif (ifflag) get_opt("rn",&i); Xfor (; i<ac; i++) { X for (j=0; rpn[j].str && Strcmp(rpn[j].str,av[i]); j++) ; X n0=stack[sp-1]; X n1=stack[sp-2]; X sp -= (rpn[j].parsin); X if (sp<0) { fprintf(stderr, "RPN: Empty stack\n"); return 1; } X switch (j) { X case 0: n0 += n1; break; X case 1: n0 = n1-n0; break; X case 2: n0 *= n1; break; X case 3: n0 = n1/n0; break; X case 4: n0 = n1%n0; break; X case 5: n0 &= n1; break; X case 6: n0 |= n1; break; X case 7: n0 = ~n0; break; X case 8: n0 = (n1 > n0); break; X case 9: n0 = (n1 < n0); break; X case 10: n0 = (n0 == n1); break; X case 11: n0 = !n0; break; X case 12: n1=n0; break; X case 13: t=n0; n0=n1; n1=t; break; X case 14: break; X case 15: printf("In Commands Out\n"); X for (temp=rpn; temp->str; temp++) X printf(" %d %-10s%d\n", X temp->parsin,temp->str,temp->parsout); X break; X default: n0=Atol(av[i]); X if (IoErr()) { X fprintf(stderr, "Bad RPN cmd: %s\n",av[i]); X return 20; X } X break; X } X stack[sp]=n0; X stack[sp+1]=n1; X sp += rpn[j].parsout; X } Xif (ifflag) return (int)(stack[sp-1]); /* called from if: return top value */ Xfor (i=sp-1;(int)i>=0;i--) printf("%ld\n", stack[i]); /* else print stack */ Xreturn 0; X} X Xdo_path() X{ Xunion { long *lp; long ll; } l; Xchar buf[256]; X Xputs("Current dir"); Xl.lp = (long *) Mycli->cli_CommandDir; Xwhile (l.ll) { X l.ll <<= 2; X PathName(l.lp[1], buf, 256L); X puts(buf); X l.ll = *l.lp; X } Xputs("C:"); Xreturn 0; X} X Xdo_pri() X{ Xint t, pri; Xstruct Process *proc; X Xt=myatoi(av[1],0,20); if (atoierr) return 20; Xpri=myatoi(av[2],-128,127); if (atoierr) return 20; XForbid(); Xproc=(t==0 ? Myprocess : FindCLI((long)t)); Xif (proc==NULL) fprintf(stderr, "process not found\n"); X else SetTaskPri(proc, (long)pri); XPermit(); Xreturn 0; X} X Xdo_strleft() X{ Xchar buf[256]; Xint n; X Xstrcpy(buf,av[2]); Xn=myatoi(av[3],1,strlen(buf)); if (atoierr) return 20; Xbuf[n]='\0'; Xset_var(LEVEL_SET, av[1], buf); Xreturn 0; X} X Xdo_strright() X{ Xchar buf[256]; Xint n; X Xstrcpy(buf, av[2]); Xn=myatoi(av[3],1,strlen(buf)); if (atoierr) return 20; Xset_var(LEVEL_SET, av[1], buf+strlen(buf)-n); Xreturn 0; X} X Xdo_strmid() X{ Xchar buf[256]; Xint n1, n2; X Xstrcpy(buf, av[2]); Xn1=myatoi(av[3],1,strlen(buf))-1; if (atoierr) return 20; Xif (ac>4) { X n2=myatoi(av[4],1,strlen(buf)-n1); if (atoierr) return 20; X buf[n1+n2]='\0'; X } Xset_var(LEVEL_SET, av[1], buf+n1); Xreturn 0; X} X Xdo_strlen() X{ Xchar buf[16]; X Xsprintf(buf,"%d",strlen(av[2])); Xset_var(LEVEL_SET, av[1], buf); Xreturn 0; X} X Xint atoierr; X Xmyatoi(s,min,max) Xchar *s; X{ Xint n; X Xn=(int)(long)Atol(s); Xif (atoierr=IoErr()) X ierror(s,511); X else if (n<min || n>max) { X atoierr=1; X printf("%s(%d) not in (%d,%d)\n",s,n,min,max); X } Xreturn n; X} X Xdo_fltlower() X{ Xchar buf[256], *s; X Xwhile (!CHECKBREAK() && gets(buf)) { X for (s=buf; *s; s++) *s=tolower(*s); X puts(buf); X } Xreturn 0; X} X Xdo_fltupper() X{ Xchar buf[256], *s; X Xwhile (!CHECKBREAK() && gets(buf)) { X for (s=buf; *s; s++) *s=toupper(*s); X puts(buf); X } Xreturn 0; X} X X#define RXFB_RESULT 17 X Xstatic struct rexxmsg { X struct Message cm_Node; X LONG RFU1; X LONG RFU2; X LONG rm_Action; X LONG rm_Result1; X LONG rm_Result2; X char *cm_Args[16]; X LONG RFU7; X LONG RFU8; X LONG RFU9; X LONG RFU10; X LONG RFU11; X LONG RFU12; X} mymsg; X Xdo_rxsend() X{ Xint i=1, resflag; Xchar *result; Xstruct MsgPort *port, *reply; Xlong len; X Xget_opt("r", &i); Xresflag=options; Xif (!(port = FindPort(av[i++]))) { fprintf(stderr, "No port %s!\n", av[--i]); return 20; } Xmymsg.cm_Node.mn_Node.ln_Type = NT_MESSAGE; Xmymsg.cm_Node.mn_Length = sizeof(struct rexxmsg); Xmymsg.rm_Action = (resflag ? 1L << RXFB_RESULT : 0); Xif (!(reply = CreatePort(NULL, 0L))) { X fprintf(stderr, "No reply port\n"); X return 20; X } Xmymsg.cm_Node.mn_ReplyPort = reply; X Xfor ( ; i<ac; i++) { X mymsg.cm_Args[0] = av[i]; X mymsg.rm_Result2 = 0; /* clear out the last result. */ X PutMsg(port, &mymsg.cm_Node); X WaitPort(reply); X X if (resflag) { X result=(char *)mymsg.rm_Result2; X len=*( (long *)(result-4) ); X if (len<0 || len>256) X fprintf(stderr, "Risultato troppo lungo\n"); X else X printf("%s\n", result); X FreeMem(result, len); X } X } X Xif (reply) DeletePort(reply); Xreturn 0; X} X Xdo_rxrec() X{ Xstruct MsgPort *port; Xstruct rexxmsg *msg; Xchar *portname, *str; X Xif (ac > 1) X portname=av[1]; Xelse X portname="rexx_csh"; X Xport=CreatePort(portname, 0L); Xif (port==NULL) { X fprintf(stderr, "Can't have MsgPort %s\n", portname); X return 20; X } Xfor (;;) { X WaitPort(port); X while (msg=(struct rexxmsg *)GetMsg(port)) { X if ( ! Strcmp(msg->cm_Args[0], "bye")) { X DeletePort(port); X return 0; X } X exec_command(msg->cm_Args[0]); X if (msg->rm_Action & (1L << RXFB_RESULT)) { X str = get_var(LEVEL_SET, v_lasterr); X msg->rm_Result2=(str) ? atoi(str) : 20; X } X ReplyMsg((struct Message *)msg); X } X } X} END_OF_FILE if test 12209 -ne `wc -c <'comm3.c'`; then echo shar: \"'comm3.c'\" unpacked with wrong size! fi # end of 'comm3.c' fi if test -f 'globals.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'globals.c'\" else echo shar: Extracting \"'globals.c'\" \(3551 characters\) sed "s/^X//" >'globals.c' <<'END_OF_FILE' X X/* X * GLOBALS.C X * X * (c)1986 Matthew Dillon 9 October 1986 X * X * Version 2.07M by Steve Drew 10-Sep-87 X * X * Most global variables. X * X * Version 4.00A by Carlo Borreo & Cesare Dieni 13-Jan-90 X * X */ X Xchar v_titlebar []="_titlebar"; /* Window title */ Xchar v_prompt []="_prompt"; /* your prompt (ascii command) */ Xchar v_hist []="_history"; /* set history depth (value) */ Xchar v_histnum []="_histnum"; /* set history numbering var */ Xchar v_debug []="_debug"; /* set debug mode */ Xchar v_verbose []="_verbose"; /* set verbose for source files */ Xchar v_stat []="_maxerr"; /* worst return value to date */ Xchar v_lasterr []="_lasterr"; /* return value from last comm. */ Xchar v_cwd []="_cwd"; /* current directory */ Xchar v_except []="_except"; /* "nnn;command" */ Xchar v_passed []="_passed"; /* passed arguments to source file */ Xchar v_path []="_path"; /* search path for external commands */ Xchar v_gotofwd []="_gtf"; /* set name for fwd goto name */ Xchar v_linenum []="_linenum"; /* name for forline line # */ X Xstruct HIST *H_head, *H_tail; /* HISTORY lists */ X Xstruct PERROR Perror[]= { /* error code->string */ X 103, "Insufficient free storage", X 105, "Task table full", X 120, "Argument line invalid or too long", X 121, "File is not an object module", X 122, "Invalid resident library during load", X 201, "No default directory", X 202, "Object in use", X 203, "Object already exists", X 204, "Directory not found", X 205, "Object not found", X 206, "Bad stream name", X 207, "Object too large", X 209, "Action not known", X 210, "Invalid stream component name", X 211, "Invalid object lock", X 212, "Object not of required type", X 213, "Disk not validated", X 214, "Disk write protected", X 215, "Rename across devices", X 216, "Directory not empty", X 217, "Too many levels", X 218, "Device not mounted", X 219, "Seek error", X 220, "Comment too long", X 221, "Disk full", X 222, "File delete protected", X 223, "File write protected", X 224, "File read protected", X 225, "Not a DOS disk", X 226, "No disk", X X /* custom error messages */ X X 500, "Bad arguments", X 501, "Label not found", X 502, "Must be within source file", X 503, "Syntax Error", X 504, "Redirection error", X 505, "Pipe error", X 506, "Too many arguments", X 507, "Destination not a directory", X 508, "Cannot mv a filesystem", X 509, "Error in command name", X 510, "Bad drive name", X 511, "Illegal number", X 0, NULL X}; X Xchar *av[MAXAV]; /* Internal argument list */ Xlong Src_base[MAXSRC]; /* file pointers for source files */ Xlong Src_pos[MAXSRC]; /* seek position storage for same */ Xchar If_base[MAXIF]; /* If/Else stack for conditionals */ Xint H_len, H_tail_base; /* History associated stuff */ Xint H_stack; /* AddHistory disable stack */ Xint E_stack; /* Exception disable stack */ Xint Src_stack, If_stack; /* Stack Indexes */ Xint forward_goto; /* Flag for searching for foward lables */ Xint ac; /* Internal argc */ Xint debug; /* Debug mode */ Xint disable; /* Disable com. execution (conditionals)*/ Xint Verbose; /* Verbose mode for source files */ Xint Lastresult; /* Last return code */ Xint Exec_abortline; /* flag to abort rest of line */ Xint Quit; /* Quit flag */ Xlong Cout, Cin; /* Current input and output file handles*/ Xlong Cout_append; /* append flag for Cout */ Xchar *Cin_name, *Cout_name; /* redirection input/output name or NULL*/ Xchar *Pipe1, *Pipe2; /* the two pipe temp. files */ Xstruct Process *Myprocess; Xstruct CommandLineInterface *Mycli; Xint S_histlen = 20; /* Max # history entries */ Xunsigned int options; END_OF_FILE if test 3551 -ne `wc -c <'globals.c'`; then echo shar: \"'globals.c'\" unpacked with wrong size! fi # end of 'globals.c' fi if test -f 'main.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'main.c'\" else echo shar: Extracting \"'main.c'\" \(4977 characters\) sed "s/^X//" >'main.c' <<'END_OF_FILE' X/* X * MAIN.C X * X * Matthew Dillon, 24 Feb 1986 X * (c)1986 Matthew Dillon 9 October 1986 X * X * Version 2.07M by Steve Drew 10-Sep-87 X * X * Version 4.00A by Carlo Borreo & Cesare Dieni 13-Jan-90 X * X */ X Xchar shellname[]="Shell V4.00A"; Xchar shellctr []="CshCounter"; X Xint aux; /* for use with aux: driver */ Xchar *oldtitle; Xchar trueprompt[100]; Xchar Inline[260]; Xstruct IntuitionBase *IntuitionBase; Xstruct Window *w; Xstruct ArpBase *ArpBase; X Xmain(argc, argv) Xregister char *argv[]; X{ X#if RAW_CONSOLE X char *rawgets(); X#endif X Xregister unsigned int i; Xextern int Enable_Abort; Xchar buf[10]; Xstatic char pipe1[32], pipe2[32]; Xstruct Window *getwindow(); X XArpBase=(struct ArpBase *)OpenLibrary("arp.library",34L); Xif (ArpBase==NULL) { printf("No arp library\n"); exit(0); } X XForbid(); Xi=0; Xif (Getenv(shellctr,buf,10L)) { X i=(int)(long)Atol(buf); X if (IoErr()) i=0; X } Xsprintf(buf,"%d",i+1); XSetenv(shellctr,buf); XPermit(); X XIntuitionBase=(struct IntuitionBase *)ArpBase->IntuiBase; X Xstdin->_flags |= 0x80; /* make sure we're set as a tty */ Xstdout->_flags |= 0x80; /* in case of redirection in .login */ XClose(_devtab[2].fd); X_devtab[2].mode |= O_STDIO; X_devtab[2].fd = _devtab[1].fd; /* set stderr to Output() otherwise */ X /* don't work with aux driver */ XMyprocess = (struct Process *)FindTask(0L); XMycli=(struct CommandLineInterface *)((long)Myprocess->pr_CLI << 2); Xw=getwindow(); XPipe1 = pipe1; XPipe2 = pipe2; Xsprintf(pipe1, "ram:pipe1_%ld", Myprocess); Xsprintf(pipe2, "ram:pipe2_%ld", Myprocess); X Xsprintf(buf,"%ld",Myprocess->pr_TaskNum); Xset_var(LEVEL_SET, "_clinumber", buf); X Xoldtitle=(char *)(w->Title); X Xset_var(LEVEL_SET, v_titlebar, shellname); Xset_var(LEVEL_SET, v_prompt, X (IsInteractive(Input())) ? "\23337m%p> \2330m" : ""); Xset_var(LEVEL_SET, v_hist, "20"); Xset_var(LEVEL_SET, v_lasterr, "0"); Xset_var(LEVEL_SET, v_stat, "0"); Xset_var(LEVEL_SET, v_path, "RAM:,RAM:c/,df0:c/,df1:c/,sys:system/"); Xset_var(LEVEL_SET, "_insert", "1"); Xset_var(LEVEL_SET, "f1", "cdir df0:\15"); Xset_var(LEVEL_SET, "F1", "cdir df1:\15"); Xset_var(LEVEL_SET, "f3", "cdir RAM:\15"); Xset_var(LEVEL_SET, "F3", "cdir vd0:\15"); Xset_var(LEVEL_SET, "f4", "cd df0:\15"); Xset_var(LEVEL_SET, "F4", "cd df1:\15"); Xset_var(LEVEL_SET, "f5", "cls; ls\15"); Xset_var(LEVEL_SET, "F5", "cdir "); Xset_var(LEVEL_SET, "f6", "lc\15"); Xset_var(LEVEL_SET, "f7", "info\15"); Xset_var(LEVEL_SET, "F7", "assign \15"); Xset_var(LEVEL_SET, "f8", "window -lf\15"); Xset_var(LEVEL_SET, "F8", "window -sb\15"); Xset_var(LEVEL_SET, "f10", "cls\15"); Xset_var(LEVEL_SET, "F10", "exit\15"); Xset_var(LEVEL_ALIAS, "cls", "echo -n ^l"); Xset_var(LEVEL_ALIAS, "lc", "ls -s"); Xset_var(LEVEL_ALIAS, "kr", "rm -r RAM:* >NIL:"); Xset_var(LEVEL_ALIAS, "cdir", "%q cd $q; cls; dir"); Xset_var(LEVEL_ALIAS, "exit", "endcli;quit"); Xset_var(LEVEL_ALIAS, "lp", "cat >PRT:"); Xseterr(); Xif (Myprocess->pr_CurrentDir == NULL) X do_cd("x :"); Xelse do_pwd(NULL); XEnable_Abort = 0; X Xif (exists(av[1] = "S:.login")) do_source("x S:.login"); X Xfor (i = 1; i < argc; ++i) { X if (!strcmp(argv[i],"-c")) { X Inline[0] = ' '; X Inline[1] = '\0'; X while (++i < argc) X { strcat(Inline,argv[i]); strcat(Inline," "); } X exec_command(Inline); X main_exit(Lastresult); X } X if (!strcmp(argv[i],"-a")) { aux = 1; continue; } X sprintf (Inline, "source %s",argv[i]); X av[1] = argv[i]; X do_source (Inline); X } Xfor (;;) { X if (breakcheck()) X while (WaitForChar(Input(), 100L) || stdin->_bp < stdin->_bend) X gets(Inline); X clearerr(stdin); /* prevent acidental quit */ X#if RAW_CONSOLE X if (Quit || !rawgets(Inline, disable ? "_ " : trueprompt)) main_exit(0); X#else X printf("%s", disable ? "_ " : trueprompt); X fflush(stdout); X if (Quit || !gets(Inline)) main_exit(0); X#endif X breakreset(); X if (*Inline) exec_command(Inline); X } X} X Xmain_exit(n) X{ Xregister unsigned short i; Xchar buf[10]; X XGetenv(shellctr,buf,10L); Xi=(int)Atol(buf); Xsprintf(buf,"%d",i-1); XSetenv(shellctr,buf); XSetWindowTitles(w,oldtitle,-1L); Xfor (i=1; i<MAXMYFILES; i++) myclose((int)i); XArpExit(0L,0L); /* Intuition need not to be closed */ X} X Xbreakcheck() X{ Xreturn (int)(SetSignal(0L,0L) & SIGBREAKF_CTRL_C); X} X Xbreakreset() X{ XSetSignal(0L, SIGBREAKF_CTRL_C); X} X Xdobreak() X{ Xif (breakcheck()) { printf("^C\n"); return(1); } Xreturn(0); X} X X/* this routine causes manx to use this Chk_Abort() rather than it's own */ X/* otherwise it resets our ^C when doing any I/O (even when Enable_Abort */ X/* is zero). Since we want to check for our own ^C's */ X XChk_Abort() X{ Xreturn(0); X} X X_wb_parse() X{ X} X Xdo_howmany() X{ Xchar buf[10]; X XGetenv(shellctr, buf, 10L); Xprintf("Shell(s) running: %s\n",buf); X} X Xstruct Window *getwindow() X{ Xstruct InfoData *infodata; Xstruct Window *win; Xlong args[8]; X Xinfodata=AllocMem((long)sizeof(struct InfoData),MEMF_CLEAR | MEMF_PUBLIC); Xargs[0]=(long)infodata >> 2; XSendPacket(ACTION_DISK_INFO,args,Myprocess->pr_ConsoleTask); Xwin=(struct Window *)infodata->id_VolumeNode; XFreeMem(infodata,(long)sizeof(struct InfoData)); Xreturn win; X} END_OF_FILE if test 4977 -ne `wc -c <'main.c'`; then echo shar: \"'main.c'\" unpacked with wrong size! fi # end of 'main.c' fi if test -f 'makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'makefile'\" else echo shar: Extracting \"'makefile'\" \(1019 characters\) sed "s/^X//" >'makefile' <<'END_OF_FILE' X###################################################################### X# X# Makefile to build Shell 4.00A X# by Carlo Borreo & Cesare Dieni 13-Gen-90 X# X###################################################################### X XOBJS = run.o main.o comm1.o comm2.o comm3.o execom.o set.o sub.o \ X globals.o rawconsole.o X XINCL = shell.h X XShell : Shell.syms $(OBJS) X ln +q -m -o Shell $(OBJS) -la -lc32 X XShell.syms : $(INCL) X cc +L +HShell.syms shell.h -DAZTEC_C X Xrawconsole.o : rawconsole.c $(INCL) X cc +L +IShell.syms rawconsole.c X Xrun.o : run.c $(INCL) X cc +L +IShell.syms run.c X Xmain.o : main.c $(INCL) X cc +L +IShell.syms main.c X Xcomm1.o : comm1.c $(INCL) X cc +L +IShell.syms comm1.c X Xcomm2.o : comm2.c $(INCL) X cc +L +IShell.syms comm2.c X Xcomm3.o : comm3.c $(INCL) X cc +L +IShell.syms comm3.c X Xset.o : set.c $(INCL) X cc +L +IShell.syms set.c X Xsub.o : sub.c $(INCL) X cc +L +IShell.syms sub.c X Xglobals.o : globals.c $(INCL) X cc +L +IShell.syms globals.c X Xexecom.o : execom.c $(INCL) X cc +L +IShell.syms execom.c END_OF_FILE if test 1019 -ne `wc -c <'makefile'`; then echo shar: \"'makefile'\" unpacked with wrong size! fi # end of 'makefile' fi if test -f 'rawconsole.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'rawconsole.c'\" else echo shar: Extracting \"'rawconsole.c'\" \(9156 characters\) sed "s/^X//" >'rawconsole.c' <<'END_OF_FILE' X/* X * RawConsole.c X * X * Shell 2.07M 17-Jun-87 X * console handling, command line editing support for Shell X * using new console packets from 1.2. X * Written by Steve Drew. (c) 14-Oct-86. X * 16-Dec-86 Slight mods to rawgets() for Disktrashing. X * X * Version 4.00A by Carlo Borreo & Cesare Dieni 13-Jan-90 X * X */ X X#if RAW_CONSOLE X Xchar *tyahdptr; X Xmyget() X{ Xif (*tyahdptr) return *tyahdptr++; Xreturn getchar(); X} X Xextern int aux; /* for use with aux: */ X X#define SETRAW setrawcon(-1L); X#define SETCON setrawcon(0L); X Xint width; X Xnewwidth() X{ Xextern struct Window *w; X Xwidth=(w->Width- (w->BorderLeft + w->BorderRight)) / w->RPort->TxWidth; X} X Xchar *rawgets(line,prompt) Xchar *line, *prompt; X{ Xchar *get_var(); Xchar *gets(); Xregister int n, pl; Xregister int max, i; Xunsigned char c1,c2,c3; Xchar fkeys[5]; Xchar *s; Xchar *ps; Xchar typeahd[256]; Xint fkey, savn; Xint insert = 1; Xint recall = -1; Xstruct HIST *hist; X Xnewwidth(); X Xif (aux) { X printf("%s",prompt); X fflush(stdout); X } Xif (!IsInteractive(Input()) || aux ) return(gets(line)); Xif (WaitForChar((long)Input(), 100L) || /* don't switch to 1L ...*/ X stdin->_bp < stdin->_bend) { /* else causes read err's*/ X gets(line); X return(line); X } XSETRAW; Xprintf("\015%s\2336n",prompt); Xsavn = pl = n = 0; Xtyahdptr = typeahd; Xwhile((typeahd[n]=getchar()) != 'R') { X if ((unsigned char)typeahd[n] == 155) savn = n; X n++; X } X /* typeahd now contains possible type a head chars X followed by <CSI> cursor position report. X */ Xtypeahd[savn] = '\0'; Xif (typeahd[n-2] != ';') pl = (typeahd[n-2] - 48) * 10; Xpl += typeahd[n-1] - 49; Xps = line + pl; Xline[max = i = pl] = '\0'; X Xif (s = get_var (LEVEL_SET, "_insert")) insert = atoi(s) ? 1 : 0; X Xwhile( (c1 = myget()) != 255) { X switch(c1) { X case 155: X c2 = myget(); X switch(c2) { X case 'A': /* up arrow */ X n = ++recall; X case 'B': /* down arrow */ X line[pl] = '\0'; X if (recall >= 0 || c2 == 'A') { X if (c2 == 'B') n = --recall; X if (recall >= 0) { X for(hist = H_head; hist && n--; X hist = hist->next); X if (hist) strcpy(&line[pl],hist->line); X else recall = H_len; X } X } X if (i != pl) X printf("\233%dD",i); X printf("\015\233J%s%s",prompt,ps); X i = max = strlen(ps) + pl; X break; X case 'C': /* right arrow*/ X if (i < max) { X i++; X printf("\233C"); X } X break; X case 'D': /* left arrow */ X if (i > pl) { X i--; X printf("\233D"); X } X break; X case 'T': /* shift-up */ X n = recall = H_len-1; X case 'S': /* shift-down */ X line[pl] = '\0'; X if (c2 == 'S') { X n = recall = 0; X if (H_head) strcpy(&line[pl], H_head->line); X } X else if (H_tail) strcpy(&line[pl], H_tail->line); X printf("\015\233J%s%s", prompt, ps); X i = max = strlen(ps) + pl; X break; X case ' ': /* shift -> <-*/ X c3 = myget(); X switch(c3) { X case('@'): /* shift -> */ X while (ps[i-pl-1] == ' ' && i<max) { X i++; X printf("\233C"); X } X while (ps[i-pl-1] != ' ' && i<max) { X i++; X printf("\233C"); X } X break; X case('A'): /* shift <- */ X while (ps[i-pl-1] == ' ' && i>pl) { X i--; X printf("\233D"); X } X while (ps[i-pl-1] != ' ' && i>pl) { X i--; X printf("\233D"); X } X break; X default: X break; X } X break; X default: X c3 = myget(); X if (c3 == '~') { X fkey = c2; X fkeys[0] = 'f'; X if (c2 == '?') { X strcpy(ps,"help"); X goto done; X } X } X else if (myget() != '~') { /* window was resized */ X while(myget() != '|'); X newwidth(); X break; X } X else { X fkey = c3; X fkeys[0] = 'F'; X } X sprintf(fkeys+1,"%d",fkey - 47); X if (s = get_var(LEVEL_SET, fkeys)) X tyahdptr = strcpy(typeahd,s); X break; X } X break; X case 8: X if (i > pl) { X i--; X printf("\010"); X } X else break; X case 127: X if (i < max) { X int j,t,l = 0; X movmem(&line[i+1],&line[i],max-i); X --max; X printf("\233P"); X j = width - i % width - 1; /* amount to end */ X t = max/width - i/width; /* no of lines */ X for(n = 0; n < t; n++) { X l += j; /* no. of char moved */ X if (j) printf("\233%dC",j); /* goto eol */ X printf("%c\233P",line[width*(i/width+n+1)-1]); X j = width-1; X } X if (t) X printf("\233%dD",l+t); /* get back */ X } X break; X case 18: X n = i/width; X if (n) printf("\233%dF",n); X printf("\015\233J%s%s",prompt,ps); X i = max; X break; X case 27: X break; X case 1: X insert ^= 1; X break; X case 21: X case 24: X case 26: X if (i>pl) printf("\233%dD",i-pl); X i = pl; X if (c1 == 26) break; X case 11: /* ^K */ X printf("\233J"); X max = i; X line[i] = '\0'; X break; X case 28: /* ^\ */ X SETCON; X return(NULL); X case 5: X if (i!=max) printf("\233%dC",max - i); X i = max; X break; X case 10: X case 13: X line[max] = '\0'; Xdone: printf("\233%dC\n",max - i); X X SETCON; X strcpy(line, ps); X return(line); X default: X c1 &= 0x7f; X if (c1 == 9) c1 = 32; X if (c1 > 31 & i < 256) { X if (i < max && insert) { X int j,t,l = 0; X movmem(&line[i], &line[i+1], max - i); X printf("\233@%c",c1); X t = max/width - i/width; X j = width - i % width - 1; X for(n = 0; n < t; n++) { X l += j; X if (j) printf("\233%dC",j); X printf("\233@%c",line[width*(i/width+n+1)]); X j = width-1; X } X if (t) printf("\233%dD",l + t); X ++max; X } X else { X if(i == pl && max == i) printf("\015%s%s",prompt,ps); X putchar(c1); X } X line[i++] = c1; X if (max < i) max = i; X line[max] = '\0'; X } X } X } XSETCON; Xreturn(NULL); X} X Xsetrawcon(flag) /* -1L=RAW:, 0L=CON: */ Xlong flag; X{ Xlong packargs[8]; X Xpackargs[0]=flag; XSendPacket(994L, packargs, Myprocess->pr_ConsoleTask); X} X X#endif END_OF_FILE if test 9156 -ne `wc -c <'rawconsole.c'`; then echo shar: \"'rawconsole.c'\" unpacked with wrong size! fi # end of 'rawconsole.c' fi if test -f 'run.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'run.c'\" else echo shar: Extracting \"'run.c'\" \(1712 characters\) sed "s/^X//" >'run.c' <<'END_OF_FILE' X X/* X * RUN.C X * X * (c)1986 Matthew Dillon 9 October 1986 X * X * RUN handles running of external commands. X * X * Version 2.07M by Steve Drew 10-Sep-87 X * X * Version 4.00A by Carlo Borreo & Cesare Dieni 13-Jan-90 X * X */ X Xchar *FindIt(); X Xdo_run(str) Xchar *str; X{ Xint retcode; Xchar buf[200]; /* enough space for 100 char cmd name + path stuff */ Xchar *path, *argline, *trueargline, *copy, *p = av[0]; X Xwhile(*p++) *p &= 0x7F; /* allow "com mand" */ X Xargline=compile_av(av, 1, ac, ' ', 1); Xtrueargline= (*argline ? argline : "\n"); X Xif (strlen(av[0]) > 100) { ierror(NULL,509); return -1; } X Xsprintf(buf,"res_%s",BaseName(av[0])); Xif (Getenv(buf, buf+100, 90L) && loadres(av[0])) Setenv(buf,NULL); Xretcode=SyncRun(av[0],trueargline,0L,0L); Xif (retcode>=0) { free(argline); return retcode; } Xif (path = FindIt(av[0],"",buf)) { X retcode = SyncRun(path,trueargline,0L,0L); X free(argline); X return retcode; X } Xelse free(argline); Xif ((path = FindIt(av[0],".sh",buf)) == NULL) { X fprintf(stderr,"Command Not Found %s\n",av[0]); X return -1; X } Xav[1] = buf; Xcopy = malloc(strlen(str)+3); Xsprintf(copy,"x %s",str); Xretcode = do_source(copy); Xfree(copy); Xreturn retcode; X} X Xchar *dofind(cmd, ext, buf) Xchar *cmd, *ext, *buf; X{ Xchar *ptr, *s; X Xsprintf(buf,"%s%s",cmd,ext); Xif (exists(buf)) return buf; Xif (BaseName(buf)==buf) { X s = get_var(LEVEL_SET, v_path); X while (*s) { X for (ptr=buf; *s && *s!=','; ) *ptr++ = *s++; X sprintf(ptr, "%s%s", cmd, ext); X if (exists(buf)) return buf; X if (*s) s++; X } X } Xreturn NULL; X} X Xchar *FindIt(cmd,ext,buf) Xchar *cmd, *ext, *buf; X{ Xchar *response; X XMyprocess->pr_WindowPtr = (APTR)(-1); Xresponse=dofind(cmd,ext,buf); XMyprocess->pr_WindowPtr = NULL; Xreturn response; X} END_OF_FILE if test 1712 -ne `wc -c <'run.c'`; then echo shar: \"'run.c'\" unpacked with wrong size! fi # end of 'run.c' fi if test -f 'set.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'set.c'\" else echo shar: Extracting \"'set.c'\" \(3884 characters\) sed "s/^X//" >'set.c' <<'END_OF_FILE' X X/* X * SET.C X * X * (c)1986 Matthew Dillon 9 October 1986 X * X * Version 2.07M by Steve Drew 10-Sep-87 X * X * Version 4.00A by Carlo Borreo & Cesare Dieni 13-Jan-90 X * X */ X Xextern struct Window *w; X X#define MAXLEVELS (3 + MAXSRC) X Xstruct MASTER { X struct MASTER *next; X struct MASTER *last; X char *name; X char *text; X}; X Xstatic struct MASTER *Mbase[MAXLEVELS]; X Xchar *set_var(level, name, str) Xregister char *name, *str; X{ X register struct MASTER *base = Mbase[level]; X register struct MASTER *last; X register int len; X X for (len = 0; isalphanum(name[len]); ++len); X while (base != NULL) { X if (strlen(base->name) == len && strncmp (name, base->name, len) == 0) { X Free (base->text); X goto gotit; X } X last = base; X base = base->next; X } X if (base == Mbase[level]) { X base = Mbase[level] = (struct MASTER *)malloc (sizeof(struct MASTER)); X base->last = NULL; X } else { X base = (struct MASTER *)malloc (sizeof(struct MASTER)); X base->last = last; X last->next = base; X } X base->name = malloc (len + 1); X bmov (name, base->name, len); X base->name[len] = 0; X base->next = NULL; Xgotit: X base->text = malloc (strlen(str) + 1); X strcpy (base->text, str); X if (*name=='_') sys_vars(); X return (base->text); X} X Xchar *get_var (level, name) Xregister char *name; X{ X register struct MASTER *base = Mbase[level]; X register unsigned char *scr; X register int len; X X for (scr = (unsigned char *)name; *scr && *scr != 0x80 && *scr != ' ' && *scr != ';' && *scr != '|'; ++scr); X len = scr - name; X X while (base != NULL) { X if (strlen(base->name) == len && strncmp (name, base->name, len) == 0) X return (base->text); X base = base->next; X } X return (NULL); X} X Xunset_level(level) X{ X register struct MASTER *base = Mbase[level]; X X while (base) { X Free (base->name); X Free (base->text); X Free (base); X base = base->next; X } X Mbase[level] = NULL; X} X Xunset_var(level, name) Xchar *name; X{ X register struct MASTER *base = Mbase[level]; X register struct MASTER *last = NULL; X register int len; X X for (len = 0; isalphanum(name[len]); ++len); X while (base) { X if (strlen(base->name) == len && strncmp (name, base->name, len) == 0) { X if (base != Mbase[level]) X last->next = base->next; X else X Mbase[level] = base->next; X if (base->next != NULL) X base->next->last = last; X if (base == Mbase[level]) X Mbase[level] = base->next; X Free (base->name); X Free (base->text); X Free (base); X return (1); X } X last = base; X base = base->next; X } X return (-1); X} X Xdo_unset_var(str, level) Xchar *str; X{ Xregister unsigned int i; X Xfor (i = 1; i < ac; ++i) unset_var (level, av[i]); Xsys_vars(); Xreturn 0; X} X Xdo_set_var(command, level) Xchar *command; X{ Xregister struct MASTER *base = Mbase[level]; Xregister char *str; X Xswitch (ac) { Xcase 1: X while (base && !dobreak()) { X printf ("\2330m%-10s %s\n", base->name, base->text); X base = base->next; X } X break; Xcase 2: X if (str=get_var(level,av[1])) printf ("%-10s %s\n", av[1], str); X break; Xdefault: X set_var (level, av[1], next_word (next_word (command))); X if (*av[1]=='_') sys_vars(); X break; X } Xreturn 0; X} X Xsys_vars() X{ Xregister char *str, *t; Xextern char trueprompt[100]; X Xif (strcmp(w->Title, str=get_var(LEVEL_SET, v_titlebar))) X SetWindowTitles(w, str, -1L); XS_histlen=(str = get_var(LEVEL_SET, v_hist)) ? atoi(str) : 0; Xdebug =(get_var(LEVEL_SET, v_debug) !=NULL); XVerbose=(get_var(LEVEL_SET, v_verbose)!=NULL); Xif (S_histlen < 2) S_histlen=2; X Xif ( (str=get_var(LEVEL_SET,v_prompt)) ==NULL) str="$ "; Xt=trueprompt; Xwhile (*str) X if (*str=='%' && str[1]=='p') { X str+=2; X strcpy(t,get_var(LEVEL_SET, "_cwd")); X t+=strlen(t); X } X else *t++=*str++; Xstrcpy(t,"\2330m"); X} END_OF_FILE if test 3884 -ne `wc -c <'set.c'`; then echo shar: \"'set.c'\" unpacked with wrong size! fi # end of 'set.c' fi if test -f 'shell.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'shell.h'\" else echo shar: Extracting \"'shell.h'\" \(3029 characters\) sed "s/^X//" >'shell.h' <<'END_OF_FILE' X X/* X * SHELL.H X * X * (c)1986 Matthew Dillon 9 October 1986 X * X * X * SHELL include file.. contains shell parameters and extern's X * X * Version 2.07M by Steve Drew 10-Sep-87 X * X * Version 4.00A by Carlo Borreo & Cesare Dieni 13-Jan-90 X * X */ X X#define RAW_CONSOLE 1 /* Set to 0 to compile out Cmd Line Editing */ X X#include <stdio.h> X#include <exec/exec.h> X#include <time.h> X#include <libraries/dos.h> X#include <libraries/dosextens.h> X#include <intuition/intuition.h> X#include <intuition/intuitionbase.h> X#include "shellfunctions.h" X#include <fcntl.h> X#include <libraries/arpbase.h> X Xtypedef struct FileInfoBlock FIB; X X#define bmov movmem X X#define MAXAV 256 /* Max. # arguments */ X#define MAXSRC 5 /* Max. # of source file levels */ X#define MAXIF 10 /* Max. # of if levels */ X#define MAXALIAS 20 /* Max. # of alias levels */ X#define MAXMYFILES 9 /* Max. # of internal files */ X X#define LEVEL_SET 0 /* which variable list to use */ X#define LEVEL_ALIAS 1 X#define LEVEL_LABEL 2 X X /* EXECOM.C defines */ X X#define FL_DOLLAR 0x01 /* One of the following */ X#define FL_BANG 0x02 X#define FL_PERCENT 0x04 X#define FL_QUOTE 0x08 X#define FL_IDOLLAR 0x10 /* Any or all of the following may be set */ X#define FL_EOC 0x20 X#define FL_EOL 0x40 X#define FL_OVERIDE 0x80 X#define FL_WILD 0x100 X#define FL_MASK (FL_DOLLAR|FL_BANG|FL_PERCENT|FL_QUOTE) X X#ifndef NULL X#define NULL 0L X#endif X X#define CHECKBREAK() dobreak() X X#ifndef AZTEC_C Xstruct _dev { X long fd; X short mode; X }; X#endif X Xstruct HIST { X struct HIST *next, *prev; /* doubly linked list */ X char *line; /* line in history */ X}; X Xstruct PERROR { X int errnum; /* Format of global error lookup */ X char *errstr; X}; X Xstruct DPTR { /* Format of directory fetch pointer */ X BPTR lock; /* lock on directory */ X FIB *fib; /* mod'd fib for entry */ X }; X Xextern struct HIST *H_head, *H_tail; Xextern struct PERROR Perror[]; Xextern struct DPTR *dopen(); Xextern char *set_var(), *get_var(), *next_word(); Xextern char *get_history(), *compile_av(), *get_pwd(); Xextern char *malloc(), *strcpy(), *strcat(), *index(); Xextern char **expand(); Xextern char *av[]; Xextern char *Current; Xextern int H_len, H_tail_base, H_stack; Xextern int E_stack; Xextern int Src_stack, If_stack, forward_goto; Xextern int ac; Xextern int debug, Rval, Verbose, disable, Quit; Xextern int Lastresult, atoierr; Xextern int Exec_abortline; Xextern int S_histlen; Xextern unsigned int options; Xextern long Cin, Cout, Cout_append; Xextern char *Cin_name, *Cout_name; Xextern char Cin_type, Cout_type; /* these variables are in transition */ Xextern char *Pipe1, *Pipe2; X Xextern long Src_base[MAXSRC]; Xextern long Src_pos[MAXSRC]; Xextern char If_base[MAXIF]; Xextern struct Process *Myprocess; Xextern struct CommandLineInterface *Mycli; X Xextern struct ArpBase *ArpBase; X Xextern long atol(), Atol(), myatol(); X Xextern char v_titlebar[], v_prompt[], v_hist[], v_histnum[], v_debug[], X v_verbose[], v_stat[], v_lasterr[], v_cwd[], v_except[], X v_passed[], v_path[], v_gotofwd[], v_linenum[]; END_OF_FILE if test 3029 -ne `wc -c <'shell.h'`; then echo shar: \"'shell.h'\" unpacked with wrong size! fi # end of 'shell.h' fi if test -f 'shellfunctions.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'shellfunctions.h'\" else echo shar: Extracting \"'shellfunctions.h'\" \(9694 characters\) sed "s/^X//" >'shellfunctions.h' <<'END_OF_FILE' Xtypedef long cList; Xextern int Enable_Abort; X Xlong AbleICR(); Xlong AbortIO(); Xlong ActivateGadget(); Xvoid ActivateWindow(); Xvoid AddAnimOb(); Xvoid AddBob(); Xvoid AddConfigDev(); Xvoid AddDevice(); Xlong AddDosNode(); Xvoid AddFont(); Xvoid AddFreeList(); Xshort AddGadget(); Xunsigned short AddGList(); Xvoid AddHead(); Xstruct Interrupt * AddICRVector(); Xvoid AddIntServer(); Xvoid AddLibrary(); Xlong AddMemList(); Xvoid AddPort(); Xvoid AddResource(); Xvoid AddSemaphore(); Xvoid AddTail(); Xvoid AddTask(); Xvoid AddTime(); Xvoid AddVSprite(); Xlong Alert(); Xvoid * AllocAbs(); Xlong AllocBoardMem(); XcList AllocCList(); Xstruct ConfigDev * AllocConfigDev(); Xstruct MemList * AllocEntry(); Xunsigned long AllocExpansionMem(); Xvoid * AllocMem(); Xlong AllocPotBits(); Xvoid * AllocRaster(); Xchar * AllocRemember(); Xlong AllocSignal(); Xlong AllocTrap(); Xstruct WBObject * AllocWBObject(); Xvoid * Allocate(); Xvoid AlohaWorkbench(); Xvoid AndRectRegion(); Xlong AndRegionRegion(); Xvoid Animate(); Xshort AreaDraw(); Xlong AreaEllipse(); Xvoid AreaEnd(); Xshort AreaMove(); Xvoid AskFont(); Xlong AskSoftStyle(); Xlong AttemptLockLayerRom(); Xlong AttemptSemaphore(); Xshort AutoRequest(); Xlong AvailFonts(); Xlong AvailMem(); Xvoid BeginIO(); Xvoid BeginRefresh(); Xvoid BeginUpdate(); Xvoid BeginLayer(); Xlong BltBitMap(); Xlong BltBitMapRastPort(); Xvoid BltClear(); Xvoid BltMaskBitMapRastPort(); Xvoid BltPattern(); Xvoid BltTemplate(); Xstruct Window * BuildSysRequest(); Xchar * BumpRevision(); Xvoid Cause(); Xvoid CBump(); Xstruct Events * CDInputHandler(); Xvoid ChangeSprite(); Xstruct IORequest * CheckIO(); Xshort ClearDMRequest(); Xvoid ClearEOL(); Xvoid ClearMenuStrip(); Xvoid ClearPointer(); Xvoid ClearRegion(); Xlong ClearRectRegion(); Xvoid ClearScreen(); Xvoid ClipBit(); Xvoid Close(); Xvoid CloseDevice(); Xvoid CloseFont(); Xvoid CloseLibrary(); Xvoid CloseScreen(); Xvoid CloseWindow(); Xshort CloseWorkBench(); Xvoid CMove(); Xshort CmpTime(); Xlong ConcatCList(); Xlong ConfigBoard(); Xlong ConfigChain(); Xlong ConsoleDevice(); Xlong CopperListInit(); XcList CopyCList(); Xvoid CopyMem(); Xvoid CopyMemQuick(); Xvoid CopySBitMap(); Xstruct Layer * CreateBehindLayer(); XBPTR CreateDir(); Xstruct MsgPort * CreatePort(); Xstruct Process * CreateProc(); Xstruct IOStdReq * CreateStdIO(); Xstruct Task * CreateTask(); Xstruct Layer * CreateUpfrontLayer(); XBPTR CurrentDir(); Xvoid CurrentTime(); Xvoid CWait(); Xlong * DateStamp(); Xvoid Deallocate(); Xvoid Debug(); Xvoid Delay(); Xshort DeleteFile(); Xvoid DeleteLayer(); Xvoid DeletePort(); Xvoid DeleteStdIO(); Xvoid DeleteTask(); Xstruct Process * DeviceProc(); Xvoid Disable(); Xvoid DisownBlitter(); Xshort DisplayAlert(); Xvoid DisplayBeep(); Xvoid DisposeRegion(); Xvoid DoCollision(); Xlong DoIO(); Xshort DoubleClick(); Xvoid Draw(); Xvoid DrawBorder(); Xvoid DrawEllipse(); Xvoid DrawGList(); Xvoid DrawImage(); XBPTR DupLock(); Xvoid Enable(); Xvoid EndRefresh(); Xvoid EndRequest(); Xvoid EndUpdate(); Xvoid Enqueue(); Xshort ExNext(); Xshort Examine(); Xshort Execute(); Xvoid Exit(); Xstruct ConfigDev * FindConfigDev(); Xstruct Node * FindName(); Xstruct MsgPort * FindPort(); Xstruct Resident * FindResident(); Xstruct SignalSemaphore * FindSemaphore(); Xstruct Task * FindTask(); Xchar * FindToolType(); Xshort Flood(); Xvoid FlushCList(); Xvoid Forbid(); Xvoid FreeBoardMem(); Xvoid FreeCList(); Xvoid FreeColorMap(); Xvoid FreeConfigDev(); Xvoid FreeCopList(); Xvoid FreeCprList(); Xvoid FreeDiskObject(); Xvoid FreeEntry(); Xvoid FreeExpansionMem(); Xvoid FreeFreeList(); Xvoid FreeGBuffers(); Xvoid FreeMem(); Xvoid FreePotBits(); Xvoid FreeRaster(); Xvoid FreeRemember(); Xvoid FreeSignal(); Xvoid FreeSprite(); Xvoid FreeSysRequest(); Xvoid FreeTrap(); Xvoid FreeVPortCopLists(); Xvoid FreeWBObject(); Xlong GetCC(); Xlong GetCLBuf(); Xshort GetCLChar(); Xshort GetCLWord(); Xstruct ColorMap * GetColorMap(); Xlong GetCurrentBinding(); Xstruct Preferences * GetDefPrefs(); Xstruct DiskObject * GetDiskObject(); Xshort GetGBuffers(); Xlong GetIcon(); Xstruct Message * GetMsg(); Xstruct Preferences * GetPrefs(); Xshort GetRGB4(); Xlong GetScreenData(); Xshort GetSprite(); Xstruct WBObject * GetWBObject(); Xlong IncrCLMark(); Xshort Info(); Xvoid InitArea(); Xvoid InitBitMap(); Xlong InitCLPool(); Xvoid InitCode(); Xvoid InitGMasks(); Xvoid InitGels(); Xvoid InitMasks(); Xvoid InitRastPort(); Xvoid InitRequester(); Xvoid InitResident(); Xvoid InitSemaphore(); Xvoid InitStruct(); Xvoid InitTmpRas(); Xvoid InitVPort(); Xvoid InitView(); XBPTR Input(); Xvoid Insert(); Xstruct Region * InstallClipRegion(); Xlong IntuiTextLength(); Xstruct InputEvent * Intuition(); Xlong IoErr(); Xshort IsInteractive(); Xstruct MenuItem * ItemAddress(); Xvoid LoadRGB4(); Xstruct Segment * LoadSeg(); Xvoid LoadView(); XBPTR Lock(); Xvoid LockLayer(); Xvoid LockLayerInfo(); Xvoid LockLayerRom(); Xvoid LockLayers(); Xstruct DeviceNode * MakeDosNode(); Xlong MakeFunctions(); Xstruct Library * MakeLibrary(); Xvoid MakeScreen(); Xvoid MakeVPort(); Xlong MarkCList(); Xlong MatchToolValue(); Xvoid ModifyIDCMP(); Xvoid ModifyProp(); Xvoid Move(); Xlong MoveLayer(); Xvoid MoveScreen(); Xvoid MoveSprite(); Xvoid MoveWindow(); Xvoid MrgCop(); Xvoid NewList(); Xvoid NewModifyProp(); Xstruct Region * NewRegion(); Xvoid ObtainConfigBinding(); Xvoid ObtainSemaphore(); Xvoid ObtainSemaphoreList(); Xvoid OffGadget(); Xvoid OffMenu(); Xvoid OnGadget(); Xvoid OnMenu(); XBPTR Open(); Xlong OpenDevice(); Xstruct Font * OpenDiskFont(); Xstruct Font * OpenFont(); Xvoid OpenIntuition(); Xstruct Library * OpenLibrary(); Xstruct MiscResource * OpenResource(); Xstruct Screen * OpenScreen(); Xstruct Window * OpenWindow(); Xshort OpenWorkBench(); Xvoid OrRectRegion(); Xlong OrRegionRegion(); XBPTR Output(); Xvoid OwnBlitter(); XBPTR ParentDir(); Xshort PeekCLMark(); Xvoid Permit(); Xvoid PolyDraw(); Xvoid PrintIText(); Xlong PutCLBuf(); Xlong PutCLChar(); Xlong PutCLWord(); Xshort PutDiskObject(); Xlong PutIcon(); Xvoid PutMsg(); Xlong PutWBObject(); Xvoid QBSBlit(); Xvoid QBlit(); Xshort RawKeyConvert(); Xlong Read(); Xchar ReadExpansionByte(); Xlong ReadExpansionRom(); Xshort ReadPixel(); Xvoid RectFill(); Xvoid RefreshGadgets(); Xvoid RefreshGList(); Xvoid RefreshWindowFrame(); Xvoid ReleaseConfigBinding(); Xvoid ReleaseSemaphore(); Xvoid ReleaseSemaphoreList(); Xvoid RemConfigDev(); Xlong RemDevice(); Xvoid RemFont(); Xstruct Node * RemHead(); Xvoid RemIBob(); Xvoid RemICRVector(); Xvoid RemIntServer(); Xlong RemLibrary(); Xunsigned short RemoveGList(); Xvoid RemPort(); Xvoid RemResource(); Xvoid RemSemaphore(); Xstruct Node * RemTail(); Xvoid RemTask(); Xvoid RemVSprite(); Xvoid RemakeDisplay(); Xvoid Remove(); Xunsigned short RemoveGadget(); Xshort Rename(); Xvoid ReplyMsg(); Xvoid ReportMouse(); Xshort Request(); Xvoid RethinkDisplay(); Xvoid ScreenToBack(); Xvoid ScreenToFront(); Xvoid ScrollLayer(); Xvoid ScrollRaster(); Xvoid ScrollVPort(); Xlong Seek(); Xvoid SendIO(); Xvoid SetAPen(); Xvoid SetBPen(); Xvoid SetCollision(); Xshort SetComment(); Xvoid SetCurrentBinding(); Xshort SetDMRequest(); Xvoid SetDRMd(); Xlong SetExcept(); Xlong SetFont(); Xlong SetFunction(); Xlong SetICR(); Xstruct Interrupt * SetIntVector(); Xshort SetMenuStrip(); Xvoid SetPointer(); Xstruct Preferences * SetPrefs(); Xshort SetProtection(); Xvoid SetRast(); Xvoid SetRGB4(); Xvoid SetRGB4CM(); Xlong SetSR(); Xlong SetSignal(); Xlong SetSoftStyle(); Xshort SetTaskPri(); Xvoid SetWindowTitles(); Xvoid ShowTitle(); Xvoid Signal(); Xlong SizeCList(); Xshort SizeLayer(); Xvoid SizeWindow(); Xvoid SortGList(); XcList SplitCList(); XcList SubCList(); Xvoid SubTime(); Xvoid SubLibrary(); Xvoid SumKickData(); Xlong SuperState(); Xvoid SwapBitsRastPortClipRect(); Xvoid SyncSBitMap(); Xlong Text(); Xlong TextLength(); Xlong Translate(); Xlong UnGetCLChar(); Xlong UnGetCLWord(); Xvoid UnLoadSeg(); Xvoid UnLock(); Xshort UnPutCLChar(); Xshort UnPutCLWord(); Xvoid UnlockLayer(); Xvoid UnlockLayerInfo(); Xvoid UnlockLayerRom(); Xvoid UnlockLayers(); Xshort UpfrontLayer(); Xvoid UserState(); Xshort VBeamPos(); Xstruct View * ViewAddress(); Xstruct ViewPort * ViewPortAddress(); Xshort WBenchToBack(); Xshort WBenchToFront(); Xlong Wait(); Xvoid WaitBOVP(); Xvoid WaitBlit(); Xshort WaitForChar(); Xlong WaitIO(); Xstruct Message * WaitPort(); Xvoid WaitTOF(); Xstruct Layer * WhichLayer(); Xshort WindowLimits(); Xvoid WindowToBack(); Xvoid WindowToFront(); Xlong Write(); Xlong WriteExpansionByte(); Xvoid WritePixel(); Xvoid WritePotgo(); Xvoid XorRectRegion(); Xlong XorRegionRegion(); END_OF_FILE if test 9694 -ne `wc -c <'shellfunctions.h'`; then echo shar: \"'shellfunctions.h'\" unpacked with wrong size! fi # end of 'shellfunctions.h' fi echo shar: End of archive 1 \(of 4\). cp /dev/null ark1isdone MISSING="" for I in 1 2 3 4 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 4 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0 -- Submissions to comp.sources.amiga and comp.binaries.amiga should be sent to: amiga@cs.odu.edu or amiga@xanth.cs.odu.edu ( obsolescent mailers may need this address ) or ...!uunet!xanth!amiga ( very obsolescent mailers need this address ) Comments, questions, and suggestions s should be addressed to ``amiga-request'' (only use ``amiga'' for submissions) at the above addresses.