/*
 *  ARGS.C
 */

/*
 * (c)Copyright 1992-93 by Tobias Ferber.
 *
 * This file is part of CPDIST.
 *
 * CPDIST is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation; either version 1 of the License,
 * or (at your option) any later version.
 *
 * CPDIST is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with CPDIST; see the file COPYING.  If not, write to
 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <string.h>

static char *howtouse[]= {
  "-a", "--replace-all",      "don't ask before blowing files away",
  "-a", "--assume-replace",   "",
  "-b", "--buffer-size",      "set the copy buffer size",
  "-c", "--check-existence",  "look for files before copying anything",
  "-D", "--key",              "make a distribution key valid",
  "-E", "--stderr",           "redirect the error output",
  "-f", "--file",             "use a certain 'distfile' filename",
  "-h", "--help",             "display short usage information and exit",
  "-i", "--ignore-errors",    "try to parse the 'distfile' completely",
  "-k", "--keep-going",       "go on, even if in case of an I/O error",
  "-n", "--just-print",       "don't copy anything, just print",
  "-n", "--dry-run",          "",
  "-n", "--recon",            "",
  "-s", "--silent",           "don't print filenames when copying",
  "-s", "--quiet",            "",
  "-v", "--version",          "display author and version information",
  (char *)0L, (char *)0L
};

/* Note that this way of transforming options does not take care of the
 * OPTION_PREFIX which is defined in 'cpdist.h'.
 * This may change in future revisions.
 */

char *
convert_args(s)
char *s;
{
  char **t= howtouse;

  while(*t)
  { if(!strcmp(s,t[1]))
      break;
    t= &t[3];
  }

  return (*t) ? *t : s;
}

void display_args(void)
{
  char **t= howtouse;

  while(*t)
  { if(t[2] && *t[2])
      printf("%s or %-20s %s\n",t[0],t[1],t[2]);
    t= &t[3];
  }
}
