Index: ossp-pkg/rc/rc_proc.c RCS File: /v/ossp/cvs/ossp-pkg/rc/rc_proc.c,v rcsdiff -q -kk '-r1.25' '-r1.26' -u '/v/ossp/cvs/ossp-pkg/rc/rc_proc.c,v' 2>/dev/null --- rc_proc.c 2003/05/19 19:04:22 1.25 +++ rc_proc.c 2003/05/20 11:47:51 1.26 @@ -46,19 +46,13 @@ ************************************************/ rc_proc_t *procNew(void) { -/* int nIter = 0;*/ 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 */ - - /* Logic needed for multiple run-command section combination with priorities */ - 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();*/ + pNewrc->m_ppLabvec = calloc(pNewrc->m_pAnal->m_nRcs, sizeof(rc_label_t *)); return(pNewrc); } @@ -80,11 +74,11 @@ ************************************************/ rc_return_t procPopulate(rc_proc_t *pRc) { - int i = 0; + int nSect = 0; int nFdrc = 0; int nFdfunc = 0; int nRet = 0; - int nIter = 0; + int nRc = 0; ex_t Except; char *sBuf = NULL; @@ -118,15 +112,18 @@ } /* Iteratively read possibly globbed rc files */ - for (nIter = 0; nIter < pRc->m_pAnal->m_nRcs; nIter++) + for (nRc = 0; nRc < pRc->m_pAnal->m_nRcs; nRc++) { assert(*pRc->m_pAnal->m_szRcs); /* If one of these assertions fail, */ assert(pRc->m_pAnal->m_szLocs); /* you've probably seen the ex_ bug */ + /* Construct a new label */ + pRc->m_ppLabvec[nRc] = labelNew(pRc->m_pAnal->m_szRcs[nRc]); + /* Build the path name */ - szLocex = (char *)malloc(strlen(pRc->m_pAnal->m_szLocs) + strlen(pRc->m_pAnal->m_szRcs[nIter]) + 2); + szLocex = (char *)malloc(strlen(pRc->m_pAnal->m_szLocs) + strlen(pRc->m_pAnal->m_szRcs[nRc]) + 2); strcpy(szLocex, pRc->m_pAnal->m_szLocs); - strcat(szLocex, pRc->m_pAnal->m_szRcs[nIter]); + strcat(szLocex, pRc->m_pAnal->m_szRcs[nRc]); /* Open the rc file unconditionally */ if ((nFdrc = open(szLocex, O_RDONLY)) == -1) @@ -150,16 +147,17 @@ pSec = NULL; /* Cleanup */ } - for (i = 0; pRc->m_pAnal->m_pszSecs[i]; i++) { /* Iterate over */ + for (nSect = 0; pRc->m_pAnal->m_pszSecs[nSect]; nSect++) { /* Iterate over */ + /* Extract a section from the temp script, and append it */ - pSec = scriptSection(pTempscript, pRc->m_pAnal->m_pszSecs[i]); + pSec = scriptSection(pTempscript, pRc->m_pAnal->m_pszSecs[nSect]); if (pSec) /* Only copy if the section lookup succeeds */ - pRc->m_ppSectvec[pRc->m_pAnal->m_nSecs * nIter + i] = sectionCopy(pSec); + labelAppendsec(pRc->m_ppLabvec[nRc], 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],\ - pRc->m_pAnal->m_szRcs[nIter]); + pRc->m_pAnal->m_pszSecs[nSect],\ + pRc->m_pAnal->m_szRcs[nRc]); if (pSec) /* Cleanup iterative section string */ sectionDelete(pSec); @@ -193,14 +191,14 @@ ************************************************/ rc_return_t procRun(rc_proc_t *pRc) { - int nIter = 0; - int nTotsecs = pRc->m_pAnal->m_nRcs * pRc->m_pAnal->m_nSecs; + int nRcs = 0; + int nSecs = 0; char *pszVec[RC_EXEC_MAXARGS]; - /* Conditionally sort the section vector according to explicit priority */ + /* Conditionally sort the section vector according to explicit priority if (!strcmp(configGetrcfile(), RC_GLOB_WILD)) { qsort((void *)pRc->m_ppSectvec, (size_t)nTotsecs, sizeof (rc_section_t *), priCompare); - } + } */ /****************************************************/ /* This will execute, evaluate, or print the script */ @@ -219,21 +217,25 @@ TRACE("Bad, execvp for common script in child returned -1"); return(RC_THROW(RC_ERR_INT)); } - for (nIter = 0; nIter < nTotsecs; nIter++) { - if (pRc->m_ppSectvec[nIter]) { - pszVec[2] = (char *)sectionGetdata(pRc->m_ppSectvec[nIter]); - if (execvp(*pszVec, pszVec) == -1) { /* launch */ - TRACE("Bad, execvp for subsection in child returned -1"); - return(RC_THROW(RC_ERR_INT)); + for (nRcs = 0; nRcs < pRc->m_pAnal->m_nRcs; nRcs++) { + for (nSecs = 0; nSecs < pRc->m_pAnal->m_nSecs; nSecs++) { + if (pRc->m_ppLabvec[nRcs]->m_ppSecvec[nSecs]) { + pszVec[2] = (char *)sectionGetdata(pRc->m_ppLabvec[nRcs]->m_ppSecvec[nSecs]); + if (execvp(*pszVec, pszVec) == -1) { /* launch */ + TRACE("Bad, execvp for subsection in child returned -1"); + return(RC_THROW(RC_ERR_INT)); + } } } } } else if (configGetval(RC_PRN_VAL)) { /* Print */ scriptDump(pRc->m_pScriptcom); - for (nIter = 0; nIter < nTotsecs; nIter++) { - if (pRc->m_ppSectvec[nIter]) - sectionDump(pRc->m_ppSectvec[nIter]); + for (nRcs = 0; nRcs < pRc->m_pAnal->m_nRcs; nRcs++) { + for (nSecs = 0; nSecs < pRc->m_pAnal->m_nSecs; nSecs++) { + if (pRc->m_ppLabvec[nRcs]->m_ppSecvec && pRc->m_ppLabvec[nRcs]->m_ppSecvec[nSecs]) + sectionDump(pRc->m_ppLabvec[nRcs]->m_ppSecvec[nSecs]); + } } } else /* Something is wrong here */ @@ -248,17 +250,17 @@ ************************************************/ rc_return_t procDelete(rc_proc_t *pRc) { - int nSecvec = pRc->m_pAnal->m_nRcs * pRc->m_pAnal->m_nSecs; + int nRcs = pRc->m_pAnal->m_nRcs; - /* Destroy the section vector */ - while (nSecvec-- > 0) { - if (pRc->m_ppSectvec[nSecvec]) { - sectionDelete(pRc->m_ppSectvec[nSecvec]); - pRc->m_ppSectvec[nSecvec] = NULL; + /* Destroy the label vector */ + while (nRcs-- > 0) { + if (pRc->m_ppLabvec[nRcs]) { + labelDelete(pRc->m_ppLabvec[nRcs]); + pRc->m_ppLabvec[nRcs] = NULL; } } - free(pRc->m_ppSectvec); - pRc->m_ppSectvec = NULL; + free(pRc->m_ppLabvec); + pRc->m_ppLabvec = NULL; scriptDelete(pRc->m_pScriptcom); /* Destroy the script */ analDelete(pRc->m_pAnal); /* Destroy the analyser */ free(pRc); /* Free the processor itself */