3 /** \file version.h Macros for printing the version string. */
5 #include "git-version.h"
8 * Get the raw git version string
10 * \return The string generated by the GIT-VERSION-GEN script. It is passed
11 * as a preprocessor define during compilation.
13 const char *version_git(void)
19 * Get the version string for an executable.
21 * \param pfx The program name (without the leading "para_").
23 * \return A statically allocated string which contains the program name, the
24 * git version and the codename. It must not be freed by the caller.
26 const char *version_single_line(const char *pfx)
29 snprintf(buf, sizeof(buf) - 1,
30 "para_%s " GIT_VERSION, pfx);
35 * Get the full version text.
37 * \param pfx See \ref version_single_line().
39 * \return A string containing the same text as returned by \ref
40 * version_single_line(), augmented by additional build information, a
41 * copyright text and the email address of the author.
43 * Like \ref version_single_line(), this string is stored in a statically
44 * allocated buffer and must not be freed.
46 const char *version_text(const char *pfx)
50 snprintf(buf, sizeof(buf) - 1, "%s\n"
51 "Copyright (C) 2013 Andre Noll\n"
52 "This is free software with ABSOLUTELY NO WARRANTY."
53 " See COPYING for details.\n"
54 "Report bugs to <maan@systemlinux.org>.\n"
55 "build date: " BUILD_DATE ",\n"
56 "build system: " UNAME_RS ",\n"
57 "compiler: " CC_VERSION ".\n",
58 version_single_line(pfx)
64 * Print the version text and exit successfully.
66 * \param pfx See \ref version_single_line().
67 * \param flag Whether --version was given.
69 * If \a flag is false, this function does nothing. Otherwise it prints the
70 * full version text as returned by \ref version_text() and exits successfully.
72 void version_handle_flag(const char *pfx, bool flag)
76 printf("%s", version_text(pfx));