Bump liberty

This commit is contained in:
Přemysl Eric Janouch 2017-01-23 23:50:27 +01:00
parent 0785a6f417
commit 9e5725662f
Signed by: p
GPG Key ID: B715679E3A361BE6
5 changed files with 272 additions and 271 deletions

View File

@ -52,7 +52,7 @@ init_openssl (void)
// --- To be moved to liberty -------------------------------------------------- // --- To be moved to liberty --------------------------------------------------
static ssize_t static ssize_t
str_vector_find (const struct str_vector *v, const char *s) strv_find (const struct strv *v, const char *s)
{ {
for (size_t i = 0; i < v->len; i++) for (size_t i = 0; i < v->len; i++)
if (!strcmp (v->vector[i], s)) if (!strcmp (v->vector[i], s))
@ -702,7 +702,7 @@ socks_try_fill_read_buffer (struct socks_connector *self, size_t n)
return true; return true;
ssize_t received; ssize_t received;
str_ensure_space (&self->read_buffer, remains); str_reserve (&self->read_buffer, remains);
do do
received = recv (self->socket_fd, received = recv (self->socket_fd,
self->read_buffer.str + self->read_buffer.len, remains, 0); self->read_buffer.str + self->read_buffer.len, remains, 0);

333
degesch.c

File diff suppressed because it is too large Load Diff

170
kike.c
View File

@ -456,9 +456,9 @@ struct channel
struct channel_user *users; ///< Channel users struct channel_user *users; ///< Channel users
struct str_vector ban_list; ///< Ban list struct strv ban_list; ///< Ban list
struct str_vector exception_list; ///< Exceptions from bans struct strv exception_list; ///< Exceptions from bans
struct str_vector invite_list; ///< Exceptions from +I struct strv invite_list; ///< Exceptions from +I
}; };
static struct channel * static struct channel *
@ -469,9 +469,9 @@ channel_new (void)
self->user_limit = -1; self->user_limit = -1;
self->topic = xstrdup (""); self->topic = xstrdup ("");
str_vector_init (&self->ban_list); strv_init (&self->ban_list);
str_vector_init (&self->exception_list); strv_init (&self->exception_list);
str_vector_init (&self->invite_list); strv_init (&self->invite_list);
return self; return self;
} }
@ -490,9 +490,9 @@ channel_delete (struct channel *self)
free (link); free (link);
} }
str_vector_free (&self->ban_list); strv_free (&self->ban_list);
str_vector_free (&self->exception_list); strv_free (&self->exception_list);
str_vector_free (&self->invite_list); strv_free (&self->invite_list);
free (self); free (self);
} }
@ -633,7 +633,7 @@ struct server_context
char *server_name; ///< Our server name char *server_name; ///< Our server name
unsigned ping_interval; ///< Ping interval in seconds unsigned ping_interval; ///< Ping interval in seconds
unsigned max_connections; ///< Max. connections allowed or 0 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 nl_catd catalog; ///< Message catalog for server msgs
struct str_map operators; ///< TLS cert. fingerprints for IRCops struct str_map operators; ///< TLS cert. fingerprints for IRCops
}; };
@ -679,7 +679,7 @@ server_context_init (struct server_context *self)
self->config.free = free; self->config.free = free;
simple_config_load_defaults (&self->config, g_config_table); simple_config_load_defaults (&self->config, g_config_table);
str_vector_init (&self->motd); strv_init (&self->motd);
self->catalog = (nl_catd) -1; self->catalog = (nl_catd) -1;
str_map_init (&self->operators); str_map_init (&self->operators);
// The regular irc_strxfrm() is sufficient for fingerprints // The regular irc_strxfrm() is sufficient for fingerprints
@ -712,7 +712,7 @@ server_context_free (struct server_context *self)
str_map_free (&self->whowas); str_map_free (&self->whowas);
poller_free (&self->poller); poller_free (&self->poller);
str_vector_free (&self->motd); strv_free (&self->motd);
if (self->catalog != (nl_catd) -1) if (self->catalog != (nl_catd) -1)
catclose (self->catalog); catclose (self->catalog);
str_map_free (&self->operators); str_map_free (&self->operators);
@ -972,7 +972,7 @@ client_close_link (struct client *c, const char *reason)
} }
static bool 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", char *client = xstrdup_printf ("%s!%s@%s",
c->nickname, c->username, c->hostname); c->nickname, c->username, c->hostname);
@ -1250,7 +1250,7 @@ struct irc_cap_args
{ {
const char *subcommand; ///< The subcommand being processed const char *subcommand; ///< The subcommand being processed
const char *full_params; ///< Whole parameter string 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 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 static void
irc_handle_cap_list (struct client *c, struct irc_cap_args *a) irc_handle_cap_list (struct client *c, struct irc_cap_args *a)
{ {
struct str_vector caps; struct strv caps;
str_vector_init (&caps); strv_init (&caps);
for (size_t i = 0; i < N_ELEMENTS (irc_cap_table); i++) for (size_t i = 0; i < N_ELEMENTS (irc_cap_table); i++)
if (c->caps_enabled & irc_cap_table[i].flag) 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, ' '); char *caps_str = strv_join (&caps, " ");
str_vector_free (&caps); strv_free (&caps);
client_send (c, ":%s CAP %s LIST :%s", client_send (c, ":%s CAP %s LIST :%s",
c->ctx->server_name, a->target, caps_str); c->ctx->server_name, a->target, caps_str);
free (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.target = c->nickname ? c->nickname : "*";
args.subcommand = msg->params.vector[0]; args.subcommand = msg->params.vector[0];
args.full_params = ""; args.full_params = "";
str_vector_init (&args.params); strv_init (&args.params);
if (msg->params.len > 1) if (msg->params.len > 1)
{ {
@ -1414,7 +1414,7 @@ irc_handle_cap (const struct irc_message *msg, struct client *c)
else else
cmd->handler (c, &args); cmd->handler (c, &args);
str_vector_free (&args.params); strv_free (&args.params);
} }
static void static void
@ -1699,7 +1699,7 @@ irc_handle_user_mode_change (struct client *c, const char *mode_string)
static void static void
irc_send_channel_list (struct client *c, const char *channel_name, 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++) for (size_t i = 0; i < list->len; i++)
irc_send_reply (c, reply, channel_name, list->vector[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 added; ///< Added modes
struct str removed; ///< Removed modes struct str removed; ///< Removed modes
struct str_vector added_params; ///< Params for added modes struct strv added_params; ///< Params for added modes
struct str_vector removed_params; ///< Params for removed modes struct strv removed_params; ///< Params for removed modes
struct str *output; ///< "added" or "removed" struct str *output; ///< "added" or "removed"
struct str_vector *output_params; ///< Similarly for "*_params" struct strv *output_params; ///< Similarly for "*_params"
}; };
static void static void
@ -1766,8 +1766,8 @@ mode_processor_init (struct mode_processor *self)
str_init (&self->added); str_init (&self->added);
str_init (&self->removed); str_init (&self->removed);
str_vector_init (&self->added_params); strv_init (&self->added_params);
str_vector_init (&self->removed_params); strv_init (&self->removed_params);
} }
static void static void
@ -1776,8 +1776,8 @@ mode_processor_free (struct mode_processor *self)
str_free (&self->added); str_free (&self->added);
str_free (&self->removed); str_free (&self->removed);
str_vector_free (&self->added_params); strv_free (&self->added_params);
str_vector_free (&self->removed_params); strv_free (&self->removed_params);
} }
static const char * 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)) else if (irc_modify_mode (&target_user->modes, mode, self->adding))
{ {
str_append_c (self->output, self->mode_char); 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 static void
mode_processor_do_list (struct mode_processor *self, 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); const char *target = mode_processor_next_param (self);
if (!target) if (!target)
@ -1869,12 +1869,12 @@ mode_processor_do_list (struct mode_processor *self,
if ((found ^ self->adding)) if ((found ^ self->adding))
{ {
if (self->adding) if (self->adding)
str_vector_add (list, mask); strv_append (list, mask);
else else
str_vector_remove (list, i); strv_remove (list, i);
str_append_c (self->output, self->mode_char); str_append_c (self->output, self->mode_char);
str_vector_add (self->output_params, mask); strv_append (self->output_params, mask);
} }
free (mask); free (mask);
} }
@ -1892,7 +1892,7 @@ mode_processor_do_key (struct mode_processor *self)
return; return;
str_append_c (&self->removed, self->mode_char); 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); free (self->channel->key);
self->channel->key = NULL; self->channel->key = NULL;
} }
@ -1905,7 +1905,7 @@ mode_processor_do_key (struct mode_processor *self)
{ {
self->channel->key = xstrdup (target); self->channel->key = xstrdup (target);
str_append_c (&self->added, self->mode_char); 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; self->channel->user_limit = x;
str_append_c (&self->added, self->mode_char); 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 else
{ {
struct str_vector channels; struct strv channels;
str_vector_init (&channels); strv_init (&channels);
cstr_split (msg->params.vector[0], ",", true, &channels); cstr_split (msg->params.vector[0], ",", true, &channels);
for (size_t i = 0; i < channels.len; i++) for (size_t i = 0; i < channels.len; i++)
if ((chan = str_map_find (&c->ctx->channels, channels.vector[i])) if ((chan = str_map_find (&c->ctx->channels, channels.vector[i]))
&& (!(chan->modes & IRC_CHAN_MODE_SECRET) && (!(chan->modes & IRC_CHAN_MODE_SECRET)
|| channel_get_user (chan, c))) || channel_get_user (chan, c)))
irc_send_rpl_list (c, chan); irc_send_rpl_list (c, chan);
str_vector_free (&channels); strv_free (&channels);
} }
irc_send_reply (c, IRC_RPL_LISTEND); irc_send_reply (c, IRC_RPL_LISTEND);
} }
@ -2238,8 +2238,8 @@ static void
irc_send_rpl_namreply (struct client *c, const struct channel *chan, irc_send_rpl_namreply (struct client *c, const struct channel *chan,
struct str_map *used_nicks) struct str_map *used_nicks)
{ {
struct str_vector nicks; struct strv nicks;
str_vector_init (&nicks); strv_init (&nicks);
char type = '='; char type = '=';
if (chan->modes & IRC_CHAN_MODE_SECRET) if (chan->modes & IRC_CHAN_MODE_SECRET)
@ -2254,20 +2254,20 @@ irc_send_rpl_namreply (struct client *c, const struct channel *chan,
continue; continue;
if (used_nicks) if (used_nicks)
str_map_set (used_nicks, iter->c->nickname, (void *) 1); 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_make_rpl_namreply_item (c, iter->c, iter));
} }
irc_send_reply_vector (c, IRC_RPL_NAMREPLY, irc_send_reply_vector (c, IRC_RPL_NAMREPLY,
nicks.vector, type, chan->name, ""); nicks.vector, type, chan->name, "");
str_vector_free (&nicks); strv_free (&nicks);
} }
static void static void
irc_send_disassociated_names (struct client *c, struct str_map *used) irc_send_disassociated_names (struct client *c, struct str_map *used)
{ {
struct str_vector nicks; struct strv nicks;
str_vector_init (&nicks); strv_init (&nicks);
struct str_map_iter iter; struct str_map_iter iter;
str_map_iter_init (&iter, &c->ctx->users); 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) if ((target->mode & IRC_USER_MODE_INVISIBLE)
|| str_map_find (used, target->nickname)) || str_map_find (used, target->nickname))
continue; continue;
str_vector_add_owned (&nicks, strv_append_owned (&nicks,
irc_make_rpl_namreply_item (c, target, NULL)); irc_make_rpl_namreply_item (c, target, NULL));
} }
if (nicks.len) if (nicks.len)
irc_send_reply_vector (c, IRC_RPL_NAMREPLY, irc_send_reply_vector (c, IRC_RPL_NAMREPLY,
nicks.vector, '*', "*", ""); nicks.vector, '*', "*", "");
str_vector_free (&nicks); strv_free (&nicks);
} }
static void static void
@ -2315,8 +2315,8 @@ irc_handle_names (const struct irc_message *msg, struct client *c)
} }
else else
{ {
struct str_vector channels; struct strv channels;
str_vector_init (&channels); strv_init (&channels);
cstr_split (msg->params.vector[0], ",", true, &channels); cstr_split (msg->params.vector[0], ",", true, &channels);
for (size_t i = 0; i < channels.len; i++) for (size_t i = 0; i < channels.len; i++)
if ((chan = str_map_find (&c->ctx->channels, channels.vector[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_rpl_namreply (c, chan, NULL);
irc_send_reply (c, IRC_RPL_ENDOFNAMES, channels.vector[i]); 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) if (target->away_message)
irc_send_reply (c, IRC_RPL_AWAY, nick, target->away_message); irc_send_reply (c, IRC_RPL_AWAY, nick, target->away_message);
struct str_vector channels; struct strv channels;
str_vector_init (&channels); strv_init (&channels);
struct str_map_iter iter; struct str_map_iter iter;
str_map_iter_init (&iter, &c->ctx->channels); 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) else if (channel_user->modes & IRC_CHAN_MODE_VOICE)
str_append_c (&item, '+'); str_append_c (&item, '+');
str_append (&item, chan->name); 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, ""); 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); 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])) 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]); RETURN_WITH_REPLY (c, IRC_ERR_NOSUCHSERVER, msg->params.vector[0]);
struct str_vector masks; struct strv masks;
str_vector_init (&masks); strv_init (&masks);
const char *masks_str = msg->params.vector[msg->params.len > 1]; const char *masks_str = msg->params.vector[msg->params.len > 1];
cstr_split (masks_str, ",", true, &masks); cstr_split (masks_str, ",", true, &masks);
for (size_t i = 0; i < masks.len; i++) 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); irc_send_reply (c, IRC_ERR_NOSUCHNICK, mask);
} }
} }
str_vector_free (&masks); strv_free (&masks);
} }
static void 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]); RETURN_WITH_REPLY (c, IRC_ERR_NOSUCHSERVER, msg->params.vector[2]);
// The "count" parameter is ignored, we only store one entry for a nick // The "count" parameter is ignored, we only store one entry for a nick
struct str_vector nicks; struct strv nicks;
str_vector_init (&nicks); strv_init (&nicks);
cstr_split (msg->params.vector[0], ",", true, &nicks); cstr_split (msg->params.vector[0], ",", true, &nicks);
for (size_t i = 0; i < nicks.len; i++) 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); irc_send_reply (c, IRC_RPL_ENDOFWHOWAS, nick);
} }
str_vector_free (&nicks); strv_free (&nicks);
} }
static void 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); RETURN_WITH_REPLY (c, IRC_ERR_NEEDMOREPARAMS, msg->command);
const char *reason = msg->params.len > 1 ? msg->params.vector[1] : NULL; const char *reason = msg->params.len > 1 ? msg->params.vector[1] : NULL;
struct str_vector channels; struct strv channels;
str_vector_init (&channels); strv_init (&channels);
cstr_split (msg->params.vector[0], ",", true, &channels); cstr_split (msg->params.vector[0], ",", true, &channels);
for (size_t i = 0; i < channels.len; i++) for (size_t i = 0; i < channels.len; i++)
irc_try_part (c, channels.vector[i], reason); irc_try_part (c, channels.vector[i], reason);
str_vector_free (&channels); strv_free (&channels);
} }
static void static void
@ -2688,10 +2688,10 @@ irc_handle_kick (const struct irc_message *msg, struct client *c)
if (msg->params.len > 2) if (msg->params.len > 2)
reason = msg->params.vector[2]; reason = msg->params.vector[2];
struct str_vector channels; struct strv channels;
struct str_vector users; struct strv users;
str_vector_init (&channels); strv_init (&channels);
str_vector_init (&users); strv_init (&users);
cstr_split (msg->params.vector[0], ",", true, &channels); cstr_split (msg->params.vector[0], ",", true, &channels);
cstr_split (msg->params.vector[1], ",", true, &users); 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++) for (size_t i = 0; i < channels.len && i < users.len; i++)
irc_try_kick (c, channels.vector[i], users.vector[i], reason); irc_try_kick (c, channels.vector[i], users.vector[i], reason);
str_vector_free (&channels); strv_free (&channels);
str_vector_free (&users); strv_free (&users);
} }
static void static void
@ -2817,10 +2817,10 @@ irc_handle_join (const struct irc_message *msg, struct client *c)
return; return;
} }
struct str_vector channels; struct strv channels;
struct str_vector keys; struct strv keys;
str_vector_init (&channels); strv_init (&channels);
str_vector_init (&keys); strv_init (&keys);
cstr_split (msg->params.vector[0], ",", true, &channels); cstr_split (msg->params.vector[0], ",", true, &channels);
if (msg->params.len > 1) if (msg->params.len > 1)
cstr_split (msg->params.vector[1], ",", true, &keys); 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], irc_try_join (c, channels.vector[i],
i < keys.len ? keys.vector[i] : NULL); i < keys.len ? keys.vector[i] : NULL);
str_vector_free (&channels); strv_free (&channels);
str_vector_free (&keys); strv_free (&keys);
} }
static void static void
@ -3113,7 +3113,7 @@ irc_try_read (struct client *c)
while (true) while (true)
{ {
str_ensure_space (buf, 512); str_reserve (buf, 512);
n_read = recv (c->socket_fd, buf->str + buf->len, n_read = recv (c->socket_fd, buf->str + buf->len,
buf->alloc - buf->len - 1 /* null byte */, 0); 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; c->ssl_rx_want_tx = false;
while (true) while (true)
{ {
str_ensure_space (buf, 512); str_reserve (buf, 512);
ERR_clear_error (); ERR_clear_error ();
int n_read = SSL_read (c->ssl, buf->str + buf->len, int n_read = SSL_read (c->ssl, buf->str + buf->len,
buf->alloc - buf->len - 1 /* null byte */); buf->alloc - buf->len - 1 /* null byte */);
@ -3711,7 +3711,7 @@ irc_initialize_motd (struct server_context *ctx, struct error **e)
struct str line; struct str line;
str_init (&line); str_init (&line);
while (read_line (fp, &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); str_free (&line);
fclose (fp); fclose (fp);
@ -3740,8 +3740,8 @@ irc_parse_config (struct server_context *ctx, struct error **e)
PARSE_UNSIGNED (max_connections, 0, UINT_MAX); PARSE_UNSIGNED (max_connections, 0, UINT_MAX);
bool result = true; bool result = true;
struct str_vector fingerprints; struct strv fingerprints;
str_vector_init (&fingerprints); strv_init (&fingerprints);
const char *operators = str_map_find (&ctx->config, "operators"); const char *operators = str_map_find (&ctx->config, "operators");
if (operators) if (operators)
cstr_split (operators, ",", true, &fingerprints); 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_map_set (&ctx->operators, key, (void *) 1);
} }
str_vector_free (&fingerprints); strv_free (&fingerprints);
return result; 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_socktype = SOCK_STREAM;
gai_hints.ai_flags = AI_PASSIVE; gai_hints.ai_flags = AI_PASSIVE;
struct str_vector ports; struct strv ports;
str_vector_init (&ports); strv_init (&ports);
cstr_split (bind_port, ",", true, &ports); cstr_split (bind_port, ",", true, &ports);
ctx->listen_fds = xcalloc (ports.len, sizeof *ctx->listen_fds); ctx->listen_fds = xcalloc (ports.len, sizeof *ctx->listen_fds);
ctx->listen_events = xcalloc (ports.len, sizeof *ctx->listen_events); ctx->listen_events = xcalloc (ports.len, sizeof *ctx->listen_events);
for (size_t i = 0; i < ports.len; i++) for (size_t i = 0; i < ports.len; i++)
irc_listen_resolve (ctx, bind_host, ports.vector[i], &gai_hints); irc_listen_resolve (ctx, bind_host, ports.vector[i], &gai_hints);
str_vector_free (&ports); strv_free (&ports);
if (!ctx->n_listen_fds) if (!ctx->n_listen_fds)
{ {

@ -1 +1 @@
Subproject commit f53b717f3bba27ca1c42486d3742c91967f3fe93 Subproject commit 084e964286bfcd13ee6a25a2ee35dfba9da1072e

View File

@ -509,7 +509,7 @@ irc_establish_connection (struct bot_context *ctx,
static int g_signal_pipe[2]; ///< A pipe used to signal... signals static int g_signal_pipe[2]; ///< A pipe used to signal... signals
static struct str_vector static struct strv
g_original_argv, ///< Original program arguments g_original_argv, ///< Original program arguments
g_recovery_env; ///< Environment for re-exec recovery g_recovery_env; ///< Environment for re-exec recovery
@ -684,8 +684,8 @@ recovery_handler (int signum, siginfo_t *info, void *context)
static void static void
prepare_recovery_environment (void) prepare_recovery_environment (void)
{ {
str_vector_init (&g_recovery_env); strv_init (&g_recovery_env);
str_vector_add_vector (&g_recovery_env, environ); strv_append_vector (&g_recovery_env, environ);
// Prepare a location within the environment where we will put the startup // Prepare a location within the environment where we will put the startup
// (or maybe rather restart) reason in case of an irrecoverable error. // (or maybe rather restart) reason in case of an irrecoverable error.
@ -702,7 +702,7 @@ prepare_recovery_environment (void)
else else
{ {
g_startup_reason_location = g_recovery_env.vector + g_recovery_env.len; g_startup_reason_location = g_recovery_env.vector + g_recovery_env.len;
str_vector_add (&g_recovery_env, ""); strv_append (&g_recovery_env, "");
} }
} }
@ -964,7 +964,7 @@ on_plugin_readable (const struct pollfd *fd, struct plugin *plugin)
struct str *buf = &plugin->read_buffer; struct str *buf = &plugin->read_buffer;
while (true) while (true)
{ {
str_ensure_space (buf, 512 + 1); str_reserve (buf, 512 + 1);
ssize_t n_read = read (fd->fd, buf->str + buf->len, ssize_t n_read = read (fd->fd, buf->str + buf->len,
buf->alloc - buf->len - 1); buf->alloc - buf->len - 1);
@ -1173,8 +1173,8 @@ plugin_load_all_from_config (struct bot_context *ctx)
if (!plugin_list) if (!plugin_list)
return; return;
struct str_vector plugins; struct strv plugins;
str_vector_init (&plugins); strv_init (&plugins);
cstr_split (plugin_list, ",", true, &plugins); cstr_split (plugin_list, ",", true, &plugins);
for (size_t i = 0; i < plugins.len; i++) for (size_t i = 0; i < plugins.len; i++)
@ -1189,7 +1189,7 @@ plugin_load_all_from_config (struct bot_context *ctx)
} }
} }
str_vector_free (&plugins); strv_free (&plugins);
} }
// --- Main program ------------------------------------------------------------ // --- Main program ------------------------------------------------------------
@ -1214,13 +1214,13 @@ parse_bot_command (const char *s, const char *command, const char **following)
} }
static void static void
split_bot_command_argument_list (const char *arguments, struct str_vector *out) split_bot_command_argument_list (const char *arguments, struct strv *out)
{ {
cstr_split (arguments, ",", true, out); cstr_split (arguments, ",", true, out);
for (size_t i = 0; i < out->len; ) for (size_t i = 0; i < out->len; )
{ {
if (!*cstr_strip_in_place (out->vector[i], " \t")) if (!*cstr_strip_in_place (out->vector[i], " \t"))
str_vector_remove (out, i); strv_remove (out, i);
else else
i++; i++;
} }
@ -1367,8 +1367,8 @@ process_privmsg (struct bot_context *ctx, const struct irc_message *msg)
return; return;
const char *following; const char *following;
struct str_vector list; struct strv list;
str_vector_init (&list); strv_init (&list);
if (parse_bot_command (text, "quote", &following)) if (parse_bot_command (text, "quote", &following))
// This seems to replace tons of random stupid commands // This seems to replace tons of random stupid commands
@ -1408,7 +1408,7 @@ process_privmsg (struct bot_context *ctx, const struct irc_message *msg)
process_plugin_unload (ctx, msg, list.vector[i]); process_plugin_unload (ctx, msg, list.vector[i]);
} }
str_vector_free (&list); strv_free (&list);
} }
static void static void
@ -1646,7 +1646,7 @@ on_irc_readable (const struct pollfd *fd, struct bot_context *ctx)
bool disconnected = false; bool disconnected = false;
while (true) while (true)
{ {
str_ensure_space (buf, 512); str_reserve (buf, 512);
switch (fill_buffer (ctx, buf)) switch (fill_buffer (ctx, buf))
{ {
case IRC_READ_AGAIN: case IRC_READ_AGAIN:
@ -1967,8 +1967,8 @@ on_signal_pipe_readable (const struct pollfd *fd, struct bot_context *ctx)
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
str_vector_init (&g_original_argv); strv_init (&g_original_argv);
str_vector_add_vector (&g_original_argv, argv); strv_append_vector (&g_original_argv, argv);
static const struct opt opts[] = static const struct opt opts[] =
{ {
@ -2056,7 +2056,7 @@ main (int argc, char *argv[])
poller_run (&ctx.poller); poller_run (&ctx.poller);
bot_context_free (&ctx); bot_context_free (&ctx);
str_vector_free (&g_original_argv); strv_free (&g_original_argv);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }