Bump liberty
This commit is contained in:
parent
0785a6f417
commit
9e5725662f
4
common.c
4
common.c
|
@ -52,7 +52,7 @@ init_openssl (void)
|
|||
// --- To be moved to liberty --------------------------------------------------
|
||||
|
||||
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++)
|
||||
if (!strcmp (v->vector[i], s))
|
||||
|
@ -702,7 +702,7 @@ socks_try_fill_read_buffer (struct socks_connector *self, size_t n)
|
|||
return true;
|
||||
|
||||
ssize_t received;
|
||||
str_ensure_space (&self->read_buffer, remains);
|
||||
str_reserve (&self->read_buffer, remains);
|
||||
do
|
||||
received = recv (self->socket_fd,
|
||||
self->read_buffer.str + self->read_buffer.len, remains, 0);
|
||||
|
|
170
kike.c
170
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)
|
||||
{
|
||||
|
|
2
liberty
2
liberty
|
@ -1 +1 @@
|
|||
Subproject commit f53b717f3bba27ca1c42486d3742c91967f3fe93
|
||||
Subproject commit 084e964286bfcd13ee6a25a2ee35dfba9da1072e
|
34
zyklonb.c
34
zyklonb.c
|
@ -509,7 +509,7 @@ irc_establish_connection (struct bot_context *ctx,
|
|||
|
||||
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_recovery_env; ///< Environment for re-exec recovery
|
||||
|
||||
|
@ -684,8 +684,8 @@ recovery_handler (int signum, siginfo_t *info, void *context)
|
|||
static void
|
||||
prepare_recovery_environment (void)
|
||||
{
|
||||
str_vector_init (&g_recovery_env);
|
||||
str_vector_add_vector (&g_recovery_env, environ);
|
||||
strv_init (&g_recovery_env);
|
||||
strv_append_vector (&g_recovery_env, environ);
|
||||
|
||||
// Prepare a location within the environment where we will put the startup
|
||||
// (or maybe rather restart) reason in case of an irrecoverable error.
|
||||
|
@ -702,7 +702,7 @@ prepare_recovery_environment (void)
|
|||
else
|
||||
{
|
||||
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;
|
||||
while (true)
|
||||
{
|
||||
str_ensure_space (buf, 512 + 1);
|
||||
str_reserve (buf, 512 + 1);
|
||||
ssize_t n_read = read (fd->fd, buf->str + buf->len,
|
||||
buf->alloc - buf->len - 1);
|
||||
|
||||
|
@ -1173,8 +1173,8 @@ plugin_load_all_from_config (struct bot_context *ctx)
|
|||
if (!plugin_list)
|
||||
return;
|
||||
|
||||
struct str_vector plugins;
|
||||
str_vector_init (&plugins);
|
||||
struct strv plugins;
|
||||
strv_init (&plugins);
|
||||
|
||||
cstr_split (plugin_list, ",", true, &plugins);
|
||||
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 ------------------------------------------------------------
|
||||
|
@ -1214,13 +1214,13 @@ parse_bot_command (const char *s, const char *command, const char **following)
|
|||
}
|
||||
|
||||
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);
|
||||
for (size_t i = 0; i < out->len; )
|
||||
{
|
||||
if (!*cstr_strip_in_place (out->vector[i], " \t"))
|
||||
str_vector_remove (out, i);
|
||||
strv_remove (out, i);
|
||||
else
|
||||
i++;
|
||||
}
|
||||
|
@ -1367,8 +1367,8 @@ process_privmsg (struct bot_context *ctx, const struct irc_message *msg)
|
|||
return;
|
||||
|
||||
const char *following;
|
||||
struct str_vector list;
|
||||
str_vector_init (&list);
|
||||
struct strv list;
|
||||
strv_init (&list);
|
||||
|
||||
if (parse_bot_command (text, "quote", &following))
|
||||
// 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]);
|
||||
}
|
||||
|
||||
str_vector_free (&list);
|
||||
strv_free (&list);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1646,7 +1646,7 @@ on_irc_readable (const struct pollfd *fd, struct bot_context *ctx)
|
|||
bool disconnected = false;
|
||||
while (true)
|
||||
{
|
||||
str_ensure_space (buf, 512);
|
||||
str_reserve (buf, 512);
|
||||
switch (fill_buffer (ctx, buf))
|
||||
{
|
||||
case IRC_READ_AGAIN:
|
||||
|
@ -1967,8 +1967,8 @@ on_signal_pipe_readable (const struct pollfd *fd, struct bot_context *ctx)
|
|||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
str_vector_init (&g_original_argv);
|
||||
str_vector_add_vector (&g_original_argv, argv);
|
||||
strv_init (&g_original_argv);
|
||||
strv_append_vector (&g_original_argv, argv);
|
||||
|
||||
static const struct opt opts[] =
|
||||
{
|
||||
|
@ -2056,7 +2056,7 @@ main (int argc, char *argv[])
|
|||
poller_run (&ctx.poller);
|
||||
|
||||
bot_context_free (&ctx);
|
||||
str_vector_free (&g_original_argv);
|
||||
strv_free (&g_original_argv);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue