Go to the source code of this file.
Typedefs | |
typedef int | ident_callback_t (void *client_data, const char *ip, int port, const char *ident) |
Functions | |
int | egg_ident_lookup (const char *ip, int their_port, int our_port, int timeout, ident_callback_t *callback, void *client_data, event_owner_t *owner) |
int | egg_ident_cancel (int id, int issue_callback) |
int | egg_ident_cancel_by_owner (struct egg_module *module, void *script) |
typedef int ident_callback_t(void *client_data, const char *ip, int port, const char *ident) |
int egg_ident_cancel | ( | int | id, | |
int | issue_callback | |||
) |
Definition at line 86 of file ident.c.
References _ident_info::callback, _ident_info::client_data, _ident_info::id, _ident_info::idx, _ident_info::ip, _ident_info::next, NULL, event_owner_b::on_delete, _ident_info::owner, sockbuf_delete(), and _ident_info::their_port.
Referenced by kill_session().
00087 { 00088 ident_info_t *ptr, *prev; 00089 00090 prev = NULL; 00091 for (ptr = ident_head; ptr; ptr = ptr->next) { 00092 if (ptr->id == id) break; 00093 prev = ptr; 00094 } 00095 if (!ptr) return(-1); 00096 if (prev) prev->next = ptr->next; 00097 else ident_head = ptr->next; 00098 sockbuf_delete(ptr->idx); 00099 if (issue_callback) { 00100 ptr->callback(ptr->client_data, ptr->ip, ptr->their_port, NULL); 00101 } 00102 if (ptr->owner && ptr->owner->on_delete) ptr->owner->on_delete(ptr->owner, ptr->client_data); 00103 free(ptr->ip); 00104 free(ptr); 00105 return(0); 00106 }
int egg_ident_cancel_by_owner | ( | struct egg_module * | module, | |
void * | script | |||
) |
Definition at line 108 of file ident.c.
References _ident_info::client_data, event_owner_b::client_data, _ident_info::idx, _ident_info::ip, event_owner_b::module, _ident_info::next, NULL, event_owner_b::on_delete, _ident_info::owner, and sockbuf_delete().
Referenced by script_remove_events_by_owner().
00109 { 00110 int removed = 0; 00111 ident_info_t *ptr, *prev = NULL, *next; 00112 00113 for (ptr = ident_head; ptr; ptr = next) { 00114 next = ptr->next; 00115 if (!ptr->owner || ptr->owner->module != module || (script && ptr->owner->client_data != script)) { 00116 prev = ptr; 00117 continue; 00118 } 00119 if (prev) prev->next = ptr->next; 00120 else ident_head = ptr->next; 00121 ++removed; 00122 sockbuf_delete(ptr->idx); 00123 if (ptr->owner && ptr->owner->on_delete) ptr->owner->on_delete(ptr->owner, ptr->client_data); 00124 free(ptr->ip); 00125 free(ptr); 00126 } 00127 return removed; 00128 }
int egg_ident_lookup | ( | const char * | ip, | |
int | their_port, | |||
int | our_port, | |||
int | timeout, | |||
ident_callback_t * | callback, | |||
void * | client_data, | |||
event_owner_t * | owner | |||
) |
Definition at line 57 of file ident.c.
References _ident_info::callback, _ident_info::client_data, egg_connect(), _ident_info::id, _ident_info::idx, _ident_info::ip, _ident_info::next, NULL, event_owner_b::on_delete, _ident_info::our_port, _ident_info::owner, sockbuf_set_handler(), _ident_info::their_port, and _ident_info::timeout.
Referenced by dcc_on_connect(), irc_on_newclient(), and telnet_on_newclient().
00058 { 00059 static int ident_id = 0; 00060 int idx; 00061 ident_info_t *ident_info; 00062 00063 idx = egg_connect(ip, 113, -1); 00064 if (idx < 0) { 00065 callback(client_data, ip, their_port, NULL); 00066 if (owner && owner->on_delete) owner->on_delete(owner, client_data); 00067 return(-1); 00068 } 00069 ident_info = calloc(1, sizeof(*ident_info)); 00070 ident_info->ip = strdup(ip); 00071 ident_info->their_port = their_port; 00072 ident_info->our_port = our_port; 00073 ident_info->timeout = timeout; 00074 ident_info->callback = callback; 00075 ident_info->client_data = client_data; 00076 ident_info->owner = owner; 00077 ident_info->idx = idx; 00078 ident_info->id = ident_id++; 00079 ident_info->next = ident_head; 00080 ident_head = ident_info; 00081 sockbuf_set_handler(idx, &ident_handler, ident_info, NULL); 00082 return(ident_info->id); 00083 }