]> granicus.if.org Git - sudo/commitdiff
added -v flag and usage()
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 25 May 1994 03:08:45 +0000 (03:08 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 25 May 1994 03:08:45 +0000 (03:08 +0000)
visudo.c

index fefdd79b02c27be74ced5e02dba5e3d63f98c032..5c59bc7cb7c52d87bf5c0bfa9bbe87571807c543 100644 (file)
--- a/visudo.c
+++ b/visudo.c
@@ -55,6 +55,7 @@ static char rcsid[] = "$Id$";
 #include <sys/file.h>
 
 #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);
+}