Go to the source code of this file.
Functions | |
int | socktimer_on (int idx, int timeout, int flags, void(*Callback)(int idx, void *cd), void *client_data, event_owner_t *owner) |
Turns linebuffering on an index on. | |
int | socktimer_off (int idx) |
Turns linebuffering on an index off. | |
int | socktimer_check (int idx) |
Checks if an index is in linebuffered mode. |
int socktimer_check | ( | int | idx | ) |
Checks if an index is in linebuffered mode.
idx | the index to check |
Definition at line 148 of file socktimer.c.
References sockbuf_get_filter_data(), and sockbuf_isvalid().
00149 { 00150 if (!sockbuf_isvalid(idx)) return -1; 00151 return !sockbuf_get_filter_data(idx, &socktimer_filter, 0); 00152 }
int socktimer_off | ( | int | idx | ) |
Turns linebuffering on an index off.
If there if a line currently buffered it's send of immidiatly.
idx | the index to turn off linebuffering for |
Definition at line 125 of file socktimer.c.
References sockbuf_detach_filter(), timer_destroy(), and socktimer_t::timerid.
Referenced by dcc_on_read(), irc_on_read(), and telnet_on_read().
00126 { 00127 int ret; 00128 socktimer_t *data; 00129 00130 ret = sockbuf_detach_filter(idx, &socktimer_filter, &data); 00131 if (ret) return ret; 00132 if (data) { 00133 if (data->timerid >= 0) { 00134 timer_destroy(data->timerid); 00135 } 00136 free(data); 00137 } 00138 return 0; 00139 }
int socktimer_on | ( | int | idx, | |
int | timeout, | |||
int | flags, | |||
void(*)(int idx, void *cd) | Callback, | |||
void * | client_data, | |||
event_owner_t * | owner | |||
) |
Turns linebuffering on an index on.
idx | the index to turn on linebuffering for |
Definition at line 90 of file socktimer.c.
References socktimer_t::Callback, socktimer_t::client_data, socktimer_t::idx, socktimer_t::new_owner, event_owner_b::on_delete, on_timer_delete(), socktimer_t::original_owner, sockbuf_attach_filter(), sockbuf_get_filter_data(), sockbuf_isvalid(), timer_callback(), timer_create_complex(), timer_destroy(), socktimer_t::timerflags, and socktimer_t::timerid.
Referenced by do_link(), got_chat_request(), got_version(), idx_on_newclient(), irc_on_newclient(), recving_login(), sending_login(), and telnet_on_newclient().
00091 { 00092 egg_timeval_t timeval = {timeout, 0}; 00093 socktimer_t *data; 00094 00095 if (!sockbuf_isvalid(idx)) return -1; 00096 if (!Callback) flags = 0; 00097 if (!sockbuf_get_filter_data(idx, &socktimer_filter, &data)) { 00098 if (data->timerid >= 0) timer_destroy(data->timerid); 00099 } else { 00100 data = malloc(sizeof(*data)); 00101 sockbuf_attach_filter(idx, &socktimer_filter, data); 00102 } 00103 00104 data->idx = idx; 00105 data->timerflags = flags; 00106 data->Callback = Callback; 00107 data->client_data = client_data; 00108 data->original_owner = owner; 00109 data->new_owner = *owner; 00110 data->new_owner.on_delete = on_timer_delete; 00111 data->timerid = timer_create_complex(&timeval, "socktimer", timer_callback, data, flags, &data->new_owner); 00112 00113 return 0; 00114 }