[HICN-33] Hicn Fdio logo for windows 21/17321/7
authorAngelo Mantellini <manangel@cisco.com>
Tue, 5 Feb 2019 11:59:15 +0000 (12:59 +0100)
committerAngelo Mantellini <manangel@cisco.com>
Thu, 7 Feb 2019 15:49:05 +0000 (16:49 +0100)
Change-Id: I1c68da4462f4ccb627419a9a8073a3fe11d36cf6
Signed-off-by: Angelo Mantellini <manangel@cisco.com>
hicn-light/src/command_line/controller/hicnLightControl_main.c
hicn-light/src/command_line/daemon/hicnLightDaemon_main.c

index 03f7469..ff1a20a 100644 (file)
@@ -80,14 +80,52 @@ typedef struct controller_main_state {
   ControlState *controlState;
 } ControlMainState;
 
+static void _printRed(const char *output) {
+
+#ifndef _WIN32
+  printf("\033[0;31m%s", output);
+#else
+  HANDLE hConsole = NULL;
+  WORD currentConsoleAttr;
+  CONSOLE_SCREEN_BUFFER_INFO csbi;
+  hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
+  if (GetConsoleScreenBufferInfo(hConsole, &csbi))
+    currentConsoleAttr = csbi.wAttributes;
+  SetConsoleTextAttribute(hConsole, 4);
+  printf("%s", output);
+  SetConsoleTextAttribute(hConsole, currentConsoleAttr);
+#endif
+
+}
+
+static void _printWhite(const char *output) {
+
+#ifndef _WIN32
+       printf("\033[0m%s", output);
+#else
+  HANDLE  hConsole = NULL;
+  WORD currentConsoleAttr;
+  CONSOLE_SCREEN_BUFFER_INFO csbi;
+  SetConsoleTextAttribute(hConsole, 7);
+  if (GetConsoleScreenBufferInfo(hConsole, &csbi))
+    currentConsoleAttr = csbi.wAttributes;
+  hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
+  printf("%s", output);
+  SetConsoleTextAttribute(hConsole, currentConsoleAttr);
+#endif
+
+}
+
 static void _displayForwarderLogo(void) {
-  const char cli_banner[] =
-      "\033[0;31m   ____ ___      _       \033[0m  __    _               __ _        __   __\n"
-      "\033[0;31m  / __// _ \\    (_)___  \033[0m  / /   (_)____ ___ ____/ /(_)___ _ / /  / /_\n"
-      "\033[0;31m / _/ / // /_  / // _ \\ \033[0m / _ \\ / // __// _ \\___/ // // _ `// _ \\/ __/\n"
-      "\033[0;31m/_/  /____/(_)/_/ \\___/ \033[0m/_//_//_/ \\__//_//_/  /_//_/ \\_, //_//_/\\__/\n"
-      "                                                    /___/            \n";
-  printf("%s", cli_banner);
+  _printRed("   ____ ___      _       ");
+  _printWhite("  __    _               __ _        __   __\n");
+  _printRed("  / __// _ \\    (_)___  ");
+  _printWhite("  / /   (_)____ ___ ____/ /(_)___ _ / /  / /_\n");
+  _printRed(" / _/ / // /_  / // _ \\ ");
+  _printWhite(" / _ \\ / // __// _ \\___/ // // _ `// _ \\/ __/\n");
+  _printRed("/_/  /____/(_)/_/ \\___/ ");
+  _printWhite("/_//_//_/ \\__//_//_/  /_//_/ \\_, //_//_/\\__/\n");
+  _printWhite("                                                    /___/            \n");
   printf("\n");
 }
 
index 1b7e92e..533bb9c 100644 (file)
 #include <src/core/dispatcher.h>
 #include <src/core/forwarder.h>
 
+static void _printRed(const char *output) {
+
+#ifndef _WIN32
+  printf("\033[0;31m%s", output);
+#else
+  HANDLE hConsole = NULL;
+  WORD currentConsoleAttr;
+  CONSOLE_SCREEN_BUFFER_INFO csbi;
+  if (GetConsoleScreenBufferInfo(hConsole, &csbi))
+   currentConsoleAttr = csbi.wAttributes;
+  hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
+  SetConsoleTextAttribute(hConsole, 4);
+  printf("%s", output);
+  SetConsoleTextAttribute(hConsole, currentConsoleAttr);
+#endif
+
+}
+
+static void _printWhite(const char *output) {
+
+#ifndef _WIN32
+       printf("\033[0m%s", output);
+#else
+  HANDLE  hConsole = NULL;
+  WORD currentConsoleAttr;
+  CONSOLE_SCREEN_BUFFER_INFO csbi;
+  if (GetConsoleScreenBufferInfo(hConsole, &csbi))
+    currentConsoleAttr = csbi.wAttributes;
+  hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
+  SetConsoleTextAttribute(hConsole, 7);
+  printf("%s", output);
+  SetConsoleTextAttribute(hConsole, currentConsoleAttr);
+#endif
+
+}
+
 static void _displayForwarderLogo(void) {
-  const char cli_banner[] =
-      "\033[0;31m   ____ ___      _       \033[0m  __    _               __ _        __   __\n"
-      "\033[0;31m  / __// _ \\    (_)___  \033[0m  / /   (_)____ ___ ____/ /(_)___ _ / /  / /_\n"
-      "\033[0;31m / _/ / // /_  / // _ \\ \033[0m / _ \\ / // __// _ \\___/ // // _ `// _ \\/ __/\n"
-      "\033[0;31m/_/  /____/(_)/_/ \\___/ \033[0m/_//_//_/ \\__//_//_/  /_//_/ \\_, //_//_/\\__/\n"
-      "                                                    /___/            \n";
-  printf("%s", cli_banner);
+  _printRed("   ____ ___      _       ");
+  _printWhite("  __    _               __ _        __   __\n");
+  _printRed("  / __// _ \\    (_)___  ");
+  _printWhite("  / /   (_)____ ___ ____/ /(_)___ _ / /  / /_\n");
+  _printRed(" / _/ / // /_  / // _ \\ ");
+  _printWhite(" / _ \\ / // __// _ \\___/ // // _ `// _ \\/ __/\n");
+  _printRed("/_/  /____/(_)/_/ \\___/ ");
+  _printWhite("/_//_//_/ \\__//_//_/  /_//_/ \\_, //_//_/\\__/\n");
+  _printWhite("                                                    /___/            \n");
   printf("\n");
 }