#include "test.h"

int main(int argc, char* argv[])
{
	char iDesc[] = "matrix D, matrix Dm, matrix Dp, arrayi list, matrix PS, matrix Da, matrix Dma, matrix Dpa";
	char oDesc[] = "matrix MS, matrix NMS";
	matrix D, Dm, Dp, PS, Da, Dma, Dpa;
	int listCount;
	int *list, *iSet;	
	int oSet[] = {1, 1};
	
	FILE* input;
	
	if (! (input = ParseCmdLine(argc, argv))) return 0;
	
	setverbose(VRB_MAX);
	MemoryManager mem = CreateMemoryManager(10, 10, 0, 0);
	while (ParseStructure(input, iDesc, &iSet, &mem, &D, &Dm, &Dp, &list, &listCount, &PS, &Da, &Dma, &Dpa))
	{
		DisplayStructure(iDesc, iSet, &D, &Dm, &Dp, list, listCount, &PS, &Da, &Dma, &Dpa);
		FillDmDp(iSet, &D, &Dm, &Dp, &mem);
		FillDmDp(iSet + 5, &Da, &Dma, &Dpa, &mem);
		
		asiph_r result = asiph(iSet[1] ? &Dm : 0, iSet[2] ? &Dp : 0, iSet[3] ? list : 0, iSet[3] ? listCount : 0, iSet[4] ? &PS : 0, iSet[6] ? &Dma : 0, iSet[7] ? &Dpa : 0);
		printf("Solution:\n");
		
		DisplayStructure(oDesc, oSet, &result.MS, &result.NMS);
		
		DeallocateAsiph(&result);
		
		FreeMemory(&mem);
		mem = CreateMemoryManager(10, 10, 0, 0);
		printf("-------------------------------------------------------------------------------\n");
	}
	FreeMemory(&mem);
	
	if (input != stdin) fclose(input);
	return 0;	
}
