Configuration

Every Sophia configuraton, monitoring, database creation, etc. is done using sysctl-alike interface.

Operations sp_setstring(), sp_getstring(), sp_setint(), sp_getint(), sp_getobject() and sp_cursor() are used to set, get and iterate through configuration fields.

Most of the configuration can only be changed before opening an environment.

Any error description can be accessed through sophia.error field.

Set example:

void *env = sp_env()
sp_setstring(env, "sophia.path", "./sophia", 0);
sp_open(env);

Get example:

int error_size;
char *error = sp_getstring(env, "sophia.error", &error_size);
if (error) {
    printf("error: %s\n", error);
    free(error);
}

To get a list of all system objects and configuration values:

void *cursor = sp_getobject(env, NULL);
void *ptr = NULL;
while ((ptr = sp_get(cursor, ptr))) {
    char *key = sp_getstring(ptr, "key", NULL);
    char *value = sp_getstring(ptr, "value", NULL);
    printf("%s", key);
    if (value)
        printf(" = %s\n", value);
    else
        printf(" = \n");
}
sp_destroy(cursor);