Annotation of 40BSD/games/compat/modshell/compat.c, revision 1.1.1.1

1.1       root        1: #include "defs.h"
                      2: #define BS 8
                      3: #define        MAXARGS 300
                      4: short buf[BS];
                      5: /*
                      6:  *     Check for possible program to run under alternate runtime system
                      7:  *     If it checks out, start the rts and pass file and args
                      8:  *     Art Wetzel 3/13/80
                      9:  */
                     10: compat(file, argv, envp) char *file, *argv[], *envp[]; {
                     11:        register int fd;
                     12:        register char *rts;
                     13:        register char **nargv;
                     14:        char    *nargs[MAXARGS];
                     15:        /* alternate rts images must be readable */
                     16:        /* if not just go back and let rest of shell worry about it */
                     17:        if((fd = open(file,0))<0)
                     18:                return(0);
                     19:        /* read first BS pdp-11 words */
                     20:        if(read(fd,buf,sizeof buf) != sizeof buf) {
                     21:                close(fd);
                     22:                /* if can't, go back as it may be a short shell file */
                     23:                return(0);
                     24:        }
                     25:        close(fd);
                     26:        /* check type of image and set up run time system name */
                     27:        if(buf[0]==0407 || buf[0]==0410 || buf[0]==0411 || buf[0]==0405) {
                     28:                /* looks like UNIX a.out file */
                     29:                /* RTS or default rts */
                     30:                if((rts = rtsnod.namval) == 0)
                     31:                        rts = defrts;
                     32:                /* if header unused is set to 1 force version 6 */
                     33:                /* this is not a real difference between v6 and v7 a.outs */
                     34:                /* rather, version 6 a.outs were patched to be identifiable */
                     35:                if(buf[6] == 1)
                     36:                        rts = "/usr/bin/v6run";
                     37:        } else if(buf[6] == 0) {
                     38:                /* it looks like almost all RT-11 save images have 0 here */
                     39:                rts = "/usr/bin/rtrun";
                     40:        } else {
                     41:                /* was not a recognizable file type */
                     42:                return(0);
                     43:        }
                     44:        /* must make a new argv list with runtime system prefix */
                     45:        nargv = &nargs[0];
                     46:        *nargv++ = rts;
                     47:        /* have to pass full file name to rts */
                     48:        *nargv++ = file;
                     49:        argv++;
                     50:        while(*argv && nargv < &nargs[MAXARGS-1])
                     51:                *nargv++ = *argv++;
                     52:        /* force in final null */
                     53:        *nargv++ = (char *)0;
                     54:        /* try to start rts */
                     55:        execve(nargs[0], nargs, envp);
                     56:        /* if that failed, report no runtime system */
                     57:        failed(nargs[0], norts);
                     58: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.