OSSP CVS Repository

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

Check-in Number: 2189
Date: 2002-Jun-26 16:11:16 (local)
2002-Jun-26 14:11:16 (UTC)
User:ms
Branch:
Comment: Intermediate committal, lots of additions, compiles and works very limited.
Tickets:
Inspections:
Files:
ossp-pkg/rc/00TODO      1.25 -> 1.26     3 inserted, 0 deleted
ossp-pkg/rc/Makefile.in      1.28 -> 1.29     2 inserted, 2 deleted
ossp-pkg/rc/rc.c      1.31 -> 1.32     14 inserted, 34 deleted
ossp-pkg/rc/rc.h      1.28 -> 1.29     7 inserted, 0 deleted
ossp-pkg/rc/rc_anal.c      1.4 -> 1.5     20 inserted, 19 deleted
ossp-pkg/rc/rc_cliopt.c      1.10 -> 1.11     9 inserted, 9 deleted
ossp-pkg/rc/rc_config.c      1.16 -> 1.17     28 inserted, 22 deleted
ossp-pkg/rc/rc_const.h      1.6 -> 1.7     0 inserted, 3 deleted
ossp-pkg/rc/rc_opt.c      1.4 -> 1.5     2 inserted, 2 deleted
ossp-pkg/rc/rc_private.h      1.14 -> 1.15     7 inserted, 5 deleted
ossp-pkg/rc/rc_proc.c      1.3 -> 1.4     90 inserted, 3 deleted
ossp-pkg/rc/rc_script.c      added-> 1.1
ossp-pkg/rc/rc_test.sh      1.10 -> 1.11     18 inserted, 14 deleted

ossp-pkg/rc/00TODO 1.25 -> 1.26

--- 00TODO       2002/05/23 18:03:20     1.25
+++ 00TODO       2002/06/26 14:11:16     1.26
@@ -38,6 +38,9 @@
   Correct assertion, sanity check, and if () checks according to one standard.
   Make variable naming standard m_pksz?, and correct throughout.
   Correct according to a method naming standard like <file>Method.
+  Remove redundant method prototypes in main header file.
+  Relocate rc_anal_t and other to approproate header files rc_anal.h.
+  I think rc_anal is violating the singleton configuration.
 
 Detailed ;-) project plan
 -------------------------


ossp-pkg/rc/Makefile.in 1.28 -> 1.29

--- Makefile.in  2002/05/28 17:02:56     1.28
+++ Makefile.in  2002/06/26 14:11:16     1.29
@@ -59,10 +59,10 @@
 TARGET_PROGS    = rc
 TARGET_MANS     = rc.1 rc-sample.5
 
-SRCS            = rc.c rc_anal.c rc_config.c rc_cliopt.c \
+SRCS            = rc.c rc_anal.c rc_script.c rc_config.c rc_cliopt.c \
                   rc_proc.c rc_version.c rc_pcre.c rc_util.c
 
-OBJS            = rc.o rc_anal.o rc_config.o rc_cliopt.o \
+OBJS            = rc.o rc_anal.o rc_script.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.c 1.31 -> 1.32

--- rc.c 2002/06/05 16:24:20     1.31
+++ rc.c 2002/06/26 14:11:16     1.32
@@ -39,19 +39,15 @@
 int main(int argc, char *argv[])
 {
     ex_t Except;
-    rc_anal_t *pAnal = NULL;    /* Holds preprocessed configuration       */
 
-    ex_try {                /* Configuration and abstract analysis block  */
+    ex_try {                /* Configuration block                        */
         configNew();        /* Construct a new configuration              */
         configLoad(argc, (const char **)argv); /* Load cli, env, and conf */
         configDebug();      /* FIXME Remove FIXME */
         configVerify();     /* Test for usage, help, and version options  */
-
-        pAnal = analNew();  /* Construct a new configuration analyser     */
-        analParse(pAnal);   /* Preprocess the analysed configuration      */
     }
-    ex_catch(Except) {      /* Exceptions during configuration and analysis */
-        TRACE("Hopla, in config and anal exception block");
+    ex_catch(Except) {      /* Exceptions of the configuration block      */
+        TRACE("Hopla, in config exception block");
         if ((rc_return_t)Except.ex_value == RC_ERR_USE) {
             clioptPrintusage();
         }
@@ -60,44 +56,28 @@
                 (char *)Except.ex_class, (int)Except.ex_value,\
                 Except.ex_file, Except.ex_func, Except.ex_line);
         }
-        if (FAILED((rc_return_t)Except.ex_value)) { /* NOP on warnings */
-            exit(1); /* Report failure and exit the program */
-        }
-        else {
-        }
-    }
-
-    ex_try { /* Main script building and processing block */
-/*        rc_script_t *pScript = NULL;*/
-/*        rc_proc_t *pProc     = NULL;*/
-
-/*        pScript = scriptNew(pAnal);*/ /* Construct a new script           */
-/*        scriptBuild(pScript);*/
-
-/*        pProc = procNew(pScript);*/   /* Construct a new processor        */
-/*        procRun(pProc);*/             /* [Execute|Evaluate|Print] script  */
-/*        procDelete(pProc);*/          /* Destroy the processor            */
-/*        scriptDelete(pScript);*/      /* Destroy the script               */
-    }
-    ex_catch(Except) {  /* Error exceptions thrown during script processing */
-        fprintf(stderr, "Class '%s' threw exception %d in %s:%s():%d.\n",\
-            (char *)Except.ex_class, (int)Except.ex_value,\
-            Except.ex_file, Except.ex_func, Except.ex_line);
         if (FAILED((rc_return_t)Except.ex_value)) /* NOP on warnings */
             exit(1); /* Report failure and exit the program */
     }
 
-    ex_try {                /* Shutdown of main program  */
-        analDelete(pAnal);  /* Destroy the analyser      */
-        configDelete();     /* Destroy the configuration */
+    ex_try { /* Main processing block, the script is built here */
+        rc_proc_t *pProc = NULL;
+        pProc = procNew();      /* Construct a new processor, build script  */
+        procPopulate(pProc);    /* Populate with run commands               */
+        procRun(pProc);         /* [Execute|Evaluate|Print] script          */
+        procDelete(pProc);      /* Destroy the processor                    */
+        configDelete();         /* Destroy the configuration                */
     }
-    ex_catch(Except) { /* Error exceptions thrown during program shutdown */
+    ex_catch(Except) {  /* Error exceptions thrown during script processing */
+        TRACE("Also, exception dans le processor bloque");
         if (FAILED((rc_return_t)Except.ex_value)) { /* NOP on warnings */
             fprintf(stderr, "Class '%s' threw exception %d in %s:%s():%d.\n",\
                 (char *)Except.ex_class, (int)Except.ex_value,\
                 Except.ex_file, Except.ex_func, Except.ex_line);
             exit(1); /* Return failure */
         }
+        else
+            RC_NOP;  /* No operation on warnings */
     }
 
     exit(0);        /* Return success */


ossp-pkg/rc/rc.h 1.28 -> 1.29

--- rc.h 2002/05/23 18:03:20     1.28
+++ rc.h 2002/06/26 14:11:16     1.29
@@ -104,6 +104,12 @@
 rc_return_t analSecs(rc_anal_t **, const char **);
 rc_return_t analParse(rc_anal_t *);
 
+/* Script function prototypes */
+rc_script_t *scriptNew(void);
+rc_return_t scriptAppend(rc_script_t *, char *, size_t);
+rc_return_t scriptDump(rc_script_t *);
+rc_return_t scriptDelete(rc_script_t *);
+
 /* Processor function prototypes */
 rc_proc_t *procNew(void);
 rc_return_t procDelete(rc_proc_t *);
@@ -112,6 +118,7 @@
 rc_return_t procReadrc(rc_proc_t *, const char *);
 rc_return_t procSection(rc_proc_t *, const char *);
 rc_return_t procParse(rc_proc_t *);
+rc_return_t procPopulate(rc_proc_t *);
 rc_return_t procRun(rc_proc_t *);
 
 /* Utility (nonbounded) function prototypes */


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

--- rc_anal.c    2002/06/05 16:24:20     1.4
+++ rc_anal.c    2002/06/26 14:11:16     1.5
@@ -42,7 +42,8 @@
 {
     rc_anal_t *pNew = NULL;
 
-    pNew = malloc(sizeof(rc_anal_t));
+    /* Allocate storage for 1 anal object */
+    pNew = calloc(1, sizeof(rc_anal_t));
     return(pNew);
 }
 
@@ -52,10 +53,10 @@
 ************************************************/
 rc_return_t analRcs(rc_anal_t **ppInst, const char *kszName)
 {
-    if (!kszName)
-        TRACE("Error codition, NULL passed as argument");
-/* FIXME Das ist very broken!  */
+    if (!kszName) {
+        (*ppInst)->m_szRcs = NULL;
 /*        RC_THROW(RC_WRN_NUL);*/
+    }
     else { /* Only enter block with valid string, strdup can't handle NULL */
         (*ppInst)->m_szRcs = strdup(kszName);
     }
@@ -65,13 +66,12 @@
 
 /************************************************
 * private analTmp(rc_anal_t **, const char *)   *
-* Read a temp file to use for analysis          *
+* Read a temp file to analyze                   *
 ************************************************/
 rc_return_t analTmp(rc_anal_t **ppInst, const char *kszName)
 {
     if (!kszName) {
-        TRACE("Error codition, NULL passed as argument");
-/* FIXME Das ist very broken!  */
+        (*ppInst)->m_szTmp = NULL;
 /*        RC_THROW(RC_WRN_NUL);*/
     }
     else { /* Only enter block with valid string, strdup can't handle NULL */
@@ -87,10 +87,10 @@
 ************************************************/
 rc_return_t analFuncs(rc_anal_t **ppInst, const char *kszName)
 {
-    if (!kszName)
-        TRACE("Error codition, NULL passed as argument");
-/* FIXME Das ist very broken!  */
+    if (!kszName) {
+        (*ppInst)->m_szFuncs = NULL;
 /*        RC_THROW(RC_WRN_NUL);*/
+    }
     else { /* Only enter block with valid string, strdup can't handle NULL */
         (*ppInst)->m_szFuncs = strdup(kszName);
     }
@@ -104,10 +104,10 @@
 ************************************************/
 rc_return_t analLocs(rc_anal_t **ppInst, const char *kszPathexpr)
 {
-    if (!kszPathexpr)
-        TRACE("Error codition, NULL passed as argument");
-/* FIXME Das ist very broken!  */
+    if (!kszPathexpr) {
+        (*ppInst)->m_szLocs = NULL;
 /*        RC_THROW(RC_WRN_NUL);*/
+    }
     else { /* Only enter block with valid string, strdup can't handle NULL */
         (*ppInst)->m_szLocs = strdup(kszPathexpr);
     }
@@ -123,16 +123,16 @@
 {
     ex_t Except;
 
-    if (!pkszVector)
-        TRACE("Error codition, NULL passed as argument");
-/* FIXME Das ist very broken!  */
-/*        RC_THROW(RC_WRN_NUL);*/
+    if (!pkszVector) {
+        RC_THROW(RC_WRN_NUL);
+    }
 
     ex_try {    /* Sections are a vector, so we must copy accordingly */
         (*ppInst)->m_pszSecs = vectorCopy(pkszVector);
     }
     ex_catch(Except) {
-        rethrow;
+TRACE("VectorCopy broke");
+/*        rethrow;*/
     }
 
     return(RC_THROW(RC_OK));
@@ -155,7 +155,8 @@
         analSecs (&pInst, configGetsecs());
     }
     ex_catch(Except) {
-        rethrow;
+TRACE("Parsing broke");
+/*        rethrow;*/
     }
 
     return(RC_THROW(RC_OK));


ossp-pkg/rc/rc_cliopt.c 1.10 -> 1.11

--- rc_cliopt.c  2002/05/23 18:03:20     1.10
+++ rc_cliopt.c  2002/06/26 14:11:16     1.11
@@ -41,7 +41,7 @@
 static popt_context m_Optcon;                  /* Context for parsing options */
 
 static struct popt_option m_pOptable[] = {
-    /* Long options with short keys but no arguments */
+    /* Long options are defined as short keys but no arguments */
     {RC_USE_NAME, '?', POPT_ARG_NONE, 0, RC_USE_VAL, RC_USE_DESC, NULL},
     {RC_DBG_NAME, 'd', POPT_ARG_NONE, 0, RC_DBG_VAL, RC_DBG_DESC, NULL},
     {RC_VER_NAME, 'V', POPT_ARG_NONE, 0, RC_VER_VAL, RC_VER_DESC, NULL},
@@ -174,10 +174,10 @@
     if (m_pszSecs)              /* Warn on overwrites */
         RC_THROW(RC_WRN_OWR);
 
-    ex_try {
+    try {
         m_pszSecs = vectorCopy(pkszSecs);
     }
-    ex_catch(Except) {
+    catch(Except) {
         rethrow;
     }
 
@@ -282,10 +282,10 @@
 
     /* Now do options processing */
     while ((cliOpt = popt_getnextopt(m_Optcon)) >= 0) {/* Loop, each time     */
-        ex_try {                                       /* eating a new option */
+        try {                                          /* eating a new option */
             clioptProcess(cliOpt, popt_getoptarg(m_Optcon));
         }
-        ex_catch(Except) { /* Error condition probably deserves attention */
+        catch(Except) { /* Error condition probably deserves attention */
             rethrow;
         }
     }
@@ -310,11 +310,11 @@
     ex_t Except;
 
     /* Use popt as a transport to read the user specified rcfile and sections */
-    ex_try {
+    try {
         clioptSetrcfile(popt_getarg(m_Optcon));
         clioptSetsecs(popt_getargs(m_Optcon));
     }
-    ex_catch(Except) {
+    catch(Except) {
         rethrow; /* Our generic response */
     }
 
@@ -331,14 +331,14 @@
 /*    ex_t Except;
 
     assert(s_pBintab);*/                /* Error if not constructed */
-/*    ex_try {
+/*    try {
         clioptRemall();*/             /* Removes ALL list nodes   */
 /*FIXME        optDelete((rc_opt_t **)&s_pBintab->pOptlist->pvData);FIXME*/
 /*        free(s_pBintab->pOptlist);*/    /* Deallocate option list   */
 /*        free(s_pBintab);*/              /* Deallocate cliopt and    */
 /*        s_pBintab = NULL;*/             /* clear its reference      */
 /*    }
-    ex_catch(Except) {
+    catch(Except) {
         rethrow;
     }*/
 


ossp-pkg/rc/rc_config.c 1.16 -> 1.17

--- rc_config.c  2002/05/22 13:29:40     1.16
+++ rc_config.c  2002/06/26 14:11:16     1.17
@@ -48,16 +48,22 @@
 void configDebug(void)
 {
     int i = 0;
+    ex_t Except;
     char **szTemp = NULL;
 
-    fprintf(stderr, "Run command file: %s\n", configGetrcfile());
+    try {
+        fprintf(stderr, "Run command file: %s\n", configGetrcfile());
 
-    szTemp = (char **)configGetsecs();
-    fprintf(stderr, "Sections:");
-    while (szTemp[i])
-        fprintf(stderr, " %s", szTemp[i++]);
+        szTemp = (char **)configGetsecs();
+        fprintf(stderr, "Sections:");
+        while (szTemp[i])
+            fprintf(stderr, " %s", szTemp[i++]);
 
-    fprintf(stderr, "\n%s", configSummarize());
+        fprintf(stderr, "\n%s", configSummarize());
+    }
+    catch(Except) {
+        rethrow;
+    }
 }
 
 /***************************************
@@ -69,10 +75,10 @@
     ex_t Except;
 
     if (m_nLocks == 0) {                    /* If we don't have one yet */
-        ex_try {                            /* then construct a new one */
+        try {                               /* then construct a new one */
             clioptNew();                    /* Member cliopt instance   */
         }
-        ex_catch(Except) {
+        catch(Except) {
             rethrow;
         }
     }
@@ -91,7 +97,7 @@
     char *szTemp = NULL;
 
     if (m_nLocks) {                         /* Make sure config exists      */
-        ex_try {
+        try {
             if ((szTemp = (char *)clioptGetval(Optname)))
                 return((const char *)szTemp);
 /*            else if (szTemp = envoptGetval(Optname))
@@ -101,7 +107,7 @@
             else
                 return(NULL);               /* Special case when not found  */
         }
-        ex_catch(Except) {
+        catch(Except) {
             rethrow;
         }
     }
@@ -138,14 +144,14 @@
     ex_t Except;
 
     if (m_nLocks) {                     /* Make sure config exists   */
-        ex_try {
+        try {
             /* Because (1) only one rc file can be specified and     */
             /*         (2) it must be specified on the command line, */
             /* we don't bother checking the environment or conf file */
             /* contrary to the behaviour of Getval earlier           */
             return(clioptGetrcfile());
         }
-        ex_catch(Except) {
+        catch(Except) {
             rethrow;
         }
     }
@@ -161,10 +167,10 @@
     ex_t Except;
 
     if (m_nLocks) {                             /* Make sure config exists   */
-        ex_try {                                /* FIXME Might need to check */
+        try {                                   /* FIXME Might need to check */
             return(clioptGetsecs());            /* FIXME env, conf, configs  */
         }
-        ex_catch(Except) {
+        catch(Except) {
             rethrow;
         }
     }
@@ -188,7 +194,7 @@
     m_szSummary = malloc(NULL);
     for (i = 0; i < RC_NUMOPTS; i++)
     {
-        ex_try {    /* FIXME Not threadsafe, wrap with crit section */
+        try { /* FIXME Not threadsafe, wrap with crit section */
             if (configGetval(i) == NULL); /* NOP */
             else if (!(strcmp(configGetval(i), "1"))) {
                 szTemp = malloc(strlen(m_szSummary) + strlen(configGetval(i)));
@@ -213,7 +219,7 @@
                 m_szSummary = szTemp;
             }
         }               /* FIXME Not threadsafe, wrap with crit section */
-        ex_catch(Except) {  /* Breaks the otherwise endless loop above  */
+        catch(Except) {     /* Breaks the otherwise endless loop above  */
             rethrow;
         }
     }
@@ -229,13 +235,13 @@
 {
     ex_t Except;
 
-    ex_try {    /* Parse option groups in order of priority          */
+    try {       /* Parse option groups in order of priority          */
         clioptParseopts(nTotal, szArgvec);  /* Command line options  */
         clioptParseargs();                  /* Command line args */
 /*        envoptParse(m_nLocks->pOpt);*/    /* Environment options   */
 /*        cnfoptParse(m_nLocks->pOpt);*/    /* Configfile options    */
     }
-    ex_catch(Except) {
+    catch(Except) {
         rethrow;
     }
 
@@ -250,7 +256,7 @@
 {
     ex_t Except;
 
-    ex_try { /* Basic checks of version, usage, and help options */
+    try { /* Basic checks of version, usage, and help options */
         if (configGetval(RC_VER_VAL))
             fprintf(stdout, "OSSP rc %s\n", RC_VERSION);
         if (configGetval(RC_USE_VAL))
@@ -258,7 +264,7 @@
         if (configGetval(RC_HLP_VAL))
             clioptPrintusage(); /* FIXME Replace with real help FIXME */
     }
-    ex_catch(Except) {
+    catch(Except) {
         rethrow;
     }
 
@@ -274,12 +280,12 @@
     ex_t Except;
 
     if (--m_nLocks == 0) {          /* If m_nLocks is 0, deallocate */
-        ex_try {                    /* FIXME, not thread-safe       */
+        try {                       /* FIXME, not thread-safe       */
             clioptDelete();
             if (m_szSummary)
                 free(m_szSummary);
         }
-        ex_catch(Except) {
+        catch(Except) {
             rethrow;
         }
     }


ossp-pkg/rc/rc_const.h 1.6 -> 1.7

--- rc_const.h   2002/05/22 13:29:40     1.6
+++ rc_const.h   2002/06/26 14:11:16     1.7
@@ -110,7 +110,4 @@
 
 #define RC_CONF_WILD  "all"
 
-/* FIXME Tie to shtool generation */
-#define RC_VERSION    "77.77"
-
 #endif /* __OSSPRC_CONST_H__ */


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

--- rc_opt.c     2002/04/24 16:47:07     1.4
+++ rc_opt.c     2002/06/26 14:11:16     1.5
@@ -107,7 +107,7 @@
     ex_t Except;
 
     assert(*ppOption);                  /* Error if not constructed */
-    ex_try {
+    try {
         if ((*ppOption)->szName)        /* Might not be mallocd yet */
             free((*ppOption)->szName);
         if ((*ppOption)->szVal)         /* Might not be mallocd yet */
@@ -115,7 +115,7 @@
         free(*ppOption);                /* Deallocate option and    */
         *ppOption = NULL;               /* clear its reference      */
     }
-    ex_catch(Except) {
+    catch(Except) {
         rethrow;
     }
 


ossp-pkg/rc/rc_private.h 1.14 -> 1.15

--- rc_private.h 2002/05/23 18:03:20     1.14
+++ rc_private.h 2002/06/26 14:11:16     1.15
@@ -46,8 +46,12 @@
 #endif
 
 
+/* FIXME Tie to shtool generation */
+#define RC_VERSION    "77.77"
+
+#define RC_READ_BUFSIZE 1024
 #define RC_STR_ID "OSSP rc"                         /* APPID for OSSP rc */
-#define RC_UID_ID f8a1845c55e6449481176f6e9cea34b   /* UUID for OSSP rc */
+#define RC_UID_ID 0xf8a1845c55e6449481176f6e9cea34b /* UUID for OSSP rc  */
 
 /* Intentional no operation */
 #define RC_NOP ((void)0)
@@ -75,13 +79,11 @@
 } rc_anal_t;
 
 /* Script type */
-typedef struct {
-    rc_anal_t *m_pAnal;
-    char *m_szText;
-} rc_script_t;
+typedef char * rc_script_t;
 
 /* Processor class */
 typedef struct {
+    rc_anal_t *m_pAnal;
     rc_script_t *m_pScript;
 } rc_proc_t;
 


ossp-pkg/rc/rc_proc.c 1.3 -> 1.4

--- rc_proc.c    2002/05/22 14:32:20     1.3
+++ rc_proc.c    2002/06/26 14:11:16     1.4
@@ -27,9 +27,15 @@
 **  rc_proc.c: Run-command processor ISO C source file
 */
 
-#include <stdlib.h>
+#include <stdlib.h>     /* Standard system headers  */
+#include <fcntl.h>      /* For reading rc files     */
+#include <unistd.h>     /* For reading rc files     */
+#include <string.h>     /* For string manipulation  */
 
-#include "rc.h"     /* Public interfaces */
+/* FIXME: Remove */
+#include <sys/stat.h>
+
+#include "rc.h"         /* Public interfaces        */
 
 
 /************************************************
@@ -41,6 +47,10 @@
     rc_proc_t *pNewrc = NULL;
 
     pNewrc = malloc(sizeof(rc_proc_t));
+    pNewrc->m_pAnal = analNew();        /* Construct a configuration analyser */
+    pNewrc->m_pScript = scriptNew();    /* Construct a run-command script     */
+    analParse(pNewrc->m_pAnal);         /* Preprocess the anal configuration  */
+
     return(pNewrc);
 }
 
@@ -56,12 +66,89 @@
 }
 
 /************************************************
+* procPopulate(rc_proc_t *)                     *
+* Populate the processor with run commands      *
+************************************************/
+rc_return_t procPopulate(rc_proc_t *pRc)
+{
+    int nFdrc     = 0;
+    int nFdfunc   = 0;
+    int nRet      = 0;
+    char *szBuf   = NULL;
+
+    char *szFucka = NULL;
+
+    /* FIXME: Do not hardcode location or prefix! */
+    szFucka = (char *)malloc(strlen(pRc->m_pAnal->m_szRcs) + 8);
+    strcpy(szFucka, "rcfiles/rc.");
+    strcat(szFucka, pRc->m_pAnal->m_szRcs);
+
+    szBuf = (char *)calloc(0, RC_READ_BUFSIZE);
+
+    /* Open the rc file unconditionally */
+    if ((nFdrc = open(szFucka, O_RDONLY)) == -1) {
+/*        RC_THROW(RC_ERR_IO);*/
+        TRACE("Problem with procPopulate open(2)");
+    }
+
+    /* Open the func file if it belongs to the configuration */
+    if (pRc->m_pAnal->m_szFuncs) {
+        if ((nFdfunc = open(pRc->m_pAnal->m_szFuncs, O_RDONLY)) == -1) {
+    /*        RC_THROW(RC_ERR_IO);*/
+        TRACE("Problem with procPopulate open(2)");
+        }
+        /* Read data from the func file */
+        while ((nRet = read(nFdfunc, szBuf, RC_READ_BUFSIZE)) > 0)
+            scriptAppend(pRc->m_pScript, szBuf, nRet);
+        if (nRet == -1) /* Handle read errors */
+            TRACE("Problem with procPopulate read(2)");
+    /*        RC_THROW(RC_ERR_IO);*/
+    }
+
+    /* Read data from the rc file */
+    while ((nRet = read(nFdrc, szBuf, RC_READ_BUFSIZE)) > 0)
+        scriptAppend(pRc->m_pScript, szBuf, nRet);
+    if (nRet == -1) /* Handle read errors */
+        TRACE("Problem with procPopulate read(2)");
+/*        RC_THROW(RC_ERR_IO);*/
+
+    /* Filehandle cleanups */
+    close(nFdrc);
+    close(nFdfunc);
+
+    /* Memory cleanups */
+    if (szFucka) {
+        free(szFucka);
+        szFucka = NULL;
+    }
+    if (szBuf) {
+        free(szBuf);
+        szBuf = NULL;
+    }
+
+    return(RC_THROW(RC_OK));
+}
+
+/************************************************
+* procRun(rc_proc_t *)                          *
+* Run the processed run-command script          *
+************************************************/
+rc_return_t procRun(rc_proc_t *pRc)
+{
+    scriptDump(pRc->m_pScript);
+
+    return(RC_THROW(RC_OK));
+}
+
+/************************************************
 * procDelete(rc_proc_t *)                       *
 * Destruct a processor                          *
 ************************************************/
 rc_return_t procDelete(rc_proc_t *pRc)
 {
-    free(pRc);
+    scriptDelete(pRc->m_pScript);   /* Destroy the script        */
+    analDelete(pRc->m_pAnal);       /* Destroy the analyser      */
+    free(pRc);                      /* Free the processor itself */
 
     return(RC_THROW(RC_OK));
 }


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

*** /dev/null    Fri Mar 29 16:55:00 2024
--- -    Fri Mar 29 16:58:15 2024
***************
*** 0 ****
--- 1,123 ----
+ /*  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_script.c: Run-command processor ISO C source file
+ */
+ 
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ #include "rc.h"
+ 
+ 
+ /************************************************
+ * scriptNew(void)                               *
+ * Construct a script                            *
+ ************************************************/
+ rc_script_t *scriptNew(void)
+ {
+     rc_script_t *pScript = NULL;
+ 
+     pScript = (rc_script_t *)malloc(sizeof(rc_script_t));
+     *pScript = NULL;
+ 
+     return(pScript);
+ }
+ 
+ /************************************************
+ * scriptAppend(rc_script_t *, char *, size_t)   *
+ * Append text to a script                       *
+ ************************************************/
+ rc_return_t scriptAppend(rc_script_t *pScript, char *szInbuf, size_t Size)
+ {
+     int nResize     = 0;
+     void *pvRealloc = NULL;
+ 
+     if (!szInbuf) {
+ TRACE("Problem with appendScript");
+ /*        return(RC_THROW(RC_ERR_USE));*/
+     }
+ 
+     /* Short circuit in case of dumb noop call */
+     if (Size == 0) {
+         return(RC_THROW(RC_OK));
+     }
+ 
+     /* Add 2 to end of nResize to ensure that a \0 precedes any strings */
+     nResize = (*pScript != NULL ? strlen(*pScript) : 0) + Size + 2;
+     /* Don't trust realloc(3) in this case */
+     if ((pvRealloc = calloc(1, (size_t)nResize)) == NULL) {
+ TRACE("Problem with appendScript");
+ /*        return(RC_THROW(RC_ERR_MEM));*/
+     }
+ 
+     /* Coerce strings into one Script again */
+     if (*pScript) {
+         strcpy(pvRealloc, *pScript);
+         strncat(pvRealloc, szInbuf, Size);
+     }
+     else
+         strncpy(pvRealloc, szInbuf, Size);
+ 
+     /* Coerce strings into one Script again */
+     if (*pScript) {
+         free(*pScript);
+         *pScript = NULL;
+     }
+     *pScript = pvRealloc;
+ 
+     return(RC_THROW(RC_OK));
+ }
+ 
+ /************************************************
+ * scriptDump(rc_script_t *)                    *
+ * Print a script to standard out                *
+ ************************************************/
+ rc_return_t scriptDump(rc_script_t *pScript)
+ {
+     fprintf(stdout, "\n**************** Dumpskripte ****************\n");
+     fprintf(stdout, "%s\n", *pScript);
+     fprintf(stdout, "**************** Dumpskripte ****************\n\n");
+ 
+     return(RC_THROW(RC_OK));
+ }
+ 
+ /************************************************
+ * scriptDelete(rc_script_t *)                   *
+ * Destruct a script                             *
+ ************************************************/
+ rc_return_t scriptDelete(rc_script_t *pScript)
+ {
+     if (*pScript)
+         free(*pScript);
+     else {
+ TRACE("Empty script created, unused, then destroyed");
+ /*        RC_THROW(RC_WRN_NUL);*/
+     }
+     free(pScript);
+ 
+     return(RC_THROW(RC_OK));
+ }


ossp-pkg/rc/rc_test.sh 1.10 -> 1.11

--- rc_test.sh   2002/05/22 13:29:40     1.10
+++ rc_test.sh   2002/06/26 14:11:16     1.11
@@ -28,26 +28,26 @@
 #  test_rc.sh: Run-command processor test script
 
 # Test short options, should fail for false combination usage
-echo "./rc -dVehilpsrvxLcfqt samba start sleep=2 restart"
-./rc -dVehilpsrvxLcfqt samba start sleep=2 restart
+echo "./rc -dvef rcfunc/rc.func -hilpsrvxLcqt samba start sleep=2 restart"
+./rc -dVef rcfunc/rc.func -hilpsrvxLcqt samba start sleep=2 restart
 
 # Test short options, should succeed
-echo; echo "./rc -derv -L /sfw/etc/rc.d/rc.%{RCFILE:s/^all$/*/} -c /sfw/etc/rc.conf -f /sfw/etc/rc.func -t /tmp openssh stop sleep=4 start daily minsize=2097152"
-./rc -derv -L /sfw/etc/rc.d/rc.%{RCFILE:s/^all$/*/} -c /sfw/etc/rc.conf -f /sfw/etc/rc.func -t /tmp openssh stop sleep=4 start daily minsize=2097152
+echo; echo "./rc -derv -L /u/ms/ossp/rc/rcdings/rcfiles/rc.%{RCFILE:s/^all$/*/} -c /u/ms/ossp/rc/rcdings/rc.conf -f /u/ms/ossp/rc/rcfunc/rc.func -t /tmp openssh stop sleep=4 start daily minsize=2097152"
+./rc -derv -L /u/ms/ossp/rc/rcdings/rcfiles/rc.d/rc.%{RCFILE:s/^all$/*/} -c /u/ms/ossp/rc/rcdings/rc.conf -f /u/ms/ossp/rc/rcfunc/rc.func -t /tmp openssh stop sleep=4 start daily minsize=2097152
 
 # Test some long options, should fail for false combination usage
 echo; echo "./rc --verbose --silent uucp stop sleep=6 start"
 ./rc --verbose --silent uucp stop sleep=6 start
 echo; echo "./rc --query myvar --silent zebra bing bang"
 ./rc --query myvar --silent zebra bing bang
-echo; echo "./rc --conf /sfw/rc.conf --locate /etc/rc3.d:/sfw/etc/rc.d --query what to enter here"
-./rc --conf /sfw/rc.conf --locate /etc/rc3.d:/sfw/etc/rc.d --query what to enter here
+echo; echo "./rc --conf /sfw/rc.conf --locate /u/ms/ossp/rc/rcdings/rcfiles/ --query this barf test"
+./rc --conf /sfw/rc.conf --locate /u/ms/ossp/rc/rcdings/rcfiles/ --query this barf test
 
 # Test minimal set of long options, should succeed
 echo; echo "./rc --debug --version rsyncd nothing matters but the version"
 ./rc --debug --version rsyncd nothing matters but the version
-echo; echo "./rc --conf /sfw/rc.conf --locate /cw/etc/rc.d:/sfw/etc/rc.d:/etc/rc --query what to enter here"
-./rc --conf /sfw/rc.conf --locate /cw/etc/rc.d:/sfw/etc/rc.d:/etc/rc --query what to enter here
+echo; echo "./rc --conf /sfw/rc.conf --locate /cw/etc/rc.d:/u/ms/ossp/rc/rcdings/rcfiles:/etc/rc --query this barf test"
+./rc --conf /sfw/rc.conf --locate /cw/etc/rc.d:/u/ms/ossp/rc/rcdings/rcfiles:/etc/rc --query this barf test
 
 # FIXME these cases are not handled yet by our configuration FIXME #
 #echo; echo "./rc --debug --version"
@@ -62,12 +62,16 @@
 #./rc --conf /sfw/rc.conf --tmp /sfw/RPM/TMP --debug --labels rsyncd
 # FIXME these cases are not handled yet by our configuration FIXME #
 
-echo; echo "./rc --func /sfw/etc/rc.func --print --verbose openssh stop sleep=4 start"
-./rc --func /sfw/etc/rc.func --print --verbose openssh stop sleep=4 start
-echo; echo "./rc --func /sfw/etc/rc.func --debug --eval uucp restart"
-./rc --func /sfw/etc/rc.func --debug --eval uucp restart
-echo; echo "./rc --conf ./myrc --func /sfw/etc/rc.func --tmp /tmp --debug --silent --exec uucp start"
-./rc --conf ./myrc --func /sfw/etc/rc.func --tmp /tmp --debug --silent --exec uucp start
+echo; echo "./rc --func /u/ms/ossp/rc/rcfunc/rc.func --print --verbose openssh stop sleep=4 start"
+./rc --func /u/ms/ossp/rc/rcfunc/rc.func --print --verbose openssh stop sleep=4 start
+echo; echo "./rc --func /u/ms/ossp/rc/rcfunc/rc.func --debug --eval uucp restart"
+./rc --func /u/ms/ossp/rc/rcfunc/rc.func --debug --eval uucp restart
+echo; echo "./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func --tmp /tmp --exec uucp start"
+./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func --tmp /tmp --exec uucp start
+echo; echo "./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func --tmp /tmp --debug --exec ntp sync"
+./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func --tmp /tmp --debug --exec ntp sync
+echo; echo "./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func --tmp /tmp --debug --silent --exec ralf feed suppe"
+./rc --conf rcdings/myrc.conf --func /u/ms/ossp/rc/rcfunc/rc.func --tmp /tmp --debug --silent --exec ralf feed suppe
 
 # Next milestone
 #RequireOwner

CVSTrac 2.0.1