From: Enrico Scholz Date: Mon, 5 Jan 2004 22:17:52 +0000 (+0000) Subject: initial checkin X-Git-Tag: VERSION_0_10~976 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4120329ce43d920b9c19648768684761ec3ba28;p=util-vserver.git initial checkin git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@549 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/util-vserver/src/vserver-info.c b/util-vserver/src/vserver-info.c new file mode 100644 index 0000000..8a170f0 --- /dev/null +++ b/util-vserver/src/vserver-info.c @@ -0,0 +1,186 @@ +// $Id$ --*- c -*-- + +// Copyright (C) 2003 Enrico Scholz +// +// 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; version 2 of the License. +// +// 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. + + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "util.h" +#include "wrappers.h" + +#include "internal.h" +#include "vserver.h" + +#include +#include +#include +#include + +typedef enum { tgNONE,tgCONTEXT, tgRUNNING, + tgVDIR, tgNAME, tgCFGDIR } VserverTag; + +static struct { + char const * const tag; + VserverTag const val; + char const * const descr; +} const TAGS[] = { + { "CONTEXT", tgCONTEXT, "the current and/or assigned context" }, + { "RUNNING", tgRUNNING, "gives out '1' when vserver is running; else, it fails without output" }, + { "VDIR", tgVDIR, "gives out the root-directory of the vserver" }, + { "NAME", tgNAME, "gives out the name of the vserver" }, + { "CFGDIR", tgCFGDIR, "gives out the configuration directory of the vserver" } +}; + +#define TAGS_COUNT (sizeof(TAGS)/sizeof(TAGS[0])) + +int wrapper_exit_code = 1; + +static struct option const +CMDLINE_OPTIONS[] = { + { "help", no_argument, 0, 'h' }, + { "version", no_argument, 0, 'v' }, + { 0,0,0,0 } +}; + + +static void +showHelp(int fd, char const *cmd, int res) +{ + WRITE_MSG(fd, "Usage: "); + WRITE_STR(fd, cmd); + WRITE_MSG(fd, + " [-q] \n" + "Please report bugs to " PACKAGE_BUGREPORT "\n"); + exit(res); +} + +static void +showVersion() +{ + WRITE_MSG(1, + "vserver-info " VERSION " -- returns information about vservers\n" + "This program is part of " PACKAGE_STRING "\n\n" + "Copyright (C) 2003 Enrico Scholz\n" + VERSION_COPYRIGHT_DISCLAIMER); + exit(0); +} + +static void +showTags() +{ + char const * delim = ""; + size_t i; + + WRITE_MSG(1, "Valid tags are: "); + for (i=0; i