当前位置: 首页>>代码示例>>C++>>正文


C++ sp_getstring函数代码示例

本文整理汇总了C++中sp_getstring函数的典型用法代码示例。如果您正苦于以下问题:C++ sp_getstring函数的具体用法?C++ sp_getstring怎么用?C++ sp_getstring使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sp_getstring函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: object_set_get

static void
object_set_get(void)
{
	void *env = sp_env();
	t( env != NULL );
	t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
	t( sp_setint(env, "scheduler.threads", 0) == 0 );
	t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
	t( sp_open(env) == 0 );
	t( sp_setstring(env, "db", "test", 0) == 0 );
	t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
	t( sp_setstring(env, "db.test.index.key", "u32", 0) == 0 );
	t( sp_setint(env, "db.test.sync", 0) == 0 );
	void *db = sp_getobject(env, "db.test");
	t( db != NULL );
	t( sp_open(db) == 0 );

	int key = 7;
	void *o = sp_object(db);
	t(o != NULL);
	t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
	t( sp_setstring(o, "value", &key, sizeof(key)) == 0 );
	int size = 0;
	t( *(int*)sp_getstring(o, "key", &size) == key );
	t( size == sizeof(key) );
	t( *(int*)sp_getstring(o, "value", &size) == key );
	t( size == sizeof(key) );
	sp_destroy(o);

	sp_destroy(env);
}
开发者ID:mneumann,项目名称:sophia,代码行数:31,代码来源:object.test.c

示例2: meta_scheduler

static void
meta_scheduler(void)
{
	void *env = sp_env();
	t( env != NULL );

	t( sp_setint(env, "scheduler.threads", 2) == 0 );
	t( sp_setint(env, "log.enable", 0) == 0 );
	t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
	t( sp_getstring(env, "scheduler.0.trace", NULL) == NULL );
	t( sp_open(env) == 0 );

	char *v = sp_getstring(env, "scheduler.0.trace", NULL);
	t( v != NULL );
	t( strcmp(v, "malfunction") != 0 );
	free(v);

	v = sp_getstring(env, "scheduler.1.trace", NULL);
	t( v != NULL );
	t( strcmp(v, "malfunction") != 0 );
	free(v);

	v = sp_getstring(env, "scheduler.2.trace", NULL);
	t( v == NULL );

	t( sp_destroy(env) == 0 );
}
开发者ID:Wanderfalke,项目名称:sophia,代码行数:27,代码来源:meta.test.c

示例3: meta_db

static void
meta_db(void)
{
	void *env = sp_env();
	t( env != NULL );
	t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
	t( sp_setint(env, "scheduler.threads", 0) == 0 );
	t( sp_setstring(env, "db", "test", 0) == 0 );
	t( sp_setstring(env, "db.test.index", "key_b", 0) == 0 );
	t( sp_setint(env, "db.test.id", 777) == 0 );
	t( sp_setint(env, "db.test.sync", 0) == 0 );
	t( sp_open(env) == 0 );
	void *db = sp_getobject(env, "db.test");
	t( db != NULL );
	char *s = sp_getstring(db, "name",  NULL);
	t( strcmp(s, "test") == 0 );
	free(s);
	t( sp_getint(db, "id") == 777 );
	t( sp_getint(db, "key-count") == 2 );
	s = sp_getstring(env, "db.test.index.key", 0);
	t( s != NULL );
	t( strcmp(s, "string") == 0 );
	free(s);
	s = sp_getstring(env, "db.test.index.key_b", 0);
	t( s != NULL );
	t( strcmp(s, "string") == 0 );
	free(s);
	t( sp_destroy(env) == 0 );
}
开发者ID:Wanderfalke,项目名称:sophia,代码行数:29,代码来源:meta.test.c

示例4: multipart_schema

static void
multipart_schema(void)
{
	void *env = sp_env();
	t( env != NULL );
	t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
	t( sp_setint(env, "scheduler.threads", 0) == 0 );
	t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
	t( sp_setstring(env, "db", "test", 0) == 0 );
	t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
	t( sp_setstring(env, "db.test.index", "key_b", 0) == 0 );
	t( sp_setint(env, "db.test.sync", 0) == 0 );

	char *v = sp_getstring(env, "db.test.index.key", 0);
	t( strcmp(v, "string") == 0 );
	free(v);

	v = sp_getstring(env, "db.test.index.key_b", 0);
	t( strcmp(v, "string") == 0 );
	free(v);

	t( sp_setstring(env, "db.test.index.key_b", "u32", 0) == 0 );

	v = sp_getstring(env, "db.test.index.key_b", 0);
	t( strcmp(v, "u32") == 0 );
	free(v);

	t( sp_open(env) == 0 );

	t( sp_setstring(env, "db.test.index.key_b", "string", 0) == -1 );
	t( sp_destroy(env) == 0 );
}
开发者ID:egmkang,项目名称:green_turtle,代码行数:32,代码来源:multipart.test.c

示例5: meta_cursor

static void
meta_cursor(void)
{
	void *env = sp_env();
	t( env != NULL );

	t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
	t( sp_setint(env, "scheduler.threads", 0) == 0 );
	t( sp_setstring(env, "db", "test", 0) == 0 );
	t( sp_setstring(env, "db.test.index", "key_b", 0) == 0 );
	t( sp_setint(env, "db.test.sync", 0) == 0 );
	t( sp_open(env) == 0 );
	t( sp_setstring(env, "snapshot", "test_snapshot0", 0) == 0 );

	fprintf(st_r.output, "\n");

	void *cur = sp_getobject(env, NULL);
	t( cur != NULL );
	fprintf(st_r.output, "\n");
	void *o = NULL;
	while ((o = sp_get(cur, o))) {
		char *key = sp_getstring(o, "key", 0);
		char *value = sp_getstring(o, "value", 0);
		fprintf(st_r.output, "%s", key);
		if (value)
			fprintf(st_r.output, " = %s\n", value);
		else
			fprintf(st_r.output, " = \n");
	}
	fprintf(st_r.output, "\n");

	t( sp_destroy(cur) == 0 );
	t( sp_destroy(env) == 0 );
}
开发者ID:Wanderfalke,项目名称:sophia,代码行数:34,代码来源:meta.test.c

示例6: compact_directio

static void
compact_directio(void)
{
	void *env = sp_env();
	t( env != NULL );
	t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
	t( sp_setint(env, "scheduler.threads", 0) == 0 );
	t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
	t( sp_setstring(env, "db", "test", 0) == 0 );
	t( sp_setint(env, "db.test.compaction.branch_wm", 1) == 0 );
	t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
	t( sp_setstring(env, "db.test.scheme", "key", 0) == 0 );
	t( sp_setstring(env, "db.test.scheme.key", "u32,key(0)", 0) == 0 );
	t( sp_setstring(env, "db.test.scheme", "value", 0) == 0 );
	t( sp_setint(env, "db.test.sync", 0) == 0 );
	t( sp_setint(env, "db.test.direct_io", 1) == 0 );
	t( sp_setint(env, "log.sync", 0) == 0 );
	t( sp_setint(env, "log.rotate_sync", 0) == 0 );
	void *db = sp_getobject(env, "db.test");
	t( db != NULL );
	t( sp_open(env) == 0 );

	char value[100];
	memset(value, 0, sizeof(value));

	int key = 0;
	while (key < 300000) {
		void *o = sp_document(db);
		t( o != NULL );
		t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
		t( sp_setstring(o, "value", value, sizeof(value)) == 0 );
		t( sp_set(db, o) == 0 );
		if ((key % 10000) == 0 && key > 0) {
			if (sp_setint(env, "db.test.compaction.branch", 0) == -1) {
				char *e = sp_getstring(env, "sophia.error", NULL);
				printf("%s, %d\n", (e) ? e: "null", errno);
				t( 0 );
			}
			/*t( sp_setint(env, "db.test.compaction.branch", 0) == 0 );*/
		}
		key++;
	}

	t( sp_setint(env, "db.test.compaction.compact", 0) == 0 );

	key = 0;
	while (key < 1000) {
		void *o = sp_document(db);
		t( o != NULL );
		t( sp_setstring(o, "key", &key, sizeof(key)) == 0 );
		o = sp_get(db, o);
		t( o != NULL );
		t( *(int*)sp_getstring(o, "key", NULL) == key );
		sp_destroy(o);
		key++;
	}

	t( sp_destroy(env) == 0 );
}
开发者ID:ConfusedReality,项目名称:sophia,代码行数:59,代码来源:compact.test.c

示例7: mt_async_read

static void
mt_async_read(void)
{
	void *env = sp_env();
	t( env != NULL );
	t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
	t( sp_setint(env, "scheduler.threads", 5) == 0 );
	t( sp_setint(env, "compaction.0.async", 1) == 0 );
	t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
	t( sp_setstring(env, "db", "test", 0) == 0 );
	t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
	t( sp_setint(env, "db.test.sync", 0) == 0 );
	t( sp_setstring(env, "db.test.format", "kv", 0) == 0 );
	t( sp_setstring(env, "db.test.index.key", "u32", 0) == 0 );
	void *db = sp_getobject(env, "db.test");
	t( db != NULL );
	t( sp_open(env) == 0 );

	int i = 0;
	while (i < 100000) {
		void *o = sp_object(db);
		assert(o != NULL);
		sp_setstring(o, "key", &i, sizeof(i));
		int rc = sp_set(db, o);
		t( rc == 0 );
		print_current(i);
		i++;
	}
	fprintf(st_r.output, " (insert done..iterate) ");

	void *async = sp_asynchronous(db);
	t( async != NULL );

	/* trigger iteration */
	void *o = sp_object(async);
	sp_setstring(o, "order", ">=", 0);
	o = sp_get(db, o);
	t( o != NULL );
	sp_destroy(o);

	i = 0;
	while (i < 100000) {
		o = sp_poll(env);
		if (o == NULL)
			continue;
		t( strcmp(sp_getstring(o, "type", 0), "on_read") == 0 );
		t( sp_getint(o, "status") == 1 );
		t( *(int*)sp_getstring(o, "key", NULL) == i );
		o = sp_get(db, o);
		t( o != NULL );
		sp_destroy(o);
		print_current(i);
		i++;
	}
	t( i == 100000 );
	fprintf(st_r.output, "(complete)");
	t( sp_destroy(env) == 0 );
}
开发者ID:holys,项目名称:sophia,代码行数:58,代码来源:multithread_be.test.c

示例8: scheme_test0

static void
scheme_test0(void)
{
	void *env = sp_env();
	t( env != NULL );
	t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
	t( sp_setint(env, "scheduler.threads", 0) == 0 );
	t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
	t( sp_setstring(env, "db", "test", 0) == 0 );
	t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
	t( sp_setstring(env, "db.test.compression_cold", "zstd", 0) == 0 );
	t( sp_setstring(env, "db.test.scheme", "key", 0) == 0 );
	t( sp_setstring(env, "db.test.scheme.key", "u32,key(0)", 0) == 0 );
	t( sp_setstring(env, "db.test.scheme", "key_b", 0) == 0 );
	t( sp_setstring(env, "db.test.scheme.key_b", "string,key(1)", 0) == 0 );
	t( sp_setstring(env, "db.test.scheme", "value", 0) == 0 );
	t( sp_setint(env, "db.test.sync", 0) == 0 );
	void *db = sp_getobject(env, "db.test");
	t( db != NULL );
	t( sp_open(env) == 0 );
	t( sp_destroy(env) == 0 );

	env = sp_env();
	t( env != NULL );
	t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
	t( sp_setint(env, "scheduler.threads", 0) == 0 );
	t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
	t( sp_setint(env, "log.sync", 0) == 0 );
	t( sp_setint(env, "log.rotate_sync", 0) == 0 );
	t( sp_setstring(env, "db", "test", 0) == 0 );
	t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
	t( sp_setint(env, "db.test.sync", 0) == 0 );
	db = sp_getobject(env, "db.test");
	t( db != NULL );
	t( sp_open(env) == 0 );

	char *v = sp_getstring(env, "db.test.compression_cold", 0);
	t( v != NULL );
	t( strcmp(v, "zstd") == 0 );
	free(v);

	v = sp_getstring(env, "db.test.scheme.key", 0);
	t( v != NULL );
	t( strcmp(v, "u32,key(0)") == 0 );
	free(v);

	v = sp_getstring(env, "db.test.scheme.key_b", 0);
	t( v != NULL );
	t( strcmp(v, "string,key(1)") == 0 );
	free(v);

	v = sp_getstring(env, "db.test.scheme.value", 0);
	t( v != NULL );
	t( strcmp(v, "string") == 0 );
	free(v);

	t( sp_destroy(env) == 0 );
}
开发者ID:muthhus,项目名称:sophia,代码行数:58,代码来源:scheme.test.c

示例9: st_document_eq

void st_document_eq(stgenerator *g, sf fmt, void *o,
                  uint32_t seed,
                  uint32_t seed_value)
{
	svv *v = st_svv_seed(g, seed, seed_value);
	if (ssunlikely(v == NULL)) {
		t(0);
		return;
	}
	switch (fmt) {
	case SF_KV: {
		int i = 0;
		int size = 0;
		while (i < g->r->scheme->count) {
			void *ptr = sp_getstring(o, g->r->scheme->parts[i].name, &size);
			t( ptr != NULL );
			t( size == sf_keysize(sv_vpointer(v), i) );
			t( memcmp(ptr, sf_key(sv_vpointer(v), i), size) == 0 );
			i++;
		}
		void *ptr = sp_getstring(o, "value", &size);
		if ((g->value_start + g->value_end) > 0) {
			t( ptr != NULL );
			t( size == sf_valuesize(g->r->fmt, sv_vpointer(v), v->size,
			                        g->r->scheme->count) );
			t( memcmp(ptr, sf_value(g->r->fmt, sv_vpointer(v), g->r->scheme->count),
			          size) == 0 );
		} else {
			t( ptr == NULL );
		}
		break;
	}
	case SF_DOCUMENT: {
		int i = 0;
		int size = 0;
		while (i < g->r->scheme->count) {
			void *ptr = sp_getstring(o, g->r->scheme->parts[i].name, &size);
			t( ptr != NULL );
			t( size == sf_keysize(sv_vpointer(v), i) );
			t( memcmp(ptr, sf_key(sv_vpointer(v), i), size) == 0 );
			i++;
		}
		void *ptr = sp_getstring(o, "value", &size);
		t( ptr != NULL );
		if ((g->value_start + g->value_end) > 0) {
			int vsize = sf_valuesize(g->r->fmt, ptr, size, g->r->scheme->count);
			t( vsize == sf_valuesize(g->r->fmt, sv_vpointer(v), v->size,
			                         g->r->scheme->count) );
			ptr = sf_value(g->r->fmt, ptr, g->r->scheme->count);
			t( memcmp(ptr, sf_value(g->r->fmt, sv_vpointer(v),
			          g->r->scheme->count), vsize) == 0 );
		}
		break;
	}
	}
	sv_vfree(g->r, v);
}
开发者ID:jason-xxl,项目名称:sophia,代码行数:57,代码来源:st_document.c

示例10: github_120

static void
github_120(void)
{
	/* open or create environment and database */
	void *env = sp_env();
	sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0);
	sp_setstring(env, "db", "test", 0);
	void *db = sp_getobject(env, "db.test");
	int rc = sp_open(env);
	if (rc == -1)
		goto error;

	/* set */
	void *o = sp_document(db);
	sp_setstring(o, "key", "hello", 0);
	sp_setstring(o, "value", "world", 0);
	rc = sp_set(db, o);
	if (rc == -1)
		goto error;

	/* get */
	o = sp_document(db);
	sp_setstring(o, "key", "hello", 0);
	o = sp_get(db, o);
	if (o) {
		/* ensure key and value are correct */
		int size;
		char *ptr = sp_getstring(o, "key", &size);
		t( size == 5 );
		t( strncmp(ptr, "hello", 5) == 0 );

		ptr = sp_getstring(o, "value", &size);
		t( size == 5 );
		t( strncmp(ptr, "world", 5) == 0 );

		sp_destroy(o);
	}

	/* delete */
	o = sp_document(db);
	sp_setstring(o, "key", "hello", 0);
	rc = sp_delete(db, o);
	if (rc == -1)
		goto error;

	/* finish work */
	sp_destroy(env);
	return;

error:;
	int size;
	char *error = sp_getstring(env, "sophia.error", &size);
	printf("error: %s\n", error);
	free(error);
	sp_destroy(env);
}
开发者ID:ConfusedReality,项目名称:sophia,代码行数:56,代码来源:github.test.c

示例11: mt_set_get_kv_multipart

static void
mt_set_get_kv_multipart(void)
{
	void *env = sp_env();
	t( env != NULL );
	t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
	t( sp_setint(env, "scheduler.threads", 5) == 0 );
	t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
	t( sp_setstring(env, "db", "test", 0) == 0 );
	t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
	t( sp_setint(env, "db.test.compression_key", 1) == 0 );
	t( sp_setint(env, "db.test.sync", 0) == 0 );
	t( sp_setstring(env, "db.test.index.key", "string", 0) == 0 );
	t( sp_setstring(env, "db.test.index", "key_b", 0) == 0 );
	t( sp_setstring(env, "db.test.index.key_b", "u32", 0) == 0 );
	void *db = sp_getobject(env, "db.test");
	t( db != NULL );
	t( sp_open(env) == 0 );

	uint32_t n = 500000;
	uint32_t i;

	char key_a[] = "very_long_long_key_part";
	srand(82351);
	for (i = 0; i < n; i++) {
		uint32_t key_b = rand();
		uint32_t value = key_b;
		void *o = sp_object(db);
		t( o != NULL );
		t( sp_setstring(o, "key", key_a, sizeof(key_a)) == 0 );
		t( sp_setstring(o, "key_b", &key_b, sizeof(key_b)) == 0 );
		t( sp_setstring(o, "value", &value, sizeof(value)) == 0 );
		t( sp_set(db, o) == 0 );
		print_current(i);
	}
	srand(82351);
	for (i = 0; i < n; i++) {
		uint32_t key_b = rand();
		uint32_t value = key_b;
		void *o = sp_object(db);
		t( o != NULL );
		t( sp_setstring(o, "key", key_a, sizeof(key_a)) == 0 );
		t( sp_setstring(o, "key_b", &key_b, sizeof(key_b)) == 0 );
		o = sp_get(db, o);
		t( o != NULL );
		int size = 0;
		t( memcmp(sp_getstring(o, "key", &size), key_a, sizeof(key_a)) == 0 );
		t( *(uint32_t*)sp_getstring(o, "key_b", &size) == key_b );
		t( *(uint32_t*)sp_getstring(o, "value", &size) == value );
		sp_destroy(o);
		print_current(i);
	}

	t( sp_destroy(env) == 0 );
}
开发者ID:holys,项目名称:sophia,代码行数:55,代码来源:multithread_be.test.c

示例12: multipart_cursor1

static void
multipart_cursor1(void)
{
	void *env = sp_env();
	t( env != NULL );
	t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
	t( sp_setint(env, "scheduler.threads", 0) == 0 );
	t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
	t( sp_setstring(env, "db", "test", 0) == 0 );
	t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
	t( sp_setstring(env, "db.test.index", "key_b", 0) == 0 );
	t( sp_setstring(env, "db.test.index.key_b", "u32", 0) == 0 );
	t( sp_setstring(env, "db.test.index.key", "string", 0) == 0 );
	t( sp_setint(env, "db.test.sync", 0) == 0 );
	t( sp_open(env) == 0 );

	void *db = sp_getobject(env, "db.test");
	t( db != NULL );

	char key_a[] = "hello";
	uint32_t i = 0;
	while (i < 546) {
		void *o = sp_object(db);
		sp_setstring(o, "key", key_a, sizeof(key_a));
		sp_setstring(o, "key_b", &i, sizeof(i));
		sp_setstring(o, "value", &i, sizeof(i));
		t( sp_set(db, o) == 0);
		i++;
	}

	i = 322;
	void *cur = sp_cursor(env);
	t( cur != NULL );
	void *o = sp_object(db);
	sp_setstring(o, "key", key_a, sizeof(key_a));
	sp_setstring(o, "key_b", &i, sizeof(i));
	sp_setstring(o, "value", &i, sizeof(i));
	while ((o = sp_get(cur, o))) {
		int asize;
		t( strcmp(key_a, sp_getstring(o, "key", &asize)) == 0 );
		int bsize;
		t( *(uint32_t*)sp_getstring(o, "key_b", &bsize) == i );
		int vsize;
		t( *(uint32_t*)sp_getstring(o, "value", &vsize) == i );
		t( asize == sizeof(key_a) );
		t( bsize == sizeof(i) );
		t( vsize == sizeof(i) );
		i++;
	}
	sp_destroy(cur);
	t( i == 546 );

	t( sp_destroy(env) == 0 );
}
开发者ID:egmkang,项目名称:green_turtle,代码行数:54,代码来源:multipart.test.c

示例13: npr_test0

static void
npr_test0(void)
{
	void *env = sp_env();
	t( env != NULL );
	t( sp_setstring(env, "sophia.path", st_r.conf->sophia_dir, 0) == 0 );
	t( sp_setint(env, "sophia.recover", 3) == 0 );
	t( sp_setint(env, "scheduler.threads", 0) == 0 );
	t( sp_setstring(env, "log.path", st_r.conf->log_dir, 0) == 0 );
	t( sp_setint(env, "log.enable", 0) == 0 );
	t( sp_setint(env, "compaction.0.branch_wm", 1) == 0 );

	t( sp_open(env) == 0 );

	t( sp_setstring(env, "db", "test", 0) == 0 );
	t( sp_setstring(env, "db.test.path", st_r.conf->db_dir, 0) == 0 );
	t( sp_setstring(env, "db.test.scheme", "key", 0) == 0 );
	t( sp_setstring(env, "db.test.scheme.key", "u32,key(0)", 0) == 0 );
	t( sp_setstring(env, "db.test.scheme", "value", 0) == 0 );
	t( sp_setint(env, "db.test.sync", 0) == 0 );
	void *db = sp_getobject(env, "db.test");
	t( db != NULL );
	t( sp_open(db) == 0 );

	char *v = sp_getstring(env, "db.test.status", NULL);
	t( strcmp(v, "online") == 0 );
	free(v);

	t( sp_open(env) == 0 ); /* 2nd state */
	/* recover */

	t( sp_setstring(env, "db", "test2", 0) == 0 );
	t( sp_setint(env, "db.test2.sync", 0) == 0 );
	db = sp_getobject(env, "db.test2");
	t( db != NULL );
	t( sp_open(db) == 0 );
	v = sp_getstring(env, "db.test2.status", NULL);
	t( strcmp(v, "online") == 0 );
	free(v);

	t( sp_open(env) == 0 ); /* 3nd state */
	/* online */
	t( sp_open(env) == 0 ); /* N states */
	/* recover */
	t( sp_open(env) == 0 ); /* ... */
	/* online */

	t( sp_destroy(db) == 0 );
	t( sp_destroy(env) == 0 );
}
开发者ID:dongxu-pc,项目名称:sophia,代码行数:50,代码来源:npr.test.c

示例14: conf_version

static void
conf_version(void)
{
	void *env = sp_env();
	t( env != NULL );
	char *s = sp_getstring(env, "sophia.version", NULL);
	t( s != NULL );
	t( strcmp(s, "2.1.1") == 0 );
	free(s);
	s = sp_getstring(env, "sophia.version_storage", NULL);
	t( s != NULL );
	t( strcmp(s, "2.1.1") == 0 );
	free(s);
	t( sp_destroy(env) == 0 );
}
开发者ID:EgoIncarnate,项目名称:sophia,代码行数:15,代码来源:conf.test.c

示例15: spr_cmd_info

static inline void
spr_cmd_info(void)
{
	if (! spr_start)
		return;
	void *cur = sp_getobject(spr_env, NULL);
	void *o = NULL;
	while ((o = sp_get(cur, o)))
	{
		char *key = sp_getstring(o, "key", 0);
		char *value = sp_getstring(o, "value", 0);
		printf("%s = %s\n", key, (value) ? value : "");
	}
	sp_destroy(cur);
}
开发者ID:jason-xxl,项目名称:sophia,代码行数:15,代码来源:sophia-prof.c


注:本文中的sp_getstring函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。