summaryrefslogtreecommitdiffstats
path: root/source/lib/util_unistr.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2002-06-17 18:36:36 +0000
committerGerald Carter <jerry@samba.org>2002-06-17 18:36:36 +0000
commit1e6e5b299c235b513095a76a4cd9fffc41e8fc9c (patch)
tree9f741529073ad411cc7328334e26d3e35b1d33f1 /source/lib/util_unistr.c
parenta11c5d7ad07d259d764aede4745d13f8163a8212 (diff)
downloadsamba-1e6e5b299c235b513095a76a4cd9fffc41e8fc9c.tar.gz
samba-1e6e5b299c235b513095a76a4cd9fffc41e8fc9c.tar.xz
samba-1e6e5b299c235b513095a76a4cd9fffc41e8fc9c.zip
beginning to sync up for 2.2.5 release....
Diffstat (limited to 'source/lib/util_unistr.c')
-rw-r--r--source/lib/util_unistr.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/source/lib/util_unistr.c b/source/lib/util_unistr.c
index a2bd0cf4913..efad8df1ea8 100644
--- a/source/lib/util_unistr.c
+++ b/source/lib/util_unistr.c
@@ -310,11 +310,11 @@ void unistr_to_ascii(char *dest, const uint16 *src, int len)
}
/*******************************************************************
- Convert a (little-endian) UNISTR2 structure to an ASCII string
- Warning: this version does DOS codepage.
+ Convert a (little-endian) UNISTR2 structure to an ASCII string, either
+ DOS or UNIX codepage.
********************************************************************/
-void unistr2_to_ascii(char *dest, const UNISTR2 *str, size_t maxlen)
+static void unistr2_to_mbcp(char *dest, const UNISTR2 *str, size_t maxlen, uint16 *ucs2_to_mbcp)
{
char *p;
uint16 *src;
@@ -335,7 +335,7 @@ void unistr2_to_ascii(char *dest, const UNISTR2 *str, size_t maxlen)
for (p = dest; (p-dest < maxlen-3) && (src - str->buffer < str->uni_str_len) && *src; src++) {
uint16 ucs2_val = SVAL(src,0);
- uint16 cp_val = ucs2_to_doscp[ucs2_val];
+ uint16 cp_val = ucs2_to_mbcp[ucs2_val];
if (cp_val < 256)
*p++ = (char)cp_val;
@@ -349,18 +349,23 @@ void unistr2_to_ascii(char *dest, const UNISTR2 *str, size_t maxlen)
}
/*******************************************************************
- duplicate a UNISTR2 string into a null terminated char*
- using a talloc context
+ Convert a (little-endian) UNISTR2 structure to an ASCII string
+ Warning: this version does DOS codepage.
********************************************************************/
-char *unistr2_tdup(TALLOC_CTX *ctx, const UNISTR2 *str)
-{
- char *s;
- int maxlen = (str->uni_str_len+1)*4;
- if (!str->buffer) return NULL;
- s = (char *)talloc(ctx, maxlen); /* convervative */
- if (!s) return NULL;
- unistr2_to_ascii(s, str, maxlen);
- return s;
+
+void unistr2_to_dos(char *dest, const UNISTR2 *str, size_t maxlen)
+{
+ unistr2_to_mbcp(dest, str, maxlen, ucs2_to_doscp);
+}
+
+/*******************************************************************
+ Convert a (little-endian) UNISTR2 structure to an ASCII string
+ Warning: this version does UNIX codepage.
+********************************************************************/
+
+void unistr2_to_unix(char *dest, const UNISTR2 *str, size_t maxlen)
+{
+ unistr2_to_mbcp(dest, str, maxlen, ucs2_to_unixcp);
}
/*******************************************************************