summaryrefslogtreecommitdiffstats
path: root/stringbuf.h
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2005-09-15 15:05:11 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2005-09-15 15:05:11 +0000
commite34ca1e7d952906fd2593850e3be47252211649c (patch)
tree191925e6cb7205a130bce6aae78e9f6924850293 /stringbuf.h
parentcaf76db7c08183bc23167687702cb8652c254337 (diff)
downloadrsyslog-e34ca1e7d952906fd2593850e3be47252211649c.tar.gz
rsyslog-e34ca1e7d952906fd2593850e3be47252211649c.tar.xz
rsyslog-e34ca1e7d952906fd2593850e3be47252211649c.zip
on the way to adding property-based filters - right before changing
cfline()
Diffstat (limited to 'stringbuf.h')
-rwxr-xr-xstringbuf.h39
1 files changed, 24 insertions, 15 deletions
diff --git a/stringbuf.h b/stringbuf.h
index a38a0997..1e2f5515 100755
--- a/stringbuf.h
+++ b/stringbuf.h
@@ -19,14 +19,14 @@
#ifndef _STRINGBUF_H_INCLUDED__
#define _STRINGBUF_H_INCLUDED__ 1
-#define sbSTRBCHECKVALIDOBJECT(x) {assert(x != NULL); assert(x->OID == OIDrsCStr);}
-
/**
* The dynamic string buffer object.
*/
struct rsCStrObject
{
+#ifndef NDEBUG
rsObjID OID; /**< object ID */
+#endif
char *pBuf; /**< pointer to the string buffer, may be NULL if string is empty */
char *pszBuf; /**< pointer to the sz version of the string (after it has been created )*/
int iBufSize; /**< current maximum size of the string buffer */
@@ -57,19 +57,19 @@ void rsCStrDestruct(rsCStrObj *pThis);
rsRetVal rsCStrAppendChar(rsCStrObj *pThis, char c);
/**
- * Finish the string buffer. That means, the string
- * is returned to the caller and then the string
- * buffer is destroyed. The caller is reponsible for
- * freeing the returned string pointer.
- *
- * After calling this method, the string buffer object
- * is destroyed and thus the provided handle (pThis)
- * can no longer be used.
- *
- * \retval pointer to \0 terminated string. May be NULL
- * (empty string) and MUST be free()ed by caller.
+ * Finish the string buffer dynamic allocation.
*/
-void rsCStrFinish(rsCStrObj *pThis);
+rsRetVal rsCStrFinish(rsCStrObj *pThis);
+
+/**
+ * Truncate "n" number of characters from the end of the
+ * string. The buffer remains unchanged, just the
+ * string length is manipulated. This is for performance
+ * reasons.
+ */
+rsRetVal rsCStrTruncate(rsCStrObj *pThis, int nTrunc);
+
+rsRetVal rsCStrTrimTrailingWhiteSpace(rsCStrObj *pThis);
/**
* Append a string to the buffer.
@@ -102,5 +102,14 @@ rsRetVal rsCStrAppendInt(rsCStrObj *pThis, int i);
char* rsCStrConvSzStrAndDestruct(rsCStrObj *pThis);
-int rsCStrLen(rsCStrObj *pThis);
+
+/* now come inline-like functions */
+#ifdef NDEBUG
+# define rsCStrLen(x) ((x)->iStrLen)
+#else
+ int rsCStrLen(rsCStrObj *pThis);
#endif
+
+#define rsCStrGetBufBeg(x) ((x)->pBuf)
+
+#endif /* single include */