static GET_DCC_REC *dcc_get_create(IRC_SERVER_REC *server, CHAT_DCC_REC *chat, const char *nick, const char *arg) { GET_DCC_REC *dcc; dcc = g_new0(GET_DCC_REC, 1); dcc->orig_type = module_get_uniq_id_str("DCC", "SEND"); dcc->type = module_get_uniq_id_str("DCC", "GET"); dcc->fhandle = -1; dcc_init_rec(DCC(dcc), server, chat, nick, arg); return dcc; }
void query_init(QUERY_REC *query, int automatic) { g_return_if_fail(query != NULL); g_return_if_fail(query->name != NULL); queries = g_slist_append(queries, query); MODULE_DATA_INIT(query); query->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "QUERY"); query->destroy = (void (*) (WI_ITEM_REC *)) query_destroy; query->get_target = query_get_target; query->createtime = time(NULL); query->last_unread_msg = time(NULL); query->visible_name = g_strdup(query->name); if (query->server_tag != NULL) { query->server = server_find_tag(query->server_tag); if (query->server != NULL) { query->server->queries = g_slist_append(query->server->queries, query); } } signal_emit("query created", 2, query, GINT_TO_POINTER(automatic)); }
void channel_init(CHANNEL_REC *channel, SERVER_REC *server, const char *name, const char *visible_name, int automatic) { g_return_if_fail(channel != NULL); g_return_if_fail(name != NULL); g_return_if_fail(server != NULL); if (visible_name == NULL) visible_name = name; MODULE_DATA_INIT(channel); channel->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "CHANNEL"); channel->destroy = (void (*) (WI_ITEM_REC *)) channel_destroy; channel->get_target = channel_get_target; channel->get_join_data = get_join_data; channel->chat_type = server->chat_type; channel->server = server; channel->name = g_strdup(name); channel->visible_name = g_strdup(visible_name); channel->mode = g_strdup(""); channel->createtime = time(NULL); channels = g_slist_append(channels, channel); server->channels = g_slist_append(server->channels, channel); signal_emit("channel created", 2, channel, GINT_TO_POINTER(automatic)); }
static void perl_signal_to(const char *signal, const char *func, int last) { PERL_SIGNAL_REC *rec; GHashTable *table; GSList *siglist; void *signal_idp; if (perl_signal_find(signal, func, last)) return; rec = g_new(PERL_SIGNAL_REC, 1); rec->signal_id = module_get_uniq_id_str("signals", signal); rec->signal = g_strdup(signal); rec->func = g_strdup(func); rec->last = last; table = last ? last_signals : first_signals; signal_idp = GINT_TO_POINTER(rec->signal_id); siglist = g_hash_table_lookup(table, signal_idp); if (siglist != NULL) g_hash_table_remove(table, signal_idp); siglist = g_slist_append(siglist, rec); g_hash_table_insert(table, signal_idp, siglist); if (!last && !signal_grabbed) { signal_grabbed = TRUE; signal_add("signal", (SIGNAL_FUNC) sig_signal); } else if (last && !siglast_grabbed) { siglast_grabbed = TRUE; signal_add("last signal", (SIGNAL_FUNC) sig_lastsignal); } }
int dcc_str2type(const char *str) { if (gslist_find_string(dcc_types, str) == NULL) return -1; return module_get_uniq_id_str("DCC", str); }
void perl_signal_remove(const char *signal, const char *func) { GSList *list; int signal_id; signal_id = module_get_uniq_id_str("signals", signal); list = g_hash_table_lookup(first_signals, GINT_TO_POINTER(signal_id)); if (list != NULL) perl_signal_remove_list(list, func); else { list = g_hash_table_lookup(last_signals, GINT_TO_POINTER(signal_id)); if (list != NULL) perl_signal_remove_list(list, func); } }
void channel_init(CHANNEL_REC *channel, int automatic) { g_return_if_fail(channel != NULL); g_return_if_fail(channel->name != NULL); channels = g_slist_append(channels, channel); if (channel->server != NULL) { channel->server->channels = g_slist_append(channel->server->channels, channel); } MODULE_DATA_INIT(channel); channel->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "CHANNEL"); channel->mode = g_strdup(""); channel->createtime = time(NULL); signal_emit("channel created", 2, channel, GINT_TO_POINTER(automatic)); }
void query_init(QUERY_REC *query, int automatic) { g_return_if_fail(query != NULL); g_return_if_fail(query->name != NULL); queries = g_slist_append(queries, query); MODULE_DATA_INIT(query); query->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "QUERY"); if (query->server_tag != NULL) { query->server = server_find_tag(query->server_tag); if (query->server != NULL) { query->server->queries = g_slist_append(query->server->queries, query); } } signal_emit("query created", 2, query, GINT_TO_POINTER(automatic)); }
static EXEC_WI_REC *exec_wi_create(WINDOW_REC *window, PROCESS_REC *rec) { EXEC_WI_REC *item; g_return_val_if_fail(window != NULL, NULL); g_return_val_if_fail(rec != NULL, NULL); item = g_new0(EXEC_WI_REC, 1); item->type = module_get_uniq_id_str("WINDOW ITEM TYPE", "EXEC"); item->destroy = (void (*) (WI_ITEM_REC *)) exec_wi_destroy; item->get_target = exec_get_target; item->visible_name = rec->name != NULL ? g_strdup(rec->name) : g_strdup_printf("%%%d", rec->id); item->createtime = time(NULL); item->process = rec; MODULE_DATA_INIT(item); window_item_add(window, (WI_ITEM_REC *) item, FALSE); return item; }
static int perl_signal_find(const char *signal, const char *func, int last) { GHashTable *table; GSList *siglist; int signal_id; table = last ? last_signals : first_signals; signal_id = module_get_uniq_id_str("signals", signal); siglist = g_hash_table_lookup(table, GINT_TO_POINTER(signal_id)); while (siglist != NULL) { PERL_SIGNAL_REC *rec = siglist->data; if (strcmp(rec->func, func) == 0) return TRUE; siglist = siglist->next; } return FALSE; }