| | 44 | | char *ban_get_mask(IRC_CHANNEL_REC *channel, const char *nick, int ban_type) | | | 45 | | { | | | 46 | | NICK_REC *rec; | | | 47 | | char *str, *user, *host; | | | 48 | | int size; | | | 49 | | | | | 50 | | g_return_val_if_fail(IS_IRC_CHANNEL(channel), NULL);
| | | 51 | | g_return_val_if_fail(nick != NULL, NULL);
| | | 52 | | | | | 53 | | rec = nicklist_find(CHANNEL(channel), nick);
| | | 54 | | if (rec == NULL) return NULL;
| | | 55 | | if (rec->host == NULL) {
| | | 56 | | g_warning("channel %s is not synced, using nick ban for %s", channel->name, nick);
| | | 57 | | return g_strdup_printf("%s!*@*", nick); | | | 58 | | } | | | 59 | | | | | 60 | | if (ban_type <= 0) | | | 61 | | ban_type = default_ban_type; | | | 62 | | |
| | 59 | | | | char *irc_get_mask(const char *nick, const char *address, int flags) | | | 60 | | | | { | | | 61 | | | | char *ret, *user, *host; | | | 62 | | | | | | | 63 | | | | | | | 64 | | | | user = g_strconcat("*", ishostflag(*address) ?
| | | 65 | | | | address+1 : address, NULL);
| | | 66 | | | | | | | 67 | | | | | | | 68 | | | | host = strchr(user, '@'); | | | 69 | | | | if (host == NULL) {
| | | 70 | | | | g_free(user); | | true | 71 | | | | return NULL;
| | | 72 | | | | } | | | 73 | | | | *host++ = '\0'; | | | 74 | | | | | | | 75 | | | | if (flags & IRC_MASK_HOST) {
| | | 76 | | | | | | | 77 | | | | } else if (flags & IRC_MASK_DOMAIN) {
| | | 78 | | | | | | | 79 | | | | host = get_domain_mask(host); | | | 80 | | | | } else { | | | 81 | | | | | | | 82 | | | | host = "*"; | | | 83 | | | | } | | | 84 | | | | | | | 85 | | | | ret = g_strdup_printf("%s!%s@%s", | | | 86 | | | | (flags & IRC_MASK_NICK) ? nick : "*",
| | | 87 | | | | (flags & IRC_MASK_USER) ? user : "*",
| | | 88 | | | | host); | | | 89 | | | | g_free(user); | | | 90 | | | | | | | 91 | | | | return ret; | | irc_get_mask$return <= 4095 | 92 | | | | } |
|