home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR2 / CBUFF09.ZIP / SRC.ZIP / MERGE.C < prev    next >
C/C++ Source or Header  |  1993-11-16  |  2KB  |  96 lines

  1. /*  $Id$
  2.  *  
  3.  *  File    merge.c
  4.  *  Part of    ChessBase utilities file format (CBUFF)
  5.  *  Author    Anjo Anjewierden, anjo@swi.psy.uva.nl
  6.  *  Purpose    Merge databases
  7.  *  Works with    GNU CC 2.4.5
  8.  *  
  9.  *  Notice    Copyright (c) 1993  Anjo Anjewierden
  10.  *  
  11.  *  History    17/07/93  (Created)
  12.  *          17/10/93  (Last modified)
  13.  */ 
  14.  
  15.  
  16. /*------------------------------------------------------------
  17.  *  Directives
  18.  *------------------------------------------------------------*/
  19.  
  20. #include "cbuff.h"
  21.  
  22. char *        UTILITY_NAME = "Merge utility";
  23. char *        UTILITY_VERSION = "1.1.0";
  24.  
  25. void        helpUtility(FILE *fd);
  26.  
  27. void        mergeUtility(Option);
  28.  
  29.  
  30. /*------------------------------------------------------------
  31.  *  Merge utility
  32.  *------------------------------------------------------------*/
  33.  
  34. void
  35. mergeUtility(Option opt)
  36. { if (opt->dump == NULL)
  37.   { fprintf(stderr, "No output database specified (-dump or -append option)\n");
  38.     exit(1);
  39.   }
  40.  
  41.   reportCBase(opt->database, stderr);
  42.  
  43.   exportManyCBase(opt->dump, opt->database, opt->from, opt->to);
  44. }
  45.  
  46.  
  47. /*------------------------------------------------------------
  48.  *  Main
  49.  *------------------------------------------------------------*/
  50.  
  51. int
  52. main(int argc, char *argv[])
  53. { int i;
  54.   Option options = newOption();
  55.  
  56.   for (i=1; i<argc; i++)
  57.   {
  58.     if (strhead(argv[i], "-"))
  59.     { int n;
  60.  
  61.       n = genericOption(options, argv, argc, i);
  62.       if (n == 0)
  63.       { fprintf(stderr, "Fatal: Unknown command %s\n", argv[i]);
  64.     fprintf(stderr, "Do ``%s -help'' or see the documentation\n", argv[0]);
  65.     exit(1);
  66.       }
  67.       i = n;
  68.       continue;
  69.     }
  70.  
  71.     setCurrentCBase(argv[i], "-database", argc, i);
  72.     options->database = CurrentBase;
  73.     mergeUtility(options);
  74.     freeCBase(options->database);
  75.     options->database = (CBase) NULL;
  76.   }
  77.  
  78.   if (options->database)
  79.   { mergeUtility(options);
  80.     freeCBase(options->database);
  81.   }
  82.  
  83.   exit(0);
  84. }
  85.  
  86.  
  87. /*------------------------------------------------------------
  88.  *  Help
  89.  *------------------------------------------------------------*/
  90.  
  91. void
  92. helpUtility(FILE *fd)
  93. { helpCBUFF(fd);
  94.   fprintf(fd, "%s options:\n", UTILITY_NAME);
  95. }
  96.