summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2002-03-25 07:41:42 +0000
committerAndrew Bartlett <abartlet@samba.org>2002-03-25 07:41:42 +0000
commit62098eade38fe0a948e05527b80d54b4b0df1d24 (patch)
tree90aab01ca15ca666edc2a022307a8364e15a7f08 /source3
parentcf60c28ea83ce30d90b4272ad48e3c790854dbd4 (diff)
downloadsamba-62098eade38fe0a948e05527b80d54b4b0df1d24.tar.gz
samba-62098eade38fe0a948e05527b80d54b4b0df1d24.tar.bz2
samba-62098eade38fe0a948e05527b80d54b4b0df1d24.zip
add {push,pull}_ucs2{allocate,talloc}() functions.
Andrew Bartlett (This used to be commit ce7990b4a4f251536dd26be5a62c12711df57787)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/charcnv.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index d4e46ec89a..cdfca8eb97 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -418,6 +418,36 @@ int push_ucs2(const void *base_ptr, void *dest, const char *src, int dest_len, i
return len;
}
+/**
+ * Copy a string from a unix char* src to a UCS2 destination, allocating a buffer using talloc
+ *
+ * @param dest always set at least to NULL
+ *
+ * @retval The number of bytes occupied by the string in the destination
+ **/
+int push_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src)
+{
+ int src_len = strlen(src)+1;
+
+ *dest = NULL;
+ return convert_string_talloc(ctx, CH_UNIX, CH_UCS2, src, src_len, dest);
+}
+
+/**
+ * Copy a string from a unix char* src to a UCS2 destination, allocating a buffer
+ *
+ * @param dest always set at least to NULL
+ *
+ * @retval The number of bytes occupied by the string in the destination
+ **/
+int push_ucs2_allocate(void **dest, const char *src)
+{
+ int src_len = strlen(src)+1;
+
+ *dest = NULL;
+ return convert_string_allocate(CH_UNIX, CH_UCS2, src, src_len, dest);
+}
+
/****************************************************************************
copy a string from a char* src to a UTF-8 destination
return the number of bytes occupied by the string in the destination
@@ -534,6 +564,34 @@ int pull_ucs2_fstring(char *dest, const void *src)
return pull_ucs2(NULL, dest, src, sizeof(fstring), -1, STR_TERMINATE);
}
+/**
+ * Copy a string from a UCS2 src to a unix char * destination, allocating a buffer using talloc
+ *
+ * @param dest always set at least to NULL
+ *
+ * @retval The number of bytes occupied by the string in the destination
+ **/
+int pull_ucs2_talloc(TALLOC_CTX *ctx, void **dest, const char *src)
+{
+ int src_len = strlen(src)+1;
+ *dest = NULL;
+ return convert_string_talloc(ctx, CH_UCS2, CH_UNIX, src, src_len, dest);
+}
+
+/**
+ * Copy a string from a UCS2 src to a unix char * destination, allocating a buffer
+ *
+ * @param dest always set at least to NULL
+ *
+ * @retval The number of bytes occupied by the string in the destination
+ **/
+int pull_ucs2_allocate(void **dest, const char *src)
+{
+ int src_len = strlen(src)+1;
+ *dest = NULL;
+ return convert_string_allocate(CH_UCS2, CH_UNIX, src, src_len, dest);
+}
+
/****************************************************************************
copy a string from a utf-8 source to a unix char* destination
flags can have: