2 * Copyright (C) 2013 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 version string for an executable.
16 * \param pfx The program name (without the leading "para_").
18 * \return A statically allocated string which contains the program name and
19 * the git version. It must not be freed by the caller.
21 const char *version_single_line(const char *pfx)
24 snprintf(buf, sizeof(buf) - 1,
25 "para_%s " GIT_VERSION, pfx);
30 * Get the full version text.
32 * \param pfx See \ref version_single_line().
34 * \return A string containing the same text as returned by \ref
35 * version_single_line(), augmented by additional build information, a
36 * copyright text and the email address of the author.
38 * Like \ref version_single_line(), this string is stored in a statically
39 * allocated buffer and must not be freed.
41 const char *version_text(const char *pfx)
45 snprintf(buf, sizeof(buf) - 1, "%s\n"
46 "Copyright (C) 2002-2015 Andre Noll\n"
47 "This is free software with ABSOLUTELY NO WARRANTY."
48 " See COPYING for details.\n"
49 "Report bugs to <maan@tuebingen.mpg.de>.\n"
50 "build date: " BUILD_DATE ",\n"
51 "build system: " UNAME_RS ",\n"
52 "compiler: " CC_VERSION ".\n",
53 version_single_line(pfx)
59 * Print the version text and exit successfully.
61 * \param pfx See \ref version_single_line().
62 * \param flag Whether --version was given.
64 * If \a flag is false, this function does nothing. Otherwise it prints the
65 * full version text as returned by \ref version_text() and exits successfully.
67 void version_handle_flag(const char *pfx, bool flag)
71 printf("%s", version_text(pfx));