コード例 #1
0
ファイル: client_lib.c プロジェクト: dawnfan/egui
/**
 * 发送带有附加内容的负载,读取返回的retval。如果发送或接受过程出错或malloc失败返回-1,否则返回回应包的retval
 *
 * @param request_type 请求类型
 * @param respond_type 回应类型
 * @param body 标准负载指针
 * @param body_len 标准负载的长度
 * @param extra_context 附加内容指针
 * @param extra_context_len 附加内容长度
 **/
static si_t send_body_with_extra_context_and_return_respond(si_t request_type, si_t respond_type,
        const_addr_t body         , ui_t body_len,
        const_addr_t extra_context, ui_t extra_context_len)
{
	si_t result = 0;
	if(0 != comm_send_request_with_extra(lib_uds, request_type, body, body_len, extra_context, extra_context_len))
	{
		EGUI_PRINT_ERROR("failed to send request[%s] with extra content", request_type_to_str(request_type));
		return -1;
	}

	if(0 != comm_recv_respond(lib_uds, respond_type, &result, message_queue))
	{
		EGUI_PRINT_ERROR("failed to receive respond[%s]", respond_type_to_str(respond_type));
		return -1;
	}
	return result;
}
コード例 #2
0
ファイル: test_client.c プロジェクト: FangKuangKuang/egui
/**
 * 发送注册窗口请求
 **/
int fake_register_window(struct egui_uds* uds_ptr, si_t parent_fd, char* title)
{
	struct packet_body_register_window body;
	si_t ret = 0;

	request_set_register_window(&body, parent_fd, title, strlen(title) + 1, 0, 0, 0, 0, 0, 0, 0);
	if(0 != comm_send_request_with_extra(uds_ptr, REQUEST_TYPE_REGISTER_WINDOW, 
			&body, sizeof(body), title, strlen(title) + 1))
	{
		EGUI_PRINT_ERROR("failed to send register window request");
		return -1;
	}
	if(0 != comm_recv_respond(uds_ptr, RESPOND_TYPE_REGISTER_WINDOW, &ret, NULL))
	{
		EGUI_PRINT_ERROR("failed to recv register window respond");
		return -1;
	}

	EGUI_PRINT_INFO("send register window request, recv ret %d", (int)ret);

	return 0;
}