Annotation of 43BSDTahoe/new/spms/src/bin/pexec/exec.c, revision 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 "null.h"
        !             9: #include "path.h"
        !            10: #include "pdb.h"
        !            11: #include "pdlist.h"
        !            12: #include "pld.h"
        !            13: #include "slslist.h"
        !            14: #include "spms.h"
        !            15: #include "yesno.h"
        !            16: 
        !            17: /*
        !            18:  * execlist() executes a project directory list. Returns non-zero error
        !            19:  * status if error.
        !            20:  */
        !            21: execlist(pdlist)
        !            22:        PDLIST *pdlist;                 /* project directory list */
        !            23: {
        !            24:        extern int ERRSTATUS;           /* pexec error status */
        !            25:        extern int EXECUTE;             /* execute command? */
        !            26:        extern int PRINT_HEADING;       /* print headings for project dirs */
        !            27:        int ch_dir();                   /* change current working directory */
        !            28:        int execcmd();                  /* execute command in directory */
        !            29:        int status = 0;                 /* return status */
        !            30:        PDBLK *pdblk;                   /* project directory list block */
        !            31:        void print_title();             /* print project directory title */
        !            32: 
        !            33:        for (pdblk = pdlist->head; pdblk != NULL; pdblk = pdblk->next)
        !            34:                {
        !            35:                if (PRINT_HEADING == YES)
        !            36:                        print_title(pdblk->ppath);
        !            37:                if (ch_dir(pdblk->rpath) == NO)
        !            38:                        status = ERRSTATUS;
        !            39:                else if (EXECUTE == YES)
        !            40:                        status |= execcmd(pdblk->project);
        !            41:                }
        !            42:        return(status);
        !            43: }
        !            44: 
        !            45: 
        !            46: 
        !            47: /*
        !            48:  * execproject() builds a project directory list and executes commands
        !            49:  * within directories on that list.
        !            50:  */
        !            51: execproject(ppathname, pathname)
        !            52:        char *ppathname;                /* project root dir project pathname */
        !            53:        char *pathname;                 /* regular project root dir pathname */
        !            54: {
        !            55:        extern int ERRSTATUS;           /* pexec error status */
        !            56:        char ppathbuf[PPATHSIZE];       /* project pathname buffer */
        !            57:        char *pdprepend();              /* prepend project directory */
        !            58:        char *ppathcat();               /* project pathname concatenation */
        !            59:        char *slsprepend();             /* prepend key+string */
        !            60:        int closepdb();                 /* close database */
        !            61:        int errpdb();                   /* print database error message */
        !            62:        int execlist();                 /* execute project directory list */
        !            63:        int slssort();                  /* sort list */
        !            64:        int status = 0;                 /* return status */
        !            65:        int strcmp();                   /* string comparison */
        !            66:        PATH *pd;                       /* pathname struct pointer */
        !            67:        PATH *readpld();                /* read project link directory entry */
        !            68:        PDB *openpdb();                 /* open database */
        !            69:        PDB *pldp;                      /* project link directory stream */
        !            70:        PDLIST *pdinit();               /* initialize project directory list */
        !            71:        PDLIST *pdlist;                 /* project directory list */
        !            72:        SLSBLK *pblk;                   /* project list block */
        !            73:        SLSLIST *plist;                 /* project list */
        !            74:        SLSLIST *slsinit();             /* initialize list */
        !            75:        void pdrm();                    /* remove project directory list */
        !            76:        void pdsort();                  /* sort project directory list */
        !            77:        void slsrm();                   /* remove list item */
        !            78: 
        !            79:        pdlist = pdinit();
        !            80:        plist = slsinit();
        !            81: 
        !            82:        /* read PLDNAME project link directory */
        !            83:        if ((pldp = openpdb(PLDNAME, pathname, "r")) == NULL)
        !            84:                return(errpdb((PDB *) NULL));
        !            85:        while ((pd = readpld(pldp)) != NULL)
        !            86:                {
        !            87:                if (EQUAL(pd->p_alias, PARENTPROJECT))
        !            88:                        continue;
        !            89: 
        !            90:                if (EQUAL(pd->p_alias, CURPROJECT))
        !            91:                        {
        !            92:                        pdprepend(ppathname, pd->p_path, pathname, pdlist);
        !            93:                        }
        !            94:                else if (pd->p_mode == P_IFPROOT)
        !            95:                        {
        !            96:                        if (slsprepend(pd->p_alias, pd->p_path, plist) == NULL)
        !            97:                                pxexit();
        !            98:                        }
        !            99:                else    {
        !           100:                        ppathcat(ppathbuf, ppathname, pd->p_alias);
        !           101:                        pdprepend(ppathbuf, pd->p_path, pathname, pdlist);
        !           102:                        }
        !           103:                }
        !           104:        if (closepdb(pldp) != 0)
        !           105:                status = ERRSTATUS;
        !           106: 
        !           107:        /* sort and execute project directories */
        !           108:        pdsort(strcmp, pdlist);
        !           109:        status |= execlist(pdlist);
        !           110:        pdrm(pdlist);
        !           111: 
        !           112:        /* execute subprojects */
        !           113:        if (slssort(strcmp, plist) == NO)
        !           114:                pxexit();
        !           115:        for (pblk = plist->head; pblk != NULL; pblk = pblk->next)
        !           116:                {
        !           117:                ppathcat(ppathbuf, ppathname, pblk->key);
        !           118:                status |= execproject(ppathbuf, pblk->string);
        !           119:                }
        !           120:        slsrm(CNULL, plist);
        !           121: 
        !           122:        return(status);
        !           123: }

unix.superglobalmegacorp.com

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