Commit d5ef957d authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼
Browse files

utils: move copyright and version printing code into separate file

parent 1eb5c4fe
/** Various helper functions.
*
* @file
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* VILLASnode
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#pragma once
/* Alternate character set
*
* The suffixed of the BOX_ macro a constructed by
* combining the following letters in the written order:
* - U for a line facing upwards
* - D for a line facing downwards
* - L for a line facing leftwards
* - R for a line facing rightwards
*
* E.g. a cross can be constructed by combining all line fragments:
* BOX_UDLR
*/
#define BOX(chr) "\e(0" chr "\e(B"
#define BOX_LR BOX("\x71") /**< Boxdrawing: ─ */
#define BOX_UD BOX("\x78") /**< Boxdrawing: │ */
#define BOX_UDR BOX("\x74") /**< Boxdrawing: ├ */
#define BOX_UDLR BOX("\x6E") /**< Boxdrawing: ┼ */
#define BOX_UDL BOX("\x75") /**< Boxdrawing: ┤ */
#define BOX_ULR BOX("\x76") /**< Boxdrawing: ┴ */
#define BOX_UL BOX("\x6A") /**< Boxdrawing: ┘ */
#define BOX_DLR BOX("\x77") /**< Boxdrawing: ┘ */
#define BOX_DL BOX("\x6B") /**< Boxdrawing: ┘ */
/** Various helper functions.
*
* @file
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* VILLASnode
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#pragma once
/* CPP stringification */
#define XSTR(x) STR(x)
#define STR(x) #x
/* Some color escape codes for pretty log messages */
#define CLR(clr, str) "\e[" XSTR(clr) "m" str "\e[0m"
#define CLR_GRY(str) CLR(30, str) /**< Print str in gray */
#define CLR_RED(str) CLR(31, str) /**< Print str in red */
#define CLR_GRN(str) CLR(32, str) /**< Print str in green */
#define CLR_YEL(str) CLR(33, str) /**< Print str in yellow */
#define CLR_BLU(str) CLR(34, str) /**< Print str in blue */
#define CLR_MAG(str) CLR(35, str) /**< Print str in magenta */
#define CLR_CYN(str) CLR(36, str) /**< Print str in cyan */
#define CLR_WHT(str) CLR(37, str) /**< Print str in white */
#define CLR_BLD(str) CLR( 1, str) /**< Print str in bold */
/** Various helper functions.
*
* @file
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* VILLASnode
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#pragma once
namespace villas {
/** Print copyright message to stdout. */
void print_copyright();
/** Print version to stdout. */
void print_version();
} // namespace villas
......@@ -191,7 +191,7 @@ public:
}
};
} // namespace villas
} // namespace utils
} // namespace villas
#endif
......@@ -23,6 +23,10 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <stdint.h>
#include <sched.h>
......@@ -33,10 +37,6 @@
#include <villas/config.h>
#include <villas/log.h>
#ifdef __cplusplus
extern "C" {
#endif
extern pthread_t main_thread;
#ifdef __GNUC__
......
......@@ -44,12 +44,6 @@ assertExcept(bool condition, const T& exception)
throw exception;
}
/** Print copyright message to stdout. */
void print_copyright();
/** Print version to stdout. */
void print_version();
/** Register a exit callback for program termination: SIGINT, SIGKILL & SIGALRM. */
int signals_init(void (*cb)(int signal, siginfo_t *sinfo, void *ctx));
......
......@@ -46,6 +46,7 @@ add_library(villas-common SHARED
cpuset.cpp
terminal.cpp
version.cpp
copyright.cpp
common.c
)
......
/** General purpose helper functions.
*
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* VILLASnode
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
#include <iostream>
#include <villas/copyright.hpp>
#include <villas/colors.hpp>
#include <villas/config.h>
void villas::print_copyright()
{
std::cout << PROJECT_NAME " " << CLR_BLU(PROJECT_BUILD_ID)
<< " (built on " CLR_MAG(__DATE__) " " CLR_MAG(__TIME__) ")" << std::endl
<< " Copyright 2014-2017, Institute for Automation of Complex Power Systems, EONERC" << std::endl
<< " Steffen Vogel <StVogel@eonerc.rwth-aachen.de>" << std::endl;
}
void villas::print_version()
{
std::cout << PROJECT_BUILD_ID << std::endl;
}
......@@ -60,19 +60,6 @@ tokenize(std::string s, std::string delimiter)
return tokens;
}
void print_copyright()
{
std::cout << PROJECT_NAME " " << CLR_BLU(PROJECT_BUILD_ID)
<< " (built on " CLR_MAG(__DATE__) " " CLR_MAG(__TIME__) ")" << std::endl
<< " Copyright 2014-2017, Institute for Automation of Complex Power Systems, EONERC" << std::endl
<< " Steffen Vogel <StVogel@eonerc.rwth-aachen.de>" << std::endl;
}
void print_version()
{
std::cout << PROJECT_BUILD_ID << std::endl;
}
ssize_t read_random(char *buf, size_t len)
{
int fd;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment