home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / glimpse-2.1 / compress / main_tbuild.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-16  |  1.5 KB  |  55 lines

  1. /* Copyright (c) 1994 Burra Gopal, Udi Manber.  All Rights Reserved. */
  2.  
  3. /*
  4.  * main_tbuild.c: calls tbuild.c/compute_dictionary() after reading options.
  5.  */
  6.  
  7. #include "defs.h"
  8.  
  9. extern int compute_dictionary();
  10. extern char **environ;
  11.  
  12. usage(progname)
  13. char    *progname;
  14. {
  15.     fprintf(stderr, "usage: %s [-H directory] [-t threshold] [-l stop-list-size]\n", progname);
  16.     fprintf(stderr, "defaults: %d %d %d ~\n", DEF_SPECIAL_WORDS, DEF_THRESHOLD, DEF_BLOCKSIZE);
  17.     exit(1);
  18. }
  19.  
  20. main(argc, argv)
  21.     int    argc;
  22.     unsigned char    *argv[];
  23. {
  24.     char    comp_dir[MAX_LINE_LEN];
  25.     int    threshold, specialwords;
  26.     int    i = 1;
  27.     char    *home;
  28.  
  29.     /* fill in default options */
  30.     comp_dir[0] = '\0';
  31.     threshold = DEF_THRESHOLD;
  32.     specialwords = DEF_SPECIAL_WORDS;
  33.  
  34.     while(i < argc) {
  35.         if (argv[i][0] != '-') return usage(argv[0]);
  36.         else if (argv[i][1] == 'H') strcpy(comp_dir, argv[++i]);
  37.         else if (argv[i][1] == 't') threshold = atoi(argv[++i]);
  38.         else if (argv[i][1] == 'l') specialwords = atoi(argv[++i]);
  39.         else if (argv[i][1] == 'V') {
  40.             printf("\nThis is tbuild version %s. Copyright (c) %s, University of Arizona.\n\n", CAST_VERSION, CAST_DATE);
  41.         }
  42.         else return usage(argv[0]);
  43.         i++;
  44.     }
  45.         if (comp_dir[0] == '\0') {
  46.                 if ((home = (char *)getenv("HOME")) == NULL) {
  47.                         getcwd(comp_dir, MAX_LINE_LEN-1);
  48.                         fprintf(stderr, "using working-directory '%s' to locate index\n", comp_dir);
  49.                 }
  50.                 else strncpy(comp_dir, home, MAX_LINE_LEN);
  51.         }
  52.  
  53.     compute_dictionary(threshold, DISKBLOCKSIZE, specialwords, comp_dir);
  54. }
  55.