/**
* Send a line to the network.
* @param s Network to send to.
+ * @param c Client the line was sent by originally.
* @param ol Line to send to the network
- * @param is_private Whether the line should not be broadcast to other clients
*/
-gboolean network_send_line(struct irc_network *s, const struct irc_line *ol)
+gboolean network_send_line(struct irc_network *s, struct irc_client *c,
- const struct irc_line *ol, gboolean is_private)
++ const struct irc_line *ol)
{
struct irc_line l;
-- char *tmp = NULL;
g_assert(ol);
g_assert(s);
l = *ol;
if (l.origin == NULL && s->external_state != NULL) {
-- tmp = l.origin = g_strdup(s->external_state->me.hostmask);
++ l.origin = s->external_state->me.hostmask;
}
if (l.origin != NULL) {
if (!s->callbacks->process_to_server(s, &l)) {
-- g_free(tmp);
return TRUE;
}
- g_free(tmp);
}
- g_assert(l.args[0] != NULL);
-
- /* Also write this message to all other clients currently connected */
- if (!is_private &&
- (!g_strcasecmp(l.args[0], "PRIVMSG") ||
- !g_strcasecmp(l.args[0], "NOTICE"))) {
- g_assert(l.origin);
- if (s->global->config->report_time == REPORT_TIME_ALWAYS)
- line_prefix_time(&l, time(NULL)+s->global->config->report_time_offset);
-
- clients_send(s->clients, &l, c);
- }
-
- g_free(tmp);
-
- redirect_record(&s->queries, s, c, ol);
-
- return network_send_line_direct(s, ol);
+ return network_send_line_direct(s, c, ol);
}
/**
l = virc_parse_line(NULL, ap);
va_end(ap);
- ret = network_send_line(s, NULL, l, TRUE);
- ret = network_send_line(s, l);
++ ret = network_send_line(s, NULL, l);
free_line(l);
G_MODULE_EXPORT gboolean connect_network(struct irc_network *);
G_MODULE_EXPORT void irc_network_select_next_server(struct irc_network *n);
G_MODULE_EXPORT gboolean disconnect_network(struct irc_network *s);
- G_MODULE_EXPORT gboolean network_send_line(struct irc_network *s, struct irc_client *c, const struct irc_line *, gboolean);
-G_MODULE_EXPORT gboolean network_send_line(struct irc_network *s, const struct irc_line *);
++G_MODULE_EXPORT gboolean network_send_line(struct irc_network *s, struct irc_client *c, const struct irc_line *);
G_MODULE_EXPORT gboolean network_send_args(struct irc_network *s, ...);
G_MODULE_EXPORT void register_virtual_network(struct virtual_network_ops *);
G_MODULE_EXPORT struct virtual_network_ops *find_virtual_network(const char *name);
for (i = 0; nc->autocmd && nc->autocmd[i]; i++) {
struct irc_line *l = irc_parse_line(nc->autocmd[i]);
- network_send_line(n, NULL, l, FALSE);
- network_send_line(n, l);
++ network_send_line(n, NULL, l);
free_line(l);
}
* @param c Client that originally sent the line
* @param is_private Whether the line should not be broadcast to other clients
*/
--gboolean network_forward_line(struct irc_network *s, struct irc_client *c, const struct irc_line *l,
-- gboolean is_private)
++gboolean network_forward_line(struct irc_network *s, struct irc_client *c,
++ const struct irc_line *l, gboolean is_private)
{
- return network_send_line(s, c, l, is_private);
- }
+ /* Also write this message to all other clients currently connected */
+ if (!is_private &&
+ (!g_strcasecmp(l->args[0], "PRIVMSG") ||
+ !g_strcasecmp(l->args[0], "NOTICE"))) {
- g_assert(l->origin != NULL);
++ struct irc_line *nl = linedup(l);
++ g_free(nl->origin);
++ nl->origin = g_strdup(s->external_state->me.hostmask);
+ if (s->global->config->report_time == REPORT_TIME_ALWAYS)
- line_prefix_time(l, time(NULL)+s->global->config->report_time_offset);
++ line_prefix_time(nl, time(NULL)+s->global->config->report_time_offset);
+
- clients_send(s->clients, l, c);
++ clients_send(s->clients, nl, c);
++ free_line(nl);
+ }
- return network_send_line(s, l);
+ redirect_record(&s->queries, s, c, l);
+
++ return network_send_line(s, NULL, l);
+ }