static VALUE cb_libcouchbase_version(VALUE self) { const char *ver = lcb_get_version(NULL); (void)self; return STR_NEW_CSTR(ver); }
/* initialize couchbase connection */ static int mod_instantiate(CONF_SECTION *conf, void *instance) { static bool version_done; rlm_couchbase_t *inst = instance; /* our module instance */ if (!version_done) { version_done = true; INFO("rlm_couchbase: json-c version: %s", json_c_version()); INFO("rlm_couchbase: libcouchbase version: %s", lcb_get_version(NULL)); } { char *server, *p; size_t len, i; bool sep = false; len = talloc_array_length(inst->server_raw); server = p = talloc_array(inst, char, len); for (i = 0; i < len; i++) { switch (inst->server_raw[i]) { case '\t': case ' ': case ',': /* Consume multiple separators occurring in sequence */ if (sep == true) continue; sep = true; *p++ = ';'; break; default: sep = false; *p++ = inst->server_raw[i]; break; } } *p = '\0'; inst->server = server; } /* setup item map */ if (mod_build_attribute_element_map(conf, inst) != 0) { /* fail */ return -1; } /* initiate connection pool */ inst->pool = fr_connection_pool_module_init(conf, inst, mod_conn_create, mod_conn_alive, NULL); /* check connection pool */ if (!inst->pool) { ERROR("rlm_couchbase: failed to initiate connection pool"); /* fail */ return -1; } /* return okay */ return 0; }
static PyObject * Connection_lcb_version(pycbc_Connection *self) { const char *verstr; lcb_uint32_t vernum; PyObject *ret; verstr = lcb_get_version(&vernum); ret = Py_BuildValue("(s,k)", verstr, vernum); (void)self; return ret; }
static int mod_load(void) { INFO("libcouchbase version: %s", lcb_get_version(NULL)); fr_json_version_print(); return 0; }
/** Initialize the rlm_couchbase module * * Intialize the module and create the initial Couchbase connection pool. * * @param conf The module configuration. * @param instance The module instance. * @return Returns 0 on success, -1 on error. */ static int mod_instantiate(CONF_SECTION *conf, void *instance) { static bool version_done; rlm_couchbase_t *inst = instance; /* our module instance */ if (!version_done) { version_done = true; INFO("rlm_couchbase: json-c version: %s", json_c_version()); INFO("rlm_couchbase: libcouchbase version: %s", lcb_get_version(NULL)); } { char *server, *p; size_t len, i; bool sep = false; len = talloc_array_length(inst->server_raw); server = p = talloc_array(inst, char, len); for (i = 0; i < len; i++) { switch (inst->server_raw[i]) { case '\t': case ' ': case ',': /* Consume multiple separators occurring in sequence */ if (sep == true) continue; sep = true; *p++ = ';'; break; default: sep = false; *p++ = inst->server_raw[i]; break; } } *p = '\0'; inst->server = server; } /* setup item map */ if (mod_build_attribute_element_map(conf, inst) != 0) { /* fail */ return -1; } /* initiate connection pool */ inst->pool = fr_connection_pool_module_init(conf, inst, mod_conn_create, mod_conn_alive, NULL); /* check connection pool */ if (!inst->pool) { ERROR("rlm_couchbase: failed to initiate connection pool"); /* fail */ return -1; } /* load clients if requested */ if (inst->read_clients) { CONF_SECTION *cs; /* conf section */ /* attempt to find client section */ cs = cf_section_sub_find(conf, "client"); if (!cs) { ERROR("rlm_couchbase: failed to find client section while loading clients"); /* fail */ return -1; } /* attempt to find attribute subsection */ cs = cf_section_sub_find(cs, "attribute"); if (!cs) { ERROR("rlm_couchbase: failed to find attribute subsection while loading clients"); /* fail */ return -1; } /* debugging */ DEBUG("rlm_couchbase: preparing to load client documents"); /* attempt to load clients */ if (mod_load_client_documents(inst, cs) != 0) { /* fail */ return -1; } } /* return okay */ return 0; }