// main.C
//
// Created by Cristina Videira Lopes on 12/20/94.
//
// This file contains the main program for the Library System.
//
// command syntax : run 
// run the interactive library system


#include "library.h"

void out_of_store()
{
  cerr << "library: operator new failed, out of store\n";
  exit( 1 );
}

#ifndef __GNUC__
extern PF set_new_handler( PF );
#else
extern "C"  PF set_new_handler( PF );
#endif



/*
 * GEN_DIR is a global variable containing the path of the generation
 * environment. This path is used to find the cd-print and cd-parse
 * class dictionaries.
 * Do NOT delete the following statement.
 */

char* GEN_DIR = getenv( "GEN_DIR" );

int main( int argc, char* argv[], char* envp[] )
{
  // set new handler to catch out of memory exception
  set_new_handler( &out_of_store );

  // *** Instantiate main objects ***

  LibrarySystem* iLibrarySystem = new LibrarySystem();
  Book_List *bl = new Book_List;
  iLibrarySystem->set_books (bl);
  User_List *ul = new User_List;
  iLibrarySystem->set_users (ul);

  // *** End of block ***

  // Initialize books and users in the library
#include "lib.init"

  // Initialize operations
  iLibrarySystem->init_ops();

  // Run
  iLibrarySystem->run();

  return(0);
}

