home *** CD-ROM | disk | FTP | other *** search
- /*+++*
- * title: optutil.c
- * RCS optutil.c,v 1.1 1996/12/01 17:03:26 tom Exp
- * abstract: command-line option handling support stuff.
- * author: Tom Hageman, The Netherlands <tom@basil.icce.rug.nl>
- * created: November 1996
- * modified:
- *---*/
-
- #import <stdio.h>
- #import <stdlib.h>
- #import <string.h>
-
- #import "optutil.h"
- #import "version.h"
-
- const char *basename(const char *path)
- {
- const char *s = strrchr(path, '/');
-
- return (s ? ++s : path);
- }
-
- const char *_progname = "(unset)";
-
- void handle_usage_help_version(int what, const char *usage, const char *help)
- {
- switch (what) {
- case EXIT_USAGE:
- fprintf(stderr, usage, progname());
- fprintf(stderr, "try `%s -H' for more information.\n", progname());
- break;
- case EXIT_HELP:
- printf(usage, progname());
- printf(help, progname());
- what = EXIT_SUCCESS;
- break;
- case EXIT_VERSION:
- printf("%s: %s version %s, %s.\n",
- progname(), PACKAGE, VERSION, VERSION_DATE);
- what = EXIT_SUCCESS;
- break;
- default:
- return; /* no-op. */
- }
- exit(what);
- }
-