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 " (" CODENAME ")", 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 "built: " BUILD_DATE ", " UNAME_RS ", " CC_VERSION "\n"
52 "Copyright (C) 2013 Andre Noll\n"
53 "This is free software with ABSOLUTELY NO WARRANTY."
54 " See COPYING for details.\n"
55 "Report bugs to <maan@systemlinux.org>.\n",
56 version_single_line(pfx)
62 * Print the version text and exit successfully.
64 * \param pfx See \ref version_single_line().
65 * \param flag Whether --version was given.
67 * If \a flag is false, this function does nothing. Otherwise it prints the
68 * full version text as returned by \ref version_text() and exits successfully.
70 void version_handle_flag(const char *pfx, bool flag)
74 printf("%s", version_text(pfx));