Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zcrypt.c

    r6249a88f r8f335a8  
    1616#include <sys/wait.h>
    1717#include <ctype.h>
     18#include <limits.h>
     19#include <getopt.h>
    1820
    1921#include <config.h>
     
    2628
    2729#include "filterproc.h"
     30
     31#ifndef OWL_VERSION_STRING
     32#ifdef  GIT_VERSION
     33#define stringify(x)       __stringify(x)
     34#define __stringify(x)     #x
     35#define OWL_VERSION_STRING stringify(GIT_VERSION)
     36#else
     37#define OWL_VERSION_STRING PACKAGE_VERSION
     38#endif
     39#endif /* !OWL_VERSION_STRING */
    2840
    2941/* Annotate functions in which the caller owns the return value and is
     
    106118}
    107119
     120void usage(FILE *file, const char *progname)
     121{
     122  fprintf(file, "Usage: %s [-Z|-D|-E|-R|-S] [-F Keyfile] [-c class] [-i instance]\n", progname);
     123  fprintf(file, "       [-advqtluon] [-s signature] [-f arg] [-m message]\n");
     124  fprintf(file, "  One or more of class, instance, and keyfile must be specified.\n");
     125}
     126
    108127int main(int argc, char *argv[])
    109128{
     
    116135  int mode = M_NONE;
    117136
    118   char c;
     137  int c;
    119138
    120139  int messageflag = FALSE;
     
    122141  zoptions.flags = 0;
    123142
    124   while ((c = getopt(argc, argv, "ZDERSF:c:i:advqtluons:f:m")) != (char)EOF)
     143  enum {
     144    OPT_VERSION = CHAR_MAX + 1,
     145    OPT_HELP,
     146  };
     147  static const struct option options[] = {
     148    {"version", no_argument, NULL, OPT_VERSION},
     149    {"help", no_argument, NULL, OPT_HELP},
     150    {NULL, 0, NULL, 0}
     151  };
     152
     153  while ((c = getopt_long(argc, argv, "ZDERSF:c:i:advqtluons:f:m", options, NULL)) != -1)
    125154  {
    126155    switch(c)
    127156    {
     157      case OPT_VERSION:
     158        /* Version */
     159        printf("This is zcrypt version %s\n", OWL_VERSION_STRING);
     160        exit(0);
     161      case OPT_HELP:
     162        /* Help */
     163        usage(stdout, argv[0]);
     164        exit(0);
    128165      case 'Z':
    129166        /* Zephyr encrypt */
     
    257294  if (error || !cryptspec)
    258295  {
    259     fprintf(stderr, "Usage: %s [-Z|-D|-E|-R|-S] [-F Keyfile] [-c class] [-i instance]\n", argv[0]);
    260     fprintf(stderr, "       [-advqtluon] [-s signature] [-f arg] [-m message]\n");
    261     fprintf(stderr, "  One or more of class, instance, and keyfile must be specified.\n");
     296    usage(stderr, argv[0]);
    262297    exit(1);
    263298  }
Note: See TracChangeset for help on using the changeset viewer.