void InfoBoxContentTemperatureForecast::Update(InfoBoxData &data) { auto temperature = CommonInterface::GetComputerSettings().forecast_temperature; data.SetValue(_T("%2.1f"), temperature.ToUser()); data.SetValueUnit(Units::current.temperature_unit); }
void showbanlist(char *source, char *ch, char *args) { char buffer[200]; char channel[80]; register achannel *chan; register aban *curr; if (*args == '#') { GetWord(0, args, channel); } else { strcpy(channel, ch); GuessChannel(source, channel); } if (!strcmp(channel, "*")) { notice(source, "SYNTAX: banlist <channel>"); return; } /* user must be on a channel to see the ban list */ if (ToUser(channel, source) == NULL) { sprintf(buffer, "%s: You are not on that channel", channel); notice(source, buffer); return; } chan = ToChannel(channel); curr = chan->bans; if (curr == NULL) { sprintf(buffer, "%s: ban list is empty.", channel); notice(source, buffer); return; } while (curr != NULL) { notice(source, curr->pattern); curr = curr->next; } sprintf(buffer, "%s: End of ban list", channel); notice(source, buffer); }
static void* DebugAllocator(size_t size, bool Noexcept, ALLOCATION_TYPE type,const char* Function, const char* File, int Line) { size_t realSize = GetRequiredSize(size); auto Info = static_cast<MEMINFO*>(malloc(realSize)); if (!Info) { if (Noexcept) return nullptr; else throw far_bad_alloc(File, Line, Function, type, size); } Info->AllocationType = type; Info->Size = realSize; Info->Function = Function; Info->File = File; Info->Line = Line; GetMarker(Info) = EndMarker; RegisterBlock(Info); return ToUser(Info); }
int CheckFlood(char *source, char *channel, int length) { char buffer[200]; register achannel *chan; register auser *user; register amsg *msg, *prev; register int count = 0; chan = ToChannel(channel); user = ToUser(channel, source); if (!chan || !chan->on || !user) return 0; /* BEGINNING OF FLOOD PROTECTION ROUTINE */ /* 1st clean msghist older than 15 seconds */ prev = NULL; msg = user->msghist; while (msg) { if (msg->time < (now - 15)) { if (prev) { prev->next = msg->next; TTLALLOCMEM -= sizeof(amsg); free(msg); msg = prev->next; } else { user->msghist = msg->next; TTLALLOCMEM -= sizeof(amsg); free(msg); msg = user->msghist; } } else { prev = msg; msg = msg->next; } } /* now add the current msg to the history */ msg = (amsg *) MALLOC(sizeof(amsg)); msg->time = now; msg->length = length; msg->next = user->msghist; user->msghist = msg; /* now count the number of entry in the history.. if it's greater than the max allowed... bite! */ count = 0; for (msg = user->msghist; msg; msg = msg->next, count++); if (chan->MsgFloodPro != 0 && count == chan->MsgFloodPro) { notice(source, "### FLOOD PROTECTION ACTIVATED ###"); sprintf(buffer, "%s!%s@%s %d", user->N->nick, user->N->username, user->N->site, PUBLIC_FLOOD_SUSPEND_TIME); suspend("", channel, buffer); count = IsShit(channel, source, NULL, NULL); #ifdef DEBUG printf("Argh! %s has a shit level %d\n", source, count); #endif sprintf(buffer, "FLOODPRO ACTIVATED BY %s ON %s", source, channel); log(buffer); switch (count) { case 0: case 1: case 2: case 3: case 4: log("First warning"); sprintf(buffer, "%s That was not very smart!", source); break; case 5: case 6: case 7: case 8: case 9: log("Second warning"); sprintf(buffer, "%s You're pushing your luck too far!", source); break; default: sprintf(buffer, "%s That was one time too many", source); } kick("", channel, buffer); sprintf(buffer, "%s %d %d *** FLOOD ***", user->N->nick, PUBLIC_FLOOD_SHITLIST_TIME, (count < 10) ? count + 5 : PUBLIC_FLOOD_SHITLIST_LEVEL); AddToShitList("", channel, buffer, 0); return 1; } return 0; }
void ban(char *source, char *chan, char *nicklist) { char buffer[300]; char OneNick[NICK_LENGTH]; char channel[CHANNELNAME_LENGTH]; register auser *user; register aluser *luser; register achannel *ch; register int i = 0; if (*nicklist == '#') { GetWord(0, nicklist, channel); nicklist = ToWord(1, nicklist); } else { strcpy(channel, chan); GuessChannel(source, channel); } if (!strcmp(channel, "*")) { notice(source, "SYNTAX: ban <channel> <nick1|addr1> [nick2|addr2] [...]"); return; } #ifdef DEBUG printf("BAN REQUEST FOR %s\nON CHANNEL %s\nBY %s (%d)\n", nicklist, channel, source, Access(channel, source)); #endif if (*source && Access(channel, source) < BAN_LEVEL) { notice(source, "Your Access on this channel is too low"); return; } ch = ToChannel(channel); /* I'm not on this channel.. so screw it! */ if (ch == NULL || !ch->on) { notice(source, "I'm NOT on that channel!"); return; } if (!ch->AmChanOp) { notice(source, "I'm not channel operator!"); return; } if (!*nicklist) { notice(source, "SYNTAX: ban <channel> <nick1|addr1> [nick2|addr2] [...]"); return; } GetWord(0, nicklist, OneNick); while (*OneNick) { luser = ToLuser(OneNick); if (luser) sprintf(buffer, "%s!%s@%s", luser->nick, luser->username, luser->site); if (luser) { sprintf(buffer, "I BAN %s!%s@%s ON %s", luser->nick, luser->username, luser->site, channel); log(buffer); user = ToUser(channel, OneNick); if (user && user->chanop) { changemode(channel, "-o", user->N->nick, 0); } MakeBanMask(luser, buffer); changemode(channel, "+b", buffer, 0); } GetWord(++i, nicklist, OneNick); } flushmode(channel); }
void onwhois(char *source, char *nick) { register aluser *user; register auser *usr; register achannelnode *chan; char buffer[512]; user = ToLuser(nick); if (user == NULL) { sprintf(buffer, ":%s 401 %s %s :No such nick\n", SERVERNAME, source, nick); sendtoserv(buffer); } else { sprintf(buffer, ":%s 311 %s %s %s %s * :\n", SERVERNAME, source, user->nick, user->username, user->site); sendtoserv(buffer); chan = user->channel; if (chan != NULL && strcmp(user->nick, "X") && strcmp(user->nick, "W")) { sprintf(buffer, ":%s 319 %s %s :", SERVERNAME, source, nick); while (chan != NULL) { /* show a channel only if it is * not +s or +p */ if (!IsSet(chan->N->name, 's', "") && !IsSet(chan->N->name, 'p', "")) { usr = ToUser(chan->N->name, nick); if (usr->chanop) strcat(buffer, "@"); strcat(buffer, chan->N->name); strcat(buffer, " "); } chan = chan->next; if (strlen(buffer) > 300) { strcat(buffer, "\n"); sendtoserv(buffer); sprintf(buffer, ":%s 319 %s %s :", SERVERNAME, source, nick); } } strcat(buffer, "\n"); sendtoserv(buffer); } sprintf(buffer, ":%s 312 %s %s %s :\n", SERVERNAME, source, source, user->server->name); sendtoserv(buffer); if (user->mode & LFL_ISOPER) { sprintf(buffer, ":%s 313 %s %s :is an IRC Operator\n", SERVERNAME, source, user->nick); sendtoserv(buffer); } } sprintf(buffer, ":%s 318 %s :End of /WHOIS list.\n", SERVERNAME, source); sendtoserv(buffer); }