Example #1
0
int initCppAPI(char* cppFilterLib) {
	char *error = NULL;

	// try load lib in local directory, so we need 2 strigns,
	// the first with ./, em the second whithout
	char* libnameLocal = (char*)malloc(strlen(cppFilterLib) + 3);
	sprintf(libnameLocal, "./%s", cppFilterLib);

	// get the library handler
	void* filterLibHandler = NULL;
	if (((filterLibHandler = dlopen(libnameLocal, RTLD_NOW)) == NULL) &&
		((filterLibHandler = dlopen(cppFilterLib, RTLD_NOW)) == NULL )) {
			fprintf(stderr, "api_cpp.cpp: could not load filter %s library, %s\n", cppFilterLib, dlerror());
			dlclose(cppFilterLib);
			return -1;
	}
	free(libnameLocal);

	// load filter from dynamic library : filterFactory()
	// warnnig: here we only try to load simbols in C
	filterFactory_t* filterLibFactory = (filterFactory_t *)dlsym(filterLibHandler, "filterFactory");
	if ((error = dlerror()) != NULL)  {
		fprintf (stderr, "Erro no dlsym: %s\n", error);
		dlclose(filterLibHandler);
		return -1;
	}

	// call filterFactory() to register the filter object
	filterLibFactory();
	return 1;
}
Example #2
0
int finalizeFilterEvent(){
	// call filterFactory() to register the filter object
	filterLibFactory();

	return 1;
}