Index: ossp-pkg/rc/Makefile.in
RCS File: /v/ossp/cvs/ossp-pkg/rc/Makefile.in,v
rcsdiff -q -kk '-r1.30' '-r1.31' -u '/v/ossp/cvs/ossp-pkg/rc/Makefile.in,v' 2>/dev/null
--- Makefile.in 2002/07/10 19:02:24 1.30
+++ Makefile.in 2002/08/02 16:38:09 1.31
@@ -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_config.c \
+SRCS = rc.c rc_error.c rc_anal.c rc_script.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_config.o \
+OBJS = rc.o rc_error.o rc_anal.o rc_script.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@
Index: ossp-pkg/rc/rc.h
RCS File: /v/ossp/cvs/ossp-pkg/rc/rc.h,v
rcsdiff -q -kk '-r1.37' '-r1.38' -u '/v/ossp/cvs/ossp-pkg/rc/rc.h,v' 2>/dev/null
--- rc.h 2002/07/30 16:36:41 1.37
+++ rc.h 2002/08/02 16:38:09 1.38
@@ -112,11 +112,21 @@
/* Script function prototypes */
rc_script_t *scriptNew(void);
rc_return_t scriptAppend(rc_script_t *, char *, size_t);
-char *scriptSection(rc_script_t *, const char *);
+rc_section_t *scriptSection(rc_script_t *, const char *);
rc_return_t scriptDump(rc_script_t *);
const char *scriptTostring(rc_script_t *);
rc_return_t scriptDelete(rc_script_t *);
+/* Section function prototypes */
+rc_section_t *sectionNew(void);
+const int sectionGetpri(rc_section_t *);
+const int sectionGetuid(rc_section_t *);
+const char *sectionGetdata(rc_section_t *);
+rc_return_t sectionSetpri(rc_section_t *, int);
+rc_return_t sectionSetuid(rc_section_t *, int);
+rc_return_t sectionSetdata(rc_section_t *, const char *);
+rc_return_t sectionDelete(rc_section_t *);
+
/* Processor function prototypes */
rc_proc_t *procNew(void);
rc_return_t procDelete(rc_proc_t *);
Index: ossp-pkg/rc/rc_private.h
RCS File: /v/ossp/cvs/ossp-pkg/rc/rc_private.h,v
rcsdiff -q -kk '-r1.19' '-r1.20' -u '/v/ossp/cvs/ossp-pkg/rc/rc_private.h,v' 2>/dev/null
--- rc_private.h 2002/07/30 16:36:41 1.19
+++ rc_private.h 2002/08/02 16:38:09 1.20
@@ -74,6 +74,7 @@
/* Analyser type */
typedef struct {
+ short m_nRcs; /* How many rc files */
char **m_szRcs; /* Rc file names */
char *m_szTmp; /* Temp file name */
char *m_szFuncs; /* Function file names */
@@ -84,6 +85,13 @@
/* Script type */
typedef char * rc_script_t;
+/* Section type */
+typedef struct {
+ int nPri;
+ int nUid;
+ char *szData;
+} rc_section_t;
+
/* Processor class */
typedef struct {
rc_anal_t *m_pAnal;
Index: ossp-pkg/rc/rc_sect.c
RCS File: /v/ossp/cvs/ossp-pkg/rc/rc_sect.c,v
co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/rc/rc_sect.c,v' | diff -u /dev/null - -L'ossp-pkg/rc/rc_sect.c' 2>/dev/null
--- ossp-pkg/rc/rc_sect.c
+++ - 2025-05-20 13:40:52.311288426 +0200
@@ -0,0 +1,144 @@
+/* OSSP rc - Run-command processor
+** Copyright (c) 2002 Ralf S. Engelschall
+** Copyright (c) 2002 Cable & Wireless Deutschland GmbH
+** Copyright (c) 2002 The OSSP Project
+**
+** 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_sect.c: Run-command processor ISO C source file
+*/
+
+#include /* For string copy and such data ops */
+
+#include "rc.h" /* Public Rc interface */
+
+
+/************************************************
+* sectionNew(void) *
+* Construct a section *
+************************************************/
+rc_section_t *sectionNew(void)
+{
+ rc_section_t *pSec = NULL;
+
+ /* Among other things, they make great coffee at Cable & Wireless */
+ /* This code would probably have more bugs if the coffee was not as good */
+ pSec = (rc_section_t *)malloc(sizeof(rc_section_t));
+ *pSec = NULL;
+
+ return(pSec);
+}
+
+/************************************************
+* sectionGetXXX(rc_section_t *) *
+* Accessor methods *
+************************************************/
+const int sectionGetpri(rc_section_t *pSec)
+{ /* Priority of section, used to order sections during exec|eval|print */
+ if (pSec)
+ return(pSec->nPri);
+ else
+ RC_THROW(RC_ERR_USE);
+
+ return(0); /* Not reached */
+}
+
+const int sectionGetuid(rc_section_t *pSec)
+{ /* Userid of section, used with setuid during exec or eval */
+ if (pSec)
+ return(pSec->nUid);
+ else
+ RC_THROW(RC_ERR_USE);
+
+ return(0); /* Not reached */
+}
+
+const char *sectionGetdata(rc_section_t *pSec)
+{ /* Data of section, this is the script body of the particular section */
+ if (pSec && pSec->szData)
+ return(pSec->szData);
+ else
+ RC_THROW(RC_ERR_USE);
+
+ return(0); /* Not reached */
+}
+
+/************************************************
+* sectionSetXXX(rc_section_t *) *
+* Accessor methods *
+************************************************/
+rc_return_t sectionSetpri(rc_section_t *pSec, int nPriority)
+{ /* Priority of section, used to order sections during exec|eval|print */
+ if (pSec) {
+ pSec->nPri = nPriority;
+ return(RC_THROW(RC_OK));
+ }
+
+ return(RC_THROW(RC_ERR_USE));
+}
+
+rc_return_t sectionSetuid(rc_section_t *pSec, int nUserid)
+{ /* Userid of section, used with setuid during exec or eval */
+ if (pSec) {
+ pSec->nUid = nUserid;
+ return(RC_THROW(RC_OK));
+ }
+
+ return(RC_THROW(RC_ERR_USE));
+}
+
+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) {
+ if (pSec->szData) { /* The section data is already in use */
+ free(pSec->szData);
+ pSec->szData = malloc(strlen(kszScript) + sizeof(char));
+ strcpy(pSec->szData, kszScript);
+ }
+ else { /* Set the data the usual way */
+ pSec->szData = malloc(strlen(kszScript) + sizeof(char));
+ strcpy(pSec->szData, kszScript);
+ }
+ return(RC_THROW(RC_OK));
+ }
+
+ return(RC_THROW(RC_ERR_USE));
+}
+
+/************************************************
+* sectionDelete(rc_section_t *) *
+* Destruct a section *
+************************************************/
+rc_return_t sectionDelete(rc_section_t *pSec)
+{
+ /* Cleanup our junk */
+ if (pSec) {
+ if (pSec->szData)
+ free(pSec->szData);
+ free(pSec);
+ }
+ else /* Dumbass passed an empty section object */
+ assert(FALSE);
+
+ return(RC_THROW(RC_OK));
+}
+