X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=lttng%2Fcommands%2Fversion.c;fp=lttng%2Fcommands%2Fversion.c;h=d18afeb2b0dc1dd6af22aa14095cb1b59e9a4a75;hp=0000000000000000000000000000000000000000;hb=eb9cb8b758bc88e9117fd0726646a7c9ae4f7984;hpb=636167b6d43e1b9e9e96c90672001c735dd61087 diff --git a/lttng/commands/version.c b/lttng/commands/version.c new file mode 100644 index 000000000..d18afeb2b --- /dev/null +++ b/lttng/commands/version.c @@ -0,0 +1,83 @@ +/* + * 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 + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include +#include + +#include "cmd.h" +#include "conf.h" +#include "utils.h" + +enum { + OPT_HELP = 1, +}; + +static struct poptOption long_options[] = { + /* longName, shortName, argInfo, argPtr, value, descrip, argDesc */ + {"help", 'h', POPT_ARG_NONE, 0, OPT_HELP, 0, 0}, + {0, 0, 0, 0, 0, 0, 0} +}; + +/* + * usage + */ +static void usage(FILE *ofp) +{ + fprintf(ofp, "usage: lttng version\n"); + fprintf(ofp, "\n"); + fprintf(ofp, " -h, --help Show this help\n"); + fprintf(ofp, "\n"); +} + +/* + * cmd_version + */ +int cmd_version(int argc, const char **argv) +{ + int opt, ret = CMD_SUCCESS; + static poptContext pc; + + pc = poptGetContext(NULL, argc, argv, long_options, 0); + poptReadDefaultConfig(pc, 0); + + while ((opt = poptGetNextOpt(pc)) != -1) { + switch (opt) { + case OPT_HELP: + usage(stderr); + ret = CMD_SUCCESS; + goto end; + default: + usage(stderr); + ret = CMD_UNDEFINED; + goto end; + } + } + + MSG("lttng version " VERSION); + MSG("Web site: http://lttng.org/"); + MSG("\nlttng is free software and under the GPL license."); + +end: + return ret; +}