1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-23 20:59:10 +03:00

pidl: Add and use ndr_print_steal_switch_value(), removing ndr_print_get_switch_value()

This avoids really long token lists for switch values
that will not be needed past this point.

The function name is changed to clarify what exactly is being
done here, and the old function is removed to ensure it is
not being used anywhere else.

Merge the removal of ndr_print_get_switch_value into
just-tagged librpc/ABI/ndr-1.0.0.sigs as this
has not been put into any release yet.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13876

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
This commit is contained in:
Andrew Bartlett
2019-11-18 12:02:03 +13:00
parent e1a15710a4
commit e08461b284
8 changed files with 19 additions and 10 deletions

View File

@ -49,7 +49,6 @@ ndr_print_double: void (struct ndr_print *, const char *, double)
ndr_print_enum: void (struct ndr_print *, const char *, const char *, const char *, uint32_t)
ndr_print_function_debug: void (ndr_print_function_t, const char *, int, void *)
ndr_print_function_string: char *(TALLOC_CTX *, ndr_print_function_t, const char *, int, void *)
ndr_print_get_switch_value: uint32_t (struct ndr_print *, const void *)
ndr_print_gid_t: void (struct ndr_print *, const char *, gid_t)
ndr_print_hyper: void (struct ndr_print *, const char *, uint64_t)
ndr_print_int16: void (struct ndr_print *, const char *, int16_t)
@ -68,6 +67,7 @@ ndr_print_printf_helper: void (struct ndr_print *, const char *, ...)
ndr_print_ptr: void (struct ndr_print *, const char *, const void *)
ndr_print_set_switch_value: enum ndr_err_code (struct ndr_print *, const void *, uint32_t)
ndr_print_sockaddr_storage: void (struct ndr_print *, const char *, const struct sockaddr_storage *)
ndr_print_steal_switch_value: uint32_t (struct ndr_print *, const void *)
ndr_print_string: void (struct ndr_print *, const char *, const char *)
ndr_print_string_array: void (struct ndr_print *, const char *, const char **)
ndr_print_string_helper: void (struct ndr_print *, const char *, ...)

View File

@ -619,7 +619,7 @@ enum ndr_err_code ndr_print_set_switch_value(struct ndr_print *ndr, const void *
uint32_t ndr_push_get_switch_value(struct ndr_push *ndr, const void *p);
uint32_t ndr_push_steal_switch_value(struct ndr_push *ndr, const void *p);
uint32_t ndr_pull_get_switch_value(struct ndr_pull *ndr, const void *p);
uint32_t ndr_print_get_switch_value(struct ndr_print *ndr, const void *p);
uint32_t ndr_print_steal_switch_value(struct ndr_print *ndr, const void *p);
uint32_t ndr_pull_steal_switch_value(struct ndr_pull *ndr, const void *p);
enum ndr_err_code ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, ndr_pull_flags_fn_t fn);
enum ndr_err_code ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p, ndr_pull_flags_fn_t fn);

View File

@ -1257,9 +1257,18 @@ _PUBLIC_ uint32_t ndr_pull_get_switch_value(struct ndr_pull *ndr, const void *p)
return ndr_token_peek(&ndr->switch_list, p);
}
_PUBLIC_ uint32_t ndr_print_get_switch_value(struct ndr_print *ndr, const void *p)
/* retrieve a switch value and remove it from the list */
_PUBLIC_ uint32_t ndr_print_steal_switch_value(struct ndr_print *ndr, const void *p)
{
return ndr_token_peek(&ndr->switch_list, p);
enum ndr_err_code status;
uint32_t v;
status = ndr_token_retrieve(&ndr->switch_list, p, &v);
if (!NDR_ERR_CODE_IS_SUCCESS(status)) {
return 0;
}
return v;
}
/* retrieve a switch value and remove it from the list */

View File

@ -577,7 +577,7 @@ enum ndr_err_code ndr_pull_drsuapi_DsBindInfo(struct ndr_pull *ndr, int ndr_flag
_PUBLIC_ void ndr_print_drsuapi_DsBindInfo(struct ndr_print *ndr, const char *name, const union drsuapi_DsBindInfo *r)
{
uint32_t level;
level = ndr_print_get_switch_value(ndr, r);
level = ndr_print_steal_switch_value(ndr, r);
ndr_print_union(ndr, name, level, "drsuapi_DsBindInfo");
switch (level) {
case 24:

View File

@ -164,7 +164,7 @@ _PUBLIC_ void ndr_print_ntlmssp_lm_response(TALLOC_CTX *mem_ctx,
_PUBLIC_ void ndr_print_ntlmssp_Version(struct ndr_print *ndr, const char *name, const union ntlmssp_Version *r)
{
int level;
level = ndr_print_get_switch_value(ndr, r);
level = ndr_print_steal_switch_value(ndr, r);
switch (level) {
case NTLMSSP_NEGOTIATE_VERSION:
ndr_print_ntlmssp_VERSION(ndr, name, &r->version);

View File

@ -27,7 +27,7 @@
_PUBLIC_ void ndr_print_NL_AUTH_MESSAGE_BUFFER(struct ndr_print *ndr, const char *name, const union NL_AUTH_MESSAGE_BUFFER *r)
{
int level;
level = ndr_print_get_switch_value(ndr, r);
level = ndr_print_steal_switch_value(ndr, r);
switch (level) {
case NL_FLAG_OEM_NETBIOS_DOMAIN_NAME:
ndr_print_string(ndr, name, r->a);
@ -58,7 +58,7 @@ _PUBLIC_ void ndr_print_NL_AUTH_MESSAGE_BUFFER(struct ndr_print *ndr, const char
_PUBLIC_ void ndr_print_NL_AUTH_MESSAGE_BUFFER_REPLY(struct ndr_print *ndr, const char *name, const union NL_AUTH_MESSAGE_BUFFER_REPLY *r)
{
int level;
level = ndr_print_get_switch_value(ndr, r);
level = ndr_print_steal_switch_value(ndr, r);
switch (level) {
case NL_NEGOTIATE_RESPONSE:
ndr_print_uint32(ndr, name, r->dummy);

View File

@ -1096,7 +1096,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_spoolss_DriverInfo101(struct ndr_pull *ndr,
void ndr_print_spoolss_Field(struct ndr_print *ndr, const char *name, const union spoolss_Field *r)
{
int level;
level = ndr_print_get_switch_value(ndr, r);
level = ndr_print_steal_switch_value(ndr, r);
ndr_print_union(ndr, name, level, "spoolss_Field");
switch (level) {
case PRINTER_NOTIFY_TYPE:

View File

@ -2019,7 +2019,7 @@ sub ParseUnionPrint($$$$$)
$self->start_flags($e, $ndr);
$self->pidl("level = ndr_print_get_switch_value($ndr, $varname);");
$self->pidl("level = ndr_print_steal_switch_value($ndr, $varname);");
$self->pidl("ndr_print_union($ndr, name, level, \"$name\");");