/**********************************************************************
 
	Copyright (C) 2003 Hirohisa MORI <joshua@nichibun.ac.jp>
 
	This program is free software; you can redistribute it 
	and/or modify it under the terms of the GLOBALBASE 
	Library General Public License (G-LGPL) as published by 

	http://www.globalbase.org/
 
	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.

**********************************************************************/


#include	<stdio.h>
#include	"pfc.h"

int
save_pfc(PFC * pfc)
{
FILE * fd;

	fd = fopen(pfc->filename,"w+");
	if ( fd == 0 )
		return -1;
	fprintf(fd,"%i\n%lf\n%i\n%lf\n%i\n%i\n",
		pfc->interval,
		pfc->target,
		pfc->sign,
		pfc->evaluation,
		pfc->last_checkpoint,
		pfc->accumulate);
	fclose(fd);
	return 0;
}

int
load_pfc(PFC * pfc)
{
FILE * fd;
	fd = fopen(pfc->filename,"r+");
	if ( fd == 0 ) {
		return -1;
	}
	fscanf(fd,"%i %lf %i %lf %i %i\n",
		&pfc->interval,
		&pfc->target,
		&pfc->sign,
		&pfc->evaluation,
		&pfc->last_checkpoint,
		&pfc->accumulate);
	fclose(fd);
	return 0;
}
