2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
5 * Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
7 * This file is part of InspIRCd. InspIRCd is free software: you can
8 * redistribute it and/or modify it under the terms of the GNU General Public
9 * License as published by the Free Software Foundation, version 2.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #define TRED FOREGROUND_RED | FOREGROUND_INTENSITY
25 #define TGREEN FOREGROUND_GREEN | FOREGROUND_INTENSITY
26 #define TYELLOW FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY
27 #define TNORMAL FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE
28 #define TWHITE TNORMAL | FOREGROUND_INTENSITY
29 #define TBLUE FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY
31 inline void sc(WORD color) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color); }
33 /* Handles colors in printf */
34 int printf_c(const char * format, ...)
36 // Better hope we're not multithreaded, otherwise we'll have chickens crossing the road other side to get the to :P
37 static char message[500];
38 static char temp[500];
44 vsnprintf(message, 500, format, ap);
47 /* search for unix-style escape sequences */
50 const char * p = message;
55 // Escape sequence -> copy into the temp buffer, and parse the color.
58 while ((*p) && (*p != 'm'))
69 if (sscanf(temp, "[%u;%u", &color1, &color2) == 2)
74 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_INTENSITY); // Yellow
79 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
88 // Returning to normal colour.
89 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
94 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), TWHITE);
99 sprintf(message, "Unknown color code: %s", temp);
100 MessageBox(0, message, message, MB_OK);