home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / f / futi14as.zip / GETVERSI.C < prev    next >
C/C++ Source or Header  |  1992-02-22  |  2KB  |  72 lines

  1. /* getversion.c -- select backup filename type
  2.    Copyright (C) 1990 Free Software Foundation, Inc.
  3.  
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 1, or (at your option)
  7.    any later version.
  8.  
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18. /* Written by David MacKenzie <djm@ai.mit.edu> */
  19.  
  20. /* MS-DOS port (c) 1990 by Thorsten Ohl, ohl@gnu.ai.mit.edu
  21.    This port is also distributed under the terms of the
  22.    GNU General Public License as published by the
  23.    Free Software Foundation.
  24.  
  25.    Please note that this file is not identical to the
  26.    original GNU release, you should have received this
  27.    code as patch to the official release.
  28.  
  29.    $Header: e:/gnu/fileutil/RCS/getversi.c 1.4.0.2 90/09/19 12:27:31 tho Exp $
  30.  */
  31.  
  32. #include "backupfile.h"
  33.  
  34. #ifdef MSDOS
  35. extern enum backup_type get_version (char *version);
  36. extern int argmatch (char *arg, char **optlist);
  37. extern void invalid_arg (char *kind, char *value, int problem);
  38. #else /* not MSDOS */
  39. int argmatch ();
  40. void invalid_arg ();
  41. #endif /* not MSDOS */
  42.  
  43. extern char *program_name;
  44.  
  45. static char *backup_args[] =
  46. {
  47.   "never", "simple", "nil", "existing", "t", "numbered", 0
  48. };
  49.  
  50. static enum backup_type backup_types[] =
  51. {
  52.   simple, simple, numbered_existing, numbered_existing, numbered, numbered
  53. };
  54.  
  55. /* Return the type of backup indicated by VERSION.
  56.    Unique abbreviations are accepted. */
  57.  
  58. enum backup_type
  59. get_version (version)
  60.      char *version;
  61. {
  62.   int i;
  63.  
  64.   if (version == 0 || *version == 0)
  65.     return numbered_existing;
  66.   i = argmatch (version, backup_args);
  67.   if (i >= 0)
  68.     return backup_types[i];
  69.   invalid_arg ("version control type", version, i);
  70.   return numbered_existing;
  71. }
  72.