X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Fversion.c;h=9f606bf44396bcad8a8e60dfc54662a044356f3d;hp=13e5c994f16ce8b496a5919c61a833544c1d629d;hb=0de2479d5f5a287d31c69e34ea5202a69019f224;hpb=50bba0f31cc69df963f3f652e53b9d6828882410 diff --git a/src/bin/lttng/commands/version.c b/src/bin/lttng/commands/version.c index 13e5c994f..9f606bf44 100644 --- a/src/bin/lttng/commands/version.c +++ b/src/bin/lttng/commands/version.c @@ -1,21 +1,11 @@ /* - * Copyright (C) 2011 - David Goulet + * Copyright (C) 2011 David Goulet * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2 only, - * as published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE +#define _LGPL_SOURCE #include #include #include @@ -23,11 +13,17 @@ #include #include #include -#include #include #include "../command.h" +#include "version.h" + +#ifdef LTTNG_EMBED_HELP +static const char help_msg[] = +#include +; +#endif enum { OPT_HELP = 1, @@ -43,19 +39,6 @@ static struct poptOption long_options[] = { {0, 0, 0, 0, 0, 0, 0} }; -/* - * usage - */ -static void usage(FILE *ofp) -{ - fprintf(ofp, "usage: lttng version [OPTIONS]\n"); - fprintf(ofp, "\n"); - fprintf(ofp, "Options:\n"); - fprintf(ofp, " -h, --help Show this help\n"); - fprintf(ofp, " --list-options Simple listing of options\n"); - fprintf(ofp, "\n"); -} - /* * create_version */ @@ -73,7 +56,7 @@ static void create_version(struct mi_lttng_version *version) /* * Print the machine interface output of this command. */ -static int print_mi() +static int print_mi(void) { int ret = CMD_SUCCESS; struct mi_writer *writer = NULL; @@ -149,13 +132,12 @@ int cmd_version(int argc, const char **argv) while ((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case OPT_HELP: - usage(stdout); + SHOW_HELP(); goto end; case OPT_LIST_OPTIONS: list_cmd_options(stdout, long_options); goto end; default: - usage(stderr); ret = CMD_UNDEFINED; goto end; } @@ -164,10 +146,20 @@ int cmd_version(int argc, const char **argv) if (lttng_opt_mi) { ret = print_mi(); } else { - MSG("lttng version " FULL_VERSION " - " VERSION_NAME); + MSG("lttng version " VERSION " - " VERSION_NAME "%s", + GIT_VERSION[0] == '\0' ? "" : " - " GIT_VERSION); MSG("\n" VERSION_DESCRIPTION "\n"); - MSG("Web site: http://lttng.org"); + MSG("Web site: https://lttng.org"); MSG("\n%s", lttng_license); + if (EXTRA_VERSION_NAME[0] != '\0') { + MSG("\nExtra version name: " EXTRA_VERSION_NAME); + } + if (EXTRA_VERSION_DESCRIPTION[0] != '\0') { + MSG("\nExtra version description:\n\t" EXTRA_VERSION_DESCRIPTION); + } + if (EXTRA_VERSION_PATCHES[0] != '\0') { + MSG("\nExtra version patches:\n\t" EXTRA_VERSION_PATCHES); + } } end: