home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / UNIX / Mail / appnmail-1.8-Solaris / mailapp-utilities / optutil.c < prev    next >
Encoding:
Text File  |  1996-12-01  |  1.1 KB  |  48 lines

  1. /*+++*
  2.  *  title:    optutil.c
  3.  *  RCS         optutil.c,v 1.1 1996/12/01 17:03:26 tom Exp
  4.  *  abstract:    command-line option handling support stuff.
  5.  *  author:    Tom Hageman, The Netherlands <tom@basil.icce.rug.nl>
  6.  *  created:    November 1996
  7.  *  modified:    
  8.  *---*/
  9.  
  10. #import <stdio.h>
  11. #import <stdlib.h>
  12. #import <string.h>
  13.  
  14. #import "optutil.h"
  15. #import "version.h"
  16.  
  17. const char *basename(const char *path)
  18. {
  19.    const char *s = strrchr(path, '/');
  20.  
  21.    return (s ? ++s : path);
  22. }
  23.  
  24. const char *_progname = "(unset)";
  25.  
  26. void handle_usage_help_version(int what, const char *usage, const char *help)
  27. {
  28.    switch (what) {
  29.    case EXIT_USAGE:
  30.       fprintf(stderr, usage, progname());
  31.       fprintf(stderr, "try `%s -H' for more information.\n", progname()); 
  32.       break;
  33.    case EXIT_HELP:
  34.       printf(usage, progname());
  35.       printf(help, progname());
  36.       what = EXIT_SUCCESS;
  37.       break;
  38.    case EXIT_VERSION:
  39.       printf("%s: %s version %s, %s.\n",
  40.              progname(), PACKAGE, VERSION, VERSION_DATE);
  41.       what = EXIT_SUCCESS;
  42.       break;
  43.    default:
  44.       return; /* no-op. */
  45.    }
  46.    exit(what);
  47. }
  48.