mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
start using automatic union printing
(This used to be commit e81040a902
)
This commit is contained in:
parent
161321f68d
commit
deeb8d98a1
@ -72,6 +72,7 @@ struct ndr_print {
|
||||
|
||||
/* useful macro for debugging */
|
||||
#define NDR_PRINT_DEBUG(type, p) ndr_print_debug((ndr_print_fn_t)ndr_print_ ##type, #p, p)
|
||||
#define NDR_PRINT_UNION_DEBUG(type, level, p) ndr_print_union_debug((ndr_print_union_fn_t)ndr_print_ ##type, #p, level, p)
|
||||
|
||||
|
||||
|
||||
@ -112,6 +113,7 @@ typedef NTSTATUS (*ndr_pull_fn_t)(struct ndr_pull *, void *);
|
||||
typedef NTSTATUS (*ndr_push_flags_fn_t)(struct ndr_push *, int ndr_flags, void *);
|
||||
typedef NTSTATUS (*ndr_pull_flags_fn_t)(struct ndr_pull *, int ndr_flags, void *);
|
||||
typedef void (*ndr_print_fn_t)(struct ndr_print *, const char *, void *);
|
||||
typedef void (*ndr_print_union_fn_t)(struct ndr_print *, const char *, uint16, void *);
|
||||
|
||||
/* now pull in the individual parsers */
|
||||
#include "librpc/ndr/ndr_sec.h"
|
||||
|
@ -300,7 +300,25 @@ void ndr_print_debug(void (*fn)(struct ndr_print *, const char *, void *),
|
||||
ndr.mem_ctx = talloc_init("ndr_print_debug");
|
||||
if (!ndr.mem_ctx) return;
|
||||
ndr.print = ndr_print_debug_helper;
|
||||
ndr.depth = 0;
|
||||
ndr.depth = 1;
|
||||
fn(&ndr, name, ptr);
|
||||
talloc_destroy(ndr.mem_ctx);
|
||||
}
|
||||
|
||||
/*
|
||||
a useful helper function for printing idl unions via DEBUG()
|
||||
*/
|
||||
void ndr_print_union_debug(void (*fn)(struct ndr_print *, const char *, uint16, void *),
|
||||
const char *name,
|
||||
uint16 level,
|
||||
void *ptr)
|
||||
{
|
||||
struct ndr_print ndr;
|
||||
|
||||
ndr.mem_ctx = talloc_init("ndr_print_debug");
|
||||
if (!ndr.mem_ctx) return;
|
||||
ndr.print = ndr_print_debug_helper;
|
||||
ndr.depth = 1;
|
||||
fn(&ndr, name, level, ptr);
|
||||
talloc_destroy(ndr.mem_ctx);
|
||||
}
|
||||
|
@ -375,9 +375,9 @@ NTSTATUS ndr_pull_NTTIME(struct ndr_pull *ndr, NTTIME *t)
|
||||
}
|
||||
|
||||
|
||||
void ndr_print_struct(struct ndr_print *ndr, const char *name)
|
||||
void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type)
|
||||
{
|
||||
ndr->print(ndr, "%s:", name);
|
||||
ndr->print(ndr, "%s: struct %s", name, type);
|
||||
}
|
||||
|
||||
void ndr_print_uint8(struct ndr_print *ndr, const char *name, uint8 v)
|
||||
@ -418,3 +418,13 @@ void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t)
|
||||
{
|
||||
ndr->print(ndr, "%-25s: %s", name, nt_time_string(ndr->mem_ctx, &t));
|
||||
}
|
||||
|
||||
void ndr_print_union(struct ndr_print *ndr, const char *name, uint16 level, const char *type)
|
||||
{
|
||||
ndr->print(ndr, "%-25s: union %s(case %u)", name, type, level);
|
||||
}
|
||||
|
||||
void ndr_print_bad_level(struct ndr_print *ndr, const char *name, uint16 level)
|
||||
{
|
||||
ndr->print(ndr, "UNKNOWN LEVEL %u", level);
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_Name(struct ndr_print *ndr, const char *name, struct lsa_Name *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_Name");
|
||||
ndr->depth++;
|
||||
ndr_print_uint16(ndr, "name_len", r->name_len);
|
||||
ndr_print_uint16(ndr, "name_size", r->name_size);
|
||||
@ -97,7 +97,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_PrivEntry(struct ndr_print *ndr, const char *name, struct lsa_PrivEntry *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_PrivEntry");
|
||||
ndr->depth++;
|
||||
ndr_print_lsa_Name(ndr, "name", &r->name);
|
||||
ndr_print_uint32(ndr, "luid_low", r->luid_low);
|
||||
@ -128,7 +128,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_PrivArray(struct ndr_print *ndr, const char *name, struct lsa_PrivArray *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_PrivArray");
|
||||
ndr->depth++;
|
||||
ndr_print_uint32(ndr, "count", r->count);
|
||||
ndr_print_ptr(ndr, "privs", r->privs);
|
||||
@ -220,7 +220,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_QosInfo(struct ndr_print *ndr, const char *name, struct lsa_QosInfo *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_QosInfo");
|
||||
ndr->depth++;
|
||||
ndr_print_uint16(ndr, "impersonation_level", r->impersonation_level);
|
||||
ndr_print_uint8(ndr, "context_mode", r->context_mode);
|
||||
@ -265,7 +265,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_ObjectAttribute(struct ndr_print *ndr, const char *name, struct lsa_ObjectAttribute *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_ObjectAttribute");
|
||||
ndr->depth++;
|
||||
ndr_print_ptr(ndr, "root_dir", r->root_dir);
|
||||
ndr->depth++;
|
||||
@ -333,7 +333,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_AuditLogInfo(struct ndr_print *ndr, const char *name, struct lsa_AuditLogInfo *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_AuditLogInfo");
|
||||
ndr->depth++;
|
||||
ndr_print_uint32(ndr, "percent_full", r->percent_full);
|
||||
ndr_print_uint32(ndr, "log_size", r->log_size);
|
||||
@ -357,7 +357,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_AuditEventsInfo(struct ndr_print *ndr, const char *name, struct lsa_AuditEventsInfo *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_AuditEventsInfo");
|
||||
ndr->depth++;
|
||||
ndr_print_uint32(ndr, "auditing_mode", r->auditing_mode);
|
||||
ndr->depth--;
|
||||
@ -399,6 +399,19 @@ done:
|
||||
|
||||
void ndr_print_lsa_PolicyInformation(struct ndr_print *ndr, const char *name, uint16 level, union lsa_PolicyInformation *r)
|
||||
{
|
||||
ndr_print_union(ndr, name, level, "lsa_PolicyInformation");
|
||||
switch (level) {
|
||||
case 1:
|
||||
ndr_print_lsa_AuditLogInfo(ndr, "audit_log", &r->audit_log);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
ndr_print_lsa_AuditEventsInfo(ndr, "audit_events", &r->audit_events);
|
||||
break;
|
||||
|
||||
default:
|
||||
ndr_print_bad_level(ndr, name, level);
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS ndr_push_lsa_QueryInfoPolicy(struct ndr_push *ndr, struct lsa_QueryInfoPolicy *r)
|
||||
@ -502,7 +515,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_SidPtr(struct ndr_print *ndr, const char *name, struct lsa_SidPtr *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_SidPtr");
|
||||
ndr->depth++;
|
||||
ndr_print_ptr(ndr, "sid", r->sid);
|
||||
ndr->depth++;
|
||||
@ -550,7 +563,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_SidArray(struct ndr_print *ndr, const char *name, struct lsa_SidArray *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_SidArray");
|
||||
ndr->depth++;
|
||||
ndr_print_uint32(ndr, "num_sids", r->num_sids);
|
||||
ndr_print_ptr(ndr, "sids", r->sids);
|
||||
@ -616,7 +629,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_DomainInformation(struct ndr_print *ndr, const char *name, struct lsa_DomainInformation *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_DomainInformation");
|
||||
ndr->depth++;
|
||||
ndr_print_lsa_Name(ndr, "name", &r->name);
|
||||
ndr_print_ptr(ndr, "sid", r->sid);
|
||||
@ -651,7 +664,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_DomainList(struct ndr_print *ndr, const char *name, struct lsa_DomainList *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_DomainList");
|
||||
ndr->depth++;
|
||||
ndr_print_uint32(ndr, "count", r->count);
|
||||
ndr_print_ptr(ndr, "domains", r->domains);
|
||||
@ -707,7 +720,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_TranslatedSid(struct ndr_print *ndr, const char *name, struct lsa_TranslatedSid *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_TranslatedSid");
|
||||
ndr->depth++;
|
||||
ndr_print_uint16(ndr, "sid_type", r->sid_type);
|
||||
ndr_print_uint32(ndr, "rid", r->rid);
|
||||
@ -752,7 +765,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_TransSidArray(struct ndr_print *ndr, const char *name, struct lsa_TransSidArray *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_TransSidArray");
|
||||
ndr->depth++;
|
||||
ndr_print_uint32(ndr, "count", r->count);
|
||||
ndr_print_ptr(ndr, "sids", r->sids);
|
||||
@ -787,7 +800,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_TrustInformation(struct ndr_print *ndr, const char *name, struct lsa_TrustInformation *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_TrustInformation");
|
||||
ndr->depth++;
|
||||
ndr_print_lsa_Name(ndr, "name", &r->name);
|
||||
ndr_print_ptr(ndr, "sid", r->sid);
|
||||
@ -823,7 +836,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_RefDomainList(struct ndr_print *ndr, const char *name, struct lsa_RefDomainList *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_RefDomainList");
|
||||
ndr->depth++;
|
||||
ndr_print_uint32(ndr, "count", r->count);
|
||||
ndr_print_ptr(ndr, "domains", r->domains);
|
||||
@ -898,7 +911,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_TranslatedName(struct ndr_print *ndr, const char *name, struct lsa_TranslatedName *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_TranslatedName");
|
||||
ndr->depth++;
|
||||
ndr_print_uint16(ndr, "sid_type", r->sid_type);
|
||||
ndr_print_lsa_Name(ndr, "name", &r->name);
|
||||
@ -943,7 +956,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_TransNameArray(struct ndr_print *ndr, const char *name, struct lsa_TransNameArray *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_TransNameArray");
|
||||
ndr->depth++;
|
||||
ndr_print_uint32(ndr, "count", r->count);
|
||||
ndr_print_ptr(ndr, "names", r->names);
|
||||
@ -1028,7 +1041,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_LUID(struct ndr_print *ndr, const char *name, struct lsa_LUID *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_LUID");
|
||||
ndr->depth++;
|
||||
ndr_print_uint32(ndr, "low", r->low);
|
||||
ndr_print_uint32(ndr, "high", r->high);
|
||||
@ -1049,7 +1062,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_LUIDAttribute(struct ndr_print *ndr, const char *name, struct lsa_LUIDAttribute *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_LUIDAttribute");
|
||||
ndr->depth++;
|
||||
ndr_print_lsa_LUID(ndr, "luid", &r->luid);
|
||||
ndr_print_uint32(ndr, "attribute", r->attribute);
|
||||
@ -1070,10 +1083,13 @@ done:
|
||||
|
||||
void ndr_print_lsa_PrivilegeSet(struct ndr_print *ndr, const char *name, struct lsa_PrivilegeSet *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_PrivilegeSet");
|
||||
ndr->depth++;
|
||||
ndr_print_uint32(ndr, "count", r->count);
|
||||
ndr_print_lsa_LUIDAttribute(ndr, "set", r->set);
|
||||
ndr_print_ptr(ndr, "set", r->set);
|
||||
ndr->depth++;
|
||||
ndr_print_array(ndr, "set", r->set, sizeof(r->set[0]), r->count, (ndr_print_fn_t)ndr_print_lsa_LUIDAttribute);
|
||||
ndr->depth--;
|
||||
ndr->depth--;
|
||||
}
|
||||
|
||||
@ -1338,7 +1354,7 @@ NTSTATUS ndr_pull_ENUMACCTWITHRIGHT(struct ndr_pull *ndr, struct ENUMACCTWITHRIG
|
||||
|
||||
void ndr_print_lsa_RightAttribute(struct ndr_print *ndr, const char *name, struct lsa_RightAttribute *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_RightAttribute");
|
||||
ndr->depth++;
|
||||
ndr_print_ptr(ndr, "name", r->name);
|
||||
ndr->depth++;
|
||||
@ -1372,7 +1388,7 @@ done:
|
||||
|
||||
void ndr_print_lsa_RightSet(struct ndr_print *ndr, const char *name, struct lsa_RightSet *r)
|
||||
{
|
||||
ndr_print_struct(ndr, name);
|
||||
ndr_print_struct(ndr, name, "lsa_RightSet");
|
||||
ndr->depth++;
|
||||
ndr_print_uint32(ndr, "count", r->count);
|
||||
ndr_print_ptr(ndr, "names", r->names);
|
||||
|
@ -212,7 +212,6 @@ static BOOL test_LookupSids(struct dcerpc_pipe *p,
|
||||
struct lsa_TransNameArray names;
|
||||
uint32 count = sids->num_sids;
|
||||
NTSTATUS status;
|
||||
int i;
|
||||
|
||||
printf("\nTesting LookupSids\n");
|
||||
|
||||
@ -312,7 +311,6 @@ static BOOL test_EnumAccountRights(struct dcerpc_pipe *p,
|
||||
NTSTATUS status;
|
||||
struct lsa_EnumAccountRights r;
|
||||
struct lsa_RightSet rights;
|
||||
int i;
|
||||
|
||||
printf("Testing EnumAccountRights\n");
|
||||
|
||||
@ -434,7 +432,6 @@ static BOOL test_EnumPrivs(struct dcerpc_pipe *p,
|
||||
struct lsa_EnumPrivs r;
|
||||
struct lsa_PrivArray privs1;
|
||||
uint32 resume_handle = 0;
|
||||
int i;
|
||||
|
||||
printf("\ntesting EnumPrivs\n");
|
||||
|
||||
@ -465,7 +462,6 @@ static BOOL test_EnumTrustDom(struct dcerpc_pipe *p,
|
||||
{
|
||||
struct lsa_EnumTrustDom r;
|
||||
NTSTATUS status;
|
||||
int i;
|
||||
uint32 resume_handle = 0;
|
||||
struct lsa_DomainList domains;
|
||||
|
||||
@ -508,7 +504,7 @@ static BOOL test_QueryInfoPolicy(struct dcerpc_pipe *p,
|
||||
return False;
|
||||
}
|
||||
|
||||
NDR_PRINT_DEBUG(lsa_AuditLogInfo, &r.out.info->audit_log);
|
||||
NDR_PRINT_UNION_DEBUG(lsa_PolicyInformation, r.in.level, r.out.info);
|
||||
|
||||
return True;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user