Ejemplo n.º 1
0
struct ub_event*
ub_signal_new(struct ub_event_base* base, int fd,
	void (*cb)(int, short, void*), void* arg)
{
	struct event *ev = (struct event*)calloc(1, sizeof(struct event));

	if (!ev)
		return NULL;

	signal_set(ev, fd, cb, arg);
	if (event_base_set(AS_EVENT_BASE(base), ev) != 0) {
		free(ev);
		return NULL;
	}
	return AS_UB_EVENT(ev);
}
Ejemplo n.º 2
0
struct ub_event*
ub_event_new(struct ub_event_base* base, int fd, short bits,
	void (*cb)(int, short, void*), void* arg)
{
	struct event *ev = (struct event*)calloc(1, sizeof(struct event));

	if (!ev)
		return NULL;

	event_set(ev, fd, NATIVE_BITS(bits), NATIVE_BITS_CB(cb), arg);
	if (event_base_set(AS_EVENT_BASE(base), ev) != 0) {
		free(ev);
		return NULL;
	}
	return AS_UB_EVENT(ev);
}
Ejemplo n.º 3
0
struct ub_event*
ub_winsock_register_wsaevent(struct ub_event_base* base, void* wsaevent,
	void (*cb)(int, short, void*), void* arg)
{
#if defined(USE_MINI_EVENT) && defined(USE_WINSOCK)
	struct event *ev = (struct event*)calloc(1, sizeof(struct event));

	if (!ev)
		return NULL;

	if (winsock_register_wsaevent(AS_EVENT_BASE(base), ev, wsaevent, cb,
				arg))
		return AS_UB_EVENT(ev);
	free(ev);
	return NULL;
#else
	(void)base;
	(void)wsaevent;
	(void)cb;
	(void)arg;
	return NULL;
#endif
}