home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume20 / gperf / part01 / cperf / src / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-10-18  |  2.0 KB  |  75 lines

  1. /* Driver program for the Perfect hash function generator.
  2.    Copyright (C) 1989 Free Software Foundation, Inc.
  3.    written by Douglas C. Schmidt (schmidt@ics.uci.edu)
  4.  
  5. This file is part of GNU GPERF.
  6.  
  7. GNU GPERF is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 1, or (at your option)
  10. any later version.
  11.  
  12. GNU GPERF is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GNU GPERF; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. /* Simple driver program for the Perfect.hash function generator.
  22.    Most of the hard work is done in class Perfect and its class methods. */
  23.  
  24. #include <stdio.h>
  25. #include "stderr.h"
  26. #include "options.h"
  27. #include "perfect.h"
  28.  
  29. /* Calls the appropriate intialization routines for each
  30.    ADT.  Note that certain initialization routines require
  31.    initialization *after* certain values are computed.  Therefore,
  32.    they cannot be called here. */
  33.    
  34. static void 
  35. init_all (argc, argv)
  36.      int argc;
  37.      char *argv[];
  38. {
  39.   options_init (argc, argv);    
  40.   key_list_init ();
  41.   perfect_init ();              
  42. }
  43.  
  44. /* Calls appropriate destruction routines for each ADT.  These
  45.    routines print diagnostics if the debugging option is enabled. */
  46.  
  47. static void
  48. destroy_all ()
  49. {
  50.   options_destroy ();
  51.   bool_array_destroy ();
  52.   hash_table_destroy ();
  53.   key_list_destroy ();
  54.   perfect_destroy ();
  55. }
  56.  
  57. /* Driver for perfect hash function generation. */
  58.  
  59. int
  60. main (argc, argv)
  61.      int argc;
  62.      char *argv[];
  63. {
  64.   int status;
  65.   
  66.   /* Sets the options. */
  67.   init_all (argc, argv);
  68.  
  69.   /* Generates the perfect hash table.
  70.      Also prints generated code neatly to the output. */
  71.   status = perfect_generate ();
  72.   destroy_all ();
  73.   return status;
  74. }
  75.