2 * Copyright (C) 2013-2014 Andre Noll <maan@tuebingen.mpg.de>
4 * Licensed under the GPL v2. For licencing details see COPYING.
7 /** \file version.c Some helpers for printing version and copyright strings. */
11 #include "git-version.h"
14 * Get the raw git version string
16 * \return The string generated by the GIT-VERSION-GEN script. It is passed
17 * as a preprocessor define during compilation.
19 __a_const const char *version_git(void)
25 * Get the version string for an executable.
27 * \param pfx The program name (without the leading "para_").
29 * \return A statically allocated string which contains the program name and
30 * the git version. It must not be freed by the caller.
32 const char *version_single_line(const char *pfx)
35 snprintf(buf, sizeof(buf) - 1,
36 "para_%s " GIT_VERSION, pfx);
41 * Get the full version text.
43 * \param pfx See \ref version_single_line().
45 * \return A string containing the same text as returned by \ref
46 * version_single_line(), augmented by additional build information, a
47 * copyright text and the email address of the author.
49 * Like \ref version_single_line(), this string is stored in a statically
50 * allocated buffer and must not be freed.
52 const char *version_text(const char *pfx)
56 snprintf(buf, sizeof(buf) - 1, "%s\n"
57 "Copyright (C) 2014 Andre Noll\n"
58 "This is free software with ABSOLUTELY NO WARRANTY."
59 " See COPYING for details.\n"
60 "Report bugs to <maan@tuebingen.mpg.de>.\n"
61 "build date: " BUILD_DATE ",\n"
62 "build system: " UNAME_RS ",\n"
63 "compiler: " CC_VERSION ".\n",
64 version_single_line(pfx)
70 * Print the version text and exit successfully.
72 * \param pfx See \ref version_single_line().
73 * \param flag Whether --version was given.
75 * If \a flag is false, this function does nothing. Otherwise it prints the
76 * full version text as returned by \ref version_text() and exits successfully.
78 void version_handle_flag(const char *pfx, bool flag)
82 printf("%s", version_text(pfx));