testprogs: Use new kerberos options for samba-tool in test_kpasswd_mit.sh
[Samba.git] / librpc / ndr / ndr_orpc.c
blob01ba885d94250a9c8805b8554228a5173eacee0c
1 /*
2 Unix SMB/CIFS implementation.
4 routines for marshalling/unmarshalling DCOM string arrays
6 Copyright (C) Jelmer Vernooij 2004
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "includes.h"
24 #include "librpc/gen_ndr/ndr_orpc.h"
26 enum ndr_err_code ndr_pull_DUALSTRINGARRAY(struct ndr_pull *ndr, int ndr_flags, struct DUALSTRINGARRAY *ar)
28 uint16_t num_entries, security_offset;
29 uint16_t towerid;
30 uint32_t towernum = 0, conformant_size;
32 if (!(ndr_flags & NDR_SCALARS)) {
33 return NDR_ERR_SUCCESS;
36 NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &conformant_size));
37 NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &num_entries));
38 NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &security_offset));
40 ar->stringbindings = talloc_array(ndr, struct STRINGBINDING *, 1);
41 ar->stringbindings[0] = NULL;
43 do {
44 /* 'Peek' */
45 NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &towerid));
47 if (towerid > 0) {
48 ndr->offset -= 2;
49 ar->stringbindings = talloc_realloc(ndr, ar->stringbindings, struct STRINGBINDING *, towernum+2);
50 ar->stringbindings[towernum] = talloc(ndr, struct STRINGBINDING);
51 NDR_CHECK(ndr_pull_STRINGBINDING(ndr, ndr_flags, ar->stringbindings[towernum]));
52 towernum++;
54 } while (towerid != 0);
56 ar->stringbindings[towernum] = NULL;
57 towernum = 0;
59 ar->securitybindings = talloc_array(ndr, struct SECURITYBINDING *, 1);
60 ar->securitybindings[0] = NULL;
62 do {
63 /* 'Peek' */
64 NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &towerid));
66 if (towerid > 0) {
67 ndr->offset -= 2;
68 ar->securitybindings = talloc_realloc(ndr, ar->securitybindings, struct SECURITYBINDING *, towernum+2);
69 ar->securitybindings[towernum] = talloc(ndr, struct SECURITYBINDING);
70 NDR_CHECK(ndr_pull_SECURITYBINDING(ndr, ndr_flags, ar->securitybindings[towernum]));
71 towernum++;
73 } while (towerid != 0);
75 ar->securitybindings[towernum] = NULL;
77 return NDR_ERR_SUCCESS;
80 enum ndr_err_code ndr_push_DUALSTRINGARRAY(struct ndr_push *ndr, int ndr_flags, const struct DUALSTRINGARRAY *ar)
82 return ndr_push_error(ndr, NDR_ERR_STRING, "ndr_push_DUALSTRINGARRAY not implemented");
86 print a dom_sid
88 void ndr_print_DUALSTRINGARRAY(struct ndr_print *ndr, const char *name, const struct DUALSTRINGARRAY *ar)
90 int i;
91 ndr->print(ndr, "%-25s: DUALSTRINGARRAY", name);
92 ndr->depth++;
93 ndr->print(ndr, "STRING BINDINGS");
94 ndr->depth++;
95 for (i=0;ar->stringbindings[i];i++) {
96 char idx[13]; /* 2^32 has 10 digits */
97 snprintf(idx, sizeof(idx), "[%d]", i);
98 ndr_print_STRINGBINDING(ndr, idx, ar->stringbindings[i]);
100 ndr->depth--;
101 ndr->print(ndr, "SECURITY BINDINGS");
102 ndr->depth++;
103 for (i=0;ar->securitybindings[i];i++) {
104 char idx[13]; /* 2^32 has 10 digits */
105 snprintf(idx, sizeof(idx), "[%d]", i);
106 ndr_print_SECURITYBINDING(ndr, idx, ar->securitybindings[i]);
108 ndr->depth--;
111 enum ndr_err_code ndr_pull_STRINGARRAY(struct ndr_pull *ndr, int ndr_flags, struct STRINGARRAY *ar)
113 uint16_t towerid;
114 uint32_t towernum = 0;
115 uint16_t num_entries;
117 if (!(ndr_flags & NDR_SCALARS)) {
118 return NDR_ERR_SUCCESS;
121 NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &num_entries));
123 ar->stringbindings = talloc_array(ndr, struct STRINGBINDING *, 1);
124 ar->stringbindings[0] = NULL;
126 do {
127 /* 'Peek' */
128 NDR_CHECK(ndr_pull_uint16(ndr, NDR_SCALARS, &towerid));
130 if (towerid > 0) {
131 ndr->offset -= 2;
132 ar->stringbindings = talloc_realloc(ndr, ar->stringbindings, struct STRINGBINDING *, towernum+2);
133 ar->stringbindings[towernum] = talloc(ndr, struct STRINGBINDING);
134 NDR_CHECK(ndr_pull_STRINGBINDING(ndr, ndr_flags, ar->stringbindings[towernum]));
135 towernum++;
137 } while (towerid != 0);
139 ar->stringbindings[towernum] = NULL;
141 return NDR_ERR_SUCCESS;
144 enum ndr_err_code ndr_push_STRINGARRAY(struct ndr_push *ndr, int ndr_flags, const struct STRINGARRAY *ar)
146 return ndr_push_error(ndr, NDR_ERR_STRING, "ndr_push_STRINGARRAY not implemented");
150 print a dom_sid
152 void ndr_print_STRINGARRAY(struct ndr_print *ndr, const char *name, const struct STRINGARRAY *ar)
154 int i;
155 ndr->print(ndr, "%-25s: STRINGARRAY", name);
156 ndr->depth++;
157 for (i=0;ar->stringbindings[i];i++) {
158 char idx[13]; /* 2^32 has 10 digits */
159 snprintf(idx, sizeof(idx), "[%d]", i);
160 ndr_print_STRINGBINDING(ndr, idx, ar->stringbindings[i]);
162 ndr->depth--;