This API provides the ability to write a plugin that implements a backend to any database of papers. The hope being that libscipaper with eventually have modules that implement fetching from all major scientific databases. Full documentation can be found here: Module API. For the convenience of module developers, a Jason parsing API is also provided. This API is documented here: Json Parsing API.
A libscipaper module is a C or C++ tanslation unit that contains #define MODULE_NAME "some-name"
as well as exporting the symbols sci_module_init of type sci_module_init_fn and sci_module_exit of type sci_module_exit_fn.
modules are expected to use the sci_conf_*
family of functions to gain external site specific information sutch as API keys and use sci_module_log for debug as well as error output. Any library such as libcurl may be used to gather information to be returned.
For a module to be usefull it must also define an implementation at least one of the following functions:
and must register one or more of these functions with libscipaper using sci_plugin_register
thus the basic structure of a libscipaper plugin looks like this:
#include <glib.h>
#include "sci-backend.h"
#include "scipaper.h"
#define MODULE_NAME "test"
};
struct TestPriv {
int id;
};
{
struct TestPriv* priv = userData;
}
static char* test_get_document_text(
const DocumentMeta* meta,
void* userData)
{
struct TestPriv* priv = userData;
return g_strdup("This should be the document text");
}
{
struct TestPriv* priv = userData;
return NULL;
}
G_MODULE_EXPORT const gchar *sci_module_init(void** data);
const gchar *sci_module_init(void** data)
{
struct TestPriv* priv = g_malloc0(sizeof(*priv));
*data = priv;
priv->id =
sci_plugin_register(&module_info, test_fill_meta, test_get_document_text, test_get_document_pdf_data, priv);
}
G_MODULE_EXPORT void sci_module_exit(void* data);
void sci_module_exit(void* data)
{
struct TestPriv* priv = data;
g_free(priv);
}
RequestReturn * request_return_new(size_t count, size_t maxCount)
Allocates a empty RequestReturn struct.
@ SCI_CAP_GET_TEXT
Backend can get full text of documents.
Definition types.h:52
@ SCI_CAP_GET_PDF
Backend can get pdfs of documents.
Definition types.h:53
@ SCI_CAP_FILL
Backend can fill DocumentMeta structs.
Definition types.h:51
int sci_plugin_register(const BackendInfo *backend_info, RequestReturn *(*fill_meta_in)(const DocumentMeta *, size_t, size_t, void *), char *(*get_document_text_in)(const DocumentMeta *, void *), PdfData *(*get_document_pdf_data_in)(const DocumentMeta *, void *), void *user_data)
Registers a backend, not all functions have to be regisered for eatch backend, pass NULL for unwanted...
Headers for the module handling for SCIPAPER.
Backend information struct.
Definition types.h:75
const char *const name
Name of the plugin.
Definition types.h:76
This struct contains the raw data of a PDF document.
Definition types.h:260
This struct is details the result of a metadata search.
Definition types.h:234