/* $Id: version.c 28052 2008-07-31 09:00:16Z mindaugas $ */

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

#include "version.h"

int print_version(HFncExtractor hExtractor, HFncMatcher hMatcher)
{
	NResult ret;
	NLibraryInfo extractorinfo, matcherinfo;

	printf("\n  %s (version: %s). %s\n\n", DEMO_NAME, DEMO_VERSION, DEMO_COPYRIGHT);
	printf("Components used:\n");

	ret = FnceGetInfo(&extractorinfo);
	if (ret != N_OK)
	{
		printf("GetInfo returns %d\n, exitting.\n", ret);
		return -1;
	}

	printf("  %s (version: %u.%u.%u.%u). ", extractorinfo.Title,
		extractorinfo.VersionMajor,
		extractorinfo.VersionMinor,
		extractorinfo.VersionBuild,
		extractorinfo.VersionRevision);
	printf("%s\n", extractorinfo.Copyright);

	ret = FncmGetInfo(&matcherinfo);
	if (ret != N_OK)
	{
		printf("GetInfo returns %d\n, exitting.\n", ret);
		return -1;
	}

	printf("  %s (version: %u.%u.%u.%u). ", matcherinfo.Title,
		matcherinfo.VersionMajor,
		matcherinfo.VersionMinor,
		matcherinfo.VersionBuild,
		matcherinfo.VersionRevision);
	printf("%s\n", matcherinfo.Copyright);
	printf("\n\n");
/*
	string_size = FnceGetParameter(hExtractor, FNCEP_NAME, NULL);
	if (string_size <= 0)
	{
		printf ("GetParameter returns %d, exitting.\n", string_size);
		return -1;
	}
	max_string_size = string_size;

	string_size = FnceGetParameter(hExtractor, FNCEP_COPYRIGHT, NULL);
	if (string_size <= 0)
	{
		printf ("GetParameter returns %d, exitting.\n", string_size);
		return -1;
	}
	if (string_size > max_string_size)
	{
		max_string_size = string_size ;
	}
	string_size = FncmGetParameter(hMatcher, FNCMP_NAME, NULL);
	if (string_size <= 0)
	{
		printf ("GetParameter returns %d, exitting.\n", string_size);
		return -1;
	}
	if (string_size > max_string_size)
	{
		max_string_size = string_size;
	}

	string_size = FncmGetParameter(hMatcher, FNCMP_COPYRIGHT, NULL);
	if (string_size <= 0)
	{
		printf ("GetParameter returns %d, exitting.\n", string_size);
		return -1;
	}
	if (string_size > max_string_size)
	{
		max_string_size = string_size ;
	}

	lib_name = malloc(max_string_size+1);
	if (lib_name == NULL)
	{
		printf ("out of memory.\n");
		return -1;
	}

	FnceGetParameter(hExtractor, FNCEP_NAME, lib_name);
	FnceGetParameter(hExtractor, FNCEP_VERSION_HIGH, &versionH);
	FnceGetParameter(hExtractor, FNCEP_VERSION_LOW, &versionL);
	printf("  %s (version: %u.%u.%u.%u). ", lib_name,
		versionH >> 16, versionH & 0xFFFF, versionL >> 16, versionL & 0xFFFF);
	FnceGetParameter(hExtractor, FNCEP_COPYRIGHT, lib_name);
	printf("%s\n", lib_name);

	FncmGetParameter(hMatcher, FNCMP_NAME, lib_name);
	FncmGetParameter(hMatcher, FNCMP_VERSION_HIGH, &versionH);
	FncmGetParameter(hMatcher, FNCMP_VERSION_LOW, &versionL);
	printf("  %s (version: %u.%u.%u.%u). ", lib_name,
		versionH >> 16, versionH & 0xFFFF, versionL >> 16, versionL & 0xFFFF);
	FncmGetParameter(hMatcher, FNCMP_COPYRIGHT, lib_name);
	printf("%s\n", lib_name);
	printf("\n\n");
	free(lib_name);
*/
	return 0;
}

