
/*
 * main.cc
 * Copyright (C) 2002 by John Heidemann <johnh@isi.edu>
 * $Id: main.cc,v 1.8 2002/04/05 21:36:56 johnh Exp $
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 *
 */

#include <unistd.h> // for getopt
#include <iostream>
#include <fstream>

#include <stdlib.h> // for exit

#include "master.hh"

int debug = 0;

void
usage()
{
	cerr << "usage: manager [-d] [configfile]\n"
	     << "\nBy default it reads master.conf as a config file.\n";
	exit(1);
}

void
die(char *s)
{
	cerr << s;
	exit(1);
}

int
main(int argc, char **argv)
{
	int c;
	char *config_file = "master.conf";
	extern char *optarg;
	extern int optind, opterr, optopt;

        while ((c = getopt(argc, argv, "d?")) != EOF)
                switch (c) {
		case 'd':
			debug++;
			break;
		default:
			usage();
			break;
                };
	if (optind < argc) {
		config_file = argv[optind];
		optind++;
	};
	if (optind < argc) {
		usage();
	};
	
	ifstream config_stream(config_file);
	assert(config_stream.good());
	new Master(config_stream);
}
