#include <eggdrop/eggdrop.h>
#include <unistd.h>
Go to the source code of this file.
Data Structures | |
struct | socktimer_t |
Defines | |
#define | SOCKTIMER_LEVEL SOCKBUF_LEVEL_INTERNAL + 2 |
Functions | |
static int | socktimer_on_delete (void *client_data, int idx) |
static int | on_timer_delete (event_owner_t *owner, void *client_data) |
static int | timer_callback (void *client_data) |
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. | |
Variables | |
static const char | rcsid [] = "$Id: socktimer.c,v 1.1 2008-11-02 17:46:13 sven Exp $" |
static sockbuf_filter_t | socktimer_filter |
#define SOCKTIMER_LEVEL SOCKBUF_LEVEL_INTERNAL + 2 |
Definition at line 27 of file socktimer.c.
static int on_timer_delete | ( | event_owner_t * | owner, | |
void * | client_data | |||
) | [static] |
Definition at line 49 of file socktimer.c.
References socktimer_t::client_data, socktimer_t::idx, event_owner_b::on_delete, socktimer_t::original_owner, and socktimer_t::timerid.
Referenced by socktimer_on().
00050 { 00051 socktimer_t *data = client_data; 00052 00053 if (data->original_owner && data->original_owner->on_delete) { 00054 data->original_owner->on_delete(data->original_owner, data->client_data); 00055 } 00056 data->timerid = -1; 00057 if (data->idx <= 0) free(data); 00058 00059 return 0; 00060 }
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 }
static int socktimer_on_delete | ( | void * | client_data, | |
int | idx | |||
) | [static] |
Definition at line 39 of file socktimer.c.
References socktimer_t::idx, timer_destroy(), and socktimer_t::timerid.
00040 { 00041 socktimer_t *data = client_data; 00042 00043 data->idx = -1; 00044 if (data->timerid >= 0) timer_destroy(data->timerid); 00045 else free(data); 00046 return 0; 00047 }
static int timer_callback | ( | void * | client_data | ) | [static] |
Definition at line 62 of file socktimer.c.
References socktimer_t::Callback, socktimer_t::client_data, socktimer_t::idx, and sockbuf_delete().
Referenced by socktimer_on().
00063 { 00064 socktimer_t *data = client_data; 00065 00066 if (!data->Callback) { 00067 sockbuf_delete(data->idx); 00068 return 0; 00069 } 00070 00071 data->Callback(data->idx, data->client_data); 00072 return 0; 00073 }
const char rcsid[] = "$Id: socktimer.c,v 1.1 2008-11-02 17:46:13 sven Exp $" [static] |
Definition at line 21 of file socktimer.c.
sockbuf_filter_t socktimer_filter [static] |
Initial value:
{ "socktimer", SOCKTIMER_LEVEL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, socktimer_on_delete }
Definition at line 75 of file socktimer.c.