OSSP CVS Repository

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

Check-in Number: 2213
Date: 2002-Jul-02 20:03:17 (local)
2002-Jul-02 18:03:17 (UTC)
User:ms
Branch:
Comment: Daily dump, start processing sections with regular expressions.
Tickets:
Inspections:
Files:
ossp-pkg/rc/rc_proc.c      1.10 -> 1.11     20 inserted, 12 deleted
ossp-pkg/rc/rc_script.c      1.3 -> 1.4     23 inserted, 6 deleted

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

--- rc_proc.c    2002/07/01 15:03:33     1.10
+++ rc_proc.c    2002/07/02 18:03:17     1.11
@@ -77,6 +77,8 @@
     int nFdfunc   = 0;
     int nRet      = 0;
     int nIter     = 0;
+    ex_t Except;
+
     char *sBuf    = NULL;
     char *szSec   = NULL;
     char *szLocex = NULL;
@@ -126,20 +128,26 @@
         if (nRet == -1) /* Handle read errors */
             RC_THROW(RC_ERR_IO);
 
-        for (i = 0; pRc->m_pAnal->m_pszSecs[i]; i++) { /* Iterate over secvec */
-            /* Extract a section from the temp script, and append it */
-            szSec = scriptSection(pTempscript, pRc->m_pAnal->m_pszSecs[i]);
-
-            if (szSec) /* Only call append if the section lookup succeeded */
-                scriptAppend(pRc->m_pScript, szSec, strlen(szSec));
-            else if (configGetval(RC_DBG_VAL)) /* Only show when debug is set */
-                fprintf(stderr, "#Warning: Missing section '%s' in %s!\n", pRc->m_pAnal->m_pszSecs[i], pRc->m_pAnal->m_szRcs[nIter]);
-
-            if (szSec) { /* Cleanup section string */
-                free(szSec);
-                szSec = NULL;
+        try {
+            for (i = 0; pRc->m_pAnal->m_pszSecs[i]; i++) { /* Iterate over */
+                /* Extract a section from the temp script, and append it */
+                szSec = scriptSection(pTempscript, pRc->m_pAnal->m_pszSecs[i]);
+
+                if (szSec) /* Only call append if the section lookup succeeds */
+                    scriptAppend(pRc->m_pScript, szSec, strlen(szSec));
+                else if (configGetval(RC_DBG_VAL)) /* Only show if debug set */
+                    fprintf(stderr, "#Warning: Missing section '%s' in %s!\n",\
+                        pRc->m_pAnal->m_pszSecs[i],\
+                        pRc->m_pAnal->m_szRcs[nIter]);
+
+                if (szSec) { /* Cleanup section string */
+                    free(szSec);
+                    szSec = NULL;
+                }
             }
         }
+        catch(Except)
+            rethrow;
 
         /* Clean up our crap */
         scriptDelete(pTempscript); /* Temp script */


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

--- rc_script.c  2002/06/28 17:43:23     1.3
+++ rc_script.c  2002/07/02 18:03:17     1.4
@@ -30,7 +30,9 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "rc.h"
+#include "rc.h"         /* Public Rc interface      */
+#include "rc_pcre.h"    /* For section parsing      */
+#include "rc_config.h"  /* For configuration access */
 
 
 /************************************************
@@ -100,12 +102,27 @@
 ************************************************/
 char *scriptSection(rc_script_t *pScript, const char *kszSecname)
 {
-    char *szTempout = NULL;
-    char *szTmpsec  = NULL;
-    char *piStart   = NULL;
-    char *piEnd     = NULL;
+    char *szTempout    = NULL;
+    char *szTmpsec     = NULL;
+    char *piStart      = NULL;
+    char *piEnd        = NULL;
+    int nOffset        = 0;
+    const int kiRegopt = 0;
+    const char *szErr  = NULL;
+
+    pcre *pRegex       = NULL;  /* Perl Compatible Regular Expression */
+    pcre_extra *pExtra = NULL;  /* Used for studying an expression    */
+
+    assert(pScript);            /* Check for a valid incoming script  */
+    assert(configGetval(RC_DEF_VAL));
+
+    if (!kszSecname)    /* If we get a NULL section label, give a NULL result */
+        return (NULL);  /* This might be useful in some loop constructs */
+
+    if ((pRegex = pcre_compile(configGetval(RC_DEF_VAL), kiRegopt, &szErr, &nOffset, NULL)) == NULL) {
+        RC_THROW(RC_ERR_SYS);
+    }
 
-    assert(pScript); /* Check for a valid incoming script */
     szTmpsec = malloc(strlen(kszSecname) + sizeof(char));
     strcpy(szTmpsec, "%");
     strcat(szTmpsec, kszSecname);

CVSTrac 2.0.1