OSSP CVS Repository

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

ossp-pkg/rc/rc_proc.c 1.49 -> 1.50

--- rc_proc.c    2003/06/27 10:15:19     1.49
+++ rc_proc.c    2003/06/27 14:26:13     1.50
@@ -205,9 +205,9 @@
         scriptAdd(pFatscript, pRc->m_pScriptfunc);
         /* Conditionally print config section notice in verbal mode */
         if (configGetval(RC_VRB_VAL)) {
-            nBytes = (strlen(RC_EVN_TEXT) + strlen(RC_CFG_TEXT) * 2 + 2) * sizeof (char);
+            nBytes = (strlen(RC_EVN_TEXT) + strlen(RC_DEF_NCF) * 2 + 2) * sizeof (char);
             szVerbose = malloc(nBytes);
-            sprintf(szVerbose, RC_EVN_TEXT, RC_CFG_TEXT, RC_CFG_TEXT);
+            sprintf(szVerbose, RC_EVN_TEXT, RC_DEF_NCF, RC_DEF_NCF);
             strcat(szVerbose, "\n");
             scriptAppend(pFatscript, szVerbose, strlen(szVerbose));
             free(szVerbose);
@@ -232,7 +232,7 @@
                     szTmp = (char *)sectionGetname(ppSectmp[nTmp]);
                     nBytes = (strlen(RC_EVN_TEXT) + strlen(szTmp) + 2) * sizeof (char);
                     szVerbose = malloc(nBytes);
-                    sprintf(szVerbose, RC_EVN_TEXT, szTmp, szTmp);
+                    sprintf(szVerbose, RC_EVN_TEXT, szTmp, sectionGetparent(ppSectmp[nTmp]));
                     strcat(szVerbose, "\n");
                     scriptAppend(pFatscript, szVerbose, strlen(szVerbose));
                     free(szVerbose);
@@ -322,10 +322,10 @@
                     size_t nSection = 0;
 
                     /* Allocate space just for string to prepare for verbose */
-                    nSizverb = (strlen(RC_EXN_TEXT) + strlen(RC_CFG_TEXT) * 2 \
+                    nSizverb = (strlen(RC_EXN_TEXT) + strlen(RC_DEF_NCF) * 2 \
                         + strlen(RC_ECHO_STR) + strlen("\"\"") + 1) * sizeof (char);
                     szVerbose = malloc(nSizverb);
-                    sprintf(szVerbose, RC_EXN_TEXT, RC_CFG_TEXT, RC_CFG_TEXT);
+                    sprintf(szVerbose, RC_EXN_TEXT, RC_DEF_NCF, sectionGetparent(ppSectmp[nTmp]));
 
                     /* Allocate space for entire string to execvp(3) */
                     nPrescr = (strlen(RC_VST_TEXT) + strlen(RC_EXF_TEXT) + \
@@ -337,8 +337,12 @@
                     strcat(szExec, RC_ECHO_STR);    /* Continue with the echo string */
                     strcat(szExec, "\"");           /* Append a quote next to the echo */
                     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 */
+
+                    if (strlen(szFunc) > 0) {
+                        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 funcs script code */
                     strcat(szExec, RC_ECHO_STR);    /* Continue with the echo string */
@@ -346,14 +350,39 @@
                     strcat(szExec, szVerbose);      /* Continue with the config text */
                     strcat(szExec, "\";");          /* Finalize the verbosity notice */
                     strcat(szExec, szCnf);          /* Then with the config script code  */
+
+                    /* Examine our list, and try to take the corresponding */
+                    /* common section data from it to add to your script   */
+                    {
+                        rc_section_t *pComsec = NULL;
+                        pComsec = rcfileGetsec(listGetrcfile(pRc->m_pList, \
+                            ppSectmp[nTmp]->m_szParent), configGetval(RC_CMN_VAL));
+                        if (pComsec) { /* If we have a common section to load,  */
+                            szTmp = (char *)sectionGetname(pComsec);
+                            nSecverb = (strlen(RC_EXN_TEXT) + strlen(szTmp) * 2 \
+                                + strlen(RC_ECHO_STR) + strlen("\"\"") + 1) * sizeof (char);
+                            realloc(szVerbose, nSecverb);
+                            sprintf(szVerbose, RC_EXN_TEXT, szTmp, sectionGetparent(pComsec));
+                            nSection = (strlen(szTmp) + 1) * sizeof (char);
+                            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 common text */
+                            strcat(szExec, "\";");          /* Finalize the verbosity notice */
+                            strcat(szExec, sectionGetdata(pComsec)); /* load it */
+                        }
+                    }
+
+                    /* Build last set of verbose data for the actual script */
                     szTmp = (char *)sectionGetname(ppSectmp[nTmp]);
                     nSecverb = (strlen(RC_EXN_TEXT) + strlen(szTmp) * 2 \
                         + strlen(RC_ECHO_STR) + strlen("\"\"") + 1) * sizeof (char);
                     realloc(szVerbose, nSecverb);
-                    sprintf(szVerbose, RC_EXN_TEXT, szTmp, szTmp);
-                    szTmp = (char *)sectionGetdata(ppSectmp[nTmp]);
-                    nSection = (strlen(szTmp) + 1) * sizeof (char);
+                    sprintf(szVerbose, RC_EXN_TEXT, szTmp, sectionGetparent(ppSectmp[nTmp]));
+                    nSection = (strlen(szTmp) + strlen(sectionGetdata(ppSectmp[nTmp])) + 1) * sizeof (char);
                     realloc(szExec, nSizverb + nPrescr + nSecverb + nSection);
+
+                    szTmp = (char *)sectionGetdata(ppSectmp[nTmp]);
                     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 */
@@ -392,6 +421,17 @@
                     strcpy(szExec, RC_BANG_STR);     /* Start out with the shebang string */
                     strcat(szExec, szFunc); /* Continue with just the funcs script code   */
                     strcat(szExec, szCnf);  /* Continue with just the config script code  */
+
+                    /* Examine our list, and try to take the corresponding */
+                    /* common section data from it to add to your script   */
+                    {
+                        rc_section_t *pComsec = NULL;
+                        pComsec = rcfileGetsec(listGetrcfile(pRc->m_pList, \
+                            ppSectmp[nTmp]->m_szParent), configGetval(RC_CMN_VAL));
+                        if (pComsec)   /* If we have a common section to load,  */
+                            strcat(szExec, sectionGetdata(pComsec)); /* load it */
+                    }
+
                     strcat(szExec, szTmp);  /* And build a section onto the command chain */
                     pszVec[2] = szExec;     /* Actually launch the new process image now  */
 
@@ -438,9 +478,9 @@
         scriptDump(pRc->m_pScriptfunc); /* Dump the funcs script */
         /* Conditionally print config section notice in verbal mode */
         if (configGetval(RC_VRB_VAL)) {
-            nBytes = (strlen(RC_EVN_TEXT) + strlen(RC_CFG_TEXT) * 2 + 2) * sizeof (char);
+            nBytes = (strlen(RC_EVN_TEXT) + strlen(RC_DEF_NCF) * 2 + 2) * sizeof (char);
             szVerbose = malloc(nBytes);
-            sprintf(szVerbose, RC_EVN_TEXT, RC_CFG_TEXT, RC_CFG_TEXT);
+            sprintf(szVerbose, RC_EVN_TEXT, RC_DEF_NCF, RC_DEF_NCF);
             strcat(szVerbose, "\n");
             fprintf(stderr, szVerbose);
             free(szVerbose);
@@ -465,7 +505,7 @@
                     szTmp = (char *)sectionGetname(ppSectmp[nTmp]);
                     nBytes = (strlen(RC_PRN_TEXT) + strlen(szTmp) + 1) * sizeof (char);
                     szVerbose = malloc(nBytes);
-                    sprintf(szVerbose, RC_PRN_TEXT, szTmp, szTmp);
+                    sprintf(szVerbose, RC_PRN_TEXT, szTmp, sectionGetparent(ppSectmp[nTmp]));
                     fprintf(stderr, "%s", szVerbose);
                     free(szVerbose);
                     szVerbose = NULL;
@@ -479,7 +519,7 @@
     else if (configGetval(RC_PAR_VAL)) {                    /* Parse names */
         /* Allocate a block of section pointers to use as a temporary */
         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_CFG_TEXT);
+        fprintf(stderr, "file %s, section %s\n", pRc->m_pList->m_ppFilevec[nRcs]->m_szName, RC_DEF_NCF);
         for (nSecs = 0; nSecs < nTotalsecs; nSecs++) {
             for (nRcs = 0; nRcs < pRc->m_pList->m_nFiles; nRcs++) {
                 for (nTmp = 0; nTmp < pRc->m_pList->m_ppFilevec[nRcs]->m_nSecs && \

CVSTrac 2.0.1