示例#1
0
文件: dp2pcsc.c 项目: G-nice/DP2PCSC
int main (int argc, char *argv[])
{
	client_shutdown = 0;
	init_friend_name_addr();//must be init first,load friend name reflects to address from file
	init_connector(&connectors);
	init_socket();
	init_show();
	init_file_trans_control();
	
	while(!client_shutdown){
		input();
	}
	shutdown(listen_socket_fd, SHUT_RDWR);
	close(listen_socket_fd);
	destroy_friend_name_addr(&name_address);
	close_all_connector(&connectors);//talk_thread can't be closed by themself because recv is blocking
	while (connector_length(&connectors)){//wait for thread free
		usleep(50);
	}
	destroy_connector(&connectors);
	destroy_file_trans_control(file_trans_control);
	destroy_show_tty();
	sleep(1);//wait for other thread exit,not necssary but that can make it easy for valbrind check memory leak (include still reachable)
	return 0;
}//end main-function
示例#2
0
文件: demo.c 项目: island-org/gui
static void
init_demo(struct demo_gui *gui, struct gui_font *font)
{
    struct gui_config *config = &gui->config;
    gui->font = *font;
    gui->running = gui_true;

    gui_command_buffer_init_fixed(&gui->show_buffer, gui->memory, MAX_MEMORY/2, GUI_CLIP);
    gui_command_buffer_init_fixed(&gui->control_buffer,
        gui_ptr_add(void*, gui->memory, (MAX_MEMORY/2)), MAX_MEMORY/2, GUI_CLIP);
    gui_config_default(config, GUI_DEFAULT_ALL, font);

    gui_stack_clear(&gui->stack);
    init_show(&gui->show, config, &gui->show_buffer, &gui->stack);
    init_control(&gui->control, config, &gui->control_buffer, &gui->stack);
    gui->show.hook.flags |= GUI_PANEL_HIDDEN;
}