parse_srv.c

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

C
2,455
字号
/******************************************************************* Reads or writes a structure.********************************************************************/BOOL srv_io_r_net_sess_enum(const char *desc, SRV_R_NET_SESS_ENUM *r_n, prs_struct *ps, int depth){	if (r_n == NULL)		return False;	prs_debug(ps, depth, desc, "srv_io_r_net_sess_enum");	depth++;	if(!prs_align(ps))		return False;	if(!prs_uint32("sess_level", ps, depth, &r_n->sess_level))		return False;	if (r_n->sess_level != (uint32)-1) {		if(!srv_io_srv_sess_ctr("sess_ctr", &r_n->ctr, ps, depth))			return False;	}	if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))		return False;	if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))		return False;	if(!prs_werror("status", ps, depth, &r_n->status))		return False;	return True;}/******************************************************************* Inits a SRV_Q_NET_SESS_DEL structure.********************************************************************/void init_srv_q_net_sess_del(SRV_Q_NET_SESS_DEL *q_n, const char *srv_name,			      const char *cli_name, const char *user_name){	DEBUG(5,("init_q_net_sess_enum\n"));	init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name);	init_buf_unistr2(&q_n->uni_cli_name, &q_n->ptr_cli_name, cli_name);	init_buf_unistr2(&q_n->uni_user_name, &q_n->ptr_user_name, user_name);}/******************************************************************* Reads or writes a structure.********************************************************************/BOOL srv_io_q_net_sess_del(const char *desc, SRV_Q_NET_SESS_DEL *q_n, prs_struct *ps, int depth){	if (q_n == NULL)		return False;	prs_debug(ps, depth, desc, "srv_io_q_net_sess_del");	depth++;	if(!prs_align(ps))		return False;	if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name))		return False;	if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth))		return False;	if(!prs_align(ps))		return False;	if(!prs_uint32("ptr_cli_name", ps, depth, &q_n->ptr_cli_name))		return False;	if(!smb_io_unistr2("", &q_n->uni_cli_name, q_n->ptr_cli_name, ps, depth))		return False;	if(!prs_align(ps))		return False;	if(!prs_uint32("ptr_user_name", ps, depth, &q_n->ptr_user_name))		return False;	if(!smb_io_unistr2("", &q_n->uni_user_name, q_n->ptr_user_name, ps, depth))		return False;	return True;}/******************************************************************* Reads or writes a structure.********************************************************************/BOOL srv_io_r_net_sess_del(const char *desc, SRV_R_NET_SESS_DEL *r_n, prs_struct *ps, int depth){	if (r_n == NULL)		return False;	prs_debug(ps, depth, desc, "srv_io_r_net_sess_del");	depth++;	if(!prs_align(ps))		return False;	if(!prs_werror("status", ps, depth, &r_n->status))		return False;	return True;}/******************************************************************* Inits a CONN_INFO_0 structure********************************************************************/void init_srv_conn_info0(CONN_INFO_0 *ss0, uint32 id){	DEBUG(5,("init_srv_conn_info0\n"));	ss0->id = id;}/******************************************************************* Reads or writes a structure.********************************************************************/static BOOL srv_io_conn_info0(const char *desc, CONN_INFO_0 *ss0, prs_struct *ps, int depth){	if (ss0 == NULL)		return False;	prs_debug(ps, depth, desc, "srv_io_conn_info0");	depth++;	if(!prs_align(ps))		return False;	if(!prs_uint32("id", ps, depth, &ss0->id))		return False;	return True;}/******************************************************************* Reads or writes a structure.********************************************************************/static BOOL srv_io_srv_conn_info_0(const char *desc, SRV_CONN_INFO_0 *ss0, prs_struct *ps, int depth){	if (ss0 == NULL)		return False;	prs_debug(ps, depth, desc, "srv_io_srv_conn_info_0");	depth++;	if(!prs_align(ps))		return False;	if(!prs_uint32("num_entries_read", ps, depth, &ss0->num_entries_read))		return False;	if(!prs_uint32("ptr_conn_info", ps, depth, &ss0->ptr_conn_info))		return False;	if (ss0->ptr_conn_info != 0) {		int i;		int num_entries = ss0->num_entries_read;		if (num_entries > MAX_CONN_ENTRIES) {			num_entries = MAX_CONN_ENTRIES; /* report this! */		}		if(!prs_uint32("num_entries_read2", ps, depth, &ss0->num_entries_read2))			return False;		for (i = 0; i < num_entries; i++) {			if(!srv_io_conn_info0("", &ss0->info_0[i], ps, depth))				return False;		}		if(!prs_align(ps))			return False;	}	return True;}/******************************************************************* Inits a CONN_INFO_1_STR structure********************************************************************/void init_srv_conn_info1_str(CONN_INFO_1_STR *ss1, const char *usr_name, const char *net_name){	DEBUG(5,("init_srv_conn_info1_str\n"));	init_unistr2(&ss1->uni_usr_name, usr_name, UNI_STR_TERMINATE);	init_unistr2(&ss1->uni_net_name, net_name, UNI_STR_TERMINATE);}/******************************************************************* Reads or writes a structure.********************************************************************/static BOOL srv_io_conn_info1_str(const char *desc, CONN_INFO_1_STR *ss1, prs_struct *ps, int depth){	if (ss1 == NULL)		return False;	prs_debug(ps, depth, desc, "srv_io_conn_info1_str");	depth++;	if(!prs_align(ps))		return False;	if(!smb_io_unistr2("", &ss1->uni_usr_name, True, ps, depth))		return False;	if(!smb_io_unistr2("", &ss1->uni_net_name, True, ps, depth))		return False;	return True;}/******************************************************************* Inits a CONN_INFO_1 structure********************************************************************/void init_srv_conn_info1(CONN_INFO_1 *ss1, 				uint32 id, uint32 type,				uint32 num_opens, uint32 num_users, uint32 open_time,				const char *usr_name, const char *net_name){	DEBUG(5,("init_srv_conn_info1: %s %s\n", usr_name, net_name));	ss1->id        = id       ;	ss1->type      = type     ;	ss1->num_opens = num_opens ;	ss1->num_users = num_users;	ss1->open_time = open_time;	ss1->ptr_usr_name = (usr_name != NULL) ? 1 : 0;	ss1->ptr_net_name = (net_name != NULL) ? 1 : 0;}/******************************************************************* Reads or writes a structure.********************************************************************/static BOOL srv_io_conn_info1(const char *desc, CONN_INFO_1 *ss1, prs_struct *ps, int depth){	if (ss1 == NULL)		return False;	prs_debug(ps, depth, desc, "srv_io_conn_info1");	depth++;	if(!prs_align(ps))		return False;	if(!prs_uint32("id          ", ps, depth, &ss1->id))		return False;	if(!prs_uint32("type        ", ps, depth, &ss1->type))		return False;	if(!prs_uint32("num_opens   ", ps, depth, &ss1->num_opens))		return False;	if(!prs_uint32("num_users   ", ps, depth, &ss1->num_users))		return False;	if(!prs_uint32("open_time   ", ps, depth, &ss1->open_time))		return False;	if(!prs_uint32("ptr_usr_name", ps, depth, &ss1->ptr_usr_name))		return False;	if(!prs_uint32("ptr_net_name", ps, depth, &ss1->ptr_net_name))		return False;	return True;}/******************************************************************* Reads or writes a structure.********************************************************************/static BOOL srv_io_srv_conn_info_1(const char *desc, SRV_CONN_INFO_1 *ss1, prs_struct *ps, int depth){	if (ss1 == NULL)		return False;	prs_debug(ps, depth, desc, "srv_io_srv_conn_info_1");	depth++;	if(!prs_align(ps))		return False;	if(!prs_uint32("num_entries_read", ps, depth, &ss1->num_entries_read))		return False;	if(!prs_uint32("ptr_conn_info", ps, depth, &ss1->ptr_conn_info))		return False;	if (ss1->ptr_conn_info != 0) {		int i;		int num_entries = ss1->num_entries_read;		if (num_entries > MAX_CONN_ENTRIES) {			num_entries = MAX_CONN_ENTRIES; /* report this! */		}		if(!prs_uint32("num_entries_read2", ps, depth, &ss1->num_entries_read2))			return False;		for (i = 0; i < num_entries; i++) {			if(!srv_io_conn_info1("", &ss1->info_1[i], ps, depth))				return False;		}		for (i = 0; i < num_entries; i++) {			if(!srv_io_conn_info1_str("", &ss1->info_1_str[i], ps, depth))				return False;		}		if(!prs_align(ps))			return False;	}	return True;}/******************************************************************* Reads or writes a structure.********************************************************************/static BOOL srv_io_srv_conn_ctr(const char *desc, SRV_CONN_INFO_CTR **pp_ctr, prs_struct *ps, int depth){	SRV_CONN_INFO_CTR *ctr = *pp_ctr;	prs_debug(ps, depth, desc, "srv_io_srv_conn_ctr");	depth++;	if (UNMARSHALLING(ps)) {		ctr = *pp_ctr = PRS_ALLOC_MEM(ps, SRV_CONN_INFO_CTR, 1);		if (ctr == NULL)			return False;	}			if (ctr == NULL)		return False;	if(!prs_align(ps))		return False;	if(!prs_uint32("switch_value", ps, depth, &ctr->switch_value))		return False;	if(!prs_uint32("ptr_conn_ctr", ps, depth, &ctr->ptr_conn_ctr))		return False;	if (ctr->ptr_conn_ctr != 0) {		switch (ctr->switch_value) {		case 0:			if(!srv_io_srv_conn_info_0("", &ctr->conn.info0, ps, depth))				return False;			break;		case 1:			if(!srv_io_srv_conn_info_1("", &ctr->conn.info1, ps, depth))				return False;			break;		default:			DEBUG(5,("%s no connection info at switch_value %d\n",			         tab_depth(depth), ctr->switch_value));			break;		}	}	return True;}/*******************************************************************  Reads or writes a structure.********************************************************************/void init_srv_q_net_conn_enum(SRV_Q_NET_CONN_ENUM *q_n, 				const char *srv_name, const char *qual_name,				uint32 conn_level, SRV_CONN_INFO_CTR *ctr,				uint32 preferred_len,				ENUM_HND *hnd){	DEBUG(5,("init_q_net_conn_enum\n"));	q_n->ctr = ctr;	init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name );	init_buf_unistr2(&q_n->uni_qual_name, &q_n->ptr_qual_name, qual_name);	q_n->conn_level    = conn_level;	q_n->preferred_len = preferred_len;	memcpy(&q_n->enum_hnd, hnd, sizeof(*hnd));}/******************************************************************* Reads or writes a structure.********************************************************************/BOOL srv_io_q_net_conn_enum(const char *desc, SRV_Q_NET_CONN_ENUM *q_n, prs_struct *ps, int depth){	if (q_n == NULL)		return False;	prs_debug(ps, depth, desc, "srv_io_q_net_conn_enum");	depth++;	if(!prs_align(ps))		return False;	if(!prs_uint32("ptr_srv_name ", ps, depth, &q_n->ptr_srv_name))		return False;	if(!smb_io_unistr2("", &q_n->uni_srv_name, q_n->ptr_srv_name, ps, depth))		return False;	if(!prs_align(ps))		return False;	if(!prs_uint32("ptr_qual_name", ps, depth, &q_n->ptr_qual_name))		return False;	if(!smb_io_unistr2("", &q_n->uni_qual_name, q_n->ptr_qual_name, ps, depth))		return False;	if(!prs_align(ps))		return False;	if(!prs_uint32("conn_level", ps, depth, &q_n->conn_level))		return False;		if (q_n->conn_level != (uint32)-1) {		if(!srv_io_srv_conn_ctr("conn_ctr", &q_n->ctr, ps, depth))			return False;	}	if(!prs_uint32("preferred_len", ps, depth, &q_n->preferred_len))		return False;	if(!smb_io_enum_hnd("enum_hnd", &q_n->enum_hnd, ps, depth))		return False;	return True;}/******************************************************************* Reads or writes a structure.********************************************************************/BOOL srv_io_r_net_conn_enum(const char *desc,  SRV_R_NET_CONN_ENUM *r_n, prs_struct *ps, int depth){	if (r_n == NULL)		return False;	prs_debug(ps, depth, desc, "srv_io_r_net_conn_enum");	depth++;	if(!prs_align(ps))		return False;	if(!prs_uint32("conn_level", ps, depth, &r_n->conn_level))		return False;	if (r_n->conn_level != (uint32)-1) {		if(!srv_io_srv_conn_ctr("conn_ctr", &r_n->ctr, ps, depth))			return False;	}	if(!prs_uint32("total_entries", ps, depth, &r_n->total_entries))		return False;	if(!smb_io_enum_hnd("enum_hnd", &r_n->enum_hnd, ps, depth))		return False;	if(!prs_werror("status", ps, depth, &r_n->status))		return False;	return True;}/******************************************************************* Inits a FILE_INFO_3_STR structure********************************************************************/void init_srv_file_info3_str(FILE_INFO_3_STR *fi3, const char *user_name, const char *path_name){	DEBUG(5,("init_srv_file_info3_str\n"));	init_unistr2(&fi3->uni_path_name, path_name, UNI_STR_TERMINATE);	init_unistr2(&fi3->uni_user_name, user_name, UNI_STR_TERMINATE);}/******************************************************************* Reads or writes a structure.********************************************************************/static BOOL srv_io_file_info3_str(const char *desc, FILE_INFO_3_STR *sh1, prs_struct *ps, int depth){	if (sh1 == NULL)

⌨️ 快捷键说明

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