--- rc_script.c 2003/05/12 15:42:45 1.13
+++ rc_script.c 2003/05/14 16:36:28 1.14
@@ -67,9 +67,8 @@
}
/* Short circuit in case of dumb noop call */
- if (Size == 0) {
+ 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;
@@ -110,6 +109,8 @@
char *piBlocend = NULL; /* Misnomer used to control section looping */
char *piStart = NULL;
char *piEnd = NULL;
+ long nPri = 0;
+ long nUid = 0;
int nOffset = 0;
int nFound = 0;
int nVecsize = 0;
@@ -179,9 +180,7 @@
piStart = piBlocend + *(pnVec + 6);
piEnd = piBlocend + *(pnVec + 7);
pSec = sectionNew();
- pSec->szData = malloc(piEnd - piStart + sizeof(char));
- strncpy(pSec->szData, piStart, piEnd - piStart);
- *(pSec->szData + (piEnd - piStart)) = NULL; /* Terminate outgoing */
+ sectionSetndata(pSec, piStart, piEnd - piStart);
/* Handle the section priority */
piStart = piBlocend + *(pnVec + 4);
@@ -190,10 +189,11 @@
piSubtemp = strnstr(piStart, RC_DEF_PRG, piEnd - piStart);
if (piSubtemp) { /* Priority pattern found */
/* FIXME: Remove the 1 in the following line! */
- pSec->nPri = strtol(piSubtemp + strlen(RC_DEF_PRG) + 1, (char **)NULL, 10);
+ nPri = strtol(piSubtemp + strlen(RC_DEF_PRG) + 1, (char **)NULL, 10);
+ sectionSetpri(pSec, nPri);
}
else /* Fallback to default value */
- pSec->nPri = RC_DEF_PRI;
+ sectionSetpri(pSec, RC_DEF_PRI);
/*fprintf(stderr, "nPri ist %d!\n", pSec->nPri);*/
/* Handle the section userid */
@@ -237,8 +237,12 @@
{
/* Don't remove this! It encapsulates the script object, */
/* which might not be a simple string */
- fprintf(stdout, "%s", *pScript);
- return(RC_THROW(RC_OK));
+ if (pScript) {
+ fprintf(stdout, "%s", *pScript);
+ return(RC_THROW(RC_OK));
+ }
+ else
+ return(RC_THROW(RC_ERR_USE));
}
/************************************************
|