return err_nosuchchannel(client, args[0]), sendbuf(client), 0;
if (!trie_get(&chan->members, client->key))
return err_notonchannel(client, chan), sendbuf(client), 0;
- trie_set(&chan->o, client->key, client, NULL);
+ if (trie_set(&chan->o, client->key, client, NULL) == -1)
+ abort();
copy_strf(&databuf, ":cia!cia@cia.gov MODE %s +o %s\r\n", chan->name, client->nick);
sendbuf_chan(chan);
} else if(strcmp(command, "JOIN") == 0) {
return err_nosuchnick(client, args[0]), sendbuf(client), 0;
if (trie_get(&chan->members, cl->key))
return err_useronchannel(client, cl->nick, chan), sendbuf(client), 0;
- trie_set(&chan->invitees, cl->nick, cl, NULL);
- trie_set(&cl->invites, chan->name, chan, NULL);
+ if (trie_set(&chan->invitees, cl->nick, cl, NULL) == -1)
+ abort();
+ if (trie_set(&cl->invites, chan->name, chan, NULL) == -1)
+ abort();
rpl_inviting(client, cl, chan);
sendbuf(client);
msg_invite(client, cl, chan);
if (strchr(mask, ' '))
break; // TODO: error msg
stringlower(mask);
- trie_set(list, mask, is_plus ? mask /* dummy */ : NULL, NULL);
+ if (trie_set(list, mask, is_plus ? mask /* dummy */ : NULL, NULL) == -1)
+ abort();
char which[2] = {*p, 0};
copy_strf(&databuf, ":%s!%s@%s MODE %s %s%s %s\r\n",
client->nick, client->username, client->hostname,
err_usernotinchannel(client, cl->nick, chan), sendbuf(client);
break;
}
- trie_set(*p == 'o' ? &chan->o : &chan->v, cl->key, is_plus ? cl : NULL, NULL);
+ if (trie_set(*p == 'o' ? &chan->o : &chan->v, cl->key, is_plus ? cl : NULL, NULL) == -1)
+ abort();
copy_strf(&databuf, ":%s!%s@%s MODE %s %s%s %s\r\n",
client->nick, client->username, client->hostname,
chan->name, is_plus?"+":"-", which, cl->nick);
msg_nick(client, nickname);
sendbuf(client);
sendbuf_visible(client);
- trie_set(&client_map, client->key, NULL, NULL);
+ trie_unset(&client_map, client->key, NULL);
struct trie_find *f = NULL;
if (trie_findfirst(&f, &client->channels) == 1)
do {
struct channel *chan = f->n->value;
- trie_set(&chan->members, client->key, NULL, NULL);
- trie_set(&chan->members, key, client, NULL);
+ trie_unset(&chan->members, client->key, NULL);
+ if (trie_set(&chan->members, key, client, NULL) == -1)
+ abort();
void *old;
- trie_set(&chan->o, client->key, NULL, &old);
+ trie_unset(&chan->o, client->key, &old);
if (old)
- trie_set(&chan->o, key, client, NULL);
- trie_set(&chan->v, client->key, NULL, &old);
+ if (trie_set(&chan->o, key, client, NULL) == -1)
+ abort();
+ trie_unset(&chan->v, client->key, &old);
if (old)
- trie_set(&chan->v, key, client, NULL);
+ if (trie_set(&chan->v, key, client, NULL) == -1)
+ abort();
} while(trie_findnext(&f) == 1);
free(client->nick);
free(client->key);
msg_part(client, chan, *reason ? reason : NULL);
sendbuf_chan(chan);
}
- trie_set(&client->channels, chan->key, NULL, NULL);
- trie_set(&chan->members, client->key, NULL, NULL);
- trie_set(&chan->o, client->key, NULL, NULL);
- trie_set(&chan->v, client->key, NULL, NULL);
+ trie_unset(&client->channels, chan->key, NULL);
+ trie_unset(&chan->members, client->key, NULL);
+ trie_unset(&chan->o, client->key, NULL);
+ trie_unset(&chan->v, client->key, NULL);
chan->member_count--;
if (!chan->member_count && !(chan->dmode & DMODE_PERSIST))
channel_kill(chan);
}
void channel_kill(struct channel *chan)
{
- trie_set(&channel_map, chan->key, NULL, NULL);
+ trie_unset(&channel_map, chan->key, NULL);
struct trie_find *f = NULL;
if (trie_findfirst(&f, &chan->invitees) == 1)
do {
struct client_data *cl = f->n->value;
- trie_set(&cl->invites, chan->key, NULL, NULL);
+ trie_unset(&cl->invites, chan->key, NULL);
} while(trie_findnext(&f) == 1);
free(chan->key);
free(chan->name);