parse_samr.c

来自「samba-3.0.22.tar.gz 编译smb服务器的源码」· C语言 代码 · 共 2,438 行 · 第 1/5 页

C
2,438
字号
				uint16 switch_level, uint32 start_idx,				uint32 max_entries, uint32 max_size){	DEBUG(5, ("init_samr_q_query_dispinfo\n"));	q_e->domain_pol = *pol;	q_e->switch_level = switch_level;	q_e->start_idx = start_idx;	q_e->max_entries = max_entries;	q_e->max_size = max_size;}/*******************************************************************reads or writes a structure.********************************************************************/BOOL samr_io_q_query_dispinfo(const char *desc, SAMR_Q_QUERY_DISPINFO * q_e,			      prs_struct *ps, int depth){	if (q_e == NULL)		return False;	prs_debug(ps, depth, desc, "samr_io_q_query_dispinfo");	depth++;	if(!prs_align(ps))		return False;	if(!smb_io_pol_hnd("domain_pol", &q_e->domain_pol, ps, depth))		return False;	if(!prs_uint16("switch_level", ps, depth, &q_e->switch_level))		return False;	if(!prs_align(ps))		return False;	if(!prs_uint32("start_idx   ", ps, depth, &q_e->start_idx))		return False;	if(!prs_uint32("max_entries ", ps, depth, &q_e->max_entries))		return False;	if(!prs_uint32("max_size    ", ps, depth, &q_e->max_size))		return False;	return True;}/*******************************************************************inits a SAM_DISPINFO_1 structure.********************************************************************/NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 **sam,			     uint32 num_entries, uint32 start_idx,			     struct samr_displayentry *entries){	uint32 i;	DEBUG(10, ("init_sam_dispinfo_1: num_entries: %d\n", num_entries));	if (num_entries==0)		return NT_STATUS_OK;	*sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_1, num_entries);	if (*sam == NULL)		return NT_STATUS_NO_MEMORY;	(*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY1, num_entries);	if ((*sam)->sam == NULL)		return NT_STATUS_NO_MEMORY;	(*sam)->str=TALLOC_ARRAY(ctx, SAM_STR1, num_entries);	if ((*sam)->str == NULL)		return NT_STATUS_NO_MEMORY;	for (i = 0; i < num_entries ; i++) {		init_unistr2(&(*sam)->str[i].uni_acct_name,			     entries[i].account_name, UNI_FLAGS_NONE);		init_unistr2(&(*sam)->str[i].uni_full_name,			     entries[i].fullname, UNI_FLAGS_NONE);		init_unistr2(&(*sam)->str[i].uni_acct_desc,			     entries[i].description, UNI_FLAGS_NONE);		init_sam_entry1(&(*sam)->sam[i], start_idx+i+1,				&(*sam)->str[i].uni_acct_name,				&(*sam)->str[i].uni_full_name,				&(*sam)->str[i].uni_acct_desc,				entries[i].rid, entries[i].acct_flags);	}	return NT_STATUS_OK;}/*******************************************************************reads or writes a structure.********************************************************************/static BOOL sam_io_sam_dispinfo_1(const char *desc, SAM_DISPINFO_1 * sam,				  uint32 num_entries,				  prs_struct *ps, int depth){	uint32 i;	prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_1");	depth++;	if(!prs_align(ps))		return False;	if (UNMARSHALLING(ps) && num_entries > 0) {		if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY1, num_entries)) == NULL) {			DEBUG(0, ("out of memory allocating SAM_ENTRY1\n"));			return False;		}		if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR1, num_entries)) == NULL) {			DEBUG(0, ("out of memory allocating SAM_STR1\n"));			return False;		}	}	for (i = 0; i < num_entries; i++) {		if(!sam_io_sam_entry1("", &sam->sam[i], ps, depth))			return False;	}	for (i = 0; i < num_entries; i++) {		if(!sam_io_sam_str1("", &sam->str[i],			      sam->sam[i].hdr_acct_name.buffer,			      sam->sam[i].hdr_user_name.buffer,			      sam->sam[i].hdr_user_desc.buffer, ps, depth))			return False;	}	return True;}/*******************************************************************inits a SAM_DISPINFO_2 structure.********************************************************************/NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 **sam,			     uint32 num_entries, uint32 start_idx,			     struct samr_displayentry *entries){	uint32 i;	DEBUG(10, ("init_sam_dispinfo_2: num_entries: %d\n", num_entries));	if (num_entries==0)		return NT_STATUS_OK;	*sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_2, num_entries);	if (*sam == NULL)		return NT_STATUS_NO_MEMORY;	(*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY2, num_entries);	if ((*sam)->sam == NULL)		return NT_STATUS_NO_MEMORY;	(*sam)->str=TALLOC_ARRAY(ctx, SAM_STR2, num_entries);	if ((*sam)->str == NULL)		return NT_STATUS_NO_MEMORY;	for (i = 0; i < num_entries; i++) {		init_unistr2(&(*sam)->str[i].uni_srv_name,			     entries[i].account_name, UNI_FLAGS_NONE);		init_unistr2(&(*sam)->str[i].uni_srv_desc,			     entries[i].description, UNI_FLAGS_NONE);		init_sam_entry2(&(*sam)->sam[i], start_idx + i + 1,				&(*sam)->str[i].uni_srv_name,				&(*sam)->str[i].uni_srv_desc,				entries[i].rid, entries[i].acct_flags);	}	return NT_STATUS_OK;}/*******************************************************************reads or writes a structure.********************************************************************/static BOOL sam_io_sam_dispinfo_2(const char *desc, SAM_DISPINFO_2 * sam,				  uint32 num_entries,				  prs_struct *ps, int depth){	uint32 i;	if (sam == NULL)		return False;	prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_2");	depth++;	if(!prs_align(ps))		return False;	if (UNMARSHALLING(ps) && num_entries > 0) {		if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY2, num_entries)) == NULL) {			DEBUG(0, ("out of memory allocating SAM_ENTRY2\n"));			return False;		}		if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR2, num_entries)) == NULL) {			DEBUG(0, ("out of memory allocating SAM_STR2\n"));			return False;		}	}	for (i = 0; i < num_entries; i++) {		if(!sam_io_sam_entry2("", &sam->sam[i], ps, depth))			return False;	}	for (i = 0; i < num_entries; i++) {		if(!sam_io_sam_str2("", &sam->str[i],			      sam->sam[i].hdr_srv_name.buffer,			      sam->sam[i].hdr_srv_desc.buffer, ps, depth))			return False;	}	return True;}/*******************************************************************inits a SAM_DISPINFO_3 structure.********************************************************************/NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 **sam,			     uint32 num_entries, uint32 start_idx,			     struct samr_displayentry *entries){	uint32 i;	DEBUG(5, ("init_sam_dispinfo_3: num_entries: %d\n", num_entries));	if (num_entries==0)		return NT_STATUS_OK;	*sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_3, num_entries);	if (*sam == NULL)		return NT_STATUS_NO_MEMORY;	if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY3, num_entries)))		return NT_STATUS_NO_MEMORY;	if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR3, num_entries)))		return NT_STATUS_NO_MEMORY;	for (i = 0; i < num_entries; i++) {		DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));		init_unistr2(&(*sam)->str[i].uni_grp_name,			     entries[i].account_name, UNI_FLAGS_NONE);		init_unistr2(&(*sam)->str[i].uni_grp_desc,			     entries[i].description, UNI_FLAGS_NONE);		init_sam_entry3(&(*sam)->sam[i], start_idx+i+1,				&(*sam)->str[i].uni_grp_name,				&(*sam)->str[i].uni_grp_desc,				entries[i].rid);	}	return NT_STATUS_OK;}/*******************************************************************reads or writes a structure.********************************************************************/static BOOL sam_io_sam_dispinfo_3(const char *desc, SAM_DISPINFO_3 * sam,				  uint32 num_entries,				  prs_struct *ps, int depth){	uint32 i;	if (sam == NULL)		return False;	prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_3");	depth++;	if(!prs_align(ps))		return False;	if (UNMARSHALLING(ps) && num_entries > 0) {		if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY3, num_entries)) == NULL) {			DEBUG(0, ("out of memory allocating SAM_ENTRY3\n"));			return False;		}		if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR3, num_entries)) == NULL) {			DEBUG(0, ("out of memory allocating SAM_STR3\n"));			return False;		}	}	for (i = 0; i < num_entries; i++) {		if(!sam_io_sam_entry3("", &sam->sam[i], ps, depth))			return False;	}	for (i = 0; i < num_entries; i++) {		if(!sam_io_sam_str3("", &sam->str[i],			      sam->sam[i].hdr_grp_name.buffer,			      sam->sam[i].hdr_grp_desc.buffer, ps, depth))			return False;	}	return True;}/*******************************************************************inits a SAM_DISPINFO_4 structure.********************************************************************/NTSTATUS init_sam_dispinfo_4(TALLOC_CTX *ctx, SAM_DISPINFO_4 **sam,			     uint32 num_entries, uint32 start_idx,			     struct samr_displayentry *entries){	uint32 i;	DEBUG(5, ("init_sam_dispinfo_4: num_entries: %d\n", num_entries));	if (num_entries==0)		return NT_STATUS_OK;	*sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_4, num_entries);	if (*sam == NULL)		return NT_STATUS_NO_MEMORY;	(*sam)->sam = TALLOC_ARRAY(ctx, SAM_ENTRY4, num_entries);	if ((*sam)->sam == NULL)		return NT_STATUS_NO_MEMORY;	(*sam)->str=TALLOC_ARRAY(ctx, SAM_STR4, num_entries);	if ((*sam)->str == NULL)		return NT_STATUS_NO_MEMORY;	for (i = 0; i < num_entries; i++) {		size_t len_sam_name = strlen(entries[i].account_name);		DEBUG(11, ("init_sam_dispinfo_2: entry: %d\n",i));	  		init_sam_entry4(&(*sam)->sam[i], start_idx + i + 1,				len_sam_name);		init_string2(&(*sam)->str[i].acct_name,			     entries[i].account_name, len_sam_name+1,			     len_sam_name);	}		return NT_STATUS_OK;}/*******************************************************************reads or writes a structure.********************************************************************/static BOOL sam_io_sam_dispinfo_4(const char *desc, SAM_DISPINFO_4 * sam,				  uint32 num_entries,				  prs_struct *ps, int depth){	uint32 i;	if (sam == NULL)		return False;	prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_4");	depth++;	if(!prs_align(ps))		return False;	if (UNMARSHALLING(ps) && num_entries > 0) {		if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY4, num_entries)) == NULL) {			DEBUG(0, ("out of memory allocating SAM_ENTRY4\n"));			return False;		}		if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR4, num_entries)) == NULL) {			DEBUG(0, ("out of memory allocating SAM_STR4\n"));			return False;		}	}	for (i = 0; i < num_entries; i++) {		if(!sam_io_sam_entry4("", &sam->sam[i], ps, depth))			return False;	}	for (i = 0; i < num_entries; i++) {		if(!smb_io_string2("acct_name", &sam->str[i].acct_name,			     sam->sam[i].hdr_acct_name.buffer, ps, depth))			return False;	}	return True;}/*******************************************************************inits a SAM_DISPINFO_5 structure.********************************************************************/NTSTATUS init_sam_dispinfo_5(TALLOC_CTX *ctx, SAM_DISPINFO_5 **sam,			     uint32 num_entries, uint32 start_idx,			     struct samr_displayentry *entries){	uint32 len_sam_name;	uint32 i;	DEBUG(5, ("init_sam_dispinfo_5: num_entries: %d\n", num_entries));	if (num_entries==0)		return NT_STATUS_OK;	*sam = TALLOC_ZERO_ARRAY(ctx, SAM_DISPINFO_5, num_entries);	if (*sam == NULL)		return NT_STATUS_NO_MEMORY;	if (!((*sam)->sam=TALLOC_ARRAY(ctx, SAM_ENTRY5, num_entries)))		return NT_STATUS_NO_MEMORY;	if (!((*sam)->str=TALLOC_ARRAY(ctx, SAM_STR5, num_entries)))		return NT_STATUS_NO_MEMORY;	for (i = 0; i < num_entries; i++) {		DEBUG(11, ("init_sam_dispinfo_5: entry: %d\n",i));		len_sam_name = strlen(entries[i].account_name);	  		init_sam_entry5(&(*sam)->sam[i], start_idx+i+1, len_sam_name);		init_string2(&(*sam)->str[i].grp_name, entries[i].account_name,			     len_sam_name+1, len_sam_name);	}	return NT_STATUS_OK;}/*******************************************************************reads or writes a structure.********************************************************************/static BOOL sam_io_sam_dispinfo_5(const char *desc, SAM_DISPINFO_5 * sam,				  uint32 num_entries,				  prs_struct *ps, int depth){	uint32 i;	if (sam == NULL)		return False;	prs_debug(ps, depth, desc, "sam_io_sam_dispinfo_5");	depth++;	if(!prs_align(ps))		return False;	if (UNMARSHALLING(ps) && num_entries > 0) {		if ((sam->sam = PRS_ALLOC_MEM(ps, SAM_ENTRY5, num_entries)) == NULL) {			DEBUG(0, ("out of memory allocating SAM_ENTRY5\n"));			return False;		}		if ((sam->str = PRS_ALLOC_MEM(ps, SAM_STR5, num_entries)) == NULL) {			DEBUG(0, ("out of memory allocating SAM_STR5\n"));			return False;		}	}	for (i = 0; i < num_entries; i++) {		if(!sam_io_sam_entry5("", &sam->sam[i], ps, depth))			return False;	}	for (i = 0; i < num_entries; i++) {		if(!smb_io_string2("grp_name", &sam->str[i].grp_name,			     sam->sam[i].hdr_grp_name.buffer, ps, depth))			return False;	}	return True;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?