the first independent msrpc daemon - lsarpcd.
[kai/samba.git] / source3 / lib / util_unistr.c
index e1a2e26623be72bc63db7cf31e3a0d153c25a0b6..6f90528bf43c0c8c9ebd484d56327a92a0f40d4b 100644 (file)
@@ -261,3 +261,47 @@ void buffer4_to_str(char *dest, const BUFFER4 *str, size_t maxlen)
 
        *dest = 0;
 }
+
+/*******************************************************************
+copies a UNISTR2 structure.
+********************************************************************/
+BOOL copy_unistr2(UNISTR2 *str, const UNISTR2 *from)
+{
+       if (from != NULL)
+       {
+               /* set up string lengths. add one if string is not null-terminated */
+               str->uni_max_len = from->uni_max_len;
+               str->undoc       = from->undoc;
+               str->uni_str_len = from->uni_str_len;
+
+               /* copy the string */
+               memcpy(str->buffer, from->buffer, sizeof(from->buffer));
+       }
+       else
+       {
+               str->uni_max_len = 1;
+               str->undoc = 0;
+               str->uni_str_len = 1;
+               str->buffer[0] = 0;
+       }
+
+       return True;
+}
+
+/*******************************************************************
+duplicates a UNISTR2 structure.
+********************************************************************/
+UNISTR2 *unistr2_dup(const UNISTR2 *name)
+{
+       UNISTR2 *copy = (UNISTR2*)malloc(sizeof(*copy));
+       copy_unistr2(copy, name);
+       return copy;
+}
+
+/*******************************************************************
+frees a UNISTR2 structure.
+********************************************************************/
+void unistr2_free(UNISTR2 *name)
+{
+       free(name);
+}