1 /* Copyright (C) 2013 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
3 /** \file version.c Some helpers for printing version and copyright strings. */
7 #include "git-version.h"
10 * Get the version string for an executable.
12 * \param pfx The program name (without the leading "para_").
14 * \return A statically allocated string which contains the program name and
15 * the git version. It must not be freed by the caller.
17 const char *version_single_line(const char *pfx)
20 snprintf(buf, sizeof(buf) - 1,
21 "para_%s " GIT_VERSION, pfx);
26 * Get the full version text.
28 * \param pfx See \ref version_single_line().
30 * \return A string containing the same text as returned by \ref
31 * version_single_line(), augmented by additional build information, a
32 * copyright text and the email address of the author.
34 * Like \ref version_single_line(), this string is stored in a statically
35 * allocated buffer and must not be freed.
37 const char *version_text(const char *pfx)
41 snprintf(buf, sizeof(buf) - 1, "%s\n"
42 "Copyright (C) " COPYRIGHT_YEAR " Andre Noll\n"
43 "This is free software with ABSOLUTELY NO WARRANTY."
44 " See COPYING for details.\n"
45 "Report bugs to <maan@tuebingen.mpg.de>.\n"
46 "build date: " BUILD_DATE ",\n"
47 "build system: " UNAME_RS ",\n"
48 "compiler: " CC_VERSION ".\n",
49 version_single_line(pfx)
55 * Print the version text and exit successfully.
57 * \param pfx See \ref version_single_line().
58 * \param flag Whether --version was given.
60 * If \a flag is false, this function does nothing. Otherwise it prints the
61 * full version text as returned by \ref version_text() and exits successfully.
63 void version_handle_flag(const char *pfx, bool flag)
67 printf("%s", version_text(pfx));