/*++

Copyright (C) 2021 Jan Orend

All rights reserved.

This file has been generated by the Automatic Component Toolkit (ACT) version 1.6.0.

Abstract: This is an autogenerated C application that demonstrates the
 usage of the C bindings of GladiusLib

Interface version: 1.0.0

*/

#include <stdio.h>
#include <stdlib.h>
#include "gladius_dynamic.h"


void releaseWrapper(sGladiusLibDynamicWrapperTable* pWrapperTable) {
	GladiusLibResult eResult = ReleaseGladiusLibWrapperTable(pWrapperTable);
	if (GLADIUSLIB_SUCCESS != eResult) {
		printf_s("Failed to release wrapper table\n");
	}
}

int main()
{
	// TODO: put a path to GladiusLib binary file here:
	const char* libpath = "";
	sGladiusLibDynamicWrapperTable sWrapperTable;
	GladiusLibResult eResult = GLADIUSLIB_SUCCESS;
	
	eResult = InitGladiusLibWrapperTable(&sWrapperTable);
	if (GLADIUSLIB_SUCCESS != eResult) {
		printf_s("Failed to initialize wrapper table\n");
		return eResult;
	}
	
	eResult = LoadGladiusLibWrapperTable(&sWrapperTable, libpath);
	if (GLADIUSLIB_SUCCESS != eResult) {
		printf_s("Failed to load gladius-binary\n");
		return eResult;
	}
	GladiusLib_uint32 nMajor, nMinor, nMicro;
	eResult = sWrapperTable.m_GetVersion(&nMajor, &nMinor, &nMicro);
	if (GLADIUSLIB_SUCCESS != eResult) {
		printf_s("Failed to get version\n");
		releaseWrapper(&sWrapperTable);
		return eResult;
	}
	printf_s("GladiusLib.Version = %d.%d.%d", nMajor, nMinor, nMicro);
	
	printf_s("\n");
	
	eResult = ReleaseGladiusLibWrapperTable(&sWrapperTable);
	if (GLADIUSLIB_SUCCESS != eResult) {
		printf_s("Failed to release wrapper table\n");
		return eResult;
	}
	
	return 0;
}

