OSSP CVS Repository

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

Check-in Number: 3436
Date: 2003-Jun-11 18:18:48 (local)
2003-Jun-11 16:18:48 (UTC)
User:ms
Branch:
Comment: Implement limited verbosity on eval modus, and begin mergin the label object and the section object.
Tickets:
Inspections:
Files:
ossp-pkg/rc/rc.h      1.46 -> 1.47     6 inserted, 0 deleted
ossp-pkg/rc/rc_const.h      1.20 -> 1.21     3 inserted, 0 deleted
ossp-pkg/rc/rc_lab.c      1.3 -> 1.4     29 inserted, 0 deleted
ossp-pkg/rc/rc_private.h      1.29 -> 1.30     1 inserted, 0 deleted
ossp-pkg/rc/rc_proc.c      1.41 -> 1.42     10 inserted, 0 deleted
ossp-pkg/rc/rc_sect.c      1.11 -> 1.12     42 inserted, 0 deleted
ossp-pkg/rc/rc_test.sh      1.23 -> 1.24     7 inserted, 0 deleted

ossp-pkg/rc/rc.h 1.46 -> 1.47

--- rc.h 2003/05/21 12:49:20     1.46
+++ rc.h 2003/06/11 16:18:48     1.47
@@ -123,17 +123,23 @@
 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 *);
 
 /* Section function prototypes */
 rc_section_t *sectionNew(const char *);
 rc_section_t *sectionCopy(rc_section_t *);
 const int sectionGetpri(rc_section_t *);
 const int sectionGetuid(rc_section_t *);
+const char *sectionGetname(rc_section_t *);
+const char *sectionGetlabel(rc_section_t *);
 const char *sectionGetlogin(rc_section_t *);
 const char *sectionGetdata(rc_section_t *);
 size_t sectionGetlen(rc_section_t *);
 rc_return_t sectionSetpri(rc_section_t *, long);
 rc_return_t sectionSetuid(rc_section_t *, long);
+rc_return_t sectionSetname(rc_section_t *, const char *);
+rc_return_t sectionSetlabel(rc_section_t *, const char *);
 rc_return_t sectionSetlogin(rc_section_t *, const char *);
 rc_return_t sectionSetdata(rc_section_t *, const char *);
 rc_return_t sectionSetndata(rc_section_t *, const char *, size_t);


ossp-pkg/rc/rc_const.h 1.20 -> 1.21

--- rc_const.h   2003/05/28 18:43:34     1.20
+++ rc_const.h   2003/06/11 16:18:48     1.21
@@ -37,6 +37,9 @@
 #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"
 
 /* Option descriptions used with popt, should not include termination */
 #define RC_USE_DESC "Print a short usage summary, then exit."


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

--- rc_lab.c     2003/06/03 15:26:52     1.3
+++ rc_lab.c     2003/06/11 16:18:48     1.4
@@ -95,6 +95,35 @@
 }
 
 /************************************************
+* labelGetXXX(rc_label_t *)                     *
+* Accessor methods                              *
+************************************************/
+const char *labelGetname(rc_label_t *pLab)
+{ /* Name of label, used for display during verbose */
+    if (pLab)
+        return(pLab->m_szName);
+    else
+        RC_THROW(RC_ERR_USE);
+
+    return(0); /* Not reached */
+}
+
+/************************************************
+* labelSetXXX(rc_label_t *, const ... *)        *
+* Accessor methods                              *
+************************************************/
+rc_return_t labelSetname(rc_label_t *pLab, const char *szName)
+{ /* Name of label, used for display during verbose */
+    if (pLab) {
+        pLab->m_szName = malloc((strlen(szName) + 1) * sizeof (char));
+        strcpy(pLab->m_szName, szName);
+        return(RC_THROW(RC_OK));
+    }
+
+    return(RC_THROW(RC_ERR_USE));
+}
+
+/************************************************
 * labelDelete(rc_label_t *)                     *
 * Destruct a label                              *
 ************************************************/


ossp-pkg/rc/rc_private.h 1.29 -> 1.30

--- rc_private.h 2003/05/28 15:09:29     1.29
+++ rc_private.h 2003/06/11 16:18:48     1.30
@@ -92,6 +92,7 @@
     int m_nPri;
     int m_nUid;
     char *m_szName;
+    char *m_szLabel;
     char *m_szLogin;
     char *m_szData;
     size_t m_Bytes;


ossp-pkg/rc/rc_proc.c 1.41 -> 1.42

--- rc_proc.c    2003/06/03 15:26:52     1.41
+++ rc_proc.c    2003/06/11 16:18:48     1.42
@@ -232,6 +232,16 @@
                 sizeof(rc_section_t *), priCompare);
             nTmp = 0;
             while (nTmp < pRc->m_pAnal->m_nRcs && ppSectmp[nTmp]) {
+                if (configGetval(RC_VRB_VAL)) {
+                    size_t nBytes = 0;
+                    char *szVerbose = NULL;
+                    szTmp = (char *)sectionGetname(ppSectmp[nTmp]);
+                    nBytes = (strlen(RC_EVN_TEXT) + strlen(szTmp) + 1) * sizeof (char);
+                    szVerbose = malloc (nBytes);
+                    sprintf(szVerbose, RC_EVN_TEXT, szTmp, szTmp);
+                    scriptAppend(pFatscript, szVerbose, strlen(szVerbose));
+                    free(szVerbose);
+                }
                 if ((szTmp = (char *)sectionGetlogin(ppSectmp[nTmp])) != NULL) {
                     scriptAppend(pFatscript, "#su ", strlen("#su "));
                     scriptAppend(pFatscript, szTmp, strlen(szTmp));


ossp-pkg/rc/rc_sect.c 1.11 -> 1.12

--- rc_sect.c    2003/05/27 13:14:08     1.11
+++ rc_sect.c    2003/06/11 16:18:48     1.12
@@ -115,6 +115,26 @@
     return(0); /* Not reached */
 }
 
+const char *sectionGetname(rc_section_t *pSec)
+{ /* Name of section, used for display during verbose */
+    if (pSec)
+        return(pSec->m_szName);
+    else
+        RC_THROW(RC_ERR_USE);
+
+    return(0); /* Not reached */
+}
+
+const char *sectionGetlabel(rc_section_t *pSec)
+{ /* Rc label, used for display during verbose */
+    if (pSec)
+        return(pSec->m_szLabel);
+    else
+        RC_THROW(RC_ERR_USE);
+
+    return(0); /* Not reached */
+}
+
 const char *sectionGetlogin(rc_section_t *pSec)
 { /* User name of section, used for display during print */
     if (pSec)
@@ -166,6 +186,28 @@
         return(RC_THROW(RC_OK));
     }
 
+    return(RC_THROW(RC_ERR_USE));
+}
+
+rc_return_t sectionSetname(rc_section_t *pSec, const char *szName)
+{ /* Name of section, used for display during verbose */
+    if (pSec) {
+        pSec->m_szName = malloc((strlen(szName) + 1) * sizeof (char));
+        strcpy(pSec->m_szName, szName);
+        return(RC_THROW(RC_OK));
+    }
+
+    return(RC_THROW(RC_ERR_USE));
+}
+
+rc_return_t sectionSetlabel(rc_section_t *pSec, const char *szLabel)
+{ /* Rc label, used for display during verbose */
+    if (pSec) {
+        pSec->m_szLabel = malloc((strlen(szLabel) + 1) * sizeof (char));
+        strcpy(pSec->m_szLabel, szLabel);
+        return(RC_THROW(RC_OK));
+    }
+
     return(RC_THROW(RC_ERR_USE));
 }
 


ossp-pkg/rc/rc_test.sh 1.23 -> 1.24

--- rc_test.sh   2003/06/03 15:27:32     1.23
+++ rc_test.sh   2003/06/11 16:18:48     1.24
@@ -74,6 +74,13 @@
 ./rc --locate rc_test --ParseSectionDef "^<(.+?)[ \t]*(.*?)>\n*(.*?)^<\/\1>" rsyncd go
 echo; echo "<Press enter to continue>"
 read dummy;clear
+
+echo "*** Test minimal set of long options, should succeed ***"
+echo "./rc -L rc_test --ParseSectionDef \"^%([a-zA-Z][a-zA-Z0-9]*)\s*(-[a-zA-Z]\s*\S+)*\n(.+?)\n^%\" zebra test"
+./rc -L rc_test --ParseSectionDef "^%([a-zA-Z][a-zA-Z0-9]*)\s*(-[a-zA-Z]\s*\S+)*\n(.+?)\n^%" zebra test
+echo; echo "<Press enter to continue>"
+
+read dummy;clear
 echo "*** Test minimal set of long options, should succeed ***"
 echo "./rc --version --ParseSectionDef \"^<(.+?)[ \t]*(.*?)>\n*(.*?)^<\/\1>\" rsyncd nothing matters but the version"
 ./rc --version --ParseSectionDef "^<(.+?)[ \t]*(.*?)>\n*(.*?)^<\/\1>" rsyncd nothing matters but the version

CVSTrac 2.0.1