From: Enrico Scholz Date: Tue, 21 Oct 2003 14:14:40 +0000 (+0000) Subject: implemented '--help' and '--version' X-Git-Tag: VERSION_0_10~1142 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0282de7ba7437f7213282185710b2682d9b79dc4;p=util-vserver.git implemented '--help' and '--version' git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@271 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/util-vserver/src/exec-ulimit.c b/util-vserver/src/exec-ulimit.c index 8421943..a0a484c 100644 --- a/util-vserver/src/exec-ulimit.c +++ b/util-vserver/src/exec-ulimit.c @@ -115,13 +115,40 @@ readSingleLimit(struct rlimit *lim, char const *fname_base) return is_modified; } +static void +showHelp(int fd, char const *cmd, int res) +{ + WRITE_MSG(fd, "Usage: "); + WRITE_STR(fd, cmd); + WRITE_STR(fd, + " *\n\n" + "Please report bugs to " PACKAGE_BUGREPORT "\n"); + exit(res); +} + +static void +showVersion() +{ + WRITE_MSG(1, + "exec-ulimit " VERSION " -- executes programs with resource limits\n" + "This program is part of " PACKAGE_STRING "\n\n" + "Copyright (C) 2003 Enrico Scholz\n" + VERSION_COPYRIGHT_DISCLAIMER); + exit(0); +} + int main(int argc, char *argv[]) { size_t i; int cur_fd = Eopen(".", O_RDONLY, 0); - + + if (argc==2) { + if (strcmp(argv[1], "--help")==0) showHelp(1,argv[0],0); + if (strcmp(argv[1], "--version")==0) showVersion(); + } + if (argc<3) { - WRITE_MSG(2, "Usage: exec-ulimit *\n"); + WRITE_MSG(2, "Bad parameter count; use '--help' for more information.\n"); exit(255); }