diff options
author | Anton Luka Šijanec <anton@sijanec.eu> | 2022-04-30 16:10:58 +0200 |
---|---|---|
committer | Anton Luka Šijanec <anton@sijanec.eu> | 2022-04-30 16:10:58 +0200 |
commit | 78f69152b58d9d265f6c34542e241f0e638bb5a7 (patch) | |
tree | e96c8bdceea8912390aecf56d3d36e352a9cb0e8 /ircxmpp.c | |
parent | se prevede, nepreverjeno, grem na plažo (diff) | |
download | ircxmpp-78f69152b58d9d265f6c34542e241f0e638bb5a7.tar ircxmpp-78f69152b58d9d265f6c34542e241f0e638bb5a7.tar.gz ircxmpp-78f69152b58d9d265f6c34542e241f0e638bb5a7.tar.bz2 ircxmpp-78f69152b58d9d265f6c34542e241f0e638bb5a7.tar.lz ircxmpp-78f69152b58d9d265f6c34542e241f0e638bb5a7.tar.xz ircxmpp-78f69152b58d9d265f6c34542e241f0e638bb5a7.tar.zst ircxmpp-78f69152b58d9d265f6c34542e241f0e638bb5a7.zip |
Diffstat (limited to '')
-rw-r--r-- | ircxmpp.c | 32 |
1 files changed, 16 insertions, 16 deletions
@@ -63,12 +63,14 @@ static void free_bridge (struct bridge * bridge, const char * razlog) { LOG(bridge->ircxmpp, IRCXMPP_DEBUG, "freeing bridge with reason: %s", razlog); if (bridge->irc) { irc_cmd_quit(bridge->irc, razlog); - irc_run_once(bridge); // verjetno je to potrebno, da pošlje quit + if (strcmp(razlog, "free_bridge_from_tdestroy")) + irc_run_once(bridge); // verjetno je to potrebno, da pošlje quit irc_destroy_session(bridge->irc); } if (bridge->conn) xmpp_conn_release(bridge->conn); // graceful disconnect, what is that? - tdelete(bridge, bridge->ircxmpp->bridges, bridge_compare); + if (strcmp(razlog, "free_bridge_from_tdestroy")) + tdelete(bridge, bridge->ircxmpp->bridges, bridge_compare); free(bridge->identifier); for (size_t i = 0; i < bridge->messages_length; i++) free(bridge->messages[i]); @@ -76,13 +78,12 @@ static void free_bridge (struct bridge * bridge, const char * razlog) { free(bridge); } -static char * free_reason = "global readdson not set since startup. this is a bug. report it."; -static void free_bridge_global_reason (void * bridge) { - free_bridge((struct bridge *) bridge, free_reason); +static void free_bridge_from_tdestroy (void * bridge) { + free_bridge((struct bridge *) bridge, "free_bridge_from_tdestroy"); } static void free_bridges (void ** bridges) { - free_reason = "vsi mostovi se podirajo, ker se ircxmpp izklaplja"; - tdestroy(*bridges, free_bridge_global_reason); + tdestroy(*bridges, free_bridge_from_tdestroy); + *bridges = NULL; } static struct bridge * find_bridge (void ** bridges, const char * id, enum side side) { @@ -259,9 +260,8 @@ static void dump_event_control ( irc_session_t * s, const char * e, const char * o, const char ** p, unsigned c) { struct ircxmpp * ircxmpp = (struct ircxmpp *) irc_get_ctx(s); int requiredbuf = 256; - for (unsigned int i = 0; i < c; i++) { - requiredbuf += strlen(p[c])+256; - } + for (unsigned int i = 0; i < c; i++) + requiredbuf += strlen(p[i])+256; if (requiredbuf > 65535) return; char buf[requiredbuf]; @@ -272,7 +272,7 @@ static void dump_event_control ( cp += sprintf(cp, "|"); cp += sprintf(cp, "%s", p[i]); } - cp += sprintf(cp, "]"); + /* cp += */ sprintf(cp, "]"); ircxmpp->log_handler(ircxmpp->log_userdata, IRCXMPP_DEBUG, "irc_event_control", buf); } static void dump_event ( @@ -281,7 +281,7 @@ static void dump_event ( struct ircxmpp * ircxmpp = bridge->ircxmpp; int requiredbuf = 256; for (unsigned int i = 0; i < c; i++) { - requiredbuf += strlen(p[c])+256; + requiredbuf += strlen(p[i])+256; } if (requiredbuf > 65535) return; @@ -293,7 +293,7 @@ static void dump_event ( cp += sprintf(cp, "|"); cp += sprintf(cp, "%s", p[i]); } - cp += sprintf(cp, "]"); + /* cp += */ sprintf(cp, "]"); ircxmpp->log_handler(ircxmpp->log_userdata, IRCXMPP_DEBUG, "irc_event", buf); } static void event_connect ( @@ -562,7 +562,7 @@ static void init_irc_control (struct ircxmpp * ircxmpp) { irc_run_once_control(ircxmpp); return; } -static void ircxmpp_default_logger (void * const u __attribute__((unused)), +static void default_log_handler (void * const u __attribute__((unused)), const enum ircxmpp_loglevel l, const char * const a, const char * const m) { char * t = "unspec"; switch (l) { @@ -605,14 +605,14 @@ static void send_xmpp_logs_to_me (void * const u, const xmpp_log_level_t l, cons struct ircxmpp * ircxmpp_init (void) { xmpp_initialize(); struct ircxmpp * ircxmpp = calloc(1, sizeof(struct ircxmpp)); - ircxmpp->log_handler = ircxmpp_default_logger; + ircxmpp->log_handler = default_log_handler; ircxmpp->xmpp_logger.handler = send_xmpp_logs_to_me; ircxmpp->xmpp_logger.userdata = ircxmpp; return ircxmpp; } void ircxmpp_set_log_handler (struct ircxmpp * ircxmpp, ircxmpp_logger log_handler) { if (!log_handler) - ircxmpp->log_handler = ircxmpp_default_logger; + ircxmpp->log_handler = default_log_handler; ircxmpp->log_handler = log_handler; } void ircxmpp_set_log_userdata (struct ircxmpp * ircxmpp, void * log_userdata) { |