#include "test.h"

int main(int argc, char* argv[])
{
	char iDesc[] = "matrix D, matrix Dm, matrix Dp, matrix DI, indexarray Tuc, indexarray Tuo, arrayi siphon, arrayi ipl, arrayi dpl, arrayi opl, arrayi apl, arrayi ntr, matrix M, int SkipCheck";
	char oDesc[] = "arrayi l, int how";
	admcon_p params;
	admcon_r result;
	int *iFill;
	int oFill[2] = {1, 1};
	FILE* input;
	if (! (input = ParseCmdLine(argc, argv)))
	{
		return 0;
	}
	
	MemoryManager mem = CreateMemoryManager(10, 5, 0, 0);
	matrix D;
	int dummy;
	memset(&params, 0, sizeof(admcon_p));
	while (ParseStructure(input, iDesc, &iFill, &mem, &D, &params.Dm, &params.Dp, &params.DI, &params.Tuc, &params.TucCount, &params.Tuo, &params.TuoCount, &params.siphon, &dummy, &params.ipl, &params.ipCount, &params.dpl, &params.dpCount, &params.opl, &params.opCount, &params.apl, &params.apCount, &params.ntr, &params.ntCount, &params.M, &params.skipParamCheck))
	{
		/*Display the problem.*/
		DisplayStructure(iDesc, iFill, &D, &params.Dm, &params.Dp, &params.DI, params.Tuc, params.TucCount, iFill[3] ? NumberOfColumns(params.DI) : 0, params.Tuo, params.TuoCount, iFill[3] ? NumberOfColumns(params.DI) : 0, params.siphon, dummy, params.ipl, params.ipCount, params.dpl, params.dpCount, params.opl, params.opCount, params.apl, params.apCount, params.ntr, params.ntCount, params.M, params.skipParamCheck);
		
		/*Fill in Dm and Dp if necessary.*/
		FillDmDp(iFill, &D, &params.Dm, &params.Dp, &mem);
		
		/*Solve the problem.*/
		result = admcon(&params);
		
		/*Setup filled as appropriate.*/
		oFill[0] = result.how;
		
		/*Show the result.*/
		printf("Solution:\n");
		DisplayStructure(oDesc, oFill, result.l, result.how);
		
		/*Free memory.*/
		FreeMemory(&mem);
		mem = CreateMemoryManager(10, 5, 0, 0);
		DeallocateAdmcon(&result);
	}
	FreeMemory(&mem);
	return 1;
}