diff options
author | Volker Lendecke <vlendec@samba.org> | 2005-11-13 11:38:17 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:05:24 -0500 |
commit | 32cf16f3cfaf52414c324c0a333ff29cb9a326aa (patch) | |
tree | 62fa857b878289aeddbe6ac8ba0dc868c56ea9ce /source3/lib | |
parent | 789bed878aa94edf22521c6c1946d3ab73462516 (diff) | |
download | samba-32cf16f3cfaf52414c324c0a333ff29cb9a326aa.tar.gz samba-32cf16f3cfaf52414c324c0a333ff29cb9a326aa.tar.bz2 samba-32cf16f3cfaf52414c324c0a333ff29cb9a326aa.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
(This used to be commit 62d01ce7e6c14971084c208ab61f379cb172cb22)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util_unistr.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/source3/lib/util_unistr.c b/source3/lib/util_unistr.c index d80bb2ce52..b979745d36 100644 --- a/source3/lib/util_unistr.c +++ b/source3/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 */ |