OSSP CVS Repository

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

ossp-pkg/rc/rc_proc.c 1.21 -> 1.22

--- rc_proc.c    2003/05/14 16:36:28     1.21
+++ rc_proc.c    2003/05/15 12:49:11     1.22
@@ -45,7 +45,7 @@
 ************************************************/
 rc_proc_t *procNew(void)
 {
-    int nIter = 0;
+/*    int nIter = 0;*/
     rc_proc_t *pNewrc = NULL;
 
     pNewrc = malloc(sizeof(rc_proc_t));
@@ -54,9 +54,10 @@
     pNewrc->m_pScriptcom = scriptNew(); /* Construct a run-command script     */
 
     /* Logic needed for multiple run-command section combination with priorities */
-    pNewrc->m_ppScriptvec = malloc(sizeof(rc_script_t *) * pNewrc->m_pAnal->m_nRcs);
-    for (nIter = 0; nIter < pNewrc->m_pAnal->m_nRcs; nIter++)
-        pNewrc->m_ppScriptvec[nIter] = scriptNew();
+    pNewrc->m_ppSectvec = calloc(pNewrc->m_pAnal->m_nRcs *\
+        pNewrc->m_pAnal->m_nSecs, sizeof(rc_section_t *));
+/*    for (nIter = 0; nIter < pNewrc->m_pAnal->m_nRcs; nIter++)
+        pNewrc->m_ppSectvec[nIter] = sectionNew();*/
 
     return(pNewrc);
 }
@@ -153,11 +154,8 @@
                 /* Extract a section from the temp script, and append it */
                 pSec = scriptSection(pTempscript, pRc->m_pAnal->m_pszSecs[i]);
 
-                if (pSec) { /* Only call if the section lookup succeeds */
-                    scriptAppend(pRc->m_ppScriptvec[nIter], sectionGetdata(pSec),
-                        sectionGetlen(pSec) - 1);
-                    scriptAppend(pRc->m_ppScriptvec[nIter], "\n", sizeof(char));
-                }
+                if (pSec) /* Only copy if the section lookup succeeds */
+                    pRc->m_ppSectvec[pRc->m_pAnal->m_nSecs * nIter + i] = sectionCopy(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[i],\
@@ -216,10 +214,9 @@
     }
     else if (configGetval(RC_PRN_VAL)) {                         /* Print  */
         scriptDump(pRc->m_pScriptcom);
-        for (nIter = 0; nIter < pRc->m_pAnal->m_nRcs; nIter++) {
-            if (*pRc->m_ppScriptvec[nIter])
-                scriptDump(pRc->m_ppScriptvec[nIter]);
-        }
+        for (nIter = 0; nIter < pRc->m_pAnal->m_nRcs * pRc->m_pAnal->m_nSecs; nIter++)
+            if (pRc->m_ppSectvec[nIter])
+                sectionDump(pRc->m_ppSectvec[nIter]);
     }
     else /* Something is wrong here */
         return(RC_THROW(RC_ERR_INT));
@@ -233,17 +230,17 @@
 ************************************************/
 rc_return_t procDelete(rc_proc_t *pRc)
 {
-    int nIter = 0;
+    int nSecvec = pRc->m_pAnal->m_nRcs * pRc->m_pAnal->m_nSecs;
 
-    /* Destroy the script vector */
-    for (nIter = pRc->m_pAnal->m_nRcs - 1; nIter >= 0 ; nIter--) {
-        if (pRc->m_ppScriptvec[nIter]) {
-            scriptDelete(pRc->m_ppScriptvec[nIter]);
-            pRc->m_ppScriptvec[nIter] = NULL;
+    /* Destroy the section vector */
+    while (nSecvec-- > 0) {
+        if (pRc->m_ppSectvec[nSecvec]) {
+            sectionDelete(pRc->m_ppSectvec[nSecvec]);
+            pRc->m_ppSectvec[nSecvec] = NULL;
         }
     }
-    free(pRc->m_ppScriptvec);
-    pRc->m_ppScriptvec = NULL;
+    free(pRc->m_ppSectvec);
+    pRc->m_ppSectvec = NULL;
     scriptDelete(pRc->m_pScriptcom);    /* Destroy the script        */
     analDelete(pRc->m_pAnal);           /* Destroy the analyser      */
     free(pRc);                          /* Free the processor itself */

CVSTrac 2.0.1