kike: introduce cstr_set()
This commit is contained in:
parent
4586b0e1e4
commit
670e1c5770
35
kike.c
35
kike.c
|
@ -901,8 +901,7 @@ client_unregister (struct client *c, const char *reason)
|
||||||
client_add_to_whowas (c);
|
client_add_to_whowas (c);
|
||||||
|
|
||||||
str_map_set (&c->ctx->users, c->nickname, NULL);
|
str_map_set (&c->ctx->users, c->nickname, NULL);
|
||||||
free (c->nickname);
|
cstr_set (&c->nickname, NULL);
|
||||||
c->nickname = NULL;
|
|
||||||
c->registered = false;
|
c->registered = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1442,11 +1441,9 @@ irc_handle_nick (const struct irc_message *msg, struct client *c)
|
||||||
|
|
||||||
// Release the old nickname and allocate a new one
|
// Release the old nickname and allocate a new one
|
||||||
if (c->nickname)
|
if (c->nickname)
|
||||||
{
|
|
||||||
str_map_set (&ctx->users, c->nickname, NULL);
|
str_map_set (&ctx->users, c->nickname, NULL);
|
||||||
free (c->nickname);
|
|
||||||
}
|
cstr_set (&c->nickname, xstrdup (nickname));
|
||||||
c->nickname = xstrdup (nickname);
|
|
||||||
str_map_set (&ctx->users, nickname, c);
|
str_map_set (&ctx->users, nickname, c);
|
||||||
|
|
||||||
if (!c->registered)
|
if (!c->registered)
|
||||||
|
@ -1469,10 +1466,8 @@ irc_handle_user (const struct irc_message *msg, struct client *c)
|
||||||
if (!irc_is_valid_user (username))
|
if (!irc_is_valid_user (username))
|
||||||
username = "xxx";
|
username = "xxx";
|
||||||
|
|
||||||
free (c->username);
|
cstr_set (&c->username, xstrdup (username));
|
||||||
c->username = xstrdup (username);
|
cstr_set (&c->realname, xstrdup (realname));
|
||||||
free (c->realname);
|
|
||||||
c->realname = xstrdup (realname);
|
|
||||||
|
|
||||||
unsigned long m;
|
unsigned long m;
|
||||||
if (xstrtoul (&m, mode, 10))
|
if (xstrtoul (&m, mode, 10))
|
||||||
|
@ -1872,8 +1867,7 @@ mode_processor_do_key (struct mode_processor *self)
|
||||||
|
|
||||||
str_append_c (&self->removed, self->mode_char);
|
str_append_c (&self->removed, self->mode_char);
|
||||||
strv_append (&self->removed_params, self->channel->key);
|
strv_append (&self->removed_params, self->channel->key);
|
||||||
free (self->channel->key);
|
cstr_set (&self->channel->key, NULL);
|
||||||
self->channel->key = NULL;
|
|
||||||
}
|
}
|
||||||
else if (!irc_is_valid_key (target))
|
else if (!irc_is_valid_key (target))
|
||||||
// TODO: we should notify the user somehow
|
// TODO: we should notify the user somehow
|
||||||
|
@ -2532,11 +2526,9 @@ irc_handle_topic (const struct irc_message *msg, struct client *c)
|
||||||
&& !(user->modes & IRC_CHAN_MODE_OPERATOR))
|
&& !(user->modes & IRC_CHAN_MODE_OPERATOR))
|
||||||
RETURN_WITH_REPLY (c, IRC_ERR_CHANOPRIVSNEEDED, target);
|
RETURN_WITH_REPLY (c, IRC_ERR_CHANOPRIVSNEEDED, target);
|
||||||
|
|
||||||
free (chan->topic);
|
cstr_set (&chan->topic, xstrdup (msg->params.vector[1]));
|
||||||
free (chan->topic_who);
|
cstr_set (&chan->topic_who, xstrdup_printf
|
||||||
chan->topic = xstrdup (msg->params.vector[1]);
|
("%s!%s@%s", c->nickname, c->username, c->hostname));
|
||||||
chan->topic_who = xstrdup_printf
|
|
||||||
("%s!%s@%s", c->nickname, c->username, c->hostname);
|
|
||||||
chan->topic_time = time (NULL);
|
chan->topic_time = time (NULL);
|
||||||
|
|
||||||
char *message = xstrdup_printf (":%s!%s@%s TOPIC %s :%s",
|
char *message = xstrdup_printf (":%s!%s@%s TOPIC %s :%s",
|
||||||
|
@ -2800,14 +2792,12 @@ irc_handle_away (const struct irc_message *msg, struct client *c)
|
||||||
{
|
{
|
||||||
if (msg->params.len < 1)
|
if (msg->params.len < 1)
|
||||||
{
|
{
|
||||||
free (c->away_message);
|
cstr_set (&c->away_message, NULL);
|
||||||
c->away_message = NULL;
|
|
||||||
irc_send_reply (c, IRC_RPL_UNAWAY);
|
irc_send_reply (c, IRC_RPL_UNAWAY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
free (c->away_message);
|
cstr_set (&c->away_message, xstrdup (msg->params.vector[0]));
|
||||||
c->away_message = xstrdup (msg->params.vector[0]);
|
|
||||||
irc_send_reply (c, IRC_RPL_NOWAWAY);
|
irc_send_reply (c, IRC_RPL_NOWAWAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3362,8 +3352,7 @@ on_client_gni_resolved (int result, char *host, char *port, void *user_data)
|
||||||
print_debug ("%s: %s", "getnameinfo", gai_strerror (result));
|
print_debug ("%s: %s", "getnameinfo", gai_strerror (result));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
free (c->hostname);
|
cstr_set (&c->hostname, xstrdup (host));
|
||||||
c->hostname = xstrdup (host);
|
|
||||||
(void) port;
|
(void) port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue