require '_h2ph_pre.ph';

no warnings 'redefine';

unless(defined(&_EVENT_H_)) {
    eval 'sub _EVENT_H_ () {1;}' unless defined(&_EVENT_H_);
    if(defined(&__cplusplus)) {
    }
    require 'stdarg.ph';
    if(defined(&WIN32)) {
	eval 'sub WIN32_LEAN_AND_MEAN () {1;}' unless defined(&WIN32_LEAN_AND_MEAN);
	require 'windows.ph';
	undef(&WIN32_LEAN_AND_MEAN) if defined(&WIN32_LEAN_AND_MEAN);
    }
    eval 'sub LIBEVENT_VERSION () {"1.1b";}' unless defined(&LIBEVENT_VERSION);
    eval 'sub EVLIST_TIMEOUT () {0x1;}' unless defined(&EVLIST_TIMEOUT);
    eval 'sub EVLIST_INSERTED () {0x2;}' unless defined(&EVLIST_INSERTED);
    eval 'sub EVLIST_SIGNAL () {0x4;}' unless defined(&EVLIST_SIGNAL);
    eval 'sub EVLIST_ACTIVE () {0x8;}' unless defined(&EVLIST_ACTIVE);
    eval 'sub EVLIST_INTERNAL () {0x10;}' unless defined(&EVLIST_INTERNAL);
    eval 'sub EVLIST_INIT () {0x80;}' unless defined(&EVLIST_INIT);
    eval 'sub EVLIST_ALL () {(0xf000 | 0x9f);}' unless defined(&EVLIST_ALL);
    eval 'sub EV_TIMEOUT () {0x1;}' unless defined(&EV_TIMEOUT);
    eval 'sub EV_READ () {0x2;}' unless defined(&EV_READ);
    eval 'sub EV_WRITE () {0x4;}' unless defined(&EV_WRITE);
    eval 'sub EV_SIGNAL () {0x8;}' unless defined(&EV_SIGNAL);
    eval 'sub EV_PERSIST () {0x10;}' unless defined(&EV_PERSIST);
    unless(defined(&TAILQ_ENTRY)) {
	eval 'sub _EVENT_DEFINED_TQENTRY () {1;}' unless defined(&_EVENT_DEFINED_TQENTRY);
	eval 'sub TAILQ_ENTRY {
	    my($type) = @_;
    	    eval q(\'struct struct\' { \'struct type\' * &tqe_next; \'struct type\' ** &tqe_prev; });
	}' unless defined(&TAILQ_ENTRY);
    }
    unless(defined(&RB_ENTRY)) {
	eval 'sub _EVENT_DEFINED_RBENTRY () {1;}' unless defined(&_EVENT_DEFINED_RBENTRY);
	eval 'sub RB_ENTRY {
	    my($type) = @_;
    	    eval q(\'struct struct\' { \'struct type\' * &rbe_left; \'struct type\' * &rbe_right; \'struct type\' * &rbe_parent; \'int\'  &rbe_color; });
	}' unless defined(&RB_ENTRY);
    }
    eval 'sub EVENT_SIGNAL {
        my($ev) = @_;
	    eval q( ($ev->{ev_fd}));
    }' unless defined(&EVENT_SIGNAL);
    eval 'sub EVENT_FD {
        my($ev) = @_;
	    eval q( ($ev->{ev_fd}));
    }' unless defined(&EVENT_FD);
    if(defined(&_EVENT_DEFINED_TQENTRY)) {
	undef(&TAILQ_ENTRY) if defined(&TAILQ_ENTRY);
	undef(&_EVENT_DEFINED_TQENTRY) if defined(&_EVENT_DEFINED_TQENTRY);
    } else {
    }
    if(defined(&_EVENT_DEFINED_RBENTRY)) {
	undef(&RB_ENTRY) if defined(&RB_ENTRY);
	undef(&_EVENT_DEFINED_RBENTRY) if defined(&_EVENT_DEFINED_RBENTRY);
    }
    eval 'sub TIMEOUT_DEFAULT () {{5, 0};}' unless defined(&TIMEOUT_DEFAULT);
    eval 'sub _EVENT_LOG_DEBUG () {0;}' unless defined(&_EVENT_LOG_DEBUG);
    eval 'sub _EVENT_LOG_MSG () {1;}' unless defined(&_EVENT_LOG_MSG);
    eval 'sub _EVENT_LOG_WARN () {2;}' unless defined(&_EVENT_LOG_WARN);
    eval 'sub _EVENT_LOG_ERR () {3;}' unless defined(&_EVENT_LOG_ERR);
    eval 'sub EVLOOP_ONCE () {0x1;}' unless defined(&EVLOOP_ONCE);
    eval 'sub EVLOOP_NONBLOCK () {0x2;}' unless defined(&EVLOOP_NONBLOCK);
    eval 'sub evtimer_add {
        my($ev, $tv) = @_;
	    eval q( &event_add($ev, $tv));
    }' unless defined(&evtimer_add);
    eval 'sub evtimer_set {
        my($ev, $cb, $arg) = @_;
	    eval q( &event_set($ev, -1, 0, $cb, $arg));
    }' unless defined(&evtimer_set);
    eval 'sub evtimer_del {
        my($ev) = @_;
	    eval q( &event_del($ev));
    }' unless defined(&evtimer_del);
    eval 'sub evtimer_pending {
        my($ev, $tv) = @_;
	    eval q( &event_pending($ev,  &EV_TIMEOUT, $tv));
    }' unless defined(&evtimer_pending);
    eval 'sub evtimer_initialized {
        my($ev) = @_;
	    eval q((($ev)-> &ev_flags &  &EVLIST_INIT));
    }' unless defined(&evtimer_initialized);
    eval 'sub signal_add {
        my($ev, $tv) = @_;
	    eval q( &event_add($ev, $tv));
    }' unless defined(&signal_add);
    eval 'sub signal_set {
        my($ev, $x, $cb, $arg) = @_;
	    eval q( &event_set($ev, $x,  &EV_SIGNAL| &EV_PERSIST, $cb, $arg));
    }' unless defined(&signal_set);
    eval 'sub signal_del {
        my($ev) = @_;
	    eval q( &event_del($ev));
    }' unless defined(&signal_del);
    eval 'sub signal_pending {
        my($ev, $tv) = @_;
	    eval q( &event_pending($ev,  &EV_SIGNAL, $tv));
    }' unless defined(&signal_pending);
    eval 'sub signal_initialized {
        my($ev) = @_;
	    eval q((($ev)-> &ev_flags &  &EVLIST_INIT));
    }' unless defined(&signal_initialized);
    if(defined(&WIN32)) {
	eval 'sub event_initialized {
	    my($ev) = @_;
    	    eval q((($ev)-> &ev_flags &  &EVLIST_INIT  && ($ev)-> &ev_fd !=  &INVALID_HANDLE_VALUE));
	}' unless defined(&event_initialized);
    } else {
	eval 'sub event_initialized {
	    my($ev) = @_;
    	    eval q((($ev)-> &ev_flags &  &EVLIST_INIT));
	}' unless defined(&event_initialized);
    }
    eval 'sub EVBUFFER_READ () {0x1;}' unless defined(&EVBUFFER_READ);
    eval 'sub EVBUFFER_WRITE () {0x2;}' unless defined(&EVBUFFER_WRITE);
    eval 'sub EVBUFFER_EOF () {0x10;}' unless defined(&EVBUFFER_EOF);
    eval 'sub EVBUFFER_ERROR () {0x20;}' unless defined(&EVBUFFER_ERROR);
    eval 'sub EVBUFFER_TIMEOUT () {0x40;}' unless defined(&EVBUFFER_TIMEOUT);
    eval 'sub EVBUFFER_LENGTH {
        my($x) = @_;
	    eval q(($x)-> &off);
    }' unless defined(&EVBUFFER_LENGTH);
    eval 'sub EVBUFFER_DATA {
        my($x) = @_;
	    eval q(($x)-> &buffer);
    }' unless defined(&EVBUFFER_DATA);
    eval 'sub EVBUFFER_INPUT {
        my($x) = @_;
	    eval q(($x)-> &input);
    }' unless defined(&EVBUFFER_INPUT);
    eval 'sub EVBUFFER_OUTPUT {
        my($x) = @_;
	    eval q(($x)-> &output);
    }' unless defined(&EVBUFFER_OUTPUT);
    if(defined(&__cplusplus)) {
    }
}
1;
