summaryrefslogtreecommitdiffstats
path: root/stringbuf.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2005-10-19 12:23:42 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2005-10-19 12:23:42 +0000
commitbc6d3e81e83de83871b03856d55eb71c6a5a0a4c (patch)
tree86414482a4fa2f44a5c4b92ff1bda7757987d29d /stringbuf.c
parent8dc836cf04eaf061fb4ee31bcc771e2297f7630b (diff)
downloadrsyslog-bc6d3e81e83de83871b03856d55eb71c6a5a0a4c.tar.gz
rsyslog-bc6d3e81e83de83871b03856d55eb71c6a5a0a4c.tar.xz
rsyslog-bc6d3e81e83de83871b03856d55eb71c6a5a0a4c.zip
made "!progname" fully BSD-compliant; added property "programname"
Diffstat (limited to 'stringbuf.c')
-rwxr-xr-xstringbuf.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/stringbuf.c b/stringbuf.c
index ea008e77..5aa94fc4 100755
--- a/stringbuf.c
+++ b/stringbuf.c
@@ -236,10 +236,29 @@ rsRetVal rsCStrSetSzStr(rsCStrObj *pThis, char *pszNew)
return RS_RET_OK;
}
+/* Converts the CStr object to a classical sz string and returns that.
+ * Same restrictions as in rsCStrGetSzStr() applies (see there!). This
+ * function here guarantees that a valid string is returned, even if
+ * the CStr object currently holds a NULL pointer string buffer. If so,
+ * "" is returned.
+ * rgerhards 2005-10-19
+ */
+char* rsCStrGetSzStrNoNULL(rsCStrObj *pThis)
+{
+ rsCHECKVALIDOBJECT(pThis, OIDrsCStr);
+ if(pThis->pBuf == NULL)
+ return "";
+ else
+ return rsCStrGetSzStr(pThis);
+}
+
/* Converts the CStr object to a classical zero-terminated C string
* and returns that string. The caller must not free it and must not
* destroy the CStr object as long as the ascii string is used.
+ * This function may return NULL, if the string is currently NULL. This
+ * is a feature, not a bug. If you need non-NULL in any case, use
+ * rsCStrGetSzStrNoNULL() instead.
* rgerhards, 2005-09-15
*/
char* rsCStrGetSzStr(rsCStrObj *pThis)