main.cpp 1.56 KB
//*****************************************************************
/*
	VLibras: Automatic pasteboardContents translator from Portuguese to LIBRAS

	Copyright (c) 2015 Gustavo Sobral, Erickson Silva, Leonardo Araújo
	VLibras-Core group at LAViD, Federal University of Paraiba
*/
//*****************************************************************

/**
 * \file main.cpp
 * \author Leonardo Araújo
 * \date Outubro 2015
 */

#include <stdlib.h>
#include <dlfcn.h>
#include <iostream>
#include <fstream>
#include <string>

int main()
{

	void *vlibras_lib_handler;
	const char *dlsym_error_ptr;

	vlibras_lib_handler = dlopen("plugin/libCorePlugin.so", RTLD_LAZY);
	if (!vlibras_lib_handler) 
	{
		fprintf(stderr, "%s\n", dlerror());
		exit(1);
	}

	typedef void (*coreplugin_t)();    
    dlerror();
    
    coreplugin_t core_init_f = (coreplugin_t) dlsym(vlibras_lib_handler, "coreInitialize");
    dlsym_error_ptr = dlerror();
    if (dlsym_error_ptr) 
    {
    	printf("Cannot load symbol 'coreInitialize': %s\n", dlsym_error_ptr);
        dlclose(vlibras_lib_handler);
        return 1;
    }

    /* Test coreInitialize function */
    core_init_f();

    coreplugin_t core_update_f = (coreplugin_t) dlsym(vlibras_lib_handler, "coreUpdateCheck");
    dlsym_error_ptr = dlerror();
    if (dlsym_error_ptr) 
    {
    	printf("Cannot load symbol 'coreUpdateCheck': %s\n", dlsym_error_ptr);
        dlclose(vlibras_lib_handler);
        return 1;
    }

    /* Test coreUpdateCheck function */
    core_update_f();    

    /* Close load library */
	dlclose(vlibras_lib_handler);

	return 0;
}