summaryrefslogtreecommitdiffstats
path: root/source/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2005-11-13 11:38:17 +0000
committerVolker Lendecke <vlendec@samba.org>2005-11-13 11:38:17 +0000
commita42b388aa594d69f3d6b0523a6ac13beebb98e17 (patch)
treec4f47b6a1610e350e7bb645f01c0097139ae8ec5 /source/lib
parentfb1ce8332706fb6ed51c86cb3254211b82a5710f (diff)
downloadsamba-a42b388aa594d69f3d6b0523a6ac13beebb98e17.tar.gz
samba-a42b388aa594d69f3d6b0523a6ac13beebb98e17.tar.xz
samba-a42b388aa594d69f3d6b0523a6ac13beebb98e17.zip
r11706: Implement dsr_getdcname client code. It's handy: It not only gives you the IP
address but also the fqdn of the remote dc and site info. Volker
Diffstat (limited to 'source/lib')
-rw-r--r--source/lib/util_unistr.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/source/lib/util_unistr.c b/source/lib/util_unistr.c
index d80bb2ce521..b979745d366 100644
--- a/source/lib/util_unistr.c
+++ b/source/lib/util_unistr.c
@@ -265,6 +265,34 @@ int rpcstr_pull_unistr2_fstring(char *dest, UNISTR2 *src)
src->uni_str_len * 2, 0);
}
+/* Helper function to return a talloc'ed string. I have implemented it with a
+ * copy because I don't really know how pull_ucs2 and friends calculate the
+ * target size. If this turns out to be a major bottleneck someone with deeper
+ * multi-byte knowledge needs to revisit this.
+ * My (VL) use is dsr_getdcname, which returns 6 strings, the alternative would
+ * have been to manually talloc_strdup them in rpc_client/cli_netlogon.c.
+ */
+
+size_t rpcstr_pull_unistr2_talloc(TALLOC_CTX *mem_ctx, char **dest,
+ UNISTR2 *src)
+{
+ pstring tmp;
+ size_t result;
+
+ result = pull_ucs2(NULL, tmp, src->buffer, sizeof(tmp),
+ src->uni_str_len * 2, 0);
+ if (result < 0) {
+ return result;
+ }
+
+ *dest = talloc_strdup(mem_ctx, tmp);
+ if (*dest == NULL) {
+ return -1;
+ }
+
+ return result;
+}
+
/* Converts a string from internal samba format to unicode
*/