summaryrefslogtreecommitdiff
path: root/kike.c
diff options
context:
space:
mode:
Diffstat (limited to 'kike.c')
-rw-r--r--kike.c219
1 files changed, 81 insertions, 138 deletions
diff --git a/kike.c b/kike.c
index efcb39e..166b541 100644
--- a/kike.c
+++ b/kike.c
@@ -170,7 +170,7 @@ irc_regex_match (const char *regex, const char *s)
if (!initialized)
{
- regex_cache_init (&cache);
+ cache = regex_cache_make ();
initialized = true;
}
@@ -368,12 +368,12 @@ client_new (void)
{
struct client *self = xcalloc (1, sizeof *self);
self->socket_fd = -1;
- str_init (&self->read_buffer);
- str_init (&self->write_buffer);
+ self->read_buffer = str_make ();
+ self->write_buffer = str_make ();
self->cap_version = 301;
// TODO: make this configurable and more fine-grained
flood_detector_init (&self->antiflood, 10, 20);
- str_map_init (&self->invites);
+ self->invites = str_map_make (NULL);
self->invites.key_xfrm = irc_strxfrm;
return self;
}
@@ -470,9 +470,9 @@ channel_new (void)
self->user_limit = -1;
self->topic = xstrdup ("");
- strv_init (&self->ban_list);
- strv_init (&self->exception_list);
- strv_init (&self->invite_list);
+ self->ban_list = strv_make ();
+ self->exception_list = strv_make ();
+ self->invite_list = strv_make ();
return self;
}
@@ -501,9 +501,7 @@ channel_delete (struct channel *self)
static char *
channel_get_mode (struct channel *self, bool disclose_secrets)
{
- struct str mode;
- str_init (&mode);
-
+ struct str mode = str_make ();
unsigned m = self->modes;
if (m & IRC_CHAN_MODE_INVITE_ONLY) str_append_c (&mode, 'i');
if (m & IRC_CHAN_MODE_MODERATED) str_append_c (&mode, 'm');
@@ -657,32 +655,29 @@ server_context_init (struct server_context *self)
{
memset (self, 0, sizeof *self);
- str_map_init (&self->users);
+ self->users = str_map_make (NULL);
self->users.key_xfrm = irc_strxfrm;
- str_map_init (&self->channels);
+ self->channels = str_map_make ((str_map_free_fn) channel_delete);
self->channels.key_xfrm = irc_strxfrm;
- self->channels.free = (void (*) (void *)) channel_delete;
- str_map_init (&self->handlers);
+ self->handlers = str_map_make (NULL);
self->handlers.key_xfrm = irc_strxfrm;
- str_map_init (&self->cap_handlers);
+ self->cap_handlers = str_map_make (NULL);
self->cap_handlers.key_xfrm = irc_strxfrm;
- str_map_init (&self->whowas);
+ self->whowas = str_map_make ((str_map_free_fn) whowas_info_destroy);
self->whowas.key_xfrm = irc_strxfrm;
- self->whowas.free = (void (*) (void *)) whowas_info_destroy;
poller_init (&self->poller);
- poller_timer_init (&self->quit_timer, &self->poller);
+ self->quit_timer = poller_timer_make (&self->poller);
self->quit_timer.dispatcher = on_irc_quit_timeout;
self->quit_timer.user_data = self;
- str_map_init (&self->config);
- self->config.free = free;
+ self->config = str_map_make (free);
simple_config_load_defaults (&self->config, g_config_table);
- strv_init (&self->motd);
+ self->motd = strv_make ();
self->catalog = (nl_catd) -1;
- str_map_init (&self->operators);
+ self->operators = str_map_make (NULL);
// The regular irc_strxfrm() is sufficient for fingerprints
self->operators.key_xfrm = irc_strxfrm;
}
@@ -780,12 +775,10 @@ irc_channel_destroy_if_empty (struct server_context *ctx, struct channel *chan)
static void
irc_send_to_roommates (struct client *c, const char *message)
{
- struct str_map targets;
- str_map_init (&targets);
+ struct str_map targets = str_map_make (NULL);
targets.key_xfrm = irc_strxfrm;
- struct str_map_iter iter;
- str_map_iter_init (&iter, &c->ctx->channels);
+ struct str_map_iter iter = str_map_iter_make (&c->ctx->channels);
struct channel *chan;
while ((chan = str_map_iter_next (&iter)))
{
@@ -796,7 +789,7 @@ irc_send_to_roommates (struct client *c, const char *message)
str_map_set (&targets, iter->c->nickname, iter->c);
}
- str_map_iter_init (&iter, &targets);
+ iter = str_map_iter_make (&targets);
struct client *target;
while ((target = str_map_iter_next (&iter)))
if (target != c)
@@ -819,8 +812,7 @@ client_mode_to_str (unsigned m, struct str *out)
static char *
client_get_mode (struct client *self)
{
- struct str mode;
- str_init (&mode);
+ struct str mode = str_make ();
if (self->away_message)
str_append_c (&mode, 'a');
client_mode_to_str (self->mode, &mode);
@@ -862,8 +854,7 @@ client_send_str (struct client *c, const struct str *s)
static void
client_send (struct client *c, const char *format, ...)
{
- struct str tmp;
- str_init (&tmp);
+ struct str tmp = str_make ();
va_list ap;
va_start (ap, format);
@@ -894,8 +885,8 @@ client_unregister (struct client *c, const char *reason)
irc_send_to_roommates (c, message);
free (message);
- struct str_map_unset_iter iter;
- str_map_unset_iter_init (&iter, &c->ctx->channels);
+ struct str_map_unset_iter iter =
+ str_map_unset_iter_make (&c->ctx->channels);
struct channel *chan;
while ((chan = str_map_unset_iter_next (&iter)))
{
@@ -1009,8 +1000,7 @@ client_get_ssl_cert_fingerprint (struct client *c)
unsigned char hash[SHA_DIGEST_LENGTH];
SHA1 (cert, cert_len, hash);
- struct str fingerprint;
- str_init (&fingerprint);
+ struct str fingerprint = str_make ();
for (size_t i = 0; i < sizeof hash; i++)
str_append_printf (&fingerprint, "%02x", hash[i]);
return str_steal (&fingerprint);
@@ -1086,8 +1076,7 @@ irc_make_reply (struct client *c, int id, va_list ap, struct str *output)
static void
irc_send_reply (struct client *c, int id, ...)
{
- struct str reply;
- str_init (&reply);
+ struct str reply = str_make ();
va_list ap;
va_start (ap, id);
@@ -1102,8 +1091,7 @@ irc_send_reply (struct client *c, int id, ...)
static void
irc_send_reply_vector (struct client *c, int id, char **items, ...)
{
- struct str common;
- str_init (&common);
+ struct str common = str_make ();
va_list ap;
va_start (ap, items);
@@ -1114,8 +1102,7 @@ irc_send_reply_vector (struct client *c, int id, char **items, ...)
// expects us to send this message at least once)
do
{
- struct str reply;
- str_init (&reply);
+ struct str reply = str_make ();
str_append_str (&reply, &common);
// If not even a single item fits in the limit (which may happen,
@@ -1169,8 +1156,7 @@ irc_send_lusers (struct client *c)
}
int n_channels = 0;
- struct str_map_iter iter;
- str_map_iter_init (&iter, &c->ctx->channels);
+ struct str_map_iter iter = str_map_iter_make (&c->ctx->channels);
struct channel *chan;
while ((chan = str_map_iter_next (&iter)))
if (!(chan->modes & IRC_CHAN_MODE_SECRET)
@@ -1285,9 +1271,7 @@ 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 strv caps;
- strv_init (&caps);
-
+ struct strv caps = strv_make ();
for (size_t i = 0; i < N_ELEMENTS (irc_cap_table); i++)
if (c->caps_enabled & irc_cap_table[i].flag)
strv_append (&caps, irc_cap_table[i].name);
@@ -1399,7 +1383,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 = "";
- strv_init (&args.params);
+ args.params = strv_make ();
if (msg->params.len > 1)
{
@@ -1506,8 +1490,7 @@ irc_handle_userhost (const struct irc_message *msg, struct client *c)
if (msg->params.len < 1)
RETURN_WITH_REPLY (c, IRC_ERR_NEEDMOREPARAMS, msg->command);
- struct str reply;
- str_init (&reply);
+ struct str reply = str_make ();
for (size_t i = 0; i < 5 && i < msg->params.len; i++)
{
const char *nick = msg->params.vector[i];
@@ -1632,9 +1615,7 @@ irc_update_user_mode (struct client *c, unsigned new_mode)
unsigned added = new_mode & ~old_mode;
unsigned removed = old_mode & ~new_mode;
- struct str diff;
- str_init (&diff);
-
+ struct str diff = str_make ();
if (added)
{
str_append_c (&diff, '+');
@@ -1710,8 +1691,7 @@ irc_send_channel_list (struct client *c, const char *channel_name,
static char *
irc_check_expand_user_mask (const char *mask)
{
- struct str result;
- str_init (&result);
+ struct str result = str_make ();
str_append (&result, mask);
// Make sure it is a complete mask
@@ -1764,11 +1744,11 @@ mode_processor_init (struct mode_processor *self)
{
memset (self, 0, sizeof *self);
- str_init (&self->added);
- str_init (&self->removed);
+ self->added = str_make ();
+ self->removed = str_make ();
- strv_init (&self->added_params);
- strv_init (&self->removed_params);
+ self->added_params = strv_make ();
+ self->removed_params = strv_make ();
}
static void
@@ -2030,8 +2010,7 @@ irc_handle_chan_mode_change
// TODO: limit to three changes with parameter per command
if (p.added.len || p.removed.len)
{
- struct str message;
- str_init (&message);
+ struct str message = str_make ();
str_append_printf (&message, ":%s!%s@%s MODE %s ",
p.c->nickname, p.c->username, p.c->hostname,
p.channel->name);
@@ -2176,8 +2155,7 @@ irc_handle_list (const struct irc_message *msg, struct client *c)
struct channel *chan;
if (msg->params.len == 0)
{
- struct str_map_iter iter;
- str_map_iter_init (&iter, &c->ctx->channels);
+ struct str_map_iter iter = str_map_iter_make (&c->ctx->channels);
while ((chan = str_map_iter_next (&iter)))
if (!(chan->modes & (IRC_CHAN_MODE_PRIVATE | IRC_CHAN_MODE_SECRET))
|| channel_get_user (chan, c))
@@ -2185,8 +2163,7 @@ irc_handle_list (const struct irc_message *msg, struct client *c)
}
else
{
- struct strv channels;
- strv_init (&channels);
+ struct strv channels = strv_make ();
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]))
@@ -2202,9 +2179,7 @@ static void
irc_append_prefixes (struct client *c, struct channel_user *user,
struct str *output)
{
- struct str prefixes;
- str_init (&prefixes);
-
+ struct str prefixes = str_make ();
if (user->modes & IRC_CHAN_MODE_OPERATOR) str_append_c (&prefixes, '@');
if (user->modes & IRC_CHAN_MODE_VOICE) str_append_c (&prefixes, '+');
@@ -2222,8 +2197,7 @@ static char *
irc_make_rpl_namreply_item
(struct client *c, struct client *target, struct channel_user *user)
{
- struct str result;
- str_init (&result);
+ struct str result = str_make ();
if (user)
irc_append_prefixes (c, user, &result);
@@ -2239,9 +2213,6 @@ static void
irc_send_rpl_namreply (struct client *c, const struct channel *chan,
struct str_map *used_nicks)
{
- struct strv nicks;
- strv_init (&nicks);
-
char type = '=';
if (chan->modes & IRC_CHAN_MODE_SECRET)
type = '@';
@@ -2249,6 +2220,7 @@ irc_send_rpl_namreply (struct client *c, const struct channel *chan,
type = '*';
bool on_channel = channel_get_user (chan, c);
+ struct strv nicks = strv_make ();
for (struct channel_user *iter = chan->users; iter; iter = iter->next)
{
if (!on_channel && (iter->c->mode & IRC_USER_MODE_INVISIBLE))
@@ -2267,11 +2239,8 @@ irc_send_rpl_namreply (struct client *c, const struct channel *chan,
static void
irc_send_disassociated_names (struct client *c, struct str_map *used)
{
- struct strv nicks;
- strv_init (&nicks);
-
- struct str_map_iter iter;
- str_map_iter_init (&iter, &c->ctx->users);
+ struct strv nicks = strv_make ();
+ struct str_map_iter iter = str_map_iter_make (&c->ctx->users);
struct client *target;
while ((target = str_map_iter_next (&iter)))
{
@@ -2297,12 +2266,10 @@ irc_handle_names (const struct irc_message *msg, struct client *c)
struct channel *chan;
if (msg->params.len == 0)
{
- struct str_map used;
- str_map_init (&used);
+ struct str_map used = str_map_make (NULL);
used.key_xfrm = irc_strxfrm;
- struct str_map_iter iter;
- str_map_iter_init (&iter, &c->ctx->channels);
+ struct str_map_iter iter = str_map_iter_make (&c->ctx->channels);
while ((chan = str_map_iter_next (&iter)))
if (!(chan->modes & (IRC_CHAN_MODE_PRIVATE | IRC_CHAN_MODE_SECRET))
|| channel_get_user (chan, c))
@@ -2316,8 +2283,7 @@ irc_handle_names (const struct irc_message *msg, struct client *c)
}
else
{
- struct strv channels;
- strv_init (&channels);
+ struct strv channels = strv_make ();
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]))
@@ -2335,9 +2301,7 @@ static void
irc_send_rpl_whoreply (struct client *c, const struct channel *chan,
const struct client *target)
{
- struct str chars;
- str_init (&chars);
-
+ struct str chars = str_make ();
str_append_c (&chars, target->away_message ? 'G' : 'H');
if (target->mode & IRC_USER_MODE_OPERATOR)
str_append_c (&chars, '*');
@@ -2357,8 +2321,7 @@ irc_match_send_rpl_whoreply (struct client *c, struct client *target,
const char *mask)
{
bool is_roommate = false;
- struct str_map_iter iter;
- str_map_iter_init (&iter, &c->ctx->channels);
+ struct str_map_iter iter = str_map_iter_make (&c->ctx->channels);
struct channel *chan;
while ((chan = str_map_iter_next (&iter)))
if (channel_get_user (chan, target) && channel_get_user (chan, c))
@@ -2377,7 +2340,7 @@ irc_match_send_rpl_whoreply (struct client *c, struct client *target,
// Try to find a channel they're on that's visible to us
struct channel *user_chan = NULL;
- str_map_iter_init (&iter, &c->ctx->channels);
+ iter = str_map_iter_make (&c->ctx->channels);
while ((chan = str_map_iter_next (&iter)))
if (channel_get_user (chan, target)
&& (!(chan->modes & (IRC_CHAN_MODE_PRIVATE | IRC_CHAN_MODE_SECRET))
@@ -2417,8 +2380,7 @@ irc_handle_who (const struct irc_message *msg, struct client *c)
}
else
{
- struct str_map_iter iter;
- str_map_iter_init (&iter, &c->ctx->users);
+ struct str_map_iter iter = str_map_iter_make (&c->ctx->users);
struct client *target;
while ((target = str_map_iter_next (&iter)))
if (!only_ops || (target->mode & IRC_USER_MODE_OPERATOR))
@@ -2442,11 +2404,9 @@ 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 strv channels;
- strv_init (&channels);
+ struct strv channels = strv_make ();
- struct str_map_iter iter;
- str_map_iter_init (&iter, &c->ctx->channels);
+ struct str_map_iter iter = str_map_iter_make (&c->ctx->channels);
struct channel *chan;
struct channel_user *channel_user;
while ((chan = str_map_iter_next (&iter)))
@@ -2454,8 +2414,7 @@ irc_send_whois_reply (struct client *c, const struct client *target)
&& (!(chan->modes & (IRC_CHAN_MODE_PRIVATE | IRC_CHAN_MODE_SECRET))
|| channel_get_user (chan, c)))
{
- struct str item;
- str_init (&item);
+ struct str item = str_make ();
if (channel_user->modes & IRC_CHAN_MODE_OPERATOR)
str_append_c (&item, '@');
else if (channel_user->modes & IRC_CHAN_MODE_VOICE)
@@ -2478,8 +2437,7 @@ 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 strv masks;
- strv_init (&masks);
+ struct strv masks = strv_make ();
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++)
@@ -2495,8 +2453,7 @@ irc_handle_whois (const struct irc_message *msg, struct client *c)
}
else
{
- struct str_map_iter iter;
- str_map_iter_init (&iter, &c->ctx->users);
+ struct str_map_iter iter = str_map_iter_make (&c->ctx->users);
bool found = false;
while ((target = str_map_iter_next (&iter))
&& !irc_fnmatch (mask, target->nickname))
@@ -2520,8 +2477,7 @@ 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 strv nicks;
- strv_init (&nicks);
+ struct strv nicks = strv_make ();
cstr_split (msg->params.vector[0], ",", true, &nicks);
for (size_t i = 0; i < nicks.len; i++)
@@ -2623,8 +2579,8 @@ static void
irc_part_all_channels (struct client *c)
{
// We have to be careful here, the channel might get destroyed
- struct str_map_unset_iter iter;
- str_map_unset_iter_init (&iter, &c->ctx->channels);
+ struct str_map_unset_iter iter =
+ str_map_unset_iter_make (&c->ctx->channels);
struct channel *chan;
while ((chan = str_map_unset_iter_next (&iter)))
@@ -2640,8 +2596,7 @@ 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 strv channels;
- strv_init (&channels);
+ struct strv channels = strv_make ();
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);
@@ -2689,11 +2644,9 @@ irc_handle_kick (const struct irc_message *msg, struct client *c)
if (msg->params.len > 2)
reason = msg->params.vector[2];
- struct strv channels;
- struct strv users;
- strv_init (&channels);
- strv_init (&users);
+ struct strv channels = strv_make ();
cstr_split (msg->params.vector[0], ",", true, &channels);
+ struct strv users = strv_make ();
cstr_split (msg->params.vector[1], ",", true, &users);
if (channels.len == 1)
@@ -2818,11 +2771,9 @@ irc_handle_join (const struct irc_message *msg, struct client *c)
return;
}
- struct strv channels;
- struct strv keys;
- strv_init (&channels);
- strv_init (&keys);
+ struct strv channels = strv_make ();
cstr_split (msg->params.vector[0], ",", true, &channels);
+ struct strv keys = strv_make ();
if (msg->params.len > 1)
cstr_split (msg->params.vector[1], ",", true, &keys);
@@ -2871,9 +2822,7 @@ irc_handle_ison (const struct irc_message *msg, struct client *c)
if (msg->params.len < 1)
RETURN_WITH_REPLY (c, IRC_ERR_NEEDMOREPARAMS, msg->command);
- struct str result;
- str_init (&result);
-
+ struct str result = str_make ();
const char *nick;
if (str_map_find (&c->ctx->users, (nick = msg->params.vector[0])))
str_append (&result, nick);
@@ -2918,8 +2867,7 @@ irc_handle_stats_links (struct client *c, const struct irc_message *msg)
static void
irc_handle_stats_commands (struct client *c)
{
- struct str_map_iter iter;
- str_map_iter_init (&iter, &c->ctx->handlers);
+ struct str_map_iter iter = str_map_iter_make (&c->ctx->handlers);
struct irc_command *handler;
while ((handler = str_map_iter_next (&iter)))
{
@@ -3489,19 +3437,19 @@ irc_try_fetch_client (struct server_context *ctx, int listen_fd)
LIST_PREPEND (ctx->clients, c);
ctx->n_clients++;
- poller_fd_init (&c->socket_event, &c->ctx->poller, c->socket_fd);
+ c->socket_event = poller_fd_make (&c->ctx->poller, c->socket_fd);
c->socket_event.dispatcher = (poller_fd_fn) on_client_ready;
c->socket_event.user_data = c;
- poller_timer_init (&c->kill_timer, &c->ctx->poller);
+ c->kill_timer = poller_timer_make (&c->ctx->poller);
c->kill_timer.dispatcher = (poller_timer_fn) on_client_kill_timer;
c->kill_timer.user_data = c;
- poller_timer_init (&c->timeout_timer, &c->ctx->poller);
+ c->timeout_timer = poller_timer_make (&c->ctx->poller);
c->timeout_timer.dispatcher = (poller_timer_fn) on_client_timeout_timer;
c->timeout_timer.user_data = c;
- poller_timer_init (&c->ping_timer, &c->ctx->poller);
+ c->ping_timer = poller_timer_make (&c->ctx->poller);
c->ping_timer.dispatcher = (poller_timer_fn) on_client_ping_timer;
c->ping_timer.user_data = c;
@@ -3512,7 +3460,7 @@ irc_try_fetch_client (struct server_context *ctx, int listen_fd)
c->gni->dispatcher = on_client_gni_resolved;
c->gni->user_data = c;
- poller_timer_init (&c->gni_timer, &c->ctx->poller);
+ c->gni_timer = poller_timer_make (&c->ctx->poller);
c->gni_timer.dispatcher = (poller_timer_fn) on_client_gni_timer;
c->gni_timer.user_data = c;
@@ -3546,9 +3494,7 @@ irc_ssl_info_callback (const SSL *ssl, int where, int ret)
{
// For debugging only; provides us with the most important information
- struct str s;
- str_init (&s);
-
+ struct str s = str_make ();
if (where & SSL_CB_LOOP)
str_append_printf (&s, "loop (%s) ",
SSL_state_string_long (ssl));
@@ -3709,8 +3655,7 @@ irc_initialize_motd (struct server_context *ctx, struct error **e)
return false;
}
- struct str line;
- str_init (&line);
+ struct str line = str_make ();
while (read_line (fp, &line))
strv_append_owned (&ctx->motd, str_steal (&line));
str_free (&line);
@@ -3741,8 +3686,7 @@ irc_parse_config (struct server_context *ctx, struct error **e)
PARSE_UNSIGNED (max_connections, 0, UINT_MAX);
bool result = true;
- struct strv fingerprints;
- strv_init (&fingerprints);
+ struct strv fingerprints = strv_make ();
const char *operators = str_map_find (&ctx->config, "operators");
if (operators)
cstr_split (operators, ",", true, &fingerprints);
@@ -3880,7 +3824,7 @@ irc_listen_resolve (struct server_context *ctx,
set_blocking (fd, false);
struct poller_fd *event = &ctx->listen_events[ctx->n_listen_fds];
- poller_fd_init (event, &ctx->poller, fd);
+ *event = poller_fd_make (&ctx->poller, fd);
event->dispatcher = (poller_fd_fn) on_irc_client_available;
event->user_data = ctx;
@@ -3904,8 +3848,7 @@ irc_setup_listen_fds (struct server_context *ctx, struct error **e)
gai_hints.ai_socktype = SOCK_STREAM;
gai_hints.ai_flags = AI_PASSIVE;
- struct strv ports;
- strv_init (&ports);
+ struct strv ports = strv_make ();
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);
@@ -4015,8 +3958,8 @@ main (int argc, char *argv[])
{ 0, NULL, NULL, 0, NULL }
};
- struct opt_handler oh;
- opt_handler_init (&oh, argc, argv, opts, NULL, "Experimental IRC daemon.");
+ struct opt_handler oh =
+ opt_handler_make (argc, argv, opts, NULL, "Experimental IRC daemon.");
int c;
while ((c = opt_handler_get (&oh)) != -1)
@@ -4060,7 +4003,7 @@ main (int argc, char *argv[])
exit (EXIT_FAILURE);
}
- poller_fd_init (&ctx.signal_event, &ctx.poller, g_signal_pipe[0]);
+ ctx.signal_event = poller_fd_make (&ctx.poller, g_signal_pipe[0]);
ctx.signal_event.dispatcher = (poller_fd_fn) on_signal_pipe_readable;
ctx.signal_event.user_data = &ctx;
poller_fd_set (&ctx.signal_event, POLLIN);