OSSP CVS Repository

ossp - Check-in [3444]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3444
Date: 2003-Jun-18 16:35:29 (local)
2003-Jun-18 14:35:29 (UTC)
User:ms
Branch:
Comment: Removed analyzer class, removed label class, implemented list class, implemented file class, cleanup and restructure.
Tickets:
Inspections:
Files:
ossp-pkg/rc/Makefile.in      1.32 -> 1.33     2 inserted, 2 deleted
ossp-pkg/rc/rc.h      1.48 -> 1.49     11 inserted, 11 deleted
ossp-pkg/rc/rc_anal.c      1.20->removed
ossp-pkg/rc/rc_config.c      1.32 -> 1.33     5 inserted, 4 deleted
ossp-pkg/rc/rc_const.h      1.24 -> 1.25     9 inserted, 3 deleted
ossp-pkg/rc/rc_file.c      added-> 1.1
ossp-pkg/rc/rc_lab.c      1.4->removed
ossp-pkg/rc/rc_list.c      added-> 1.1
ossp-pkg/rc/rc_private.h      1.32 -> 1.33     10 inserted, 11 deleted
ossp-pkg/rc/rc_proc.c      1.45 -> 1.46     158 inserted, 116 deleted
ossp-pkg/rc/rc_script.c      1.30 -> 1.31     2 inserted, 2 deleted
ossp-pkg/rc/rc_sect.c      1.13 -> 1.14     6 inserted, 17 deleted

ossp-pkg/rc/Makefile.in 1.32 -> 1.33

--- Makefile.in  2003/05/20 11:45:11     1.32
+++ Makefile.in  2003/06/18 14:35:29     1.33
@@ -59,10 +59,10 @@
 TARGET_PROGS    = rc
 TARGET_MANS     = rc.1 rc-sample.5
 
-SRCS            = rc.c rc_error.c rc_anal.c rc_script.c rc_lab.c rc_sect.c rc_config.c \
+SRCS            = rc.c rc_error.c rc_list.c rc_script.c rc_file.c rc_sect.c rc_config.c \
                   rc_cliopt.c rc_proc.c rc_version.c rc_pcre.c rc_util.c
 
-OBJS            = rc.o rc_error.o rc_anal.o rc_script.o rc_lab.o rc_sect.o rc_config.o \
+OBJS            = rc.o rc_error.o rc_list.o rc_script.o rc_file.o rc_sect.o rc_config.o \
                   rc_cliopt.o rc_proc.o rc_version.o rc_pcre.o rc_util.o
 
 SUBDIRS         = @SUBDIR_EX@ @SUBDIR_POPT@


ossp-pkg/rc/rc.h 1.48 -> 1.49

--- rc.h 2003/06/13 18:33:07     1.48
+++ rc.h 2003/06/18 14:35:29     1.49
@@ -98,11 +98,10 @@
 rc_return_t clioptSetrcfile(const char *);
 rc_return_t clioptSetsecs(const char **);
 
-/* Analyser function prototypes */
-rc_anal_t *analNew(void);
-rc_return_t analDelete(rc_anal_t *);
-rc_return_t analRcs(rc_anal_t *, const char *);
-rc_return_t analGloblocs(rc_anal_t *);
+/* List function prototypes */
+rc_list_t *listNew(void);
+rc_return_t listDelete(rc_list_t *);
+rc_return_t listPopulate(rc_list_t *, const char *);
 
 /* Script function prototypes */
 rc_script_t *scriptNew(void);
@@ -114,12 +113,13 @@
 const char *scriptTostring(rc_script_t *);
 rc_return_t scriptDelete(rc_script_t *);
 
-/* Label function prototypes */
-rc_label_t *labelNew(const char *);
-rc_return_t labelAppendsec(rc_label_t *, rc_section_t *);
-rc_return_t labelDelete(rc_label_t *);
-const char *labelGetname(rc_label_t *);
-rc_return_t labelSetname(rc_label_t *, const char *);
+/* Rcfile function prototypes */
+rc_file_t  *rcfileNew(const char *);
+rc_return_t rcfileAppendsec(rc_file_t *, rc_section_t *);
+const char *rcfileGetname(rc_file_t *);
+rc_return_t rcfileSetname(rc_file_t *, const char *);
+short rcfileExists(rc_file_t *);
+rc_return_t rcfileDelete(rc_file_t *);
 
 /* Section function prototypes */
 rc_section_t *sectionNew(const char *);


ossp-pkg/rc/rc_anal.c 1.20 -> 1.21



ossp-pkg/rc/rc_config.c 1.32 -> 1.33

--- rc_config.c  2003/06/13 18:33:07     1.32
+++ rc_config.c  2003/06/18 14:35:29     1.33
@@ -74,10 +74,10 @@
     char **pszTemp = NULL;  /* For holding the section string vector */
 
     try {
-        fprintf(stderr, "Run command file: %s\n", configGetrcfile());
+        fprintf(stderr, "# Run command file: %s\n", configGetrcfile());
 
         pszTemp = (char **)configGetsecs();
-        fprintf(stderr, "Sections:");
+        fprintf(stderr, "# Sections:");
         for (i = 0; pszTemp[i]; i++)
             fprintf(stderr, " %s", pszTemp[i]);
         fputc('\n', stderr);
@@ -86,11 +86,12 @@
         for (i = 0; i < RC_NUMOPTS; i++) {
             if (configGetval(i) == NULL); /* NOP */
             else if (!(strcmp(configGetval(i), "1")))
-                fprintf(stderr, "Option %s is on.\n", configGetname(i));
+                fprintf(stderr, "# Option %s is on.\n", configGetname(i));
             else
-                fprintf(stderr, "Option %s is %s.\n", configGetname(i),\
+                fprintf(stderr, "# Option %s is %s.\n", configGetname(i),\
                     configGetval(i));
         }
+        fputc('\n', stderr);
     }
 
     catch(Except)


ossp-pkg/rc/rc_const.h 1.24 -> 1.25

--- rc_const.h   2003/06/13 18:33:07     1.24
+++ rc_const.h   2003/06/18 14:35:29     1.25
@@ -37,9 +37,15 @@
 #define RC_SLO_TEXT "The silent option may not be combined with output options.\n"
 #define RC_SUM_TEXT "Option argument summary.\n"
 #define RC_RUT_TEXT "Failed to set the user id. Please become the root user and try again.\n"
-#define RC_EVN_TEXT "# Evaluating section %s of script %s.\n"
-#define RC_EXN_TEXT "# Executing section %s of script %s.\n"
-#define RC_PRN_TEXT "# Printing section %s of script %s.\n"
+
+/* Generic text, should not include newline termination */
+#define RC_VST_TEXT "# Start of run command script operations."
+#define RC_EVF_TEXT "# Evaluating code from functions file."
+#define RC_EVN_TEXT "# Evaluating section %s of script %s."
+#define RC_EXF_TEXT "# Executing code from functions file."
+#define RC_EXN_TEXT "# Executing section %s of script %s."
+#define RC_PNF_TEXT "# Printing code from functions file."
+#define RC_PRN_TEXT "# Printing section %s of script %s."
 
 /* Single word user text, should not include termination */
 #define RC_CMN_TEXT "common"


ossp-pkg/rc/rc_file.c -> 1.1

*** /dev/null    Wed Apr 24 06:45:34 2024
--- -    Wed Apr 24 06:51:14 2024
***************
*** 0 ****
--- 1,182 ----
+ /*  OSSP rc - Run-command processor
+ **  Copyright (c) 2002 Ralf S. Engelschall
+ **  Copyright (c) 2002 Cable & Wireless Deutschland GmbH
+ **  Copyright (c) 2002 The OSSP Project <http://www.ossp.org/>
+ **
+ **  This file is part of OSSP rc, a portable Run-command processor
+ **  which can be found at http://www.ossp.org/pkg/lib/rc/
+ **
+ **  Permission to use, copy, modify, and distribute this software for
+ **  any purpose with or without fee is hereby granted, provided that
+ **  the above copyright notice and this permission notice appear in all
+ **  copies.
+ **
+ **  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ **  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ **  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ **  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ **  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ **  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ **  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ **  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ **  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ **  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ **  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ **  SUCH DAMAGE.
+ **
+ **  rc_file.c: Run-command processor ISO C source file
+ */
+ 
+ #include <string.h> /* For string copy and such data ops */
+ #include <stdlib.h> /* For memory ops */
+ 
+ #include "rc.h"     /* Public Rc interface */
+ 
+ 
+ /************************************************
+ * rcfileNew(void)                               *
+ * Construct a new rcfile                        *
+ ************************************************/
+ rc_file_t *rcfileNew(const char *szName)
+ {
+     rc_file_t *pRcfile = NULL;
+ 
+     pRcfile = (rc_file_t *)calloc(1, sizeof(rc_file_t));   /* Allocate and clear */
+     if (!pRcfile)                                          /* Ensure storage */
+         RC_THROW(RC_ERR_MEM);
+ 
+     if (szName) {
+         pRcfile->m_szName = malloc((strlen(szName) + 1) * sizeof(char));
+         strcpy(pRcfile->m_szName, szName);
+     }
+     else
+         pRcfile->m_szName = NULL;
+ 
+     /* Default values */
+     pRcfile->m_nSecs = -1;
+     pRcfile->m_ppSecvec = NULL;
+ 
+     return(pRcfile);
+ }
+ 
+ /****************************************************
+ * rcfileAppendsec(rc_file_t *, rc_section_t *)      *
+ * Append a section to this rcfile                   *
+ ****************************************************/
+ rc_return_t rcfileAppendsec(rc_file_t *pRcfile, rc_section_t *pInsec)
+ {
+     assert(pRcfile);    /* Rcfile parameter must be valid */
+     if (!pInsec)        /* Check sanity */
+         return(RC_THROW(RC_ERR_USE));
+ 
+     /* When appending to a brand new rcfile, reset the object key (m_nSecs) */
+     if (pRcfile->m_nSecs == -1)
+         pRcfile->m_nSecs = 0;
+ 
+     /* First make our vector larger to hold one more section */
+     pRcfile->m_ppSecvec = realloc(pRcfile->m_ppSecvec, sizeof(rc_section_t *) \
+                                                      * (pRcfile->m_nSecs + 1));
+     pRcfile->m_ppSecvec[pRcfile->m_nSecs] = sectionNew(pInsec->m_szName);
+     pRcfile->m_ppSecvec[pRcfile->m_nSecs + 1] = NULL;
+ 
+     /* Simple value copy */
+     pRcfile->m_ppSecvec[pRcfile->m_nSecs]->m_nPri  = pInsec->m_nPri;
+     pRcfile->m_ppSecvec[pRcfile->m_nSecs]->m_nUid  = pInsec->m_nUid;
+ 
+     /* Deep copy of user name */
+     if (pInsec->m_szLogin) {
+         pRcfile->m_ppSecvec[pRcfile->m_nSecs]->m_szLogin = \
+             malloc((strlen(pInsec->m_szLogin) + sizeof(char)) * sizeof(char));
+         strcpy(pRcfile->m_ppSecvec[pRcfile->m_nSecs]->m_szLogin, pInsec->m_szLogin);
+     }
+ 
+     /* Deep copy of section text */
+     if (pInsec->m_szData) {
+         pRcfile->m_ppSecvec[pRcfile->m_nSecs]->m_szData = \
+             malloc((strlen(pInsec->m_szData) + sizeof(char)) * sizeof(char));
+         strcpy(pRcfile->m_ppSecvec[pRcfile->m_nSecs]->m_szData, pInsec->m_szData);
+     }
+ 
+     /* Finally increment section count */
+     pRcfile->m_nSecs++;
+ 
+     return(RC_THROW(RC_OK));
+ }
+ 
+ /************************************************
+ * rcfileGetXXX(rc_file_t *)                     *
+ * Accessor methods                              *
+ ************************************************/
+ const char *rcfileGetname(rc_file_t *pRcfile)
+ { /* Name of rcfile, used for display during verbose */
+     if (pRcfile)
+         return(pRcfile->m_szName);
+     else
+         RC_THROW(RC_ERR_USE);
+ 
+     return(0); /* Not reached */
+ }
+ 
+ /************************************************
+ * rcfileSetXXX(rc_file_t *, const ... *)        *
+ * Accessor methods                              *
+ ************************************************/
+ rc_return_t rcfileSetname(rc_file_t *pRcfile, const char *szName)
+ { /* Name of rcfile, used for display during verbose */
+     if (pRcfile) {
+         pRcfile->m_szName = malloc((strlen(szName) + 1) * sizeof (char));
+         strcpy(pRcfile->m_szName, szName);
+         return(RC_THROW(RC_OK));
+     }
+ 
+     return(RC_THROW(RC_ERR_USE));
+ }
+ 
+ /************************************************
+ * rcfileExists(rc_file_t *)                     *
+ * Tests for an existing rcfile object           *
+ ************************************************/
+ short rcfileExists(rc_file_t *pRcfile)
+ { /* Key on name of rcfile */
+     if (pRcfile) {
+         if (pRcfile->m_szName)
+             return(TRUE);   /* Object does indeed exist */
+         else
+             return(FALSE);  /* Object does not exist    */
+     }
+ 
+     return(RC_THROW(RC_ERR_USE));
+ }
+ 
+ /************************************************
+ * rcfileDelete(rc_file_t *)                     *
+ * Destruct a rcfile                             *
+ ************************************************/
+ rc_return_t rcfileDelete(rc_file_t *pRcfile)
+ {
+     int nSecs = pRcfile->m_nSecs;
+ 
+     /* Cleanup our junk */
+     if (pRcfile) {
+         pRcfile->m_nSecs = 0;       /* Blank the section count    */
+         if (pRcfile->m_szName) {    /* Destroy the rc name        */
+             free(pRcfile->m_szName);
+             pRcfile->m_szName = NULL;
+         }
+         while (nSecs-- > 0) {       /* Destroy the section vector */
+             if (pRcfile->m_ppSecvec[nSecs]) {
+                 sectionDelete(pRcfile->m_ppSecvec[nSecs]);
+                 pRcfile->m_ppSecvec[nSecs] = NULL;
+             }
+         }
+         free(pRcfile->m_ppSecvec);
+         pRcfile->m_ppSecvec = NULL;
+         free(pRcfile);
+         pRcfile = NULL;
+     }
+     else    /* Dumbass passed an empty rcfile object */
+         assert(FALSE);
+ 
+     return(RC_THROW(RC_OK));
+ }
+ 


ossp-pkg/rc/rc_lab.c 1.4 -> 1.5



ossp-pkg/rc/rc_list.c -> 1.1

*** /dev/null    Wed Apr 24 06:45:34 2024
--- -    Wed Apr 24 06:51:14 2024
***************
*** 0 ****
--- 1,169 ----
+ /*  OSSP rc - Run-command processor
+ **  Copyright (c) 2002 Ralf S. Engelschall
+ **  Copyright (c) 2002 Cable & Wireless Deutschland GmbH
+ **  Copyright (c) 2002 The OSSP Project <http://www.ossp.org/>
+ **
+ **  This file is part of OSSP rc, a portable Run-command processor
+ **  which can be found at http://www.ossp.org/pkg/lib/rc/
+ **
+ **  Permission to use, copy, modify, and distribute this software for
+ **  any purpose with or without fee is hereby granted, provided that
+ **  the above copyright notice and this permission notice appear in all
+ **  copies.
+ **
+ **  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ **  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ **  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ **  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+ **  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ **  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ **  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ **  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ **  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ **  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ **  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ **  SUCH DAMAGE.
+ **
+ **  rc_list.c: Run-command processor ISO C source file
+ */
+ 
+ #include <stdlib.h>
+ #include <string.h>
+ #include <dirent.h>
+ 
+ #include "rc.h"         /* Public interfaces        */
+ #include "rc_const.h"   /* String constants         */
+ #include "rc_config.h"  /* Configuration interface  */
+ 
+ 
+ /************************************************
+ * listNew(void)                                 *
+ * Construct a new rcfile list                   *
+ ************************************************/
+ rc_list_t *listNew(void)
+ {
+     rc_list_t *pNew = NULL;
+ 
+     /* Allocate storage for one list object */
+     pNew = calloc(1, sizeof(rc_list_t));
+     return(pNew);
+ }
+ 
+ /**************************************************
+ * private listPopulate(rc_list_t *, const char *) *
+ * Read the rcfile identifier and analyse it       *
+ **************************************************/
+ rc_return_t listPopulate(rc_list_t *pInst, const char *kszName)
+ {
+     ex_t Except;
+ 
+     assert(pInst); /* Verify sanity */
+     assert(!pInst->m_ppFilevec); /* Rcfiles should be NULL until we set them */
+ 
+     if (!kszName)
+         return(RC_THROW(RC_ERR_RCF));
+     else { /* Only enter block with valid string, strdup can't handle NULL */
+         pInst->m_ppFilevec = malloc(sizeof (rc_file_t *));
+         if (strcmp(kszName, RC_GLOB_WILD)) {
+             pInst->m_ppFilevec[0] = rcfileNew(kszName);  /* For an object  */
+             pInst->m_ppFilevec[1] = rcfileNew(NULL);     /* For the tail   */
+             pInst->m_nFiles = 1;             /* We handle just one rc file */
+         }
+         else { /* Wildcard rcfile indicates to glob the locs directories  */
+             try {
+                 DIR *pLocdir = NULL;
+                 struct dirent *pDirent = NULL;
+                 char *szLocations = NULL;   /* Locations of run command files */
+                 int nCount = 0;             /* How many globbed files we find */
+                 int nIter = 0;              /* Used to step through found files */
+ 
+                 assert(pInst); /* Sanity check */
+ 
+                 /* Build the location path name */
+                 if (!configGetval(RC_LOC_VAL)) {
+                     szLocations = NULL;
+                     szLocations = strdup("./"); /* FIXME: Relocate default val */
+                     RC_THROW(RC_ERR_INT);       /* Config should have given a locs default */
+                 }
+                 else { /* Only enter block with valid string, strdup can't handle NULL */
+                     if (*(configGetval(RC_LOC_VAL) + strlen(configGetval(RC_LOC_VAL)) - \
+                                                      sizeof (char)) != '/') {
+                         szLocations = malloc(strlen(configGetval(RC_LOC_VAL)) + \
+                                              sizeof (char) + \
+                                              sizeof (char));
+                         strcpy(szLocations, configGetval(RC_LOC_VAL));
+                         strcat(szLocations, "/");
+                     }
+                     else
+                         szLocations = strdup(configGetval(RC_LOC_VAL));
+                 }
+ 
+                 /* First just learn how many globbed files we have */
+                 if ((pLocdir = opendir(szLocations)) == NULL)
+                     return(RC_THROW(RC_ERR_DIR));
+                 for (pDirent = readdir(pLocdir); pDirent; pDirent = readdir(pLocdir))
+                     if (!strncmp(pDirent->d_name, "rc.", strlen("rc.")))
+                         nCount++;
+                 closedir(pLocdir);
+ 
+                 /* Prepare resources before entering rcfile allocation loop */
+                 if (nCount == 0) /* Check out the health of this directory listing */
+                     return(RC_THROW(RC_ERR_DIR));
+                 nIter = 0; /* Used in the next for block, so initialize */
+                 pInst->m_ppFilevec = calloc(nCount + 1, sizeof (rc_file_t *));
+                 if (!pInst->m_ppFilevec) /* Guard against memory overruns */
+                     return(RC_THROW(RC_ERR_MEM));
+                 if ((pLocdir = opendir(szLocations)) == NULL)
+                     return(RC_THROW(RC_ERR_DIR));
+ 
+                 /* Loop through file index setting rc file names according to dirent */
+                 for (pDirent = readdir(pLocdir); pDirent; pDirent = readdir(pLocdir))
+                     if (!strncmp(pDirent->d_name, "rc.", strlen("rc.")))
+                         pInst->m_ppFilevec[nIter++] = rcfileNew(pDirent->d_name + strlen("rc.") * sizeof (char));
+ 
+                 /* Clean up our used resources and prepare to exit */
+                 pInst->m_ppFilevec[nIter] = rcfileNew(NULL); /* Make the tail */
+                 pInst->m_nFiles = nIter;      /* Store how many globbed files */
+                 assert(nCount == nIter);    /* Be cautious, ensure numbers */
+                 free(szLocations);          /* Cleanup our temp */
+                 szLocations = NULL;         /* locations string */
+                 closedir(pLocdir);
+             }
+             catch(Except)
+                 rethrow;
+         }
+     }
+ 
+     return(RC_THROW(RC_OK));
+ }
+ 
+ /************************************************
+ * listDelete(rc_list_t *)                       *
+ * Destruct a rcfile list                        *
+ ************************************************/
+ rc_return_t listDelete(rc_list_t *pInst)
+ {
+ /* FIXME: It could be that pInst needs to be a double pointer to */
+ /*        be properly used in destruction. Otherwise members are */
+ /*        just copies of the stack parameters passed in.         */
+     int nIter = 0;
+ 
+     assert(pInst);  /* Verify sanity */
+ 
+     if (pInst->m_ppFilevec) {
+         for (nIter = 0; nIter <= pInst->m_nFiles; nIter++) {
+             if (pInst->m_ppFilevec[nIter]) {
+                 free(pInst->m_ppFilevec[nIter]); /* Deallocate a rcfile */
+                 pInst->m_ppFilevec[nIter] = NULL;
+             }
+         }
+         free(pInst->m_ppFilevec);       /* Deallocate the rcfile vector */
+         pInst->m_ppFilevec = NULL;
+     }
+ 
+     free(pInst);                        /* Deallocate the list itself   */
+     pInst = NULL;
+ 
+     return(RC_THROW(RC_OK));
+ }
+ 


ossp-pkg/rc/rc_private.h 1.32 -> 1.33

--- rc_private.h 2003/06/13 18:33:07     1.32
+++ rc_private.h 2003/06/18 14:35:29     1.33
@@ -73,12 +73,6 @@
 
 typedef int rc_opt_t;   /* For use with RC_XXX_VAL definitions  */
 
-/* Analyser type */
-typedef struct {
-    short m_nRcs;       /* How many rc files   */
-    char **m_pszRcs;    /* Rc file names       */
-} rc_anal_t;
-
 /* Script type */
 typedef char * rc_script_t;
 
@@ -89,21 +83,26 @@
     char *m_szName;
     char *m_szLogin;
     char *m_szData;
-    size_t m_Bytes;
 } rc_section_t;
 
-/* Label type */
+/* Rcfile class */
 typedef struct {
     short m_nSecs;
     char *m_szName;
     rc_section_t **m_ppSecvec;
-} rc_label_t;
+} rc_file_t;
+
+/* List class (can be implemented as array) */
+typedef struct {
+    short m_nFiles;
+    rc_file_t **m_ppFilevec;
+} rc_list_t;
 
 /* Processor class */
 typedef struct {
-    rc_anal_t *m_pAnal;
+    rc_script_t *m_pScriptfunc;
     rc_script_t *m_pScriptcom;
-    rc_label_t **m_ppLabvec;
+    rc_list_t *m_pList;
 } rc_proc_t;
 
 #endif /* __OSSPRC_PRIVATE_H__ */


ossp-pkg/rc/rc_proc.c 1.45 -> 1.46

--- 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));
 }


ossp-pkg/rc/rc_script.c 1.30 -> 1.31

--- rc_script.c  2003/06/13 18:33:07     1.30
+++ rc_script.c  2003/06/18 14:35:29     1.31
@@ -354,7 +354,7 @@
 ************************************************/
 rc_return_t scriptDelete(rc_script_t *pScript)
 {
-    assert(pScript); /* Check for a valid incoming script */
+    assert(pScript);    /* Check for a valid incoming script */
 
     if (*pScript) {
         free(*pScript);
@@ -363,7 +363,7 @@
     else
         RC_THROW(RC_WRN_NUL);
 
-    free(pScript);
+    free(pScript);      /* Free the script itself */
     pScript = NULL;
 
     return(RC_THROW(RC_OK));


ossp-pkg/rc/rc_sect.c 1.13 -> 1.14

--- rc_sect.c    2003/06/13 11:50:37     1.13
+++ rc_sect.c    2003/06/18 14:35:29     1.14
@@ -69,7 +69,6 @@
     pSec = (rc_section_t *)malloc(sizeof(rc_section_t));
     pSec->m_nPri    = pOrigsec->m_nPri;
     pSec->m_nUid    = pOrigsec->m_nUid;
-    pSec->m_Bytes   = pOrigsec->m_Bytes;
 
     /* Deep copy of user name */
     if (pOrigsec->m_szLogin) {
@@ -145,16 +144,6 @@
     return(0); /* Not reached */
 }
 
-size_t sectionGetlen(rc_section_t *pSec)
-{ /* Data length of section, length of a script body of a particular section */
-    if (pSec)
-        return(pSec->m_Bytes);
-    else
-        RC_THROW(RC_ERR_USE);
-
-    return(0); /* Not reached */
-}
-
 /************************************************
 * sectionSetXXX(rc_section_t *)                 *
 * Accessor methods                              *
@@ -204,14 +193,14 @@
 rc_return_t sectionSetdata(rc_section_t *pSec, const char *kszScript)
 { /* Data of section, this is the script body of the particular section */
     if (pSec) {
-        pSec->m_Bytes = (strlen(kszScript) + sizeof(char)) * sizeof(char);
+        size_t nBytes = (strlen(kszScript) + sizeof(char)) * sizeof(char);
         if (pSec->m_szData) { /* The section data is already in use */
             free(pSec->m_szData);
-            pSec->m_szData = malloc(pSec->m_Bytes);
+            pSec->m_szData = malloc(nBytes);
             strcpy(pSec->m_szData, kszScript);
         }
         else { /* Set the data the usual way */
-            pSec->m_szData = malloc(pSec->m_Bytes);
+            pSec->m_szData = malloc(nBytes);
             strcpy(pSec->m_szData, kszScript);
         }
         return(RC_THROW(RC_OK));
@@ -223,15 +212,15 @@
 rc_return_t sectionSetndata(rc_section_t *pSec, const char *kszScript, size_t Len)
 { /* Data of section, this is the script body of the particular section */
     if (pSec) {
-        pSec->m_Bytes = (Len + 1) * sizeof(char);       /* Set size */
+        size_t nBytes = (Len + 1) * sizeof(char);       /* Set size */
         if (pSec->m_szData) { /* The section data is already in use */
             free(pSec->m_szData);
-            pSec->m_szData = malloc(pSec->m_Bytes);
+            pSec->m_szData = malloc(nBytes);
             strncpy(pSec->m_szData, kszScript, Len);
             *(pSec->m_szData + Len) = '\0'; /* Terminate outgoing */
         }
         else { /* Set the data the usual way */
-            pSec->m_szData = malloc(pSec->m_Bytes);
+            pSec->m_szData = malloc(nBytes);
             strncpy(pSec->m_szData, kszScript, Len);
             *(pSec->m_szData + Len) = '\0'; /* Terminate outgoing */
         }

CVSTrac 2.0.1