OSSP CVS Repository

ossp - Difference in ossp-pkg/rc/rc_anal.c versions 1.19 and 1.20
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

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);
 

CVSTrac 2.0.1