コード例 #1
0
ファイル: inspircd11.c プロジェクト: danopia/denora
int denora_event_push(char *source, int ac, char **av)
{
/* Thanks to w00t from the inspircd team for helping me to write this function
 * debug: Received: :rock.musichat.net PUSH TestBOT ::rock.musichat.net 242 TestBOT :Server up 1 days, 07:47:54
 */
    Server *s;
    char *num;
    char buf[NET_BUFSIZE];

    if (denora->protocoldebug) {
        protocol_debug(source, ac, av);
    }

    num = myStrGetToken(av[1], ' ', 1);
    av[1] = myStrGetTokenRemainder(av[1], ' ', 3);

    if (!num || !av[1]) {
        alog(LOG_ERROR,
             "ERROR: Something wicked while handling the PUSH message (truncated message)");
        return MOD_CONT;
    }

    if (!strcmp(num, "375")) {
        rdb_query(QUERY_LOW, "UPDATE %s SET motd=\'\' WHERE server=\'%s\'",
                  ServerTable, source);
    } else if (!strcmp(num, "372")) {
        s = server_find(source);
        if (!s) {
            return MOD_CONT;
        }
        av[1]++;
        if (ac >= 2) {
            if (s->motd) {
                ircsnprintf(buf, NET_BUFSIZE - 1, "%s\n\r%s", s->motd,
                            av[1]);
                free(s->motd);
                s->motd = sstrdup(buf);
            } else {
                s->motd = sstrdup(av[1]);
            }
        }
    } else if (!strcmp(num, "376")) {
        s = server_find(source);
        if (!s) {
            return MOD_CONT;
        }
        sql_motd_store(s);
    } else if (!strcmp(num, "242")) {
        av[1]++;
        sql_do_uptime(source, av[1]);
    } else if (!strcmp(num, "248")) {
        av[2] = myStrGetTokenRemainder(av[1], ' ', 1);
        av[1] = myStrGetToken(av[1], ' ', 1);   /* possible memleak at this location */
        sql_uline(av[2]);
    }
    return MOD_CONT;
}
コード例 #2
0
ファイル: event_motd.c プロジェクト: wodim/irc-hispano
int denora_event_376(char *source, int ac, char **av)
{
    Server *s;
    s = server_find(source);
    if (!s) {
        return MOD_CONT;
    }
    sql_motd_store(s);
    return MOD_CONT;
}