summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2009-01-16 00:25:31 +0100
committerGünther Deschner <gd@samba.org>2009-01-16 00:28:45 +0100
commit87fec1450f1ae78d9aea58f55bd22dda3d1f362a (patch)
treead3eb530de46e634ba15c1af5ebf007866038ca1 /lib/util
parent64d8eb0cee161417c3c97f1dc8d5b67171084152 (diff)
downloadsamba-87fec1450f1ae78d9aea58f55bd22dda3d1f362a.tar.gz
samba-87fec1450f1ae78d9aea58f55bd22dda3d1f362a.tar.bz2
samba-87fec1450f1ae78d9aea58f55bd22dda3d1f362a.zip
lib: add strlen_m_term_null from s3.
Guenther
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/charset/charset.h1
-rw-r--r--lib/util/charset/util_unistr.c19
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h
index b69bef2d61..f027beb8db 100644
--- a/lib/util/charset/charset.h
+++ b/lib/util/charset/charset.h
@@ -84,6 +84,7 @@ struct smb_iconv_convenience;
char *strchr_m(const char *s, char c);
size_t strlen_m_term(const char *s);
+size_t strlen_m_term_null(const char *s);
size_t strlen_m(const char *s);
char *alpha_strcpy(char *dest, const char *src, const char *other_safe_chars, size_t maxlength);
void string_replace_m(char *s, char oldc, char newc);
diff --git a/lib/util/charset/util_unistr.c b/lib/util/charset/util_unistr.c
index 86a76f831e..41b9c94cbb 100644
--- a/lib/util/charset/util_unistr.c
+++ b/lib/util/charset/util_unistr.c
@@ -297,6 +297,25 @@ _PUBLIC_ size_t strlen_m_term(const char *s)
return strlen_m(s) + 1;
}
+/*
+ * Weird helper routine for the winreg pipe: If nothing is around, return 0,
+ * if a string is there, include the terminator.
+ */
+
+_PUBLIC_ size_t strlen_m_term_null(const char *s)
+{
+ size_t len;
+ if (!s) {
+ return 0;
+ }
+ len = strlen_m(s);
+ if (len == 0) {
+ return 0;
+ }
+
+ return len+1;
+}
+
/**
Strchr and strrchr_m are a bit complex on general multi-byte strings.
**/