summaryrefslogtreecommitdiff
path: root/kike.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-01-23 23:50:27 +0100
committerPřemysl Janouch <p.janouch@gmail.com>2017-01-23 23:50:27 +0100
commit9e5725662f944fe437be7ba1b54acbc5fc18dbe1 (patch)
treee5daa605b91dce014582f35fe0330287c1867775 /kike.c
parent0785a6f417d3a6e43d2d72132e550d517af41bc4 (diff)
downloadxK-9e5725662f944fe437be7ba1b54acbc5fc18dbe1.tar.gz
xK-9e5725662f944fe437be7ba1b54acbc5fc18dbe1.tar.xz
xK-9e5725662f944fe437be7ba1b54acbc5fc18dbe1.zip
Bump liberty
Diffstat (limited to 'kike.c')
-rw-r--r--kike.c170
1 files changed, 85 insertions, 85 deletions
diff --git a/kike.c b/kike.c
index aba5bba..4772c29 100644
--- a/kike.c
+++ b/kike.c
@@ -456,9 +456,9 @@ struct channel
struct channel_user *users; ///< Channel users
- struct str_vector ban_list; ///< Ban list
- struct str_vector exception_list; ///< Exceptions from bans
- struct str_vector invite_list; ///< Exceptions from +I
+ struct strv ban_list; ///< Ban list
+ struct strv exception_list; ///< Exceptions from bans
+ struct strv invite_list; ///< Exceptions from +I
};
static struct channel *
@@ -469,9 +469,9 @@ channel_new (void)
self->user_limit = -1;
self->topic = xstrdup ("");
- str_vector_init (&self->ban_list);
- str_vector_init (&self->exception_list);
- str_vector_init (&self->invite_list);
+ strv_init (&self->ban_list);
+ strv_init (&self->exception_list);
+ strv_init (&self->invite_list);
return self;
}
@@ -490,9 +490,9 @@ channel_delete (struct channel *self)
free (link);
}
- str_vector_free (&self->ban_list);
- str_vector_free (&self->exception_list);
- str_vector_free (&self->invite_list);
+ strv_free (&self->ban_list);
+ strv_free (&self->exception_list);
+ strv_free (&self->invite_list);
free (self);
}
@@ -633,7 +633,7 @@ struct server_context
char *server_name; ///< Our server name
unsigned ping_interval; ///< Ping interval in seconds
unsigned max_connections; ///< Max. connections allowed or 0
- struct str_vector motd; ///< MOTD (none if empty)
+ struct strv motd; ///< MOTD (none if empty)
nl_catd catalog; ///< Message catalog for server msgs
struct str_map operators; ///< TLS cert. fingerprints for IRCops
};
@@ -679,7 +679,7 @@ server_context_init (struct server_context *self)
self->config.free = free;
simple_config_load_defaults (&self->config, g_config_table);
- str_vector_init (&self->motd);
+ strv_init (&self->motd);
self->catalog = (nl_catd) -1;
str_map_init (&self->operators);
// The regular irc_strxfrm() is sufficient for fingerprints
@@ -712,7 +712,7 @@ server_context_free (struct server_context *self)
str_map_free (&self->whowas);
poller_free (&self->poller);
- str_vector_free (&self->motd);
+ strv_free (&self->motd);
if (self->catalog != (nl_catd) -1)
catclose (self->catalog);
str_map_free (&self->operators);
@@ -972,7 +972,7 @@ client_close_link (struct client *c, const char *reason)
}
static bool
-client_in_mask_list (const struct client *c, const struct str_vector *mask)
+client_in_mask_list (const struct client *c, const struct strv *mask)
{
char *client = xstrdup_printf ("%s!%s@%s",
c->nickname, c->username, c->hostname);
@@ -1250,7 +1250,7 @@ struct irc_cap_args
{
const char *subcommand; ///< The subcommand being processed
const char *full_params; ///< Whole parameter string
- struct str_vector params; ///< Split parameters
+ struct strv params; ///< Split parameters
const char *target; ///< Target parameter for replies
};
@@ -1284,15 +1284,15 @@ irc_handle_cap_ls (struct client *c, struct irc_cap_args *a)
static void
irc_handle_cap_list (struct client *c, struct irc_cap_args *a)
{
- struct str_vector caps;
- str_vector_init (&caps);
+ struct strv caps;
+ strv_init (&caps);
for (size_t i = 0; i < N_ELEMENTS (irc_cap_table); i++)
if (c->caps_enabled & irc_cap_table[i].flag)
- str_vector_add (&caps, irc_cap_table[i].name);
+ strv_append (&caps, irc_cap_table[i].name);
- char *caps_str = join_str_vector (&caps, ' ');
- str_vector_free (&caps);
+ char *caps_str = strv_join (&caps, " ");
+ strv_free (&caps);
client_send (c, ":%s CAP %s LIST :%s",
c->ctx->server_name, a->target, caps_str);
free (caps_str);
@@ -1398,7 +1398,7 @@ irc_handle_cap (const struct irc_message *msg, struct client *c)
args.target = c->nickname ? c->nickname : "*";
args.subcommand = msg->params.vector[0];
args.full_params = "";
- str_vector_init (&args.params);
+ strv_init (&args.params);
if (msg->params.len > 1)
{
@@ -1414,7 +1414,7 @@ irc_handle_cap (const struct irc_message *msg, struct client *c)
else
cmd->handler (c, &args);
- str_vector_free (&args.params);
+ strv_free (&args.params);
}
static void
@@ -1699,7 +1699,7 @@ irc_handle_user_mode_change (struct client *c, const char *mode_string)
static void
irc_send_channel_list (struct client *c, const char *channel_name,
- const struct str_vector *list, int reply, int end_reply)
+ const struct strv *list, int reply, int end_reply)
{
for (size_t i = 0; i < list->len; i++)
irc_send_reply (c, reply, channel_name, list->vector[i]);
@@ -1751,11 +1751,11 @@ struct mode_processor
struct str added; ///< Added modes
struct str removed; ///< Removed modes
- struct str_vector added_params; ///< Params for added modes
- struct str_vector removed_params; ///< Params for removed modes
+ struct strv added_params; ///< Params for added modes
+ struct strv removed_params; ///< Params for removed modes
struct str *output; ///< "added" or "removed"
- struct str_vector *output_params; ///< Similarly for "*_params"
+ struct strv *output_params; ///< Similarly for "*_params"
};
static void
@@ -1766,8 +1766,8 @@ mode_processor_init (struct mode_processor *self)
str_init (&self->added);
str_init (&self->removed);
- str_vector_init (&self->added_params);
- str_vector_init (&self->removed_params);
+ strv_init (&self->added_params);
+ strv_init (&self->removed_params);
}
static void
@@ -1776,8 +1776,8 @@ mode_processor_free (struct mode_processor *self)
str_free (&self->added);
str_free (&self->removed);
- str_vector_free (&self->added_params);
- str_vector_free (&self->removed_params);
+ strv_free (&self->added_params);
+ strv_free (&self->removed_params);
}
static const char *
@@ -1816,7 +1816,7 @@ mode_processor_do_user (struct mode_processor *self, int mode)
else if (irc_modify_mode (&target_user->modes, mode, self->adding))
{
str_append_c (self->output, self->mode_char);
- str_vector_add (self->output_params, client->nickname);
+ strv_append (self->output_params, client->nickname);
}
}
@@ -1842,7 +1842,7 @@ mode_processor_do_chan_remove
static void
mode_processor_do_list (struct mode_processor *self,
- struct str_vector *list, int list_msg, int end_msg)
+ struct strv *list, int list_msg, int end_msg)
{
const char *target = mode_processor_next_param (self);
if (!target)
@@ -1869,12 +1869,12 @@ mode_processor_do_list (struct mode_processor *self,
if ((found ^ self->adding))
{
if (self->adding)
- str_vector_add (list, mask);
+ strv_append (list, mask);
else
- str_vector_remove (list, i);
+ strv_remove (list, i);
str_append_c (self->output, self->mode_char);
- str_vector_add (self->output_params, mask);
+ strv_append (self->output_params, mask);
}
free (mask);
}
@@ -1892,7 +1892,7 @@ mode_processor_do_key (struct mode_processor *self)
return;
str_append_c (&self->removed, self->mode_char);
- str_vector_add (&self->removed_params, self->channel->key);
+ strv_append (&self->removed_params, self->channel->key);
free (self->channel->key);
self->channel->key = NULL;
}
@@ -1905,7 +1905,7 @@ mode_processor_do_key (struct mode_processor *self)
{
self->channel->key = xstrdup (target);
str_append_c (&self->added, self->mode_char);
- str_vector_add (&self->added_params, self->channel->key);
+ strv_append (&self->added_params, self->channel->key);
}
}
@@ -1931,7 +1931,7 @@ mode_processor_do_limit (struct mode_processor *self)
{
self->channel->user_limit = x;
str_append_c (&self->added, self->mode_char);
- str_vector_add (&self->added_params, target);
+ strv_append (&self->added_params, target);
}
}
}
@@ -2184,15 +2184,15 @@ irc_handle_list (const struct irc_message *msg, struct client *c)
}
else
{
- struct str_vector channels;
- str_vector_init (&channels);
+ struct strv channels;
+ strv_init (&channels);
cstr_split (msg->params.vector[0], ",", true, &channels);
for (size_t i = 0; i < channels.len; i++)
if ((chan = str_map_find (&c->ctx->channels, channels.vector[i]))
&& (!(chan->modes & IRC_CHAN_MODE_SECRET)
|| channel_get_user (chan, c)))
irc_send_rpl_list (c, chan);
- str_vector_free (&channels);
+ strv_free (&channels);
}
irc_send_reply (c, IRC_RPL_LISTEND);
}
@@ -2238,8 +2238,8 @@ static void
irc_send_rpl_namreply (struct client *c, const struct channel *chan,
struct str_map *used_nicks)
{
- struct str_vector nicks;
- str_vector_init (&nicks);
+ struct strv nicks;
+ strv_init (&nicks);
char type = '=';
if (chan->modes & IRC_CHAN_MODE_SECRET)
@@ -2254,20 +2254,20 @@ irc_send_rpl_namreply (struct client *c, const struct channel *chan,
continue;
if (used_nicks)
str_map_set (used_nicks, iter->c->nickname, (void *) 1);
- str_vector_add_owned (&nicks,
+ strv_append_owned (&nicks,
irc_make_rpl_namreply_item (c, iter->c, iter));
}
irc_send_reply_vector (c, IRC_RPL_NAMREPLY,
nicks.vector, type, chan->name, "");
- str_vector_free (&nicks);
+ strv_free (&nicks);
}
static void
irc_send_disassociated_names (struct client *c, struct str_map *used)
{
- struct str_vector nicks;
- str_vector_init (&nicks);
+ struct strv nicks;
+ strv_init (&nicks);
struct str_map_iter iter;
str_map_iter_init (&iter, &c->ctx->users);
@@ -2277,14 +2277,14 @@ irc_send_disassociated_names (struct client *c, struct str_map *used)
if ((target->mode & IRC_USER_MODE_INVISIBLE)
|| str_map_find (used, target->nickname))
continue;
- str_vector_add_owned (&nicks,
+ strv_append_owned (&nicks,
irc_make_rpl_namreply_item (c, target, NULL));
}
if (nicks.len)
irc_send_reply_vector (c, IRC_RPL_NAMREPLY,
nicks.vector, '*', "*", "");
- str_vector_free (&nicks);
+ strv_free (&nicks);
}
static void
@@ -2315,8 +2315,8 @@ irc_handle_names (const struct irc_message *msg, struct client *c)
}
else
{
- struct str_vector channels;
- str_vector_init (&channels);
+ struct strv channels;
+ strv_init (&channels);
cstr_split (msg->params.vector[0], ",", true, &channels);
for (size_t i = 0; i < channels.len; i++)
if ((chan = str_map_find (&c->ctx->channels, channels.vector[i]))
@@ -2326,7 +2326,7 @@ irc_handle_names (const struct irc_message *msg, struct client *c)
irc_send_rpl_namreply (c, chan, NULL);
irc_send_reply (c, IRC_RPL_ENDOFNAMES, channels.vector[i]);
}
- str_vector_free (&channels);
+ strv_free (&channels);
}
}
@@ -2441,8 +2441,8 @@ irc_send_whois_reply (struct client *c, const struct client *target)
if (target->away_message)
irc_send_reply (c, IRC_RPL_AWAY, nick, target->away_message);
- struct str_vector channels;
- str_vector_init (&channels);
+ struct strv channels;
+ strv_init (&channels);
struct str_map_iter iter;
str_map_iter_init (&iter, &c->ctx->channels);
@@ -2460,11 +2460,11 @@ irc_send_whois_reply (struct client *c, const struct client *target)
else if (channel_user->modes & IRC_CHAN_MODE_VOICE)
str_append_c (&item, '+');
str_append (&item, chan->name);
- str_vector_add_owned (&channels, str_steal (&item));
+ strv_append_owned (&channels, str_steal (&item));
}
irc_send_reply_vector (c, IRC_RPL_WHOISCHANNELS, channels.vector, nick, "");
- str_vector_free (&channels);
+ strv_free (&channels);
irc_send_reply (c, IRC_RPL_ENDOFWHOIS, nick);
}
@@ -2477,8 +2477,8 @@ irc_handle_whois (const struct irc_message *msg, struct client *c)
if (msg->params.len > 1 && !irc_is_this_me (c->ctx, msg->params.vector[0]))
RETURN_WITH_REPLY (c, IRC_ERR_NOSUCHSERVER, msg->params.vector[0]);
- struct str_vector masks;
- str_vector_init (&masks);
+ struct strv masks;
+ strv_init (&masks);
const char *masks_str = msg->params.vector[msg->params.len > 1];
cstr_split (masks_str, ",", true, &masks);
for (size_t i = 0; i < masks.len; i++)
@@ -2507,7 +2507,7 @@ irc_handle_whois (const struct irc_message *msg, struct client *c)
irc_send_reply (c, IRC_ERR_NOSUCHNICK, mask);
}
}
- str_vector_free (&masks);
+ strv_free (&masks);
}
static void
@@ -2519,8 +2519,8 @@ irc_handle_whowas (const struct irc_message *msg, struct client *c)
RETURN_WITH_REPLY (c, IRC_ERR_NOSUCHSERVER, msg->params.vector[2]);
// The "count" parameter is ignored, we only store one entry for a nick
- struct str_vector nicks;
- str_vector_init (&nicks);
+ struct strv nicks;
+ strv_init (&nicks);
cstr_split (msg->params.vector[0], ",", true, &nicks);
for (size_t i = 0; i < nicks.len; i++)
@@ -2538,7 +2538,7 @@ irc_handle_whowas (const struct irc_message *msg, struct client *c)
}
irc_send_reply (c, IRC_RPL_ENDOFWHOWAS, nick);
}
- str_vector_free (&nicks);
+ strv_free (&nicks);
}
static void
@@ -2639,12 +2639,12 @@ irc_handle_part (const struct irc_message *msg, struct client *c)
RETURN_WITH_REPLY (c, IRC_ERR_NEEDMOREPARAMS, msg->command);
const char *reason = msg->params.len > 1 ? msg->params.vector[1] : NULL;
- struct str_vector channels;
- str_vector_init (&channels);
+ struct strv channels;
+ strv_init (&channels);
cstr_split (msg->params.vector[0], ",", true, &channels);
for (size_t i = 0; i < channels.len; i++)
irc_try_part (c, channels.vector[i], reason);
- str_vector_free (&channels);
+ strv_free (&channels);
}
static void
@@ -2688,10 +2688,10 @@ irc_handle_kick (const struct irc_message *msg, struct client *c)
if (msg->params.len > 2)
reason = msg->params.vector[2];
- struct str_vector channels;
- struct str_vector users;
- str_vector_init (&channels);
- str_vector_init (&users);
+ struct strv channels;
+ struct strv users;
+ strv_init (&channels);
+ strv_init (&users);
cstr_split (msg->params.vector[0], ",", true, &channels);
cstr_split (msg->params.vector[1], ",", true, &users);
@@ -2702,8 +2702,8 @@ irc_handle_kick (const struct irc_message *msg, struct client *c)
for (size_t i = 0; i < channels.len && i < users.len; i++)
irc_try_kick (c, channels.vector[i], users.vector[i], reason);
- str_vector_free (&channels);
- str_vector_free (&users);
+ strv_free (&channels);
+ strv_free (&users);
}
static void
@@ -2817,10 +2817,10 @@ irc_handle_join (const struct irc_message *msg, struct client *c)
return;
}
- struct str_vector channels;
- struct str_vector keys;
- str_vector_init (&channels);
- str_vector_init (&keys);
+ struct strv channels;
+ struct strv keys;
+ strv_init (&channels);
+ strv_init (&keys);
cstr_split (msg->params.vector[0], ",", true, &channels);
if (msg->params.len > 1)
cstr_split (msg->params.vector[1], ",", true, &keys);
@@ -2829,8 +2829,8 @@ irc_handle_join (const struct irc_message *msg, struct client *c)
irc_try_join (c, channels.vector[i],
i < keys.len ? keys.vector[i] : NULL);
- str_vector_free (&channels);
- str_vector_free (&keys);
+ strv_free (&channels);
+ strv_free (&keys);
}
static void
@@ -3113,7 +3113,7 @@ irc_try_read (struct client *c)
while (true)
{
- str_ensure_space (buf, 512);
+ str_reserve (buf, 512);
n_read = recv (c->socket_fd, buf->str + buf->len,
buf->alloc - buf->len - 1 /* null byte */, 0);
@@ -3151,7 +3151,7 @@ irc_try_read_tls (struct client *c)
c->ssl_rx_want_tx = false;
while (true)
{
- str_ensure_space (buf, 512);
+ str_reserve (buf, 512);
ERR_clear_error ();
int n_read = SSL_read (c->ssl, buf->str + buf->len,
buf->alloc - buf->len - 1 /* null byte */);
@@ -3711,7 +3711,7 @@ irc_initialize_motd (struct server_context *ctx, struct error **e)
struct str line;
str_init (&line);
while (read_line (fp, &line))
- str_vector_add_owned (&ctx->motd, str_steal (&line));
+ strv_append_owned (&ctx->motd, str_steal (&line));
str_free (&line);
fclose (fp);
@@ -3740,8 +3740,8 @@ irc_parse_config (struct server_context *ctx, struct error **e)
PARSE_UNSIGNED (max_connections, 0, UINT_MAX);
bool result = true;
- struct str_vector fingerprints;
- str_vector_init (&fingerprints);
+ struct strv fingerprints;
+ strv_init (&fingerprints);
const char *operators = str_map_find (&ctx->config, "operators");
if (operators)
cstr_split (operators, ",", true, &fingerprints);
@@ -3757,7 +3757,7 @@ irc_parse_config (struct server_context *ctx, struct error **e)
}
str_map_set (&ctx->operators, key, (void *) 1);
}
- str_vector_free (&fingerprints);
+ strv_free (&fingerprints);
return result;
}
@@ -3903,14 +3903,14 @@ irc_setup_listen_fds (struct server_context *ctx, struct error **e)
gai_hints.ai_socktype = SOCK_STREAM;
gai_hints.ai_flags = AI_PASSIVE;
- struct str_vector ports;
- str_vector_init (&ports);
+ struct strv ports;
+ strv_init (&ports);
cstr_split (bind_port, ",", true, &ports);
ctx->listen_fds = xcalloc (ports.len, sizeof *ctx->listen_fds);
ctx->listen_events = xcalloc (ports.len, sizeof *ctx->listen_events);
for (size_t i = 0; i < ports.len; i++)
irc_listen_resolve (ctx, bind_host, ports.vector[i], &gai_hints);
- str_vector_free (&ports);
+ strv_free (&ports);
if (!ctx->n_listen_fds)
{