Annotation of 43BSD/contrib/spms/src/bin/pexec/misc.c, revision 1.1.1.1

1.1       root        1: /* $Header$ */
                      2: 
                      3: /*
                      4:  * Author: Peter J. Nicklin
                      5:  */
                      6: #include <stdio.h>
                      7: #include "macro.h"
                      8: #include "yesno.h"
                      9: 
                     10: /*
                     11:  * ch_dir changes current working directory. Returns integer YES if
                     12:  * successful, otherwise NO.
                     13:  */
                     14: ch_dir(pathname)
                     15:        char *pathname;                 /* pathname of destination directory */
                     16: {
                     17:        extern int IGNORE_BAD_EXIT;     /* exit if command doesn't return 0 */
                     18: 
                     19:        if (!CHDIR(pathname))
                     20:                {
                     21:                pperror(pathname);
                     22:                if (IGNORE_BAD_EXIT == NO)
                     23:                        pxexit();
                     24:                return(NO);
                     25:                }
                     26:        return(YES);
                     27: }
                     28: 
                     29: 
                     30: 
                     31: /*
                     32:  * getpvindex() returns the location of the PROJECT environment
                     33:  * variable in the global cell environ.
                     34:  */
                     35: getpvindex()
                     36: {
                     37:        extern char **environ;          /* global environment cell */
                     38:        register int i;                 /* location of PROJECT env. variable */
                     39:        int strncmp();                  /* compare n characters */
                     40: 
                     41:        for (i = 0; environ[i] != NULL; i++)
                     42:                if (strncmp(environ[i], "PROJECT=", 8) == 0)
                     43:                        return(i);
                     44:        return(-1);
                     45: }
                     46: 
                     47: 
                     48: 
                     49: /*
                     50:  * nomorecore() prints a warning error message and then exits.
                     51:  */
                     52: nomorecore()
                     53: {
                     54:        warn("out of memory");
                     55:        pxexit();
                     56: }
                     57: 
                     58: 
                     59: 
                     60: /*
                     61:  * print_title prints a project directory title.
                     62:  */
                     63: void
                     64: print_title(ppathname)
                     65:        char *ppathname;                /* project directory pathname */
                     66: {
                     67:        static int done_command;        /* has a command been done? */
                     68: 
                     69:        printf((done_command) ? "\n==> %s <==\n" : "==> %s <==\n", ppathname);
                     70:        fflush(stdout);
                     71:        done_command = 1;
                     72: }
                     73: 
                     74: 
                     75: 
                     76: /*
                     77:  * pxexit() calls exit(ERRSTATUS).
                     78:  */
                     79: pxexit()
                     80: {
                     81:        extern int ERRSTATUS;           /* pexec error status */
                     82: 
                     83:        exit(ERRSTATUS);
                     84: }

unix.superglobalmegacorp.com

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