--- rc_proc.c 2003/06/13 18:33:07 1.45
+++ rc_proc.c 2003/06/18 14:35:29 1.46
@@ -50,10 +50,10 @@
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 *));
+ pNewrc->m_pList = listNew(); /* Construct a rcfile list */
+ listPopulate(pNewrc->m_pList, configGetrcfile()); /* Prepopulate list */
+ pNewrc->m_pScriptfunc = scriptNew(); /* Construct a functions script */
+ pNewrc->m_pScriptcom = scriptNew(); /* Construct a common script */
}
ex_catch(Except)
rethrow;
@@ -71,40 +71,38 @@
int nFdrc = -1;
int nFdfunc = -1;
int nRet = 0;
- int nRc = 0;
+ int nRcs = 0;
ex_t Except;
char *sBuf = NULL;
- rc_section_t *pSec = NULL;
char *szLocex = NULL;
rc_script_t *pTempscript = NULL;
+ rc_section_t *pSec = NULL;
short nTotalsecs = vectorCount(configGetsecs());
- assert(*pRc->m_pAnal->m_pszRcs);
+ assert(pRc->m_pList->m_ppFilevec);
sBuf = (char *)calloc(1, RC_READ_BUFSIZE);
/* Open the func file if it exists in the configuration */
if (configGetval(RC_FNC_VAL)) {
-/* FIXME: Funcfile data does not belong in config section data! */
+ /* 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)
- scriptAppend(pRc->m_pScriptcom, sBuf, nRet);
+ scriptAppend(pRc->m_pScriptfunc, sBuf, nRet);
if (nRet == -1) /* Handle read errors */
RC_THROW(RC_ERR_IO);
- scriptAppend(pRc->m_pScriptcom, "\n", sizeof(char));
+ scriptAppend(pRc->m_pScriptfunc, "\n", sizeof("\n"));
}
else
RC_THROW(RC_ERR_FNC);
}
/* Iteratively read possibly globbed rc files */
- for (nRc = 0; nRc < pRc->m_pAnal->m_nRcs; nRc++)
+ for (nRcs = 0; nRcs < pRc->m_pList->m_nFiles; nRcs++)
{
- assert(*pRc->m_pAnal->m_pszRcs);
-
- /* Construct a new label */
- pRc->m_ppLabvec[nRc] = labelNew(pRc->m_pAnal->m_pszRcs[nRc]);
+ if (!pRc->m_pList->m_ppFilevec[nRcs])
+ RC_THROW(RC_ERR_INT); /* Rcfile vector is missing its tail */
/* Build the location path name */
if (!configGetval(RC_LOC_VAL)) {
@@ -117,21 +115,21 @@
szLocex = malloc(strlen(configGetval(RC_LOC_VAL)) + \
sizeof (char) + \
strlen("rc.") + \
- strlen(pRc->m_pAnal->m_pszRcs[nRc]) + \
+ strlen(pRc->m_pList->m_ppFilevec[nRcs]->m_szName) + \
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]);
+ strcat(szLocex, pRc->m_pList->m_ppFilevec[nRcs]->m_szName);
}
else {
szLocex = malloc(strlen(configGetval(RC_LOC_VAL)) + \
strlen("rc.") + \
- strlen(pRc->m_pAnal->m_pszRcs[nRc]) + \
+ strlen(pRc->m_pList->m_ppFilevec[nRcs]->m_szName) + \
sizeof (char));
strcpy(szLocex, configGetval(RC_LOC_VAL));
strcat(szLocex, "rc."); /* FIXME: Make the prefix configurable */
- strcat(szLocex, pRc->m_pAnal->m_pszRcs[nRc]);
+ strcat(szLocex, pRc->m_pList->m_ppFilevec[nRcs]->m_szName);
}
}
@@ -162,10 +160,10 @@
pSec = scriptSection(pTempscript, configGetsecs()[nSect]);
if (pSec) /* Only copy if the section lookup succeeds */
- labelAppendsec(pRc->m_ppLabvec[nRc], pSec);
+ rcfileAppendsec(pRc->m_pList->m_ppFilevec[nRcs], pSec);
else if (configGetval(RC_DBG_VAL)) /* Only show if debug set */
fprintf(stderr, "#Warning: Missing section '%s' in %s!\n",\
- configGetsecs()[nSect], pRc->m_pAnal->m_pszRcs[nRc]);
+ configGetsecs()[nSect], pRc->m_pList->m_ppFilevec[nRcs]->m_szName);
if (pSec) { /* Cleanup iterative section string */
sectionDelete(pSec);
@@ -211,6 +209,7 @@
pid_t Pidexec = -1; /* When spawning before execv(3) */
char *szTmpfile = NULL; /* Path of temporary file */
char *szTmp = NULL; /* Generic temporary string */
+ char *szFunc = NULL; /* Stores func script text */
char *szCom = NULL; /* Stores common script text */
char *szExec = NULL; /* Used only during exec mode */
char *szVerbose = NULL; /* Used when handling verbose mode */
@@ -228,43 +227,64 @@
/****************************************************/
if (configGetval(RC_EVL_VAL)) { /* Evaluate */
/* Allocate a block of section pointers to use temporarily */
- ppSectmp = calloc(pRc->m_pAnal->m_nRcs, sizeof(rc_section_t *));
+ ppSectmp = calloc(pRc->m_pList->m_nFiles, sizeof(rc_section_t *));
pFatscript = scriptNew();
scriptAppend(pFatscript, RC_BANG_STR, strlen(RC_BANG_STR)); /* Shebang */
+ /* Conditionally output initial notice in verbal mode */
+ if (configGetval(RC_VRB_VAL)) {
+ szVerbose = malloc((strlen(RC_VST_TEXT) + 2) * sizeof (char));
+ sprintf(szVerbose, "%s", RC_VST_TEXT);
+ strcat(szVerbose, "\n");
+ scriptAppend(pFatscript, szVerbose, strlen(szVerbose));
+ free(szVerbose);
+ szVerbose = NULL;
+ }
+ /* Conditionally print funcs section notice in verbal mode */
+ if (configGetval(RC_VRB_VAL)) {
+ szVerbose = malloc((strlen(RC_EVF_TEXT) + 2) * sizeof (char));
+ sprintf(szVerbose, "%s", RC_EVF_TEXT);
+ strcat(szVerbose, "\n");
+ scriptAppend(pFatscript, szVerbose, strlen(szVerbose));
+ free(szVerbose);
+ szVerbose = NULL;
+ }
+ scriptAppend(pFatscript, scriptTostring(pRc->m_pScriptfunc), \
+ strlen(scriptTostring(pRc->m_pScriptfunc)));
/* Conditionally print common section notice in verbal mode */
if (configGetval(RC_VRB_VAL)) {
- nBytes = (strlen(RC_PRN_TEXT) + strlen(RC_CMN_TEXT) * 2 + 1) * sizeof (char);
+ nBytes = (strlen(RC_EVN_TEXT) + strlen(RC_CMN_TEXT) * 2 + 2) * sizeof (char);
szVerbose = malloc(nBytes);
- sprintf(szVerbose, RC_PRN_TEXT, RC_CMN_TEXT, RC_CMN_TEXT);
+ sprintf(szVerbose, RC_EVN_TEXT, RC_CMN_TEXT, RC_CMN_TEXT);
+ strcat(szVerbose, "\n");
scriptAppend(pFatscript, szVerbose, strlen(szVerbose));
free(szVerbose);
+ szVerbose = NULL;
}
scriptAppend(pFatscript, scriptTostring(pRc->m_pScriptcom), \
strlen(scriptTostring(pRc->m_pScriptcom)));
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];
+ for (nRcs = 0; nRcs < pRc->m_pList->m_nFiles; nRcs++) {
+ for (nTmp = 0; nTmp < pRc->m_pList->m_ppFilevec[nRcs]->m_nSecs && \
+ strcmp(pRc->m_pList->m_ppFilevec[nRcs]->m_ppSecvec[nTmp]->m_szName, \
+ configGetsecs()[nSecs]); nTmp++);
+ if (nTmp < pRc->m_pList->m_ppFilevec[nRcs]->m_nSecs)
+ ppSectmp[nRcs] = pRc->m_pList->m_ppFilevec[nRcs]->m_ppSecvec[nTmp];
else
ppSectmp[nRcs] = NULL;
}
- qsort((void *)ppSectmp, (size_t)pRc->m_pAnal->m_nRcs, \
+ qsort((void *)ppSectmp, (size_t)pRc->m_pList->m_nFiles, \
sizeof(rc_section_t *), priCompare);
- nTmp = 0;
- while (nTmp < pRc->m_pAnal->m_nRcs && ppSectmp[nTmp]) {
+ for (nTmp = 0; nTmp < pRc->m_pList->m_nFiles && ppSectmp[nTmp]; nTmp++) {
/* Conditionally print each section notice in verbal mode */
if (configGetval(RC_VRB_VAL)) {
szTmp = (char *)sectionGetname(ppSectmp[nTmp]);
- nBytes = (strlen(RC_EVN_TEXT) + strlen(szTmp) + 1) * sizeof (char);
+ nBytes = (strlen(RC_EVN_TEXT) + strlen(szTmp) + 2) * sizeof (char);
szVerbose = malloc(nBytes);
sprintf(szVerbose, RC_EVN_TEXT, szTmp, szTmp);
+ strcat(szVerbose, "\n");
scriptAppend(pFatscript, szVerbose, strlen(szVerbose));
free(szVerbose);
+ szVerbose = NULL;
}
if ((szTmp = (char *)sectionGetlogin(ppSectmp[nTmp])) != NULL) {
scriptAppend(pFatscript, "#su ", strlen("#su "));
@@ -273,7 +293,6 @@
}
szTmp = (char *)sectionGetdata(ppSectmp[nTmp]);
scriptAppend(pFatscript, szTmp, strlen(szTmp) + 1);
- nTmp++;
}
}
free(ppSectmp);
@@ -303,11 +322,11 @@
/* 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 < 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]) {
+ for (nTmp = 0; nTmp < pRc->m_pList->m_nFiles; nTmp++) {
+ if (pRc->m_pList->m_ppFilevec[nTmp]->m_ppSecvec && \
+ pRc->m_pList->m_ppFilevec[nTmp]->m_ppSecvec[nSecs]) {
nRunuid = getuid();
- nSectuid = pRc->m_ppLabvec[nTmp]->m_ppSecvec[nSecs]->m_nUid;
+ nSectuid = pRc->m_pList->m_ppFilevec[nTmp]->m_ppSecvec[nSecs]->m_nUid;
/* See if root user status is needed, and bail out if so */
if (nRunuid != 0 && nSectuid != -1 && nRunuid != nSectuid) {
fprintf(stderr, RC_RUT_TEXT);
@@ -317,44 +336,57 @@
}
}
/* 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);
+ ppSectmp = calloc(pRc->m_pList->m_nFiles, sizeof(rc_section_t *));
+ szFunc = (char *)scriptTostring(pRc->m_pScriptfunc);
+ szCom = (char *)scriptTostring(pRc->m_pScriptcom);
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];
+ for (nRcs = 0; nRcs < pRc->m_pList->m_nFiles; nRcs++) {
+ for (nTmp = 0; nTmp < pRc->m_pList->m_ppFilevec[nRcs]->m_nSecs && \
+ strcmp(pRc->m_pList->m_ppFilevec[nRcs]->m_ppSecvec[nTmp]->m_szName, \
+ configGetsecs()[nSecs]); nTmp++);
+ if (nTmp < pRc->m_pList->m_ppFilevec[nRcs]->m_nSecs)
+ ppSectmp[nRcs] = pRc->m_pList->m_ppFilevec[nRcs]->m_ppSecvec[nTmp];
else
ppSectmp[nRcs] = NULL;
}
- qsort((void *)ppSectmp, (size_t)pRc->m_pAnal->m_nRcs, sizeof(rc_section_t *), priCompare);
+ qsort((void *)ppSectmp, (size_t)pRc->m_pList->m_nFiles, sizeof(rc_section_t *), priCompare);
pszVec[0] = "/bin/sh"; /* Run the bourne shell over the following */
pszVec[1] = "-c"; /* Append script code of the sections */
pszVec[3] = NULL; /* Add a NULL to mark the end of the chain */
nTmp = 0; /* Count from zero until however many sections we have */
- while (nTmp < pRc->m_pAnal->m_nRcs && ppSectmp[nTmp]) {
+ while (nTmp < pRc->m_pList->m_nFiles && ppSectmp[nTmp]) {
/* Conditionally print common and other section notices in verbal mode */
if (configGetval(RC_VRB_VAL)) {
- size_t nComverb = 0;
- size_t nCommon = 0;
+ size_t nSizverb = 0;
+ size_t nPrescr = 0;
size_t nSecverb = 0;
size_t nSection = 0;
- nComverb = (strlen(RC_EXN_TEXT) + strlen(RC_CMN_TEXT) * 2 \
+
+ /* Allocate space just for string to prepare for verbose */
+ nSizverb = (strlen(RC_EXN_TEXT) + strlen(RC_CMN_TEXT) * 2 \
+ strlen(RC_ECHO_STR) + strlen("\"\"") + 1) * sizeof (char);
- szVerbose = malloc(nComverb);
+ szVerbose = malloc(nSizverb);
sprintf(szVerbose, RC_EXN_TEXT, RC_CMN_TEXT, RC_CMN_TEXT);
- nCommon = (strlen(szCom) + strlen(RC_BANG_STR) + 1) * sizeof (char);
- szExec = malloc(nComverb + nCommon);
+
+ /* Allocate space for entire string to execvp(3) */
+ nPrescr = (strlen(RC_VST_TEXT) + strlen(RC_EXF_TEXT) + \
+ strlen(szVerbose) + strlen(szFunc) + strlen(szCom) + \
+ strlen(RC_BANG_STR) + 1) * sizeof (char);
+ szExec = malloc(nSizverb + nPrescr);
+
strcpy(szExec, RC_BANG_STR); /* Start out with the bang string */
strcat(szExec, RC_ECHO_STR); /* Continue with the echo string */
strcat(szExec, "\""); /* Append a quote next to the echo */
- strcat(szExec, szVerbose); /* Continue with the verboseity text */
- strcat(szExec, "\""); /* Finalize the verbosity notice */
- strcat(szExec, szCom); /* Then with the common script code */
+ strcat(szExec, RC_VST_TEXT); /* Continue with the start text */
+ strcat(szExec, "\n"); /* Stick a newline inbetween */
+ strcat(szExec, RC_EXF_TEXT); /* Continue with the func text */
+ strcat(szExec, "\";"); /* Finalize the verbosity notice */
+ strcat(szExec, szFunc); /* Continue with the common script code */
+ strcat(szExec, RC_ECHO_STR); /* Continue with the echo string */
+ strcat(szExec, "\""); /* Append a quote next to the echo */
+ strcat(szExec, szVerbose); /* Continue with the common text */
+ strcat(szExec, "\";"); /* Finalize the verbosity notice */
+ strcat(szExec, szCom); /* Then with the funcs script code */
szTmp = (char *)sectionGetname(ppSectmp[nTmp]);
nSecverb = (strlen(RC_EXN_TEXT) + strlen(szTmp) * 2 \
+ strlen(RC_ECHO_STR) + strlen("\"\"") + 1) * sizeof (char);
@@ -362,11 +394,11 @@
sprintf(szVerbose, RC_EXN_TEXT, szTmp, szTmp);
szTmp = (char *)sectionGetdata(ppSectmp[nTmp]);
nSection = (strlen(szTmp) + 1) * sizeof (char);
- realloc(szExec, nComverb + nCommon + nSecverb + nSection);
+ realloc(szExec, nSizverb + nPrescr + nSecverb + nSection);
strcat(szExec, RC_ECHO_STR); /* Start out with the echo string */
strcat(szExec, "\""); /* Append a quote next to the echo */
strcat(szExec, szVerbose); /* Continue with the verboseity text */
- strcat(szExec, "\""); /* Finalize the verbosity notice */
+ strcat(szExec, "\";"); /* Finalize the verbosity notice */
strcat(szExec, szTmp); /* Then with the new script code */
pszVec[2] = szExec; /* Launch the new process image now */
free(szVerbose);
@@ -396,11 +428,13 @@
}
else {
szTmp = (char *)sectionGetdata(ppSectmp[nTmp]);
- szExec = malloc((strlen(szCom) + strlen(szTmp) + 1) * sizeof(char));
- strcpy(szExec, RC_BANG_STR); /* Start out with the shebang string */
- strcat(szExec, szCom); /* Continue with just the common script code */
- strcat(szExec, szTmp); /* And build a section onto the command chain */
- pszVec[2] = szExec; /* Actually launch the new process image now */
+ szExec = malloc((strlen(szFunc) + strlen(szCom) + \
+ strlen(szTmp) + 1) * sizeof(char));
+ strcpy(szExec, RC_BANG_STR); /* Start out with the shebang string */
+ strcat(szExec, szFunc); /* Continue with just the funcs script code */
+ strcat(szExec, szCom); /* Continue with just the common script code */
+ strcat(szExec, szTmp); /* And build a section onto the command chain */
+ pszVec[2] = szExec; /* Actually launch the new process image now */
/* Spawn the section shell code */
switch (Pidexec = fork()){
@@ -430,35 +464,43 @@
}
else if (configGetval(RC_PRN_VAL)) { /* Print */
/* Allocate a block of section pointers to use as a temporary */
- ppSectmp = calloc(pRc->m_pAnal->m_nRcs, sizeof(rc_section_t *));
+ ppSectmp = calloc(pRc->m_pList->m_nFiles, sizeof(rc_section_t *));
pBangscript = scriptNew();
scriptAppend(pBangscript, RC_BANG_STR, (strlen(RC_BANG_STR) + 1) * sizeof (char));
+ scriptDump(pBangscript); /* Dump the shebang */
+ scriptDelete(pBangscript);
+
+ /* Conditionally output initial notice in verbal mode */
+ if (configGetval(RC_VRB_VAL))
+ fprintf(stderr, "%s\n", RC_VST_TEXT);
+ /* Conditionally print funcs section notice in verbal mode */
+ if (configGetval(RC_VRB_VAL))
+ fprintf(stderr, "%s\n", RC_EVF_TEXT);
+ scriptDump(pRc->m_pScriptfunc); /* Dump the funcs script */
/* Conditionally print common section notice in verbal mode */
if (configGetval(RC_VRB_VAL)) {
- nBytes = (strlen(RC_PRN_TEXT) + strlen(RC_CMN_TEXT) * 2 + 1) * sizeof (char);
+ nBytes = (strlen(RC_EVN_TEXT) + strlen(RC_CMN_TEXT) * 2 + 2) * sizeof (char);
szVerbose = malloc(nBytes);
- sprintf(szVerbose, RC_PRN_TEXT, RC_CMN_TEXT, RC_CMN_TEXT);
- scriptAppend(pBangscript, szVerbose, (strlen(szVerbose) + 1) * sizeof (char));
+ sprintf(szVerbose, RC_EVN_TEXT, RC_CMN_TEXT, RC_CMN_TEXT);
+ strcat(szVerbose, "\n");
+ fprintf(stderr, szVerbose);
free(szVerbose);
+ szVerbose = NULL;
}
- scriptDump(pBangscript); /* Dump the common script with shebang */
- scriptDump(pRc->m_pScriptcom); /* Dump the rest of the common script */
- scriptDelete(pBangscript);
+ scriptDump(pRc->m_pScriptcom); /* Dump the common script */
+
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];
+ for (nRcs = 0; nRcs < pRc->m_pList->m_nFiles; nRcs++) {
+ for (nTmp = 0; nTmp < pRc->m_pList->m_ppFilevec[nRcs]->m_nSecs && \
+ strcmp(pRc->m_pList->m_ppFilevec[nRcs]->m_ppSecvec[nTmp]->m_szName, \
+ configGetsecs()[nSecs]); nTmp++);
+ if (nTmp < pRc->m_pList->m_ppFilevec[nRcs]->m_nSecs)
+ ppSectmp[nRcs] = pRc->m_pList->m_ppFilevec[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]) {
+ qsort((void *)ppSectmp, (size_t)pRc->m_pList->m_nFiles, sizeof(rc_section_t *), priCompare);
+ for (nTmp = 0; nTmp < pRc->m_pList->m_nFiles && ppSectmp[nTmp]; nTmp++) {
/* Conditionally print each section notice in verbal mode */
if (configGetval(RC_VRB_VAL)) {
szTmp = (char *)sectionGetname(ppSectmp[nTmp]);
@@ -467,9 +509,9 @@
sprintf(szVerbose, RC_PRN_TEXT, szTmp, szTmp);
fprintf(stderr, "%s", szVerbose);
free(szVerbose);
+ szVerbose = NULL;
}
sectionDump(ppSectmp[nTmp]);
- nTmp++;
}
}
free(ppSectmp);
@@ -477,27 +519,21 @@
}
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);
+ ppSectmp = calloc(pRc->m_pList->m_nFiles, sizeof(rc_section_t *));
+ fprintf(stderr, "file %s, section %s\n", pRc->m_pList->m_ppFilevec[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];
+ for (nRcs = 0; nRcs < pRc->m_pList->m_nFiles; nRcs++) {
+ for (nTmp = 0; nTmp < pRc->m_pList->m_ppFilevec[nRcs]->m_nSecs && \
+ strcmp(pRc->m_pList->m_ppFilevec[nRcs]->m_ppSecvec[nTmp]->m_szName, \
+ configGetsecs()[nSecs]); nTmp++);
+ if (nTmp < pRc->m_pList->m_ppFilevec[nRcs]->m_nSecs)
+ ppSectmp[nRcs] = pRc->m_pList->m_ppFilevec[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]) {
+ qsort((void *)ppSectmp, (size_t)pRc->m_pList->m_nFiles, sizeof(rc_section_t *), priCompare);
+ for (nTmp = 0; nTmp < pRc->m_pList->m_nFiles && ppSectmp[nTmp]; nTmp++)
fprintf(stderr, "section %s\n", ppSectmp[nTmp]->m_szName);
- nTmp++;
- }
}
free(ppSectmp);
ppSectmp = NULL;
@@ -514,20 +550,26 @@
************************************************/
rc_return_t procDelete(rc_proc_t *pRc)
{
- int nRcs = pRc->m_pAnal->m_nRcs;
+ int nRcs = pRc->m_pList->m_nFiles;
- /* 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_ppLabvec);
- pRc->m_ppLabvec = NULL;
- scriptDelete(pRc->m_pScriptcom); /* Destroy the script */
- analDelete(pRc->m_pAnal); /* Destroy the analyser */
+ scriptDelete(pRc->m_pScriptcom); /* Destroy the common script */
+ pRc->m_pScriptcom = NULL;
+ scriptDelete(pRc->m_pScriptfunc); /* Destroy the funcs script */
+ pRc->m_pScriptcom = NULL;
+
+ /* Destroy the rcfile objects */
+ while (nRcs-- > 0)
+ if (rcfileExists(pRc->m_pList->m_ppFilevec[nRcs])) {
+ rcfileDelete(pRc->m_pList->m_ppFilevec[nRcs]);
+ pRc->m_pList->m_ppFilevec[nRcs] = NULL;
+ }
+
+ free(pRc->m_pList->m_ppFilevec);
+ pRc->m_pList->m_ppFilevec = NULL;
+ listDelete(pRc->m_pList); /* Destroy the rcfile list */
+ pRc->m_pList = NULL;
free(pRc); /* Free the processor itself */
+ pRc = NULL;
return(RC_THROW(RC_OK));
}
|