summaryrefslogtreecommitdiffstats
path: root/stringbuf.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2005-09-09 12:52:23 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2005-09-09 12:52:23 +0000
commit9a39532d953ac2a486635316ffd1970c993753de (patch)
tree63e02509d3d211d6be13e94c6ea34e51473b7a09 /stringbuf.c
parent602fb17d3307d3dbe619ec559688c5b0c2ebc47c (diff)
downloadrsyslog-9a39532d953ac2a486635316ffd1970c993753de.tar.gz
rsyslog-9a39532d953ac2a486635316ffd1970c993753de.tar.xz
rsyslog-9a39532d953ac2a486635316ffd1970c993753de.zip
initial implementation of the counted string class completed (but so far
only a very feature-less class). code compiles again.
Diffstat (limited to 'stringbuf.c')
-rwxr-xr-xstringbuf.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/stringbuf.c b/stringbuf.c
index 11a1f5e4..0c5493d0 100755
--- a/stringbuf.c
+++ b/stringbuf.c
@@ -136,6 +136,7 @@ srRetVal rsCStrAppendChar(rsCStrObj *pThis, char c)
char* rsCStrConvSzStrAndDestruct(rsCStrObj *pThis)
{
char* pRetBuf;
+ int i;
sbSTRBCHECKVALIDOBJECT(pThis);
@@ -153,6 +154,16 @@ char* rsCStrConvSzStrAndDestruct(rsCStrObj *pThis)
*(pThis->pszBuf + pThis->iStrLen) = '\0';
}
}
+ /* we now need to do a sanity check. The string mgiht contain a
+ * \0 byte. There is no way how a sz string can handle this. For
+ * the time being, we simply replace it with space - something that
+ * could definitely be improved (TODO).
+ * 2005-09-09 rgerhards
+ */
+ for(i = 0 ; i < pThis->iStrLen ; ++i) {
+ if(*(pThis->pszBuf + i) == '\0')
+ *(pThis->pszBuf + i) = ' ';
+ }
/* We got it, now free the object ourselfs. Please note
* that we can NOT use the rsCStrDestruct function as it would
@@ -202,6 +213,15 @@ void rsCStrSetAllocIncrement(rsCStrObj *pThis, int iNewIncrement)
pThis->iAllocIncrement = iNewIncrement;
}
+/* return the length of the current string
+ * 2005-09-09 rgerhards
+ */
+int rsCStrLen(rsCStrObj *pThis)
+{
+ sbSTRBCHECKVALIDOBJECT(pThis);
+ return(pThis->iStrLen);
+}
+
/*
* Local variables:
* c-indent-level: 8