/* SYNTAX: UNBAN -first | -last | <id> | <masks> */ static void cmd_unban(const char *data, IRC_SERVER_REC *server, void *item) { GHashTable *optlist; char *ban; void *free_arg; CMD_IRC_SERVER(server); if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | PARAM_FLAG_GETREST | PARAM_FLAG_STRIP_TRAILING_WS, "unban", &optlist, &ban)) return; ban = NULL; if (g_hash_table_lookup(optlist, "first") != NULL) ban = g_strdup(BAN_FIRST); else if (g_hash_table_lookup(optlist, "last") != NULL) ban = g_strdup(BAN_LAST); command_set_ban(ban ? ban : data, server, item, FALSE, 0); g_free(ban); cmd_params_free(free_arg); }
/* SYNTAX: BAN [-normal | -user | -host | -domain | -custom <type>] <nicks/masks> */ static void cmd_ban(const char *data, IRC_SERVER_REC *server, void *item) { GHashTable *optlist; const char *custom_type; char *ban; int ban_type; void *free_arg; CMD_IRC_SERVER(server); if (!cmd_get_params(data, &free_arg, 1 | PARAM_FLAG_OPTIONS | PARAM_FLAG_GETREST | PARAM_FLAG_STRIP_TRAILING_WS, "ban", &optlist, &ban)) return; if (g_hash_table_lookup(optlist, "normal") != NULL) ban_type = BAN_TYPE_NORMAL; else if (g_hash_table_lookup(optlist, "user") != NULL) ban_type = BAN_TYPE_USER; else if (g_hash_table_lookup(optlist, "host") != NULL) ban_type = BAN_TYPE_HOST; else if (g_hash_table_lookup(optlist, "domain") != NULL) ban_type = BAN_TYPE_DOMAIN; else { custom_type = g_hash_table_lookup(optlist, "custom"); if (custom_type != NULL) ban_type = parse_custom_ban(custom_type); else ban_type = default_ban_type; } command_set_ban(ban, server, item, TRUE, ban_type); cmd_params_free(free_arg); }
/* SYNTAX: UNBAN <masks> */ static void cmd_unban(const char *data, IRC_SERVER_REC *server, void *item) { command_set_ban(data, server, item, FALSE); }