summaryrefslogtreecommitdiff
path: root/source3/lib/util_unistr.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-11-19 17:51:21 -0800
committerJeremy Allison <jra@samba.org>2007-11-19 17:51:21 -0800
commitcf31bb7532484dbe26e4a00506ade0a173d8d754 (patch)
tree4ea6aff880d11920a652104a484cc191e6bf13e2 /source3/lib/util_unistr.c
parentcae4c742a896c6adb02b3e7a3c091d02aebb7339 (diff)
downloadsamba-cf31bb7532484dbe26e4a00506ade0a173d8d754.tar.gz
samba-cf31bb7532484dbe26e4a00506ade0a173d8d754.tar.bz2
samba-cf31bb7532484dbe26e4a00506ade0a173d8d754.zip
Start to remove some of the pstring functions we're
no longer using. Jeremy. (This used to be commit c21e9bdc1059268adbd14207e74097349676439e)
Diffstat (limited to 'source3/lib/util_unistr.c')
-rw-r--r--source3/lib/util_unistr.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c
index 8fad1162ac..1fef6ab239 100644
--- a/source3/lib/util_unistr.c
+++ b/source3/lib/util_unistr.c
@@ -422,16 +422,33 @@ void unistr3_to_ascii(char *dest, const UNISTR3 *str, size_t maxlen)
pull_ucs2(NULL, dest, str->str.buffer, maxlen, str->uni_str_len*2,
STR_NOALIGN);
}
-
+
/*******************************************************************
- Give a static string for displaying a UNISTR2.
+ Return a string for displaying a UNISTR2. Guarentees to return a
+ valid string - "" if nothing else.
+ Changed to use talloc_tos() under the covers.... JRA.
********************************************************************/
const char *unistr2_static(const UNISTR2 *str)
{
- static pstring ret;
- unistr2_to_ascii(ret, str, sizeof(ret));
- return ret;
+ size_t ret = (size_t)-1;
+ char *dest = NULL;
+
+ if ((str == NULL) || (str->uni_str_len == 0)) {
+ return "";
+ }
+
+ ret = pull_ucs2_base_talloc(talloc_tos(),
+ NULL,
+ &dest,
+ str->buffer,
+ str->uni_str_len*2,
+ STR_NOALIGN);
+ if (ret == (size_t)-1 || dest == NULL) {
+ return "";
+ }
+
+ return dest;
}
/*******************************************************************
@@ -992,24 +1009,6 @@ smb_ucs2_t *strstr_wa(const smb_ucs2_t *s, const char *ins)
return NULL;
}
-bool trim_string_wa(smb_ucs2_t *s, const char *front,
- const char *back)
-{
- wpstring f, b;
-
- if (front) {
- push_ucs2(NULL, f, front, sizeof(wpstring) - 1, STR_TERMINATE);
- } else {
- *f = 0;
- }
- if (back) {
- push_ucs2(NULL, b, back, sizeof(wpstring) - 1, STR_TERMINATE);
- } else {
- *b = 0;
- }
- return trim_string_w(s, f, b);
-}
-
/*******************************************************************
Returns the length in number of wide characters.
******************************************************************/