From 6e7d42f3e163e299ed7e7ec606e41ed282a90a84 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 25 May 1994 03:08:45 +0000 Subject: [PATCH] added -v flag and usage() --- visudo.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/visudo.c b/visudo.c index fefdd79b0..5c59bc7cb 100644 --- a/visudo.c +++ b/visudo.c @@ -55,6 +55,7 @@ static char rcsid[] = "$Id$"; #include #include "sudo.h" +#include "version.h" #ifndef STDC_HEADERS extern char *getenv(); @@ -66,6 +67,7 @@ extern int errno, yylineno; /* * Globals */ +char **Argv; char buffer[BUFSIZ]; char *sudoers = _PATH_SUDO_SUDOERS; char *sudoers_tmp_file = _PATH_SUDO_STMP; @@ -74,6 +76,12 @@ int status = 0, FILE *sudoers_tmp_fp=NULL, *sudoers_fp=NULL; +/* + * local functions not visible outside visudo.c + */ +static void usage(); + + static RETSIGTYPE Exit(sig) int sig; { @@ -95,6 +103,21 @@ main(argc, argv) char * Editor; #endif /* ENV_EDITOR */ + Argv = argv; + + if (argc > 1) { + /* + * print version string and exit if we got -v + */ + if (!strcmp(argv[1], "-v")) { + (void) printf("visudo version %s\n", version); + exit(0); + } else { + usage(); + } + + } + /* * handle the signals */ @@ -239,3 +262,17 @@ main(argc, argv) exit(0); } } + + +/********************************************************************** + * + * usage() + * + * this function just gives you instructions and exits + */ + +static void usage() +{ + (void) fprintf(stderr, "usage: %s [-v]\n", *Argv); + exit(1); +} -- 2.40.0