plugin_t *plugin_find_uid(const char *uid) { plugin_t *p; for (p = plugins; p; p = p->next) { if (p && p->pclass == PLUGIN_PROTOCOL && p->name && valid_plugin_uid(p, uid)) return p; } return NULL; }
int irc_autorejoin(session_t *s, int when, char *chan) { irc_private_t *j; string_t st; window_t *w; char *chanprefix; int rejoin; #if 1 /* there's no need of doing it, already checked by irc_onkick_handler() or if it goes through irc_c_init() it's even better. */ if (!s || !(j = s->priv) || (s->plugin != &irc_plugin)) return -1; #endif chanprefix = SOP(_005_CHANTYPES); rejoin = session_int_get(s, "REJOIN"); if (!(rejoin&(1<<(when)))) return -1; switch (when) { case IRC_REJOIN_CONNECT: st = string_init(NULL); for (w = windows; w; w = w->next) { if (!w->target || w->session != s) /* check if sessions match and has w->target */ continue; if (valid_plugin_uid(s->plugin, w->target) != 1) /* check if window is correct for irc: */ continue; if (!xstrchr(chanprefix, (w->target)[4])) /* check if this is channel.. */ continue; if (st->len) string_append_c(st, ','); if ((w->target)[4] == '!') { string_append_c(st, '!'); string_append(st, w->target + 10); } else { string_append(st, w->target + 4); } } if (st->len) irc_write(s, "JOIN %s\r\n", st->str); string_free(st, 1); break; case IRC_REJOIN_KICK: irc_write(s, "JOIN %s\r\n", chan); break; default: return -1; } return 0; }