Exemplo n.º 1
0
engine_t create_engine()
{
	engine_t e = malloc(sizeof(*e));
	if(e)
	{
		e->mtx = mutex_create();
		e->status = 0;
		e->buffering_event_queue = LIST_CREATE();
		e->block_thread_queue = LIST_CREATE();
		e->Init = epoll_init;
		e->Loop = epoll_loop;
		e->Register = epoll_register;
		e->UnRegister = epoll_unregister;
	}
	return e;
}
Exemplo n.º 2
0
//初始化封包池
void init_wpacket_pool(uint32_t pool_size)
{
	uint32_t i = 0;
	wpacket_t w;// = calloc(1,sizeof(*w));
	g_wpacket_pool = LIST_CREATE();//创建包链表
	for( ; i < pool_size; ++i)
	{
		w = calloc(1,sizeof(*w));
		LIST_PUSH_BACK(g_wpacket_pool,w);
	}
}
Exemplo n.º 3
0
int main( int argc, char** argv) {

    if (argc < 2) return 0;

    if (strcmpi(argv[1], "parsing") == 0) {

        string_list arguments;
        trax_properties* properties;
        int input;
        int output = fileno(stdout);

        if (argc != 3) return 0;

        input = open(argv[2], O_RDONLY);

        LIST_CREATE(arguments, 8);
        properties = trax_properties_create();

        message_stream* stream = create_message_stream_file(input, output);

        while (1) {

            int type;

            LIST_RESET(arguments);
            trax_properties_clear(properties);

            type = read_message(stream, NULL, &arguments, properties);

            if (type == TRAX_ERROR) break;

            write_message(stream, NULL, type, arguments, properties); 

        }

        close(input);

        LIST_DESTROY(arguments);
        trax_properties_release(&properties);

        destroy_message_stream(&stream);

    }

}
Exemplo n.º 4
0
Arquivo: test.c Projeto: Petititi/trax
int main( int argc, char** argv) {

    if (argc < 2) return 0;

    if (strcmpi(argv[1], "parsing") == 0) {

        string_list arguments;
        trax_properties* properties;
        FILE* input;

        if (argc != 3) return 0;

        input = fopen(argv[2], "r");

        LIST_CREATE(arguments, 8);
        properties = trax_properties_create();

        while (1) {

            int type;

            LIST_RESET(arguments);
            trax_properties_clear(properties);

            type = read_message(input, NULL, &arguments, properties);

            if (type == TRAX_ERROR) break;

            write_message(stdout, NULL, type, arguments, properties); 

        }

        fclose(input);

        LIST_DESTROY(arguments);
        trax_properties_release(&properties);

    }

}