--- rc_proc.c 2003/05/20 11:47:51 1.26
+++ rc_proc.c 2003/05/20 15:06:42 1.27
@@ -123,6 +123,7 @@
/* Build the path name */
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, "rc."); /* FIXME: Make the prefix configurable */
strcat(szLocex, pRc->m_pAnal->m_szRcs[nRc]);
/* Open the rc file unconditionally */
@@ -147,20 +148,22 @@
pSec = NULL; /* Cleanup */
}
- for (nSect = 0; pRc->m_pAnal->m_pszSecs[nSect]; nSect++) { /* Iterate over */
-
+ for (nSect = 0; nSect < pRc->m_pAnal->m_nSecs; nSect++) { /* Iterate over */
/* Extract a section from the temp script, and append it */
pSec = scriptSection(pTempscript, pRc->m_pAnal->m_pszSecs[nSect]);
- if (pSec) /* Only copy if the section lookup succeeds */
- labelAppendsec(pRc->m_ppLabvec[nRc], sectionCopy(pSec));
+ 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_szRcs[nRc]);
- if (pSec) /* Cleanup iterative section string */
+ if (pSec) { /* Cleanup iterative section string */
sectionDelete(pSec);
+ pSec = NULL;
+ }
}
}
catch(Except)
@@ -191,6 +194,7 @@
************************************************/
rc_return_t procRun(rc_proc_t *pRc)
{
+ int nTmp = 0;
int nRcs = 0;
int nSecs = 0;
char *pszVec[RC_EXEC_MAXARGS];
@@ -206,37 +210,45 @@
/* Eval - Print machine evaluatable format */
/* Print - Print human readable format */
/****************************************************/
- if (configGetval(RC_EVL_VAL)) /* Evaluate */
+ if (configGetval(RC_EVL_VAL)) /* Evaluate */
fprintf(stderr, "Error: Evaluate is not implemented yet.\n"); /* FIX */
- else if (configGetval(RC_EXC_VAL)) { /* Execute */
+ else if (configGetval(RC_EXC_VAL)) { /* Execute */
pszVec[0] = "/bin/sh";
pszVec[1] = "-c";
pszVec[2] = (char *)scriptTostring(pRc->m_pScriptcom);
pszVec[3] = NULL; /* Add a NULL to mark the end of the chain */
- if (execvp(*pszVec, pszVec) == -1) { /* launch */
+ if (execvp(*pszVec, pszVec) == -1) { /* launch */
TRACE("Bad, execvp for common script 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 */
+ for (nSecs = 0; nSecs < pRc->m_pAnal->m_nSecs; 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]))
+ nTmp++;
+ if (nTmp < pRc->m_ppLabvec[nRcs]->m_nSecs) {
+ pszVec[2] = (char *)sectionGetdata(pRc->m_ppLabvec[nRcs]->m_ppSecvec[nTmp]);
+ 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 */
+ else if (configGetval(RC_PRN_VAL)) { /* Print */
scriptDump(pRc->m_pScriptcom);
- 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]);
+ for (nSecs = 0; nSecs < pRc->m_pAnal->m_nSecs; 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]))
+ nTmp++;
+ if (nTmp < pRc->m_ppLabvec[nRcs]->m_nSecs)
+ sectionDump(pRc->m_ppLabvec[nRcs]->m_ppSecvec[nTmp]);
}
- }
}
else /* Something is wrong here */
return(RC_THROW(RC_ERR_INT));
|