Exemplo n.º 1
0
void App_Recv_Req_Data(ProHeader *header)
{
	req_id_t recv_req_id;
	recv_req_id.sequence_number = header->sequence_number;
	recv_req_id.session_id 	    = header->session_id;
	recv_req_id.need_encrypt    = header->enc_type & 0xff;
	recv_data.len 		    = header->length - EXC_DATA_SIZE;

	memcpy((uint8_t *)&recv_data.cmd_set,(uint8_t *)&header->magic, recv_data.len);

	uint8_t set_index = 0;
	uint8_t cmd_index = 0;

	set_index = find_set_index(recv_data.cmd_set,app_set_tab_ptr);
	cmd_index = find_cmd_index(recv_data.cmd_id,app_set_tab_ptr[set_index].p_cmd_handler_table);

	if(set_index == ERR_INDEX || cmd_index == ERR_INDEX)
	{
		printf("ERROR, NO SUCH CMD_SET(%d) OR CMD_ID(%d) !\n", set_index, cmd_index);
		return;
	}
	app_set_tab_ptr[set_index].p_cmd_handler_table[cmd_index].pf_cmd_handler(recv_data.cmd_id,
	                                                                         recv_data.data_buf,
	                                                                         (recv_data.len - SET_CMD_SIZE),
	                                                                         recv_req_id);
}
Exemplo n.º 2
0
Arquivo: main.c Projeto: gozfree/src
int parse_cmd(char* cmd)
{
	int cmd_index;

	skip_space(&cmd);

	if (*cmd == '\0' || *cmd == ';')
		return 1;
	
	cmd_index = find_cmd_index(&cmd, g_cmd_set_str, CMD_MAX);

	dbg_printf(LOG, "find_cmd_index: %d\n", cmd_index);
	switch (cmd_index) {
		case CMD_EXIT:
			g_exit = 1;
			break;
		case CMD_HELP:
		default:
			print_help(g_cmd_set_str, g_cmd_help, CMD_MAX);
			break;
	}
}