--- rc_script.c 2002/06/26 14:11:16 1.1
+++ rc_script.c 2002/06/28 14:20:23 1.2
@@ -56,6 +56,8 @@
int nResize = 0;
void *pvRealloc = NULL;
+ assert(pScript); /* Script parameter must be valid */
+
if (!szInbuf) {
TRACE("Problem with appendScript");
/* return(RC_THROW(RC_ERR_USE));*/
@@ -82,7 +84,7 @@
else
strncpy(pvRealloc, szInbuf, Size);
- /* Coerce strings into one Script again */
+ /* Cleanup and deallocate memory */
if (*pScript) {
free(*pScript);
*pScript = NULL;
@@ -93,6 +95,31 @@
}
/************************************************
+* scriptSection(rc_script_t *, const char *) *
+* Parse a script for a given section *
+************************************************/
+const char *scriptSection(rc_script_t *pScript, const char *kszSecname)
+{
+ char *szTempout = NULL;
+ char *szTmpsec = NULL;
+ char *piStart = NULL;
+ char *piEnd = NULL;
+
+ szTmpsec = malloc(strlen(kszSecname) + sizeof(char));
+ strcpy(szTmpsec, "%");
+ strcat(szTmpsec, kszSecname);
+
+ piStart = strstr(*pScript, szTmpsec); /* Find start of section */
+ piStart = strstr(piStart, "\n") + sizeof(char); /* Wrap to next line */
+ piEnd = strstr(piStart + sizeof(char), "%"); /* FIXME: Remove hardcoded */
+ szTempout = malloc(piEnd - piStart + sizeof(char));
+ strncpy(szTempout, piStart, piEnd - piStart);
+ *(szTempout + (piEnd - piStart)) = NULL; /* Terminate the outgoing string */
+
+ return(szTempout);
+}
+
+/************************************************
* scriptDump(rc_script_t *) *
* Print a script to standard out *
************************************************/
|