1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
17 #define TRED FOREGROUND_RED | FOREGROUND_INTENSITY
18 #define TGREEN FOREGROUND_GREEN | FOREGROUND_INTENSITY
19 #define TYELLOW FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY
20 #define TNORMAL FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE
21 #define TWHITE TNORMAL | FOREGROUND_INTENSITY
22 #define TBLUE FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY
24 inline void sc(WORD color) { SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color); }
26 /* Handles colors in printf */
27 int printf_c(const char * format, ...)
29 // Better hope we're not multithreaded, otherwise we'll have chickens crossing the road other side to get the to :P
30 static char message[500];
31 static char temp[500];
37 vsnprintf(message, 500, format, ap);
40 /* search for unix-style escape sequences */
43 const char * p = message;
48 // Escape sequence -> copy into the temp buffer, and parse the color.
51 while ((*p) && (*p != 'm'))
62 if (sscanf(temp, "[%u;%u", &color1, &color2) == 2)
67 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_INTENSITY); // Yellow
72 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
81 // Returning to normal colour.
82 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
87 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), TWHITE);
92 sprintf(message, "Unknown color code: %s", temp);
93 MessageBox(0, message, message, MB_OK);