
/*
	file:		main.c
	purpose:	contains main driver routines for area program. 

	author: leigh willard 
	date:	21 July 1992	
	place:	University of Alberta / Department of Biochemistry
*/

#include "area.h"

char resultsFname[MAX_FNAME_LEN], pdbFname[MAX_FNAME_LEN], dirShiftXP[MAX_FNAME_LEN];
void show_version(), do_area(), init_parms();
void show_err(), setup_area();


/*************************************************************/
/* main program
*/
int main(argc, argv)
int argc;
char **argv;
{
//	show_version();
	setup_area(argc, argv);

        // printf("%s\n", dirShiftXP);
	do_area(dirShiftXP, resultsFname);

	return(0);

}	/* main */


/*************************************************************/
/* current version of the program 
*/
void show_version()
{

	fprintf(stdout,  "\n");
	fprintf(stdout,  " ----------------------------------------------------------------\n");
	fprintf(stdout,  "   \n");
	fprintf(stdout,  "   Program....: area\n");
	fprintf(stdout,  "   Description: Calculate contact and accessible areas.\n");
	fprintf(stdout,  "   \n");
	fprintf(stdout,  "   Author.....: T.J. Richmond\n");
	fprintf(stdout,  "   \n");
	fprintf(stdout,  " \n");

}	/* show_version */


/*************************************************************/
/* get flags, read parameters
*/
void setup_area(argc, argv)
int argc;
char *argv[];
{
	int     i;
	char    parmsFname[MAX_FNAME_LEN];

	strcpy(parmsFname, USER_PARMS);
	for (i=1; i<argc; i++) {
		if (strcmp(argv[i], PARMS_FLAG) == 0) {
			strcpy(parmsFname, argv[i+1]);
		break;
		}
	}

	strcpy(pdbFname, "");
	for (i=1; i<argc; i++) {
		if (strcmp(argv[i], FILE_FLAG) == 0) {
			strcpy(pdbFname, argv[i+1]);
			break;
		}
	}

	if (strcmp(pdbFname, "") == 0)
		show_err(TRUE, "Area", 
				"Usage: area -f infile [ -o outfile ] [ -i parmsfile ]");
	if (checkExist(pdbFname) != TRUE)
		show_err(TRUE, "Area", "Input file does not exist");

	strcpy(resultsFname, "");
	for (i=1; i<argc; i++) {
		if (strcmp(argv[i], RESULTS_FLAG) == 0) {
			strcpy(resultsFname, argv[i+1]);
			break;
		}
	}

        // To use library table files
        // add 2011.03.17 flag = -d
	strcpy(dirShiftXP, "");
	for (i=1; i<argc; i++) {
		if (strcmp(argv[i], DIRSHIFTXP_FLAG) == 0) {
			strcpy(dirShiftXP, argv[i+1]);
			break;
		}
	}

	init_parms(parmsFname, resultsFname);

}   /* setup_area */
