--- rc_sect.c 2003/04/03 12:05:14 1.2
+++ rc_sect.c 2003/05/14 16:36:28 1.3
@@ -99,7 +99,7 @@
* sectionSetXXX(rc_section_t *) *
* Accessor methods *
************************************************/
-rc_return_t sectionSetpri(rc_section_t *pSec, int nPriority)
+rc_return_t sectionSetpri(rc_section_t *pSec, long nPriority)
{ /* Priority of section, used to order sections during exec|eval|print */
if (pSec) {
pSec->nPri = nPriority;
@@ -109,7 +109,7 @@
return(RC_THROW(RC_ERR_USE));
}
-rc_return_t sectionSetuid(rc_section_t *pSec, int nUserid)
+rc_return_t sectionSetuid(rc_section_t *pSec, long nUserid)
{ /* Userid of section, used with setuid during exec or eval */
if (pSec) {
pSec->nUid = nUserid;
@@ -122,18 +122,39 @@
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) {
- pSec->Bytes = strlen(kszScript) + sizeof(char); /* Calculate size */
+ pSec->Bytes = strlen(kszScript) * sizeof(char) + sizeof(char);
if (pSec->szData) { /* The section data is already in use */
free(pSec->szData);
- pSec->szData = malloc(pSec->szData);
+ pSec->szData = malloc(pSec->Bytes);
strcpy(pSec->szData, kszScript);
}
else { /* Set the data the usual way */
- pSec->szData = malloc(pSec->szData);
+ pSec->szData = malloc(pSec->Bytes);
strcpy(pSec->szData, kszScript);
}
return(RC_THROW(RC_OK));
}
+
+ return(RC_THROW(RC_ERR_USE));
+}
+
+rc_return_t sectionSetndata(rc_section_t *pSec, const char *kszScript, size_t Len)
+{ /* Data of section, this is the script body of the particular section */
+ if (pSec) {
+ pSec->Bytes = Len * sizeof(char) + sizeof(char); /* Set size */
+ if (pSec->szData) { /* The section data is already in use */
+ free(pSec->szData);
+ pSec->szData = malloc(pSec->Bytes);
+ strncpy(pSec->szData, kszScript, Len);
+ *(pSec->szData + Len) = NULL; /* Terminate outgoing */
+ }
+ else { /* Set the data the usual way */
+ pSec->szData = malloc(pSec->Bytes);
+ strncpy(pSec->szData, kszScript, Len);
+ *(pSec->szData + Len) = NULL; /* Terminate outgoing */
+ }
+ return(RC_THROW(RC_OK));
+ }
return(RC_THROW(RC_ERR_USE));
}
|