OSSP CVS Repository

ossp - Check-in [3442]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3442
Date: 2003-Jun-13 20:33:07 (local)
2003-Jun-13 18:33:07 (UTC)
User:ms
Branch:
Comment: Sweeping cleanups. Reduced the analyzer to almost nothing. Removed unused method prototypes. Added 'parse' mode option that doesn't work yet. Removed procReadtmp. Change the way we build path names from the locations directory.
Tickets:
Inspections:
Files:
ossp-pkg/rc/rc.h      1.47 -> 1.48     2 inserted, 12 deleted
ossp-pkg/rc/rc_anal.c      1.19 -> 1.20     39 inserted, 131 deleted
ossp-pkg/rc/rc_cliopt.c      1.17 -> 1.18     3 inserted, 0 deleted
ossp-pkg/rc/rc_config.c      1.31 -> 1.32     11 inserted, 10 deleted
ossp-pkg/rc/rc_config.h      1.5 -> 1.6     23 inserted, 22 deleted
ossp-pkg/rc/rc_const.h      1.23 -> 1.24     2 inserted, 0 deleted
ossp-pkg/rc/rc_private.h      1.31 -> 1.32     1 inserted, 6 deleted
ossp-pkg/rc/rc_proc.c      1.44 -> 1.45     82 inserted, 40 deleted
ossp-pkg/rc/rc_script.c      1.29 -> 1.30     3 inserted, 1 deleted

ossp-pkg/rc/rc.h 1.47 -> 1.48

--- rc.h 2003/06/11 16:18:48     1.47
+++ rc.h 2003/06/13 18:33:07     1.48
@@ -101,13 +101,8 @@
 /* Analyser function prototypes */
 rc_anal_t *analNew(void);
 rc_return_t analDelete(rc_anal_t *);
-rc_return_t analRcs(rc_anal_t **, const char *);
-rc_return_t analTmp(rc_anal_t **, const char *);
-rc_return_t analFuncs(rc_anal_t **, const char *);
-rc_return_t analLocs(rc_anal_t **, const char *);
-rc_return_t analSecs(rc_anal_t **, const char **);
-rc_return_t analGloblocs(rc_anal_t **);
-rc_return_t analParse(rc_anal_t *);
+rc_return_t analRcs(rc_anal_t *, const char *);
+rc_return_t analGloblocs(rc_anal_t *);
 
 /* Script function prototypes */
 rc_script_t *scriptNew(void);
@@ -150,11 +145,6 @@
 /* Processor function prototypes */
 rc_proc_t *procNew(void);
 rc_return_t procDelete(rc_proc_t *);
-rc_return_t procReadfuncs(rc_proc_t *, const char *);
-rc_return_t procReadtmp(rc_proc_t *, const char *);
-rc_return_t procReadrc(rc_proc_t *, const char *);
-rc_return_t procSection(rc_proc_t *, const char *);
-rc_return_t procParse(rc_proc_t *);
 rc_return_t procPopulate(rc_proc_t *);
 rc_return_t procRun(rc_proc_t *);
 


ossp-pkg/rc/rc_anal.c 1.19 -> 1.20

--- rc_anal.c    2003/05/28 19:03:25     1.19
+++ rc_anal.c    2003/06/13 18:33:07     1.20
@@ -50,29 +50,29 @@
 }
 
 /************************************************
-* private analRcs(rc_anal_t **, const char *)   *
+* private analRcs(rc_anal_t *, const char *)    *
 * Read a rc file identifier to analyse          *
 ************************************************/
-rc_return_t analRcs(rc_anal_t **ppInst, const char *kszName)
+rc_return_t analRcs(rc_anal_t *pInst, const char *kszName)
 {
     ex_t Except;
 
-    assert(!(*ppInst)->m_pszRcs); /* Rcs should be NULL until we set them */
+    assert(!(pInst)->m_pszRcs); /* Rcs should be NULL until we set them */
 
     if (!kszName)
         return(RC_THROW(RC_ERR_RCF));
     else { /* Only enter block with valid string, strdup can't handle NULL */
-        (*ppInst)->m_pszRcs = malloc(sizeof(char **));
+        pInst->m_pszRcs = malloc(sizeof(char **));
         if (strcmp(kszName, RC_GLOB_WILD)) {
-            (*ppInst)->m_pszRcs = malloc(sizeof(*((*ppInst)->m_pszRcs)) * 2);
-            (*ppInst)->m_pszRcs[0] = strdup(kszName);
-            (*ppInst)->m_pszRcs[0] = strdup(kszName);
-            (*ppInst)->m_pszRcs[1] = NULL;
-            (*ppInst)->m_nRcs = 1;            /* We handle just one rc file */
+            pInst->m_pszRcs = malloc(sizeof(*(pInst->m_pszRcs)) * 2);
+            pInst->m_pszRcs[0] = strdup(kszName);
+            pInst->m_pszRcs[0] = strdup(kszName);
+            pInst->m_pszRcs[1] = NULL;
+            pInst->m_nRcs = 1;            /* We handle just one rc file */
         }
         else { /* Wildcard rcfile indicates we must glob the locs directories */
             try {
-                analGloblocs(ppInst);
+                analGloblocs(pInst);
             }
             catch(Except)
                 rethrow;
@@ -83,101 +83,39 @@
 }
 
 /************************************************
-* private analTmp(rc_anal_t **, const char *)   *
-* Read a temp file to analyze                   *
-************************************************/
-rc_return_t analTmp(rc_anal_t **ppInst, const char *kszName)
-{
-    if (!kszName) {
-        (*ppInst)->m_szTmp = NULL;
-/*        RC_THROW(RC_WRN_NUL);*/
-    }
-    else { /* Only enter block with valid string, strdup can't handle NULL */
-        (*ppInst)->m_szTmp = strdup(kszName);
-    }
-
-    return(RC_THROW(RC_OK));
-}
-
-/************************************************
-* private analFuncs(rc_anal_t **, const char *) *
-* Read a functions file to analyse              *
-************************************************/
-rc_return_t analFuncs(rc_anal_t **ppInst, const char *kszName)
-{
-    if (!kszName) {
-        (*ppInst)->m_szFuncs = NULL;
-/*        RC_THROW(RC_WRN_NUL);*/
-    }
-    else { /* Only enter block with valid string, strdup can't handle NULL */
-        (*ppInst)->m_szFuncs = strdup(kszName);
-    }
-
-    return(RC_THROW(RC_OK));
-}
-
-/************************************************
-* private analLocs(rc_anal_t **, const char *)  *
-* Read a location path expression to analyse    *
+* analGloblocs(rc_anal_t *pInst)                *
+* Glob all files of the location directories    *
 ************************************************/
-rc_return_t analLocs(rc_anal_t **ppInst, const char *kszPathexpr)
+rc_return_t analGloblocs(rc_anal_t *pInst)
 {
-    if (!kszPathexpr) {
-        (*ppInst)->m_szLocs = NULL;
-        (*ppInst)->m_szLocs = strdup("./"); /* FIXME: Relocate default val */
-/*        RC_THROW(RC_WRN_NUL);*/ /* FIXME: ex_ Illegal instruction - core dumped */
+    DIR *pLocdir = NULL;
+    struct dirent *pDirent = NULL;
+    char *szLocations = NULL;   /* Locations of run command files */
+    int nCount = 0;             /* How many globbed files we find */
+    int nIter = 0;              /* Used to step through found files */
+
+    assert(pInst); /* Sanity check */
+
+    /* Build the location path name */
+    if (!configGetval(RC_LOC_VAL)) {
+        szLocations = NULL;
+        szLocations = strdup("./"); /* FIXME: Relocate default val */
+        RC_THROW(RC_ERR_INT);       /* Config should have given a locs default */
     }
     else { /* Only enter block with valid string, strdup can't handle NULL */
-        if (*(kszPathexpr + strlen(kszPathexpr)) != '/') {
-            (*ppInst)->m_szLocs = malloc(strlen(kszPathexpr) + 2 * sizeof(char));
-            strcpy((*ppInst)->m_szLocs, kszPathexpr);
-            if ((char)*((*ppInst)->m_szLocs + strlen((*ppInst)->m_szLocs) - 1) != '/')
-                strcat((*ppInst)->m_szLocs, "/");
+        if (*(configGetval(RC_LOC_VAL) + strlen(configGetval(RC_LOC_VAL)) - sizeof (char)) != '/') {
+            szLocations = malloc(strlen(configGetval(RC_LOC_VAL)) + \
+                                 sizeof (char) + \
+                                 sizeof (char));
+            strcpy(szLocations, configGetval(RC_LOC_VAL));
+            strcat(szLocations, "/");
         }
         else
-            (*ppInst)->m_szLocs = strdup(kszPathexpr);
+            szLocations = strdup(configGetval(RC_LOC_VAL));
     }
 
-    return(RC_THROW(RC_OK));
-}
-
-/************************************************
-* private analSecs(rc_anal_t **, const char **) *
-* Read a sections vector to analyse             *
-************************************************/
-rc_return_t analSecs(rc_anal_t **ppInst, const char **pkszVector)
-{
-    ex_t Except;
-
-    if (!pkszVector) {
-        RC_THROW(RC_WRN_NUL);
-    }
-
-    ex_try {    /* Sections are a vector, so we must copy accordingly */
-        (*ppInst)->m_pszSecs = vectorCopy(pkszVector);
-        (*ppInst)->m_nSecs   = vectorCount(pkszVector);
-    }
-    ex_catch(Except)
-        rethrow;
-
-    return(RC_THROW(RC_OK));
-}
-
-/************************************************
-* analGloblocs(rc_anal_t **ppInst)              *
-* Glob all files of the location directories    *
-************************************************/
-rc_return_t analGloblocs(rc_anal_t **ppInst)
-{
-    DIR *pLocdir = NULL;
-    struct dirent *pDirent = NULL;
-    int nCount = 0; /* How many globbed files we find */
-    int nIter = 0;  /* Used to step through found files */
-
-    assert(*ppInst); /* Sanity check */
-
     /* First just learn how many globbed files we have */
-    if ((pLocdir = opendir((*ppInst)->m_szLocs)) == NULL)
+    if ((pLocdir = opendir(szLocations)) == NULL)
         return(RC_THROW(RC_ERR_DIR));
     for (pDirent = readdir(pLocdir); pDirent; pDirent = readdir(pLocdir))
         if (!strncmp(pDirent->d_name, "rc.", 3))
@@ -187,44 +125,22 @@
     if (nCount == 0) /* Check out the health of this directory listing */
         return(RC_THROW(RC_ERR_DIR));
     else /* Allocate for the string array to hold directory entry names */
-        (*ppInst)->m_pszRcs = malloc(sizeof(*((*ppInst)->m_pszRcs)) * (nCount + 1));
+        pInst->m_pszRcs = malloc(sizeof(pInst->m_pszRcs) * (nCount + 1));
 
     /* Loop through file index setting rc file names according to dirent */
-    if ((pLocdir = opendir((*ppInst)->m_szLocs)) == NULL)
+    if ((pLocdir = opendir(szLocations)) == NULL)
         return(RC_THROW(RC_ERR_DIR));
     for (pDirent = readdir(pLocdir); pDirent; pDirent = readdir(pLocdir)) {
         if (!strncmp(pDirent->d_name, "rc.", 3)) {
-            (*ppInst)->m_pszRcs[nIter] = strdup(pDirent->d_name + \
+            pInst->m_pszRcs[nIter] = strdup(pDirent->d_name + \
                                          strlen("rc.") * sizeof(char));
             nIter++;
         }
     }
     closedir(pLocdir);
 
-    (*ppInst)->m_pszRcs[nIter] = NULL; /* Terminate */
-    (*ppInst)->m_nRcs = nCount; /* Store how many globbed files there are */
-
-    return(RC_THROW(RC_OK));
-}
-
-/************************************************
-* analParse(rc_anal_t *)                        *
-* Parse the analyzed configuration data         *
-************************************************/
-rc_return_t analParse(rc_anal_t *pInst)
-{
-    ex_t Except;
-
-    assert(pInst); /* Verify sanity */
-    ex_try { /* Read in data from the main configuration */
-        analLocs (&pInst, configGetval(RC_LOC_VAL));
-        analRcs  (&pInst, configGetrcfile());
-        analTmp  (&pInst, configGetval(RC_TMP_VAL));
-        analFuncs(&pInst, configGetval(RC_FNC_VAL));
-        analSecs (&pInst, configGetsecs());
-    }
-    ex_catch(Except)
-        rethrow;
+    pInst->m_pszRcs[nIter] = NULL; /* Terminate */
+    pInst->m_nRcs = nCount; /* Store how many globbed files there are */
 
     return(RC_THROW(RC_OK));
 }
@@ -247,14 +163,6 @@
             free(pInst->m_pszRcs[nIter++]);
     if (pInst->m_pszRcs)            /* Rc file name index  */
         free(pInst->m_pszRcs);
-    if (pInst->m_szTmp)             /* Temp file name      */
-        free(pInst->m_szTmp);
-    if (pInst->m_szFuncs)           /* Function file names */
-        free(pInst->m_szFuncs);
-    if (pInst->m_szLocs)            /* Location path names */
-        free(pInst->m_szLocs);
-    if (pInst->m_pszSecs)           /* Section names       */
-        vectorDel(pInst->m_pszSecs);
 
     free(pInst);
 


ossp-pkg/rc/rc_cliopt.c 1.17 -> 1.18

--- rc_cliopt.c  2003/06/03 15:27:13     1.17
+++ rc_cliopt.c  2003/06/13 18:33:07     1.18
@@ -50,6 +50,7 @@
     {RC_INF_NAME, 'i', POPT_ARG_NONE, 0, RC_INF_VAL, RC_INF_DESC, NULL},
     {RC_LBL_NAME, 'l', POPT_ARG_NONE, 0, RC_LBL_VAL, RC_LBL_DESC, NULL},
     {RC_PRN_NAME, 'p', POPT_ARG_NONE, 0, RC_PRN_VAL, RC_PRN_DESC, NULL},
+    {RC_PAR_NAME, 'a', POPT_ARG_NONE, 0, RC_PAR_VAL, RC_PAR_DESC, NULL},
     {RC_SIL_NAME, 's', POPT_ARG_NONE, 0, RC_SIL_VAL, RC_SIL_DESC, NULL},
     {RC_RAW_NAME, 'r', POPT_ARG_NONE, 0, RC_RAW_VAL, RC_RAW_DESC, NULL},
     {RC_VRB_NAME, 'v', POPT_ARG_NONE, 0, RC_VRB_VAL, RC_VRB_DESC, NULL},
@@ -210,6 +211,8 @@
             clioptSetval(cliOption, RC_DEF_ON); break;   /* Label    */
         case RC_PRN_VAL:                                   
             clioptSetval(cliOption, RC_DEF_ON); break;   /* Print    */
+        case RC_PAR_VAL:                                   
+            clioptSetval(cliOption, RC_DEF_ON); break;   /* Print    */
         case RC_SIL_VAL:                                   
             clioptSetval(cliOption, RC_DEF_ON); break;   /* Silent   */
         case RC_RAW_VAL:                                   


ossp-pkg/rc/rc_config.c 1.31 -> 1.32

--- rc_config.c  2003/05/28 18:58:16     1.31
+++ rc_config.c  2003/06/13 18:33:07     1.32
@@ -129,12 +129,12 @@
     static char *s_szOptnametab[] = { /* NULL is for alignment */
         NULL,        RC_USE_NAME, RC_DBG_NAME, RC_VER_NAME,
         RC_EVL_NAME, RC_HLP_NAME, RC_INF_NAME, RC_LBL_NAME,
-        RC_PRN_NAME, RC_SIL_NAME, RC_RAW_NAME, RC_VRB_NAME,
-        RC_EXC_NAME, RC_LOC_NAME, RC_CNF_NAME, RC_FNC_NAME,
-        RC_QRY_NAME, RC_TMP_NAME, RC_OWN_NAME, RC_GRP_NAME,
-        RC_MSK_NAME, RC_ASS_NAME, RC_DEF_NAME, RC_REF_NAME,
-        RC_PRM_NAME, RC_TRM_NAME, RC_NCF_NAME, RC_CMN_NAME,
-        RC_DFL_NAME, RC_ERR_NAME
+        RC_PRN_NAME, RC_PAR_NAME, RC_SIL_NAME, RC_RAW_NAME,
+        RC_VRB_NAME, RC_EXC_NAME, RC_LOC_NAME, RC_CNF_NAME,
+        RC_FNC_NAME, RC_QRY_NAME, RC_TMP_NAME, RC_OWN_NAME,
+        RC_GRP_NAME, RC_MSK_NAME, RC_ASS_NAME, RC_DEF_NAME,
+        RC_REF_NAME, RC_PRM_NAME, RC_TRM_NAME, RC_NCF_NAME,
+        RC_CMN_NAME, RC_DFL_NAME, RC_ERR_NAME
     };
 
     if (m_nLocks) { /* Make sure config exists  */
@@ -229,7 +229,8 @@
         /* Exec XOR Eval XOR Print */
         if (!configGetval(RC_EVL_VAL) \
             + !configGetval(RC_EXC_VAL) \
-            + !configGetval(RC_PRN_VAL) < 2) { /* Warning! Magic number */
+            + !configGetval(RC_PRN_VAL) \
+            + !configGetval(RC_PAR_VAL) < 3) { /* Warning! Magic number */
             fprintf(stderr, RC_EEP_TEXT);
             bStop = TRUE;
         }
@@ -238,8 +239,8 @@
             || configGetval(RC_VER_VAL) || configGetval(RC_EVL_VAL) \
             || configGetval(RC_HLP_VAL) || configGetval(RC_INF_VAL) \
             || configGetval(RC_LBL_VAL) || configGetval(RC_PRN_VAL) \
-            || configGetval(RC_RAW_VAL) || configGetval(RC_VRB_VAL) \
-            || configGetval(RC_QRY_VAL))) {
+            || configGetval(RC_PAR_VAL) || configGetval(RC_RAW_VAL) \
+            || configGetval(RC_VRB_VAL) || configGetval(RC_QRY_VAL))) {
             fprintf(stderr, RC_SLO_TEXT);
             bStop = TRUE;
         }
@@ -286,7 +287,7 @@
 
     try { /* Test members for empty attributes */
         if (!configGetval(RC_EVL_VAL) && !configGetval(RC_EXC_VAL) \
-            && !configGetval(RC_PRN_VAL))
+            && !configGetval(RC_PRN_VAL) && !configGetval(RC_PAR_VAL))
             clioptSetval(RC_PRN_VAL, RC_DEF_ON);
 
 /*        if (!configGetval(RC_USE_VAL))


ossp-pkg/rc/rc_config.h 1.5 -> 1.6

--- rc_config.h  2002/05/22 13:29:40     1.5
+++ rc_config.h  2003/06/13 18:33:07     1.6
@@ -40,28 +40,29 @@
 #define RC_INF_VAL   6  /* Info           */
 #define RC_LBL_VAL   7  /* Label          */
 #define RC_PRN_VAL   8  /* Print          */
-#define RC_SIL_VAL   9  /* Silent         */
-#define RC_RAW_VAL  10  /* Raw            */
-#define RC_VRB_VAL  11  /* Verbose        */
-#define RC_EXC_VAL  12  /* Exec           */
-#define RC_LOC_VAL  13  /* Locations      */
-#define RC_CNF_VAL  14  /* Conf file      */
-#define RC_FNC_VAL  15  /* Func file      */
-#define RC_QRY_VAL  16  /* Query          */
-#define RC_TMP_VAL  17  /* Temp dir       */
-#define RC_OWN_VAL  18  /* User name      */
-#define RC_GRP_VAL  19  /* Group name     */
-#define RC_MSK_VAL  20  /* Umask          */
-#define RC_ASS_VAL  21  /* Assign regex   */
-#define RC_DEF_VAL  22  /* Label regex    */
-#define RC_REF_VAL  23  /* Ref regex      */
-#define RC_PRM_VAL  24  /* Params regex   */
-#define RC_TRM_VAL  25  /* Terminal regex */
-#define RC_NCF_VAL  26  /* Config name    */
-#define RC_CMN_VAL  27  /* Common name    */
-#define RC_DFL_VAL  28  /* Default name   */
-#define RC_ERR_VAL  29  /* Error name     */
+#define RC_PAR_VAL   9  /* Parse names    */
+#define RC_SIL_VAL  10  /* Silent         */
+#define RC_RAW_VAL  11  /* Raw            */
+#define RC_VRB_VAL  12  /* Verbose        */
+#define RC_EXC_VAL  13  /* Exec           */
+#define RC_LOC_VAL  14  /* Locations      */
+#define RC_CNF_VAL  15  /* Conf file      */
+#define RC_FNC_VAL  16  /* Func file      */
+#define RC_QRY_VAL  17  /* Query          */
+#define RC_TMP_VAL  18  /* Temp dir       */
+#define RC_OWN_VAL  19  /* User name      */
+#define RC_GRP_VAL  20  /* Group name     */
+#define RC_MSK_VAL  21  /* Umask          */
+#define RC_ASS_VAL  22  /* Assign regex   */
+#define RC_DEF_VAL  23  /* Label regex    */
+#define RC_REF_VAL  24  /* Ref regex      */
+#define RC_PRM_VAL  25  /* Params regex   */
+#define RC_TRM_VAL  26  /* Terminal regex */
+#define RC_NCF_VAL  27  /* Config name    */
+#define RC_CMN_VAL  28  /* Common name    */
+#define RC_DFL_VAL  29  /* Default name   */
+#define RC_ERR_VAL  30  /* Error name     */
 
-#define RC_NUMOPTS  30  /* Increment with each option addition */
+#define RC_NUMOPTS  31  /* Increment with each option addition */
 
 #endif /* __OSSPRC_CONFIG_H__ */


ossp-pkg/rc/rc_const.h 1.23 -> 1.24

--- rc_const.h   2003/06/12 14:24:32     1.23
+++ rc_const.h   2003/06/13 18:33:07     1.24
@@ -53,6 +53,7 @@
 #define RC_INF_DESC "Print a comprehensive summary of the rc environment."
 #define RC_LBL_DESC "Learn what section labels a rcfile has."
 #define RC_PRN_DESC "Output the command(s) in a format suitable for human reading, but do not run them."
+#define RC_PAR_DESC "Parse the run command names along with each of their matching section names."
 #define RC_SIL_DESC "Be silent, and disable output to stdout."
 #define RC_RAW_DESC "Output text using no terminal control sequences."
 #define RC_VRB_DESC "Output text verbosely."
@@ -86,6 +87,7 @@
 #define RC_INF_NAME "info"
 #define RC_LBL_NAME "labels"
 #define RC_PRN_NAME "print"
+#define RC_PAR_NAME "parse"
 #define RC_SIL_NAME "silent"
 #define RC_RAW_NAME "raw"
 #define RC_VRB_NAME "verbose"


ossp-pkg/rc/rc_private.h 1.31 -> 1.32

--- rc_private.h 2003/06/13 11:50:37     1.31
+++ rc_private.h 2003/06/13 18:33:07     1.32
@@ -76,12 +76,7 @@
 /* Analyser type */
 typedef struct {
     short m_nRcs;       /* How many rc files   */
-    short m_nSecs;      /* How many sections   */
     char **m_pszRcs;    /* Rc file names       */
-    char *m_szTmp;      /* Temp file name      */
-    char *m_szFuncs;    /* Function file names */
-    char *m_szLocs;     /* Location path names */
-    char **m_pszSecs;   /* Section vector      */
 } rc_anal_t;
 
 /* Script type */
@@ -99,7 +94,7 @@
 
 /* Label type */
 typedef struct {
-    int m_nSecs;
+    short m_nSecs;
     char *m_szName;
     rc_section_t **m_ppSecvec;
 } rc_label_t;


ossp-pkg/rc/rc_proc.c 1.44 -> 1.45

--- rc_proc.c    2003/06/12 14:24:32     1.44
+++ rc_proc.c    2003/06/13 18:33:07     1.45
@@ -45,29 +45,23 @@
 ************************************************/
 rc_proc_t *procNew(void)
 {
+    ex_t Except;
     rc_proc_t *pNewrc = NULL;
 
-    pNewrc = malloc(sizeof(rc_proc_t));
-    pNewrc->m_pAnal = analNew();        /* Construct a configuration analyser */
-    analParse(pNewrc->m_pAnal);         /* Preprocess the anal configuration  */
-    pNewrc->m_pScriptcom = scriptNew(); /* Construct a run-command script     */
-    pNewrc->m_ppLabvec = calloc(pNewrc->m_pAnal->m_nRcs, sizeof(rc_label_t *));
+    ex_try {
+        pNewrc = malloc(sizeof(rc_proc_t));
+        pNewrc->m_pAnal = analNew();        /* Construct a configuration analyser */
+        analRcs (pNewrc->m_pAnal, configGetrcfile()); /* Preprocess analysis      */
+        pNewrc->m_pScriptcom = scriptNew(); /* Construct a run-command script     */
+        pNewrc->m_ppLabvec = calloc(pNewrc->m_pAnal->m_nRcs, sizeof(rc_label_t *));
+    }
+    ex_catch(Except)
+        rethrow;
 
     return(pNewrc);
 }
 
 /************************************************
-* procReadtmp(rc_proc_t *, const char *)        *
-* Open and store a temp file                    *
-************************************************/
-rc_return_t procReadtmp(rc_proc_t *pRc, const char *szTmpname)
-{
-    fprintf(stderr, "%s!!!\n", szTmpname);
-
-    return(RC_THROW(RC_OK));
-}
-
-/************************************************
 * procPopulate(rc_proc_t *)                     *
 * Populate the processor with run commands      *
 ************************************************/
@@ -84,17 +78,18 @@
     rc_section_t *pSec        = NULL;
     char         *szLocex     = NULL;
     rc_script_t  *pTempscript = NULL;
+    short         nTotalsecs  = vectorCount(configGetsecs());
 
     assert(*pRc->m_pAnal->m_pszRcs);
     sBuf = (char *)calloc(1, RC_READ_BUFSIZE);
 
     /* Open the func file if it exists in the configuration */
-    if (pRc->m_pAnal->m_szFuncs) {
-        if ((nFdfunc = open(pRc->m_pAnal->m_szFuncs, O_RDONLY)) >= 0) {
+    if (configGetval(RC_FNC_VAL)) {
+/* FIXME: Funcfile data does not belong in config section data! */
+        if ((nFdfunc = open(configGetval(RC_FNC_VAL), O_RDONLY)) >= 0) {
             /* Read data from the func file */
-            while ((nRet = read(nFdfunc, sBuf, RC_READ_BUFSIZE)) > 0) {
+            while ((nRet = read(nFdfunc, sBuf, RC_READ_BUFSIZE)) > 0)
                 scriptAppend(pRc->m_pScriptcom, sBuf, nRet);
-            }
             if (nRet == -1) /* Handle read errors */
                 RC_THROW(RC_ERR_IO);
             scriptAppend(pRc->m_pScriptcom, "\n", sizeof(char));
@@ -107,18 +102,38 @@
     for (nRc = 0; nRc < pRc->m_pAnal->m_nRcs; nRc++)
     {
         assert(*pRc->m_pAnal->m_pszRcs);
-        assert(pRc->m_pAnal->m_szLocs);
 
         /* Construct a new label */
         pRc->m_ppLabvec[nRc] = labelNew(pRc->m_pAnal->m_pszRcs[nRc]);
 
-        /* Build the path name */
-        szLocex = (char *)malloc(strlen(pRc->m_pAnal->m_szLocs) + \
+        /* Build the location path name */
+        if (!configGetval(RC_LOC_VAL)) {
+            szLocex = NULL;
+            szLocex = strdup("./"); /* FIXME: Relocate default val */
+            RC_THROW(RC_ERR_INT);   /* Config should have given a locs default */
+        }
+        else { /* Only enter block with valid string, strdup can't handle NULL */
+            if (*(configGetval(RC_LOC_VAL) + strlen(configGetval(RC_LOC_VAL)) - sizeof (char)) != '/') {
+                szLocex = malloc(strlen(configGetval(RC_LOC_VAL)) + \
+                                 sizeof (char) + \
+                                 strlen("rc.") + \
+                                 strlen(pRc->m_pAnal->m_pszRcs[nRc]) + \
+                                 sizeof (char));
+                strcpy(szLocex, configGetval(RC_LOC_VAL));
+                strcat(szLocex, "/");
+                strcat(szLocex, "rc."); /* FIXME: Make the prefix configurable */
+                strcat(szLocex, pRc->m_pAnal->m_pszRcs[nRc]);
+            }
+            else {
+                szLocex = malloc(strlen(configGetval(RC_LOC_VAL)) + \
+                                 strlen("rc.") + \
                                  strlen(pRc->m_pAnal->m_pszRcs[nRc]) + \
-                                 strlen("rc.") + 1);
-        strcpy(szLocex, pRc->m_pAnal->m_szLocs);
-        strcat(szLocex, "rc."); /* FIXME: Make the prefix configurable */
-        strcat(szLocex, pRc->m_pAnal->m_pszRcs[nRc]);
+                                 sizeof (char));
+                strcpy(szLocex, configGetval(RC_LOC_VAL));
+                strcat(szLocex, "rc."); /* FIXME: Make the prefix configurable */
+                strcat(szLocex, pRc->m_pAnal->m_pszRcs[nRc]);
+            }
+        }
 
         /* Open the rc file unconditionally */
         if ((nFdrc = open(szLocex, O_RDONLY)) == -1)
@@ -133,25 +148,24 @@
             RC_THROW(RC_ERR_IO);
 
         try {
-            /* Append config section if it exists */
+            /* Append common section if it exists */
             pSec = scriptSection(pTempscript, configGetval(RC_NCF_VAL));
             if (pSec) { /* Only operate if the section lookup succeeds */
                 scriptAppend(pRc->m_pScriptcom, sectionGetdata(pSec), strlen(sectionGetdata(pSec)));
-                scriptAppend(pRc->m_pScriptcom, "\n", sizeof(char));
+                scriptAppend(pRc->m_pScriptcom, "\n", strlen ("\n"));
                 sectionDelete(pSec);    /* Cleanup */
                 pSec = NULL;            /* Cleanup */
             }
 
-            for (nSect = 0; nSect < pRc->m_pAnal->m_nSecs; nSect++) { /* Iterate over */
+            for (nSect = 0; nSect < nTotalsecs; nSect++) { /* Iterate over */
                 /* Extract a section from the temp script, and append it */
-                pSec = scriptSection(pTempscript, pRc->m_pAnal->m_pszSecs[nSect]);
+                pSec = scriptSection(pTempscript, configGetsecs()[nSect]);
 
                 if (pSec) /* Only copy if the section lookup succeeds */
                     labelAppendsec(pRc->m_ppLabvec[nRc], pSec);
                 else if (configGetval(RC_DBG_VAL)) /* Only show if debug set */
                     fprintf(stderr, "#Warning: Missing section '%s' in %s!\n",\
-                        pRc->m_pAnal->m_pszSecs[nSect],\
-                        pRc->m_pAnal->m_pszRcs[nRc]);
+                        configGetsecs()[nSect], pRc->m_pAnal->m_pszRcs[nRc]);
 
                 if (pSec) { /* Cleanup iterative section string */
                     sectionDelete(pSec);
@@ -204,6 +218,7 @@
     rc_script_t   *pBangscript = NULL;  /* Common script with the shebang  */
     rc_script_t   *pFatscript  = NULL;  /* To build a comprehensive script */
     rc_section_t **ppSectmp    = NULL;  /* Used with priority scheduling   */
+    short          nTotalsecs  = vectorCount(configGetsecs()); /* Sections */
 
     /****************************************************/
     /* This will execute, evaluate, or print the script */
@@ -226,12 +241,12 @@
         }
         scriptAppend(pFatscript, scriptTostring(pRc->m_pScriptcom), \
             strlen(scriptTostring(pRc->m_pScriptcom)));
-        for (nSecs = 0; nSecs < pRc->m_pAnal->m_nSecs; nSecs++) {
+        for (nSecs = 0; nSecs < nTotalsecs; nSecs++) {
             for (nRcs = 0; nRcs < pRc->m_pAnal->m_nRcs; nRcs++) {
                 nTmp = 0;
                 while (nTmp < pRc->m_ppLabvec[nRcs]->m_nSecs && \
                     strcmp(pRc->m_ppLabvec[nRcs]->m_ppSecvec[nTmp]->m_szName, \
-                                pRc->m_pAnal->m_pszSecs[nSecs]))
+                                configGetsecs()[nSecs]))
                     nTmp++;
                 if (nTmp < pRc->m_ppLabvec[nRcs]->m_nSecs)
                     ppSectmp[nRcs] = pRc->m_ppLabvec[nRcs]->m_ppSecvec[nTmp];
@@ -287,7 +302,7 @@
         /* This block does nothing more than implement the feature,         */
         /* that allows rc to run unprivileged (as long as no privileged     */
         /* code is used in the script sections to be executed               */
-        for (nSecs = 0; nSecs < pRc->m_pAnal->m_nSecs; nSecs++) {
+        for (nSecs = 0; nSecs < nTotalsecs; nSecs++) {
             for (nTmp = 0; nTmp < pRc->m_pAnal->m_nRcs; nTmp++) {
                 if (pRc->m_ppLabvec[nTmp]->m_ppSecvec && \
                     pRc->m_ppLabvec[nTmp]->m_ppSecvec[nSecs]) {
@@ -304,12 +319,12 @@
         /* Allocate a block of section pointers to use temporarily */
         ppSectmp = calloc(pRc->m_pAnal->m_nRcs, sizeof(rc_section_t *));
         szCom = (char *)scriptTostring(pRc->m_pScriptcom);
-        for (nSecs = 0; nSecs < pRc->m_pAnal->m_nSecs; nSecs++) {
+        for (nSecs = 0; nSecs < nTotalsecs; nSecs++) {
             for (nRcs = 0; nRcs < pRc->m_pAnal->m_nRcs; nRcs++) {
                 nTmp = 0;
                 while (nTmp < pRc->m_ppLabvec[nRcs]->m_nSecs && \
                     strcmp(pRc->m_ppLabvec[nRcs]->m_ppSecvec[nTmp]->m_szName, \
-                                pRc->m_pAnal->m_pszSecs[nSecs]))
+                                configGetsecs()[nSecs]))
                     nTmp++;
                 if (nTmp < pRc->m_ppLabvec[nRcs]->m_nSecs)
                     ppSectmp[nRcs] = pRc->m_ppLabvec[nRcs]->m_ppSecvec[nTmp];
@@ -429,12 +444,12 @@
         scriptDump(pBangscript);        /* Dump the common script with shebang */
         scriptDump(pRc->m_pScriptcom);  /* Dump the rest of the common script */
         scriptDelete(pBangscript);
-        for (nSecs = 0; nSecs < pRc->m_pAnal->m_nSecs; nSecs++) {
+        for (nSecs = 0; nSecs < nTotalsecs; nSecs++) {
             for (nRcs = 0; nRcs < pRc->m_pAnal->m_nRcs; nRcs++) {
                 nTmp = 0;
                 while (nTmp < pRc->m_ppLabvec[nRcs]->m_nSecs && \
                     strcmp(pRc->m_ppLabvec[nRcs]->m_ppSecvec[nTmp]->m_szName, \
-                                pRc->m_pAnal->m_pszSecs[nSecs]))
+                                configGetsecs()[nSecs]))
                     nTmp++;
                 if (nTmp < pRc->m_ppLabvec[nRcs]->m_nSecs)
                     ppSectmp[nRcs] = pRc->m_ppLabvec[nRcs]->m_ppSecvec[nTmp];
@@ -457,6 +472,33 @@
                 nTmp++;
             }
         }
+        free(ppSectmp);
+        ppSectmp = NULL;
+    }
+    else if (configGetval(RC_PAR_VAL)) {                    /* Parse names */
+        /* Allocate a block of section pointers to use as a temporary */
+        ppSectmp = calloc(pRc->m_pAnal->m_nRcs, sizeof(rc_section_t *));
+        fprintf(stderr, "file %s, section %s\n", pRc->m_ppLabvec[nRcs]->m_szName, RC_CMN_TEXT);
+        for (nSecs = 0; nSecs < nTotalsecs; nSecs++) {
+            for (nRcs = 0; nRcs < pRc->m_pAnal->m_nRcs; nRcs++) {
+                nTmp = 0;
+                while (nTmp < pRc->m_ppLabvec[nRcs]->m_nSecs && \
+                    strcmp(pRc->m_ppLabvec[nRcs]->m_ppSecvec[nTmp]->m_szName, \
+                                configGetsecs()[nSecs])) {
+                    nTmp++;
+                }
+                if (nTmp < pRc->m_ppLabvec[nRcs]->m_nSecs)
+                    ppSectmp[nRcs] = pRc->m_ppLabvec[nRcs]->m_ppSecvec[nTmp];
+                else
+                    ppSectmp[nRcs] = NULL;
+            }
+            qsort((void *)ppSectmp, (size_t)pRc->m_pAnal->m_nRcs, sizeof(rc_section_t *), priCompare);
+            nTmp = 0;
+            while (nTmp < pRc->m_pAnal->m_nRcs && ppSectmp[nTmp]) {
+                fprintf(stderr, "section %s\n", ppSectmp[nTmp]->m_szName);
+                nTmp++;
+            }
+        }
         free(ppSectmp);
         ppSectmp = NULL;
     }


ossp-pkg/rc/rc_script.c 1.29 -> 1.30

--- rc_script.c  2003/06/13 10:53:53     1.29
+++ rc_script.c  2003/06/13 18:33:07     1.30
@@ -301,7 +301,9 @@
     if (pScript && *pScript)
         return(*pScript);
     else
-        RC_THROW(RC_ERR_USE); /* Script was never constructed */
+        RC_THROW(RC_ERR_USE);   /* Script was never constructed */
+
+    return(NULL); /* Not reached */
 }
 
 /************************************************

CVSTrac 2.0.1