// Blif2Bench.cpp : Defines the entry point for the console application.

#include "stdafx.h"

#ifdef _MSC_VER
#pragma hdrstop
#endif

using namespace std;

#include "../../Kernel/kernelincludes.h"
#include "../../Multilevel/Blif.h"

void help()
{
	cout << "Syntax: BlifToBench source.blif dest.bench" << endl;
}

int main(int argc, char* argv[])
{
    Blif source;
	char *src_file = NULL;
	char *dest_file = NULL;
	int i;

	cout << "BlifToBench 1.0, (c) March 2010 by Petr Fiser" << endl;
	if ( argc < 3 ) {
        help();
        exit(1);
    }

	try {
		i = 1;
		while ( i != argc ) {
			if ( argv[i][0] != '-' && src_file == NULL ) src_file = argv[i];
			else if ( argv[i][0] != '-' ) dest_file = argv[i];
			else {
				help();
				exit(1);
			}
			i++;
		}
	} catch (...) {
        help();
        exit(1);
    }

	if ( src_file == NULL || dest_file == NULL ) {
        help();
        exit(1);
    }

	try {
		source.LoadBlif(src_file);
		source.SaveBench(dest_file);
	} catch (IOException e) {
			cerr << e.GetMsg() << endl;
			exit(1);
	}

	return 0;
}


