69 lines
2.0 KiB
C
69 lines
2.0 KiB
C
/* *****************************************************************************
|
|
* core/version.c -- libp7 version message.
|
|
* Copyright (C) 2016-2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
|
|
*
|
|
* This file is part of libp7.
|
|
* libp7 is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation; either version 3.0 of the License,
|
|
* or (at your option) any later version.
|
|
*
|
|
* libp7 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 Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
* along with libp7; if not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* If the library is run directly, it should put its version message and exit.
|
|
* ************************************************************************** */
|
|
#include <libp7/internals.h>
|
|
#ifndef is_static
|
|
# include <unistd.h>
|
|
|
|
/* get loglevel string */
|
|
# if LOGLEVEL == ll_info
|
|
# define LLS "info"
|
|
# elif LOGLEVEL == ll_warn
|
|
# define LLS "warn"
|
|
# elif LOGLEVEL == ll_error
|
|
# define LLS "error"
|
|
# elif LOGLEVEL == ll_fatal
|
|
# define LLS "fatal"
|
|
# elif LOGLEVEL == ll_none
|
|
# define LLS "none"
|
|
# else
|
|
# define LLS "unknown"
|
|
# endif
|
|
|
|
/**
|
|
* version_message:
|
|
* The message that should be displayed when the library is executed.
|
|
*/
|
|
|
|
static const char version_message[] =
|
|
"libp7 v" LIBP7_VERSION " (licensed under LGPL3)\n"
|
|
"Maintained by " LIBP7_MAINTAINER ".\n"
|
|
"\n"
|
|
"Compiled with the '" LLS "' loglevel.\n"
|
|
"\n"
|
|
"This is free software; see the source for copying conditions.\n"
|
|
"There is NO warranty; not even for MERCHANTABILITY or\n"
|
|
"FITNESS FOR A PARTICULAR PURPOSE.";
|
|
|
|
/**
|
|
* __libp7_version:
|
|
* Display version when the library is executed.
|
|
*/
|
|
|
|
extern void __libp7_version(void)
|
|
__attribute__((noreturn));
|
|
void __libp7_version(void)
|
|
{
|
|
puts(version_message);
|
|
_exit(0);
|
|
}
|
|
|
|
#endif
|