/* * Pseudo shell to access gulam from a child process * * Michal Jaegermann, October 1988 * Michael Ritzert, August 1990 */ #include #include #include #define SHELLP ((char **) 0x04f6L) #define G_MAGIC 0x0135 main(argc,argv) int argc; char * argv[]; { register int k; long save_ssp; short sh_magic; char buf[258]; char *tgptr; /* storage for togu_ */ /* if you really would like to have it right, then */ /* tgptr should be a pointer to void - */ /* a bit of overkill on ST :-) */ int (* cgp)(); /* pointer to callgulam() */ /* also contains togu_, but */ /* a type is different */ void (* glp)(); /* pointer to getlineviaue() */ save_ssp = Super(0L); tgptr = *SHELLP; Super(save_ssp); if (G_MAGIC != (sh_magic = *((short *)(tgptr - 8)))) { Cconws ("wrong magic value --- this is not gulam\r\n"); exit (1); } cgp = ((int (*)()) tgptr); glp = ((void (*)()) (tgptr - 6)); if(argc > 1) { buf[0]=0; for(k=1 ; k<=argc-1 ; k++ ) { strcat(buf,argv[k]); strcat(buf," "); } (* cgp)( buf ); } else { (* cgp)("echo 'Gulaam entered.'"); (* cgp)("echo 'Please type \"exit\" to exit.'"); while ((* glp)(buf), putchar('\n'), 0 != strcmp(buf,"exit")) { /* the new line not supplied */ /* by Gulam - DIY, mate */ (* cgp)(buf); } } exit(0); }