libscipaper 1.0.x
|
Api for use by libscipaper modules. More...
Data Structures | |
struct | Pair |
A key value Pair struct to be used wih G(S)Lists. More... | |
Macros | |
#define | sci_module_log(loglevel, fmt, ...) sci_log(loglevel, "%s: " fmt, MODULE_NAME, ##__VA_ARGS__) |
Print a string to the log. | |
Typedefs | |
typedef const char * | sci_module_init_fn(void **data) |
Modules must export a symbol of this type called sci_module_init, it will be called when the module is loaded. | |
typedef void | sci_module_exit_fn(void *data) |
Modules must export a symbol of this type called sci_module_exit, it will be called just before the module is removed. | |
Functions | |
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 functions. | |
void | sci_plugin_unregister (int id) |
Unregisters a backend, must be called before the backend exits. | |
bool | sci_conf_get_bool (const gchar *group, const gchar *key, const bool defaultval, gpointer keyfileptr) |
Get a boolean configuration value. | |
gint | sci_conf_get_int (const gchar *group, const gchar *key, const gint defaultval, gpointer keyfileptr) |
Get an integer configuration value. | |
gint * | sci_conf_get_int_list (const gchar *group, const gchar *key, gsize *length, gpointer keyfileptr) |
Get an integer list configuration value. | |
gchar * | sci_conf_get_string (const gchar *group, const gchar *key, const gchar *defaultval, gpointer keyfileptr) |
Get a string configuration value. | |
gchar ** | sci_conf_get_string_list (const gchar *group, const gchar *key, gsize *length, gpointer keyfileptr) |
Get a string list configuration value. | |
gpointer | sci_conf_read_conf_file (const gchar *const conffile) |
Read configuration file. | |
gpointer | sci_conf_read_conf_bytes (const char *data, size_t length) |
Read configuration from raw memory. | |
void | sci_conf_free_conf_file (gpointer keyfileptr) |
void | pair_free (struct Pair *pair) |
Frees a pair struct. | |
struct Pair * | pair_new (const char *key, const char *value) |
Frees a pair struct. | |
GString * | buildQuery (const GSList *list) |
Builds an url encoded query string that can be added to a url. | |
PdfData * | wgetPdf (const char *url, int timeout) |
Get a pdf file va a http(s) GET request. | |
GString * | wgetUrl (const char *url, int timeout) |
Get the http data return as a string from a url via a http(s) GET request. | |
GString * | wpostUrl (const char *url, const char *data, int timeout) |
Get the http data return as a string from a url via a http(s) POST request. | |
GString * | createJsonEntry (const int indent, const char *key, const char *value, bool quote, bool newline) |
Create a json style entry string. | |
Api for use by libscipaper modules.
This api is to be used by implemeters of libscipaper modules to expose the various features of webapis used as sources of metadata as well as full text information.
#define sci_module_log | ( | loglevel, | |
fmt, | |||
... ) sci_log(loglevel, "%s: " fmt, MODULE_NAME, ##__VA_ARGS__) |
Print a string to the log.
loglevel | Log level to use |
fmt | printf style format string |
... | Values to place into format string |
typedef void sci_module_exit_fn(void *data) |
Modules must export a symbol of this type called sci_module_exit, it will be called just before the module is removed.
data | this pointer gives this funciton context passed from sci_module_init_fn. |
typedef const char * sci_module_init_fn(void **data) |
Modules must export a symbol of this type called sci_module_init, it will be called when the module is loaded.
data | this pointer may be set by the module to pass context that is later given to sci_module_exit_fn() |
GString * buildQuery | ( | const GSList * | list | ) |
Builds an url encoded query string that can be added to a url.
list | const list of struct Pairs of key=value querys to add. |
GString * createJsonEntry | ( | const int | indent, |
const char * | key, | ||
const char * | value, | ||
bool | quote, | ||
bool | newline ) |
Create a json style entry string.
indent | intent level to prepend |
key | json entry key |
value | json entry value |
quote | if true qoutes "" are placed around value |
newline | if true the returned string ends with a unix newline |
struct Pair * pair_new | ( | const char * | key, |
const char * | value ) |
Frees a pair struct.
key | the key of the key-value pair |
value | the value of the key-value pair |
bool sci_conf_get_bool | ( | const gchar * | group, |
const gchar * | key, | ||
const bool | defaultval, | ||
gpointer | keyfileptr ) |
Get a boolean configuration value.
group | The configuration group to get the value from |
key | The configuration key to get the value of |
defaultval | The default value to use if the key isn't set |
keyfileptr | A keyfile pointer, or NULL to use the default keyfile |
gint sci_conf_get_int | ( | const gchar * | group, |
const gchar * | key, | ||
const gint | defaultval, | ||
gpointer | keyfileptr ) |
Get an integer configuration value.
group | The configuration group to get the value from |
key | The configuration key to get the value of |
defaultval | The default value to use if the key isn't set |
keyfileptr | A keyfile pointer, or NULL to use the default keyfile |
gint * sci_conf_get_int_list | ( | const gchar * | group, |
const gchar * | key, | ||
gsize * | length, | ||
gpointer | keyfileptr ) |
Get an integer list configuration value.
group | The configuration group to get the value from |
key | The configuration key to get the value of |
length | The length of the list |
keyfileptr | A keyfile pointer, or NULL to use the default keyfile |
gchar * sci_conf_get_string | ( | const gchar * | group, |
const gchar * | key, | ||
const gchar * | defaultval, | ||
gpointer | keyfileptr ) |
Get a string configuration value.
group | The configuration group to get the value from |
key | The configuration key to get the value of |
defaultval | The default value to use if the key isn't set |
keyfileptr | A keyfile pointer, or NULL to use the default keyfile |
gchar ** sci_conf_get_string_list | ( | const gchar * | group, |
const gchar * | key, | ||
gsize * | length, | ||
gpointer | keyfileptr ) |
Get a string list configuration value.
group | The configuration group to get the value from |
key | The configuration key to get the value of |
length | The length of the list |
keyfileptr | A keyfile pointer, or NULL to use the default keyfile |
gpointer sci_conf_read_conf_bytes | ( | const char * | data, |
size_t | length ) |
Read configuration from raw memory.
data | Pointer to raw data to read |
length | length of data |
gpointer sci_conf_read_conf_file | ( | const gchar *const | conffile | ) |
Read configuration file.
conffile | The full path to the configuration file to read |
int sci_plugin_register | ( | const BackendInfo * | backend_info, |
RequestReturn *(*)(const DocumentMeta *, size_t, size_t, void *) | fill_meta_in, | ||
char *(*)(const DocumentMeta *, void *) | get_document_text_in, | ||
PdfData *(*)(const DocumentMeta *, void *) | get_document_pdf_data_in, | ||
void * | user_data ) |
Registers a backend, not all functions have to be regisered for eatch backend, pass NULL for unwanted functions.
backend_info | a module_info_struct descibeing the backend in question. it is expected that this struct have static lifetime. |
fill_meta_in | a function pointer to a function that takes a DocumentMeta struct and fills it. See sci_fill_meta() for details on parameters |
get_document_text_in | a function pointer to a function that gets the full text for a document. See sci_get_document_text() for details on parameters |
get_document_pdf_data_in | a function pointer to a function that gets the pdf data for a document. See sci_get_document_pdf_data() for details on parameters |
user_data | a point for context that will be passed to fill_meta_in, get_document_text_in, and get_document_pdf_data_in when called |
void sci_plugin_unregister | ( | int | id | ) |
Unregisters a backend, must be called before the backend exits.
id | the backend id to unreigster. |
PdfData * wgetPdf | ( | const char * | url, |
int | timeout ) |
Get a pdf file va a http(s) GET request.
url | The url to get |
GString * wgetUrl | ( | const char * | url, |
int | timeout ) |
Get the http data return as a string from a url via a http(s) GET request.
url | The url to get |
GString * wpostUrl | ( | const char * | url, |
const char * | data, | ||
int | timeout ) |
Get the http data return as a string from a url via a http(s) POST request.
url | The url to post |
data | null terminated string that contains the data to post to url |