summaryrefslogtreecommitdiff
path: root/source3/rpc_parse/parse_misc.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2002-04-14 09:44:16 +0000
committerAndrew Bartlett <abartlet@samba.org>2002-04-14 09:44:16 +0000
commit07e6ff5fcfe337bb65a7c3a4493a92a7761cf2ed (patch)
tree0623e2c8e4b760f294c31de6f01aec1ec1a71902 /source3/rpc_parse/parse_misc.c
parent06f15779303dc540ee7801fe843023970454166b (diff)
downloadsamba-07e6ff5fcfe337bb65a7c3a4493a92a7761cf2ed.tar.gz
samba-07e6ff5fcfe337bb65a7c3a4493a92a7761cf2ed.tar.bz2
samba-07e6ff5fcfe337bb65a7c3a4493a92a7761cf2ed.zip
Partly based on the work by mimir (Rafal Szczesniak
<mimir@diament.ists.pwr.wroc.pl>) this patch allows samba to correctly enumerate its trusted domains - by exaimining the keys in the secrets.tdb file. This patch has been tested with both NT4 and rpcclient/wbinfo, and adds some extra functionality to talloc and rpc_parse to allow it to deal with already unicode strings. Finally, this cleans up some const warnings that were in net_rpc.c by pushing another dash of const into the rpc client code. Andrew Bartlett (This used to be commit 0bdd94cb992b40942aaf2e5e0efd2868b4686296)
Diffstat (limited to 'source3/rpc_parse/parse_misc.c')
-rw-r--r--source3/rpc_parse/parse_misc.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c
index 73f285e320..f326681c64 100644
--- a/source3/rpc_parse/parse_misc.c
+++ b/source3/rpc_parse/parse_misc.c
@@ -916,6 +916,51 @@ void init_unistr2(UNISTR2 *str, const char *buf, size_t len)
rpcstr_push((char *)str->buffer, buf, len, STR_TERMINATE);
}
+/**
+ * Inits a UNISTR2 structure.
+ * @param ctx talloc context to allocate string on
+ * @param str pointer to string to create
+ * @param buf UCS2 null-terminated buffer to init from
+*/
+
+void init_unistr2_w(TALLOC_CTX *ctx, UNISTR2 *str, const smb_ucs2_t *buf)
+{
+ uint32 len = strlen_w(buf);
+ uint32 max_len = len;
+ uint32 alloc_len;
+
+ ZERO_STRUCTP(str);
+
+ /* set up string lengths. */
+ str->uni_max_len = len;
+ str->undoc = 0;
+ str->uni_str_len = len;
+
+ if (max_len < MAX_UNISTRLEN)
+ max_len = MAX_UNISTRLEN;
+
+ alloc_len = (max_len + 1) * sizeof(uint16);
+
+ str->buffer = (uint16 *)talloc_zero(ctx, alloc_len);
+ if ((str->buffer == NULL) && (alloc_len > 0))
+ {
+ smb_panic("init_unistr2_w: malloc fail\n");
+ return;
+ }
+
+ /*
+ * don't move this test above ! The UNISTR2 must be initialized !!!
+ * jfm, 7/7/2001.
+ */
+ if (buf==NULL)
+ return;
+
+ /* Yes, this is a strncpy( foo, bar, strlen(bar)) - but as
+ long as the buffer above is talloc()ed correctly then this
+ is the correct thing to do */
+ strncpy_w(str->buffer, buf, len + 1);
+}
+
/*******************************************************************
Inits a UNISTR2 structure from a UNISTR
********************************************************************/