int denora_event_spamfilter(char *source, int ac, char **av) { User * u; char setby[BUFSIZE]; char setat[10]; if (denora->protocoldebug) { protocol_debug(source, ac, av); } u = user_find(av[0]); if (!stricmp(av[1], "+") && u) { /* (char *target, char *action, char *setby, char *expires, char *setat, char *duration, char *reason, char *regex) */ ircsnprintf(setby, BUFSIZE, "%s!%s@%s", u->nick, u->username, u->vhost ? u->vhost : u->host); ircsnprintf(setat, 10, "%ld", (long int) time(NULL)); sql_do_server_spam_add(av[2], av[3], setby, "0", setat, av[4], av[ac-2], av[ac-1]); } else if (!stricmp(av[1], "-")) { /* (char *target, char *action, char *regex) */ sql_do_server_spam_remove(av[2], av[3], av[ac-1]); } return MOD_CONT; }
/* [Dec 30 16:03:09.300934 2005] Source inspircd.nomadirc.net [Dec 30 16:03:09.300990 2005] av[0] = Q [Dec 30 16:03:09.301046 2005] av[1] = ChanServ [Dec 30 16:03:09.301102 2005] av[2] = <Config> [Dec 30 16:03:09.301158 2005] av[3] = 1135968312 [Dec 30 16:03:09.301214 2005] av[4] = 0 [Dec 30 16:03:09.301270 2005] av[5] = Reserved For Services */ int denora_event_addline(char *source, int ac, char **av) { char *user, *host; int checkdur, timeset; char buf[BUFSIZE]; checkdur = atoi(av[4]); timeset = atoi(av[3]); if (checkdur != 0) { ircsnprintf(buf, BUFSIZE, "%ld", (long int) (checkdur + timeset)); } else { ircsnprintf(buf, BUFSIZE, "%ld", (long int) checkdur); } if (!stricmp(av[0], "G") || !stricmp(av[0], "E")) { user = myStrGetToken(av[1], '@', 0); host = myStrGetToken(av[1], '@', 1); sql_do_server_bans_add(av[0], user, host, av[2], av[3], buf, av[5]); if (user) free(user); if (host) free(host); } else if (!stricmp(av[0], "Q")) { sql_do_server_bans_add(av[0], (char *) "*", av[1], av[2], av[3], buf, av[5]); } else { sql_do_server_bans_add(av[0], (char *) "", av[1], av[2], av[3], buf, av[5]); } return MOD_CONT; }
int denora_event_eline(char *source, int ac, char **av) { char *user, *host; int checkdur; char buf[BUFSIZE]; char buf2[BUFSIZE]; user = myStrGetToken(av[0], '@', 0); host = myStrGetToken(av[0], '@', 1); if (ac >= 3) { ircsnprintf(buf, BUFSIZE, "%ld", (long int) time(NULL)); checkdur = atoi(av[1]); if (checkdur != 0) { ircsnprintf(buf2, BUFSIZE, "%ld", (long int) checkdur + time(NULL)); } else { ircsnprintf(buf2, BUFSIZE, "%ld", (long int) checkdur); } sql_do_server_bans_add((char *) "E", user, host, source, buf, buf2, av[2]); } else { sql_do_server_bans_remove((char *) "E", user, host); } if (user) free(user); if (host) free(host); return MOD_CONT; }
static void do_host_cloak(const char *inbuf, char *outbuf, int ipmask) { int cyc; unsigned int hosthash = 1, hosthash2 = 1; unsigned int maxcycle = strlen(inbuf); for (cyc = 0; cyc < maxcycle - 2; cyc += 2) hosthash *= (unsigned int) inbuf[cyc]; /* safety: decrement ourselves two steps back */ for (cyc = maxcycle - 1; cyc >= 1; cyc -= 2) hosthash2 *= (unsigned int) inbuf[cyc]; /* lets do some bitshifting -- this pretty much destroys the IP * sequence, while still providing a checksum. exactly what * we're shooting for. --nenolod */ hosthash += (hosthash2 / KEY); hosthash2 += (hosthash / KEY); if (ipmask == 0) ircsnprintf(outbuf, HOSTLEN, "%s-%X%X%s", ServerInfo.network_name, hosthash2, hosthash, strchr(inbuf, '.')); else ircsnprintf(outbuf, HOSTLEN, "%X%X.%s", hosthash2, hosthash, ServerInfo.network_name); }
Module *ns_load_module( const char *modfilename, Client * u ) { static char path[255]; static char loadmodname[255]; struct stat buf; strlcpy( loadmodname, modfilename, 255 ); ns_strlwr( loadmodname ); ircsnprintf( path, 255, "%s/%s%s", MOD_PATH, loadmodname, MOD_STDEXT ); if( stat( path, &buf ) != -1 ) { return load_stdmodule( path, u ); } #ifdef USE_PERL ircsnprintf( path, 255, "%s/%s%s", MOD_PATH, loadmodname, MOD_PERLEXT ); if( stat( path, &buf ) != -1 ) { Module *mod; mod = load_perlmodule( path, u ); if (!mod) { return NULL; } mod->info->build_date = ns_malloc( 10 ); strftime( ( char * )mod->info->build_date, 9, "%d/%m/%y", gmtime( &buf.st_mtime ) ); mod->info->build_time = ns_malloc( 11 ); strftime( ( char * )mod->info->build_time, 10, "%H:%M", gmtime( &buf.st_mtime ) ); return mod; } #endif /* USE_PERL */ /* if we get here, ehhh, doesn't exist */ load_module_error( u, modfilename, __( "Module file not found", u ) ); return NULL; }
void ls_switch_file( ChannelLog *cl ) { static char tmbuf[MAXPATH]; static char newfname[MAXPATH]; static char oldfname[MAXPATH]; int res; /* no need to switch, its not opened */ if( cl->logfile == NULL ) return; ls_close_log( cl ); /* check if the target directory exists */ if( os_create_dir( LogServ.savedir ) != NS_SUCCESS ) { return; } os_strftime( tmbuf, MAXPATH, "%d%m%Y%H%M%S", os_localtime( &me.now ) ); ircsnprintf( newfname, MAXPATH, "%s/%s-%s.log", LogServ.savedir, cl->filename, tmbuf ); ircsnprintf( oldfname, MAXPATH, "%s/%s.log", LogServ.logdir, cl->filename ); res = os_rename( oldfname, newfname ); if( res != 0 ) { nlog( LOG_CRITICAL, "Couldn't rename file %s: %s", oldfname, os_strerror() ); return; } nlog( LOG_NORMAL, "Switched Logfile for %s from %s to %s", cl->channame, oldfname, newfname ); }
VOIDSIG sighandler(int signum) { #ifndef _WIN32 if (started) { if (signum == SIGQUIT) { /* nothing -- terminate below */ } else if (!waiting) { alog(LOG_NORMAL, "PANIC! buffer = %s", inbuf); /* Cut off if this would make IRC command >510 characters. */ if (strlen(inbuf) > 448) { inbuf[446] = '>'; inbuf[447] = '>'; inbuf[448] = 0; } denora_cmd_global(NULL, "PANIC! buffer = %s\r\n", inbuf); } else if (waiting < 0) { /* This is static on the off-chance we run low on stack */ static char buf[BUFSIZE]; switch (waiting) { case -1: ircsnprintf(buf, sizeof(buf), "in timed_update"); break; default: ircsnprintf(buf, sizeof(buf), "waiting=%d", waiting); } denora_cmd_global(NULL, "PANIC! %s (%s)", buf, strsignal(signum)); alog(LOG_NORMAL, "PANIC! %s (%s)", buf, strsignal(signum)); } } #endif if ( #if !defined(USE_THREADS) #ifndef _WIN32 signum == SIGUSR1 || #endif #endif !(denora->qmsg = calloc(BUFSIZE, 1))) { denora->qmsg = sstrdup("Out of memory!"); } else { ircsnprintf(denora->qmsg, BUFSIZE, "Stats terminating: %s", strsignal(signum)); } send_event(EVENT_SIGNAL, 2, "unknown", denora->qmsg); if (started) { denora_shutdown(); exit(0); } else { if (isatty(2)) { fprintf(stderr, "%s\n", denora->qmsg); } else { alog(LOG_NORMAL, "%s", denora->qmsg); } exit(1); } return; }
/* * Compact G-Line store: dump active glines to a new file and remove the * current journal. * Returns 1 on success, 0 on failure. */ int glinestore_compact(void) { char buf1[512]; int newfile; /* userban.c */ extern void gs_dumpglines(int); if (forked) sendto_ops_lev(DEBUG_LEV, "Compacting G-Line store..."); journalcount = 0; /* open a compaction file to dump all active glines to */ ircsnprintf(buf1, sizeof(buf1), "%s/.glines_c", runpath); newfile = open(buf1, O_WRONLY|O_CREAT|O_TRUNC, 0700); if (newfile < 0) { ircsnprintf(buf1, sizeof(buf1), "ERROR: Unable to create G-Line" " compaction file .glines_c: %s", strerror(errno)); gs_error(buf1); return 0; } /* do the dump */ gs_dumpglines(newfile); close(newfile); /* close active storage file, rename compaction file, and reopen */ if (journal >= 0) { close(journal); journal = -1; } if (rename(buf1, journalfilename) < 0) { ircsnprintf(buf1, sizeof(buf1), "ERROR: Unable to rename G-Line" " compaction file .glines_c to .glines: %s", strerror(errno)); gs_error(buf1); return 0; } journal = open(journalfilename, O_WRONLY|O_APPEND, 0700); if (journal < 0) { ircsnprintf(buf1, sizeof(buf1), "ERROR: Unable to reopen G-Line" " storage file .glines: %s", strerror(errno)); gs_error(buf1); return 0; } return 1; }
static void cr_hashstring(char *src, char *trg) { unsigned char md[16]; MD5_CTX ctx; MD5Init(&ctx); MD5Update(&ctx, (unsigned char*)src, strlen(src)); MD5Final(md, &ctx); /* Endianness fix */ byteReverse(md, 4); ircsnprintf(trg, 9, "%08x", *(u_int32_t *) &md[0]); ircsnprintf(trg + 8, 9, "%08x", *(u_int32_t *) &md[4]); ircsnprintf(trg + 16, 9, "%08x", *(u_int32_t *) &md[8]); ircsnprintf(trg + 24, 9, "%08x", *(u_int32_t *) &md[12]); }
/* * Initialize G-Line storage. Pass 1 when glines don't need to be reloaded. * Returns 0 on failure, 1 otherwise. */ int glinestore_init(int noreload) { char buf1[1024]; FILE *jf; ircsnprintf(journalfilename, sizeof(journalfilename), "%s/.glines", runpath); if (journal >= 0) { if (noreload) return 1; close(journal); journal = -1; } /* "a+" to create if it doesn't exist */ jf = fopen(journalfilename, "a+"); if (!jf) { ircsnprintf(buf1, sizeof(buf1), "ERROR: Unable to open G-Line storage" " file .glines: %s", strerror(errno)); gs_error(buf1); return 0; } rewind(jf); /* replay journal */ while (fgets(buf1, sizeof(buf1), jf)) { char *s = strchr(buf1, '\n'); /* no newline, consider it malformed and stop here */ if (!s) break; *s = 0; if (!gs_read(buf1)) break; } fclose(jf); /* this will reopen the journal for appending */ return glinestore_compact(); }
VOIDSIG signal_rehash(int signum) { #ifdef POSIX_SIGNALS struct sigaction act; #endif #ifdef SIGHUP if (signum == SIGHUP) { #endif Dadmin *a; int i; alog(LOG_NORMAL, "Received SIGHUP: Saving Databases & Rehash Configuration"); if (initconf(denora->config, 1, mainconf) == -1) { denora->qmsg = calloc(50, 1); if (!denora->qmsg) { denora->qmsg = sstrdup(langstr(ALOG_ERR_REHASH_NO_MEM)); } else { ircsnprintf(denora->qmsg, sizeof(denora->qmsg), "%s", langstr(ALOG_ERR_REHASH)); } denora->quitting = 1; send_event(EVENT_SIGNAL, 2, "SIGHUP", denora->qmsg); } else { /* Remove all config file admins from admin struct before re-reading config file */ for (i = 0; i < 1024; i++) { for (a = adminlists[i]; a; a = a->next) { if (a->configfile) { free_admin(a); } break; } } merge_confs(); } /* Reload GeoIP db files */ if (gi) { GeoIP_delete(gi); } if (gi_v6) { GeoIP_delete(gi_v6); } gi = GeoIP_new(GEOIP_STANDARD); gi_v6 = GeoIP_open_type(GEOIP_COUNTRY_EDITION_V6, GEOIP_STANDARD); #ifdef POSIX_SIGNALS act.sa_handler = signal_rehash; act.sa_flags = 0; (void) sigemptyset(&act.sa_mask); (void) sigaddset(&act.sa_mask, SIGHUP); (void) sigaction(SIGHUP, &act, NULL); #else # ifndef _WIN32 (void) signal(SIGHUP, signal_rehash); /* sysV -argv */ # endif #endif #ifdef SIGHUP } #endif }
/* added cause this is used over and over in the code */ char *log_gettimestamp(void) { time_t t; struct tm tm; static char tbuf[256]; time(&t); #ifdef _WIN32 localtime_s(&tm, &t); #else tm = *localtime(&t); #endif #if HAVE_GETTIMEOFDAY if (denora->debug) { char *s; struct timeval tv; gettimeofday(&tv, NULL); strftime(tbuf, sizeof(tbuf) - 1, "[%b %d %H:%M:%S", &tm); s = tbuf + strlen(tbuf); s += ircsnprintf(s, sizeof(tbuf) - (s - tbuf), ".%06d", (int) tv.tv_usec); strftime(s, sizeof(tbuf) - (s - tbuf) - 1, " %Y]", &tm); } else { #endif strftime(tbuf, sizeof(tbuf) - 1, "[%b %d %H:%M:%S %Y]", &tm); #if HAVE_GETTIMEOFDAY } #endif return tbuf; }
/** * Process numeric 372 messages * * @param source is the server that sent the message * @param ac is the array count * @param av is the array * * @return return is always MOD_CONT * */ int denora_event_372(char *source, int ac, char **av) { Server *s; char buf[NET_BUFSIZE]; SET_SEGV_LOCATION(); if (denora->protocoldebug) { protocol_debug(source, ac, av); } s = server_find(source); if (!s) { return MOD_CONT; } 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]); } } return MOD_CONT; }
int InitTLDStatistics( void ) { TLD *t; SET_SEGV_LOCATION(); tldstatlist = nv_list_create( LISTCOUNT_T_MAX, "StatServ-TLD", nv_ss_tld, NV_FLAGS_RO, NULL ); if( !tldstatlist ) { nlog( LOG_CRITICAL, "Unable to create TLD list" ); return NS_FAILURE; } gi = NULL; /* now open the various DB's */ if( GeoIP_db_avail( GEOIP_COUNTRY_EDITION ) ) { gi = GeoIP_open_type( GEOIP_COUNTRY_EDITION, GEOIP_STANDARD ); if( gi != NULL ) nlog( LOG_NOTICE, "Loaded %s GeoIP Database", GeoIPDBDescription[GEOIP_COUNTRY_EDITION] ); else nlog( LOG_WARNING, "%s Database may be corrupt", GeoIPDBDescription[GEOIP_COUNTRY_EDITION] ); } else { nlog( LOG_WARNING, "GeoIP Database is not available. TLD stats will not be available" ); } t = ns_calloc( sizeof( TLD ) ); ircsnprintf( t->tld, 5, UNKNOWN_COUNTRY_CODE ); strlcpy( t->country, "Unknown", 8 ); lnode_create_append( tldstatlist, t ); DBAOpenTable( TLD_TABLE ); LoadTLDStats(); return NS_SUCCESS; }
void ilog(ilogfile dest, const char *format, ...) { FILE *logfile = *log_table[dest].logfile; char buf[BUFSIZE]; char buf2[BUFSIZE]; va_list args; if(logfile == NULL) return; va_start(args, format); ircvsnprintf(buf, sizeof(buf), format, args); va_end(args); ircsnprintf(buf2, sizeof(buf2), "%s %s\n", smalldate(), buf); if(fputs(buf2, logfile) < 0) { fclose(logfile); *log_table[dest].logfile = NULL; } fflush(logfile); }
static void m_nick( char *origin, char **argv, int argc, int srv ) { if( !srv ) { if( ircd_srv.protocol & PROTOCOL_NICKv2 ) { if( ircd_srv.protocol & PROTOCOL_NICKIP ) { char ip[25]; ircsnprintf( ip, 25, "%d", ntohl( decode_ip( argv[9] ) ) ); do_nick( argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], ip, argv[6], argv[7], argv[8], argv[10], NULL, NULL ); } else { do_nick( argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], NULL, argv[6], argv[7], argv[8], argv[9], NULL, NULL ); } } else { do_nick( argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], NULL, argv[6], NULL, NULL, argv[9], NULL, NULL ); } } else { do_nickchange( origin, argv[0], NULL ); } }
/* ** m_quit ** parv[0] = sender prefix ** parv[1] = comment */ static int m_quit(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { char *comment = LOCAL_COPY((parc > 1 && parv[1]) ? parv[1] : client_p->name); char reason[REASONLEN + 1]; source_p->flags |= FLAGS_NORMALEX; if(strlen(comment) > (size_t) REASONLEN) comment[REASONLEN] = '\0'; strip_colour(comment); if(ConfigFileEntry.client_exit && comment[0]) { ircsnprintf(reason, sizeof(reason), "Quit: %s", comment); comment = reason; } if(!IsOper(source_p) && (source_p->localClient->firsttime + ConfigFileEntry.anti_spam_exit_message_time) > CurrentTime) { exit_client(client_p, source_p, source_p, "Client Quit"); return 0; } exit_client(client_p, source_p, source_p, comment); return 0; }
/* * exit_banned_client() * * Sends an appropriate ban message and disconnects a client. */ int exit_banned_client(aClient *cptr, int loc, char type, char *banmsg, int fast) { char rbuf[512]; char *target = "*"; char *reason = "<no reason specified>"; if (cptr->name[0]) target = cptr->name; if (!BadPtr(banmsg)) reason = banmsg; ircsnprintf(rbuf, sizeof(rbuf), "%c-banned: %s", type, reason); if (!fast) { sendto_one(&me, cptr, "NOTICE %s :*** You are banned from %s", target, loc ? me.name : Network_Name); sendto_one(&me, cptr, "NOTICE %s :*** Reason: %s", target, reason); sendto_one(&me, cptr, "NOTICE %s :*** Connection info: %s [%s]", target, get_client_name(cptr, FALSE), cipntoa(cptr)); sendto_one(&me, cptr, "NOTICE %s :*** Ban contact: %s", target, loc ? Local_Kline_Address : Network_Kline_Address); sendto_one(&me, cptr, "NOTICE %s :*** When contacting %s, please include " "all of the information shown above", target, Network_Name); sendto_one(&me, cptr, err_str(ERR_YOUREBANNEDCREEP), me.name, target, rbuf); throttle_force(cipntoa(cptr)); } return exit_client(cptr, cptr, &me, rbuf); }
/* [just a helper for channel_modef_string()] */ static inline char *chmodefstrhelper(char *buf, size_t size, char t, char tdef, unsigned short l, unsigned char a, unsigned char r) { char *p; char tmpbuf[16], *p2 = tmpbuf; ircsnprintf(buf, size, "%hd", l); p = buf + strlen(buf); size_t p_size = size - strlen(buf); if (!p_size) return 0; *p++ = t; if (!--p_size) return 0; if (a && ((a != tdef) || r)) { *p++ = '#'; if (!--p_size) return 0; *p++ = a; if (!--p_size) return 0; if (r) { snprintf(tmpbuf, sizeof(tmpbuf), "%hd", (short)r); while (p_size-- && (*p = *p2++)) p++; } } if (!p_size--) return 0; *p++ = ','; return p; }
/** returns the channelmode +f string (ie: '[5k,40j]:10') */ char *channel_modef_string(ChanFloodProt *x) { static char retbuf[512]; /* overkill :p */ char *p = retbuf; *p++ = '['; /* (alphabetized) */ if (x->l[FLD_CTCP]) p = chmodefstrhelper(p, sizeof(retbuf)-(p-retbuf), 'c', 'C', x->l[FLD_CTCP], x->a[FLD_CTCP], x->r[FLD_CTCP]); if (x->l[FLD_JOIN]) p = chmodefstrhelper(p, sizeof(retbuf)-(p-retbuf), 'j', 'i', x->l[FLD_JOIN], x->a[FLD_JOIN], x->r[FLD_JOIN]); if (x->l[FLD_KNOCK]) p = chmodefstrhelper(p, sizeof(retbuf)-(p-retbuf), 'k', 'K', x->l[FLD_KNOCK], x->a[FLD_KNOCK], x->r[FLD_KNOCK]); if (x->l[FLD_MSG]) p = chmodefstrhelper(p, sizeof(retbuf)-(p-retbuf), 'm', 'm', x->l[FLD_MSG], x->a[FLD_MSG], x->r[FLD_MSG]); if (x->l[FLD_NICK]) p = chmodefstrhelper(p, sizeof(retbuf)-(p-retbuf), 'n', 'N', x->l[FLD_NICK], x->a[FLD_NICK], x->r[FLD_NICK]); if (x->l[FLD_TEXT]) p = chmodefstrhelper(p, sizeof(retbuf)-(p-retbuf), 't', '\0', x->l[FLD_TEXT], x->a[FLD_TEXT], x->r[FLD_TEXT]); if (!p) return 0; if (*(p - 1) == ',') p--; if (p>=retbuf) p=retbuf-2; *p++ = ']'; ircsnprintf(p, sizeof(retbuf)-(p-retbuf), ":%hd", x->per); return retbuf; }
void do_chanflood_action(aChannel *chptr, int what, char *text) { long modeflag = 0; aCtab *tab = &cFlagTab[0]; char m; m = chptr->mode.floodprot->a[what]; if (!m) return; /* [TODO: add extended channel mode support] */ while(tab->mode != 0x0) { if (tab->flag == m) { modeflag = tab->mode; break; } tab++; } if (!modeflag) return; if (!(chptr->mode.mode & modeflag)) { char comment[1024], target[CHANNELLEN + 8]; ircsnprintf(comment, sizeof(comment), "*** Channel %sflood detected (limit is %d per %d seconds), setting mode +%c", text, chptr->mode.floodprot->l[what], chptr->mode.floodprot->per, m); ircsnprintf(target, sizeof(target), "%%%s", chptr->chname); sendto_channelprefix_butone(NULL, &me, chptr, PREFIX_HALFOP|PREFIX_OP|PREFIX_ADMIN|PREFIX_OWNER, ":%s NOTICE %s :%s", me.name, target, comment); sendto_server(&me, 0, 0, ":%s MODE %s +%c 0", me.name, chptr->chname, m); sendto_channel_butserv(chptr, &me, ":%s MODE %s +%c", me.name, chptr->chname, m); chptr->mode.mode |= modeflag; if (chptr->mode.floodprot->r[what]) /* Add remove-chanmode timer... */ { chanfloodtimer_add(chptr, m, modeflag, TStime() + ((long)chptr->mode.floodprot->r[what] * 60) - 5); /* (since the chanflood timer event is called every 10s, we do -5 here so the accurancy will * be -5..+5, without it it would be 0..+10.) */ } } }
void Win32LoadCoreDir(char *dirname) { #ifdef USE_MODULES BOOL fFinished; HANDLE hList; TCHAR szDir[MAX_PATH + 1]; TCHAR szSubDir[MAX_PATH + 1]; WIN32_FIND_DATA FileData; char *mname = NULL; Module *m; int status; char buffer[_MAX_PATH]; /* Get the current working directory: */ if (_getcwd(buffer, _MAX_PATH) == NULL) { alog(LOG_DEBUG, "debug: Unable to set Current working directory"); } ircsnprintf(szDir, sizeof(szDir), "%s\\%s\\*", buffer, dirname); hList = FindFirstFile(szDir, &FileData); if (hList != INVALID_HANDLE_VALUE) { fFinished = FALSE; while (!fFinished) { if (!(FileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { mname = sstrdup(FileData.cFileName); mname[strlen(FileData.cFileName) - 4] = '\0'; m = findModule(mname); if (!m) { m = createCoreModule(mname); mod_current_module = m; mod_current_user = NULL; alog(LOG_DEBUG, "trying to load [%s]", mod_current_module->name); status = loadCoreModule(mod_current_module, NULL); alog(LOG_DEBUG, langstr(ALOG_MOD_STATUS), status, ModuleGetErrStr(status)); if (status != MOD_ERR_OK) { destroyModule(m); } mod_current_module = NULL; mod_current_user = NULL; } dfree(mname); } if (!FindNextFile(hList, &FileData)) { if (GetLastError() == ERROR_NO_MORE_FILES) { fFinished = TRUE; } } } } else { printf("Invalid File Handle. GetLastError reports %d\n", GetLastError()); } FindClose(hList); #endif }
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; }
void xchat_startlog( ChannelLog *chandata, const CmdParams *cmdparams ) { static char startlog[BUFSIZE]; static char tmbuf[TIMEBUFSIZE]; os_strftime( tmbuf, TIMEBUFSIZE, "%a %b %d %H:%M:%S %Y", os_localtime( &me.now ) ); ircsnprintf( startlog, BUFSIZE, XSTARTLOG, tmbuf ); os_fprintf( chandata->logfile, "%s", startlog ); }
void db_mysql_error(int severity, const char *msg) { static char buf[512]; SET_SEGV_LOCATION(); if (mysql_error(mysql)) { ircsnprintf(buf, sizeof(buf), "MySQL %s %s: %s", msg, severity == SQL_WARNING ? "warning" : "error", mysql_error(mysql)); } else { ircsnprintf(buf, sizeof(buf), "MySQL %s %s", msg, severity == SQL_WARNING ? "warning" : "error"); } log_perror("%s", buf); }
/* AF N Client1 1 947957573 User userhost.net +oiwg DAqAoB AFAAA :Generic Client. */ void asuka_cmd_nick(char *nick, char *name, const char *modes) { char nicknumbuf[6]; send_cmd(p10id, "N %s 1 %ld %s %s %s B]AAAB %sAA%c :%s", nick, (long int) time(NULL), ServiceUser, ServiceHost, modes, p10id, (p10nickcnt + 'A'), name); ircsnprintf(nicknumbuf, 6, "%sAA%c", p10id, (p10nickcnt + 'A')); new_uid(nick, nicknumbuf); p10nickcnt++; }
void asuka_cmd_bot_nick(char *nick, char *user, char *host, char *real, char *modes) { char nicknumbuf[6]; send_cmd(p10id, "N %s 1 %ld %s %s %s B]AAAB %sAA%c :%s", nick, (long int) time(NULL), user, host, modes, p10id, (p10nickcnt + 'A'), real); ircsnprintf(nicknumbuf, 6, "%sAA%c", p10id, (p10nickcnt + 'A')); new_uid(nick, nicknumbuf); p10nickcnt++; }
int denora_event_kline(char *source, int ac, char **av) { char buf[BUFSIZE]; *buf = '\0'; if (denora->protocoldebug) { protocol_debug(source, ac, av); } ircsnprintf(buf, BUFSIZE, "%ld", (long int) time(NULL)); sql_do_server_bans_add(NULL, av[2], av[3], source, buf, av[1], av[4]); return MOD_CONT; }
int denora_event_qline(char *source, int ac, char **av) { int checkdur; char buf[BUFSIZE]; char buf2[BUFSIZE]; if (ac >= 3) { ircsnprintf(buf, BUFSIZE, "%ld", (long int) time(NULL)); checkdur = atoi(av[1]); if (checkdur != 0) { ircsnprintf(buf2, BUFSIZE, "%ld", (long int) checkdur + time(NULL)); } else { ircsnprintf(buf2, BUFSIZE, "%ld", (long int) checkdur); } sql_do_server_bans_add((char *) "Q", (char *) "*", av[0], source, buf, buf2, av[2]); } else { sql_do_server_bans_remove((char *) "Q", (char *) "*", av[0]); } return MOD_CONT; }
/* * Player Plays Card */ void playcard(int cnp) { if ((cnp > 0) && (cnp < (wplayercardstotal[currentplayer] + 1))){ if (wplayercardsinhand[currentplayer][(cnp - 1)] < 13) { strlcpy (csuitcolour, "\0034", 10); strlcpy (csuit, "Hearts", 10); } else if (wplayercardsinhand[currentplayer][(cnp - 1)] < 26) { strlcpy (csuitcolour, "\0037", 10); strlcpy (csuit, "Diamonds", 10); } else if (wplayercardsinhand[currentplayer][(cnp - 1)] < 39) { strlcpy (csuitcolour, "\00314", 10); strlcpy (csuit, "Clubs", 10); } else { strlcpy (csuitcolour, "\00315", 10); strlcpy (csuit, "Spades", 10); } switch ((wplayercardsinhand[currentplayer][(cnp - 1)] % 13)) { case 12: strlcpy (csuitcard, "Ace", 10); break; case 11: strlcpy (csuitcard, "King", 10); break; case 10: strlcpy (csuitcard, "Queen", 10); break; case 9: strlcpy (csuitcard, "Jack", 10); break; default: ircsnprintf(csuitcard, 10, "%d", ((wplayercardsinhand[currentplayer][(cnp - 1)] % 13) + 2)); break; } irc_chanprivmsg (ws_bot, warroom, "\0037%s\0039 played Card\00311 %d \0039(%s %s of %s \0039)", wplayernick[currentplayer], cnp, csuitcolour, csuitcard, csuit); cnp--; wstackcards[wstackcardscurrent]= wplayercardsinhand[currentplayer][cnp]; wstackcardscurrent++; wplayercardplayed[currentplayer]= wplayercardsinhand[currentplayer][cnp]; wplayercardstotal[currentplayer]--; for (wpln = cnp; wpln < wplayercardstotal[currentplayer]; wpln++) { wplayercardsinhand[currentplayer][wpln]= wplayercardsinhand[currentplayer][(wpln +1)]; } wplayercardsinhand[currentplayer][wplayercardstotal[currentplayer]]= 0; currentplayer++; if (currentplayer < currentwarplayercount) { askplaycard(); } else { checkhandwinner(); } } }