summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--msg.c2
-rw-r--r--queue.c28
-rw-r--r--rsyslog.h1
-rw-r--r--stream.c40
-rw-r--r--stream.h2
5 files changed, 69 insertions, 4 deletions
diff --git a/msg.c b/msg.c
index 00654c21..dd635f58 100644
--- a/msg.c
+++ b/msg.c
@@ -2086,7 +2086,7 @@ rsRetVal MsgSetProperty(msg_t *pThis, property_t *pProp)
{
DEFiRet;
- assert(pThis != NULL);
+ ISOBJ_TYPE_assert(pThis, Msg);
assert(pProp != NULL);
if(isProp("iProtocolVersion")) {
diff --git a/queue.c b/queue.c
index 116b6ab1..99919ca2 100644
--- a/queue.c
+++ b/queue.c
@@ -818,13 +818,39 @@ finalize_it:
DEFpropSetMeth(queue, bImmediateShutdown, int);
+/* This function can be used as a generic way to set properties. Only the subset
+ * of properties required to read persisted property bags is supported. This
+ * functions shall only be called by the property bag reader, thus it is static.
+ * rgerhards, 2008-01-11
+ */
+#define isProp(name) !rsCStrSzStrCmp(pProp->pcsName, (uchar*) name, sizeof(name) - 1)
+static rsRetVal queueSetProperty(queue_t *pThis, property_t *pProp)
+{
+ DEFiRet;
+
+ ISOBJ_TYPE_assert(pThis, queue);
+ assert(pProp != NULL);
+
+ if(isProp("iQueueSize")) {
+ pThis->iQueueSize = pProp->val.vInt;
+ } else if(isProp("qType")) {
+ if(pThis->qType != pProp->val.vLong)
+ ABORT_FINALIZE(RS_RET_QTYPE_MISMATCH);
+ }
+
+finalize_it:
+ return iRet;
+}
+#undef isProp
+
+
/* Initialize the stream class. Must be called as the very first method
* before anything else is called inside this class.
* rgerhards, 2008-01-09
*/
BEGINObjClassInit(queue, 1)
//OBJSetMethodHandler(objMethod_SERIALIZE, strmSerialize);
- //OBJSetMethodHandler(objMethod_SETPROPERTY, strmSetProperty);
+ OBJSetMethodHandler(objMethod_SETPROPERTY, queueSetProperty);
//OBJSetMethodHandler(objMethod_CONSTRUCTION_FINALIZER, strmConstructFinalize);
ENDObjClassInit(strm)
diff --git a/rsyslog.h b/rsyslog.h
index 4608b947..93f6fe06 100644
--- a/rsyslog.h
+++ b/rsyslog.h
@@ -106,6 +106,7 @@ enum rsRetVal_ /** return value. All methods return this if not specified oth
RS_RET_VALUE_TOO_LOW = -2035, /**< a provided value is too low */
RS_RET_FILE_PREFIX_MISSING = -2036, /**< a required file prefix (parameter?) is missing */
RS_RET_INVALID_HEADER_RECTYPE = -2037, /**< invalid record type in header or invalid header */
+ RS_RET_QTYPE_MISMATCH = -2038, /**< different qType when reading back a property type */
RS_RET_OK_DELETE_LISTENTRY = 1, /**< operation successful, but callee requested the deletion of an entry (special state) */
RS_RET_TERMINATE_NOW = 2, /**< operation successful, function is requested to terminate (mostly used with threads) */
RS_RET_NO_RUN = 3, /**< operation successful, but function does not like to be executed */
diff --git a/stream.c b/stream.c
index 344c2c66..405f858f 100644
--- a/stream.c
+++ b/stream.c
@@ -638,6 +638,7 @@ rsRetVal strmSerialize(strm_t *pThis, strm_t *pStrm)
objSerializeSCALAR_VAR(pStrm, iMaxFileSize, LONG, l);
objSerializeSCALAR(pStrm, iMaxFiles, INT);
objSerializeSCALAR(pStrm, iFileNumDigits, INT);
+ objSerializeSCALAR(pStrm, bDeleteOnClose, INT);
CHKiRet(objEndSerialize(pStrm));
@@ -646,13 +647,50 @@ finalize_it:
}
+
+/* This function can be used as a generic way to set properties.
+ * rgerhards, 2008-01-11
+ */
+#define isProp(name) !rsCStrSzStrCmp(pProp->pcsName, (uchar*) name, sizeof(name) - 1)
+rsRetVal strmSetProperty(strm_t *pThis, property_t *pProp)
+{
+ DEFiRet;
+
+ ISOBJ_TYPE_assert(pThis, Msg);
+ assert(pProp != NULL);
+
+ if(isProp("sType")) {
+ CHKiRet(strmSetsType(pThis, (strmType_t) pProp->val.vInt));
+ } else if(isProp("iCurrFNum")) {
+ pThis->iCurrFNum = pProp->val.vInt;
+ } else if(isProp("pszFName")) {
+ CHKiRet(strmSetFName(pThis, rsCStrGetSzStrNoNULL(pProp->val.vpCStr), rsCStrLen(pProp->val.vpCStr)));
+ } else if(isProp("tOperationsMode")) {
+ CHKiRet(strmSettOperationsMode(pThis, pProp->val.vInt));
+ } else if(isProp("tOpenMode")) {
+ CHKiRet(strmSettOpenMode(pThis, pProp->val.vInt));
+ } else if(isProp("iMaxFileSize")) {
+ CHKiRet(strmSetiMaxFileSize(pThis, pProp->val.vLong));
+ } else if(isProp("iMaxFiles")) {
+ CHKiRet(strmSetiMaxFiles(pThis, pProp->val.vInt));
+ } else if(isProp("iFileNumDigits")) {
+ CHKiRet(strmSetiFileNumDigits(pThis, pProp->val.vInt));
+ } else if(isProp("bDeleteOnClose")) {
+ CHKiRet(strmSetiFileNumDigits(pThis, pProp->val.vInt));
+ }
+
+finalize_it:
+ return iRet;
+}
+#undef isProp
+
/* Initialize the stream class. Must be called as the very first method
* before anything else is called inside this class.
* rgerhards, 2008-01-09
*/
BEGINObjClassInit(strm, 1)
OBJSetMethodHandler(objMethod_SERIALIZE, strmSerialize);
- //OBJSetMethodHandler(objMethod_SETPROPERTY, strmSetProperty);
+ OBJSetMethodHandler(objMethod_SETPROPERTY, strmSetProperty);
OBJSetMethodHandler(objMethod_CONSTRUCTION_FINALIZER, strmConstructFinalize);
ENDObjClassInit(strm)
diff --git a/stream.h b/stream.h
index b1b93355..e48d354c 100644
--- a/stream.h
+++ b/stream.h
@@ -72,6 +72,7 @@ typedef struct strm_s {
size_t iMaxFileSize;/* maximum size a file may grow to */
int iMaxFiles; /* maximum number of files if a circular mode is in use */
int iFileNumDigits;/* min number of digits to use in file number (only in circular mode) */
+ int bDeleteOnClose; /* set to 1 to auto-delete on close -- be careful with that setting! */
/* dynamic properties, valid only during file open, not to be persistet */
size_t sIOBufSize;/* size of IO buffer */
uchar *pszDir; /* Directory */
@@ -84,7 +85,6 @@ typedef struct strm_s {
size_t iBufPtr; /* pointer into current buffer */
int iUngetC; /* char set via UngetChar() call or -1 if none set */
int bInRecord; /* if 1, indicates that we are currently writing a not-yet complete record */
- int bDeleteOnClose; /* set to 1 to auto-delete on close -- be careful with that setting! */
} strm_t;
/* prototypes */