NAME
sp_setstring, sp_getstring, sp_setint, sp_getint, sp_getobject - set or get configuration options
SYNOPSIS
#include <sophia.h>
int sp_setstring(void *object, const char *path, const void *ptr, int size);
void *sp_getstring(void *object, const char *path, int *size);
int sp_setint(void *object, const char *path, int64_t value);
int64_t sp_getint(void *object, const char *path);
void *sp_getobject(void *object, const char *path);
DESCRIPTION
For additional information take a look at the Configuration section.
EXAMPLE
void *env = sp_env()
sp_setstring(env, "sophia.path", "./sophia", 0);
sp_open(env);
char key[] = "key";
void *o = sp_document(db);
sp_setstring(o, "key", key, sizeof(key));
sp_setstring(o, "value", "hello world", 0));
sp_set(db, o);
int error_size;
char *error = sp_getstring(env, "sophia.error", &error_size);
if (error) {
printf("error: %s\n", error);
free(error);
}
void *db = sp_getobject(env, "db.test");
sp_drop(db);
RETURN VALUE
On success, sp_setstring() returns 0. On error, it returns -1.
On success, sp_getstring() returns string pointer. On error or if the variable is not set, it returns NULL.
All pointers returned by sp_getstring() must be freed using free(3) function. Exception is sp_document() object and configuration cursor document.
On success, sp_setint() returns 0. On error, it returns -1. On success, sp_getint() returns a numeric value. On error, it returns -1.
On success, sp_getobject() returns an object pointer. On error or if the variable is not set, it returns NULL.
The database object returned by sp_getobject() increments its reference counter, sp_destroy() can be used to decrement it. This should be considered for online database close/drop cases.
SEE ALSO