summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 7f47cdbdb4..4d098013f2 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -4284,11 +4284,19 @@ char *unistrn2(uint16 *buf, int len)
static int nexti;
char *lbuf = lbufs[nexti];
char *p;
+
nexti = (nexti+1)%8;
+
+ DEBUG(10, ("unistrn2: "));
+
for (p = lbuf; *buf && p-lbuf < MAXUNI-2 && len > 0; len--, p++, buf++)
{
+ DEBUG(10, ("%4x ", *buf));
*p = *buf;
}
+
+ DEBUG(10,("\n"));
+
*p = 0;
return lbuf;
}
@@ -4304,16 +4312,55 @@ char *unistr2(uint16 *buf)
static int nexti;
char *lbuf = lbufs[nexti];
char *p;
+
nexti = (nexti+1)%8;
+
+ DEBUG(10, ("unistr2: "));
+
for (p = lbuf; *buf && p-lbuf < MAXUNI-2; p++, buf++)
{
+ DEBUG(10, ("%4x ", *buf));
*p = *buf;
}
+
+ DEBUG(10,("\n"));
+
*p = 0;
return lbuf;
}
/*******************************************************************
+create a null-terminated unicode string from a null-terminated ascii string.
+return number of unicode chars copied, excluding the null character.
+
+only handles ascii strings
+********************************************************************/
+#define MAXUNI 1024
+int struni2(uint16 *p, char *buf)
+{
+ int len = 0;
+
+ if (p == NULL) return 0;
+
+ DEBUG(10, ("struni2: "));
+
+ if (buf != NULL)
+ {
+ for (; *buf && len < MAXUNI-2; len++, p++, buf++)
+ {
+ DEBUG(10, ("%2x ", *buf));
+ *p = *buf;
+ }
+
+ DEBUG(10,("\n"));
+ }
+
+ *p = 0;
+
+ return len;
+}
+
+/*******************************************************************
Return a ascii version of a unicode string
Hack alert: uses fixed buffer(s) and only handles ascii strings
********************************************************************/