/* added by Wakamori */ static void opt_logcached(int mode, const char *optstr) { #if defined(HAVE_LIBMEMCACHED) knh_syslog = memcached_syslog; knh_vsyslog = memcached_vsyslog; kbytes_t host_port = B(optstr); kbytes_t host = knh_bytes_head(host_port, ':'); kint_t port; if (!knh_bytes_parseint(knh_bytes_next(host_port, ':'), &port)) { KNH_DIE("konoha: invalid arguments."); } memc = memcached_create(NULL); char tmp = host.buf[host.len]; host.buf[host.len] = '\0'; memcached_return rc; memcached_server_list_st servers; servers = memcached_server_list_append(NULL, host.text, port, &rc); if (rc != MEMCACHED_SUCCESS) { KNH_DIE("konoha: cannot append a memcached server."); } host.buf[host.len] = tmp; rc = memcached_server_push(memc, servers); if (rc != MEMCACHED_SUCCESS) { KNH_DIE("konoha: cannot push a memcached server."); } memcached_server_list_free(servers); #else KNH_DIE("konoha: memcached library is not installed."); #endif /* defined(HAVE_LIBMEMCACHED) */ }
const knh_MapDPI_t *knh_KonohaSpace_getMapDPINULL(CTX, kKonohaSpace *ns, kbytes_t path) { kbytes_t hpath = knh_KonohaSpace_getDpiPath(_ctx, ns, knh_bytes_head(path, ':')); return (const knh_MapDPI_t*)knh_DictSet_get(_ctx, ctx->share->mapDpiDictSet, hpath); }
const knh_PathDPI_t *knh_NameSpace_getStreamDPINULL(CTX ctx, kNameSpace *ns, kbytes_t path) { kbytes_t hpath = knh_NameSpace_getDpiPath(ctx, ns, knh_bytes_head(path, ':')); return (const knh_PathDPI_t *)knh_DictSet_get(ctx, ctx->share->streamDpiDictSet, hpath); }