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


C++ bson_strdup_printf函数代码示例

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


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

示例1: test_client_install

void
test_client_install (TestSuite *suite)
{
    bool local;

    gTestUri = bson_strdup_printf("mongodb://%s/", MONGOC_TEST_HOST);
    gTestUriWithBadPassword = bson_strdup_printf("mongodb://baduser:[email protected]%s/test", MONGOC_TEST_HOST);

    local = !getenv ("MONGOC_DISABLE_MOCK_SERVER");

    if (!local) {
        TestSuite_Add (suite, "/Client/wire_version", test_wire_version);
        TestSuite_Add (suite, "/Client/read_prefs", test_mongoc_client_read_prefs);
    }
    if (getenv ("MONGOC_CHECK_IPV6")) {
        /* try to validate ipv6 too */
        TestSuite_Add (suite, "/Client/ipv6", test_mongoc_client_ipv6);
    }
    TestSuite_Add (suite, "/Client/authenticate", test_mongoc_client_authenticate);
    TestSuite_Add (suite, "/Client/authenticate_failure", test_mongoc_client_authenticate_failure);
    TestSuite_Add (suite, "/Client/command", test_mongoc_client_command);
    TestSuite_Add (suite, "/Client/command_secondary", test_mongoc_client_command_secondary);
    TestSuite_Add (suite, "/Client/preselect", test_mongoc_client_preselect);
    TestSuite_Add (suite, "/Client/exhaust_cursor", test_exhaust_cursor);
    TestSuite_Add (suite, "/Client/server_status", test_server_status);

    atexit (cleanup_globals);
}
开发者ID:KingLee2015,项目名称:mongo-c-driver,代码行数:28,代码来源:test-mongoc-client.c

示例2: multi_download_setup

static void
multi_download_setup (perf_test_t *test)
{
   multi_download_test_t *download_test;
   multi_download_thread_context_t *ctx;
   mongoc_uri_t *uri;
   int i;

   _setup_load_gridfs_files ();
   perf_test_setup (test);

   download_test = (multi_download_test_t *) test;
   uri = mongoc_uri_new (NULL);
   download_test->pool = mongoc_client_pool_new (uri);

   download_test->cnt = 50; /* DANGER!: assumes test corpus won't change */
   download_test->contexts = (multi_download_thread_context_t *) bson_malloc0 (
      download_test->cnt * sizeof (multi_download_thread_context_t));

   for (i = 0; i < download_test->cnt; i++) {
      ctx = &download_test->contexts[i];
      ctx->filename = bson_strdup_printf ("file%d.txt", i);
      ctx->path = bson_strdup_printf ("%s/%s", test->data_path, ctx->filename);
   }

   mongoc_uri_destroy (uri);
}
开发者ID:Mansuro,项目名称:mongo-c-driver-performance,代码行数:27,代码来源:gridfs-parallel-performance.c

示例3: main

int
main (int   argc,   /* IN */
      char *argv[]) /* IN */
{
   char *cwd;
   char buf[1024];

   if (argc <= 1 || !!strcmp (argv[1], "-v")) {
      mongoc_log_set_handler (log_handler, NULL);
   }

   mongoc_init ();

   cwd = getcwd(buf, sizeof(buf));
   assert(cwd);

   gTestCAFile = bson_strdup_printf("%s/" CAFILE, cwd);
   gTestPEMFileLocalhost = bson_strdup_printf("%s/" PEMFILE_LOCALHOST, cwd);

   run_test("/ReplicaSet/ssl/client", &test_replica_set_ssl_client);

   bson_free(gTestCAFile);
   bson_free(gTestPEMFileLocalhost);

   mongoc_cleanup();

   return 0;
}
开发者ID:ChristianHeckl,项目名称:mongo-c-driver,代码行数:28,代码来源:test-replica-set-ssl.c

示例4: multi_upload_setup

static void
multi_upload_setup (perf_test_t *test)
{
   multi_upload_test_t *upload_test;
   multi_upload_thread_context_t *ctx;
   mongoc_uri_t *uri;
   char *data_dir;
   DIR *dirp;
   struct dirent *dp;
   int i;

   perf_test_setup (test);

   upload_test = (multi_upload_test_t *) test;

   uri = mongoc_uri_new (NULL);
   upload_test->pool = mongoc_client_pool_new (uri);

   data_dir = bson_strdup_printf ("%s/%s", g_test_dir, test->data_path);
   dirp = opendir(data_dir);
   if (!dirp) {
      perror ("opening data path");
      abort ();
   }

   i = 0;

   while ((dp = readdir(dirp)) != NULL) {
      if (!strcmp (get_ext (dp->d_name), "txt")) {
         ++i;
      }
   }

   upload_test->cnt = i;
   upload_test->contexts = (multi_upload_thread_context_t *) bson_malloc0 (
      i * sizeof (multi_upload_thread_context_t));

   rewinddir (dirp);
   i = 0;

   while ((dp = readdir (dirp)) != NULL) {
      if (!strcmp (get_ext (dp->d_name), "txt")) {
         ctx = &upload_test->contexts[i];
         ctx->filename = bson_strdup (dp->d_name);
         ctx->path = bson_strdup_printf (
            "%s/%s/%s", g_test_dir, test->data_path, dp->d_name);

         ++i;
      }
   }

   assert (i == upload_test->cnt);

   closedir (dirp);
   bson_free (data_dir);
   mongoc_uri_destroy (uri);
}
开发者ID:Mansuro,项目名称:mongo-c-driver-performance,代码行数:57,代码来源:gridfs-parallel-performance.c

示例5: gen_test_user

static char *
gen_test_user (void)
{
    return bson_strdup_printf ("testuser_%u_%u",
                               (unsigned)time(NULL),
                               (unsigned)gettestpid());
}
开发者ID:KingLee2015,项目名称:mongo-c-driver,代码行数:7,代码来源:test-mongoc-client.c

示例6: _append_and_truncate

/*
 * free (*s) and make *s point to *s concated with suffix.
 * If *s is NULL it's treated like it's an empty string.
 * If suffix is NULL, nothing happens.
 */
static void
_append_and_truncate (char       **s,
                      const char  *suffix,
                      int          max_len)
{
   char *old_str = *s;
   char *prefix;
   const int delim_len = strlen (" / ");
   int space_for_suffix;

   BSON_ASSERT (s);

   prefix = old_str ? old_str : "";

   if (!suffix) {
      return;
   }

   space_for_suffix = max_len - strlen (prefix) - delim_len;
   BSON_ASSERT (space_for_suffix >= 0);

   *s = bson_strdup_printf ("%s / %.*s", prefix, space_for_suffix, suffix);
   BSON_ASSERT (strlen (*s) <= max_len);

   bson_free (old_str);
}
开发者ID:fionaRowan,项目名称:mongo-c-driver,代码行数:31,代码来源:mongoc-metadata.c

示例7: _mongoc_host_list_from_string

bool
_mongoc_host_list_from_string (mongoc_host_list_t *host_list,
                               const char         *host_and_port)
{
   bool rval = false;
   char *uri_str = NULL;
   mongoc_uri_t *uri = NULL;
   const mongoc_host_list_t *uri_hl;

   BSON_ASSERT (host_list);
   BSON_ASSERT (host_and_port);

   uri_str = bson_strdup_printf("mongodb://%s/", host_and_port);
   if (! uri_str) goto CLEANUP;

   uri = mongoc_uri_new(uri_str);
   if (! uri) goto CLEANUP;

   uri_hl = mongoc_uri_get_hosts(uri);
   if (uri_hl->next) goto CLEANUP;

   memcpy(host_list, uri_hl, sizeof(*uri_hl));

   rval = true;

CLEANUP:

   bson_free(uri_str);
   if (uri) mongoc_uri_destroy(uri);

   return rval;
}
开发者ID:fionaRowan,项目名称:mongo-c-driver,代码行数:32,代码来源:mongoc-uri.c

示例8: gen_good_uri

static char *
gen_good_uri (const char *username)
{
    return bson_strdup_printf("mongodb://%s:[email protected]%s/test",
                              username,
                              MONGOC_TEST_HOST);
}
开发者ID:KingLee2015,项目名称:mongo-c-driver,代码行数:7,代码来源:test-mongoc-client.c

示例9: _append_and_truncate

/*
 * free (*s) and make *s point to *s concated with suffix.
 * If *s is NULL it's treated like it's an empty string.
 * If suffix is NULL, nothing happens.
 */
static void
_append_and_truncate (char **s, const char *suffix, int max_len)
{
   char *old_str = *s;
   char *prefix;
   const int delim_len = (int) strlen (" / ");
   int space_for_suffix;

   BSON_ASSERT (s);

   prefix = old_str ? old_str : "";

   if (!suffix) {
      return;
   }

   space_for_suffix = max_len - (int) strlen (prefix) - delim_len;

   if (space_for_suffix <= 0) {
      /* the old string already takes the whole allotted space */
      return;
   }

   *s = bson_strdup_printf ("%s / %.*s", prefix, space_for_suffix, suffix);
   BSON_ASSERT (strlen (*s) <= max_len);

   bson_free (old_str);
}
开发者ID:acmorrow,项目名称:mongo-c-driver,代码行数:33,代码来源:mongoc-handshake.c

示例10: test_write_command_install

void
test_write_command_install (TestSuite *suite)
{
   gTestUri = bson_strdup_printf("mongodb://%s/", MONGOC_TEST_HOST);

   TestSuite_Add (suite, "/WriteCommand/split_insert", test_split_insert);

   atexit (cleanup_globals);
}
开发者ID:ChristianHeckl,项目名称:mongo-c-driver,代码行数:9,代码来源:test-write-commands.c

示例11: gen_collection_name

char *
gen_collection_name (const char *str)
{
   return bson_strdup_printf ("%s_%u_%u",
                              str,
                              (unsigned)time(NULL),
                              (unsigned)gettestpid());

}
开发者ID:ChristianHeckl,项目名称:mongo-c-driver,代码行数:9,代码来源:test-libmongoc.c

示例12: test_bulk_install

void
test_bulk_install (TestSuite *suite)
{
   gTestUri = bson_strdup_printf("mongodb://%s/", MONGOC_TEST_HOST);

   TestSuite_Add (suite, "/BulkOperation/basic", test_bulk);
   TestSuite_Add (suite, "/BulkOperation/update_upserted", test_update_upserted);
   TestSuite_Add (suite, "/BulkOperation/index_offset", test_index_offset);

   atexit (cleanup_globals);
}
开发者ID:ChristianHeckl,项目名称:mongo-c-driver,代码行数:11,代码来源:test-bulk.c

示例13: _mongoc_handshake_append_sasl_supported_mechs

void
_mongoc_handshake_append_sasl_supported_mechs (const mongoc_uri_t *uri,
                                               bson_t *cmd)
{
   const char *username;
   char *db_user;
   username = mongoc_uri_get_username (uri);
   db_user =
      bson_strdup_printf ("%s.%s", mongoc_uri_get_auth_source (uri), username);
   bson_append_utf8 (cmd, "saslSupportedMechs", 18, db_user, -1);
   bson_free (db_user);
}
开发者ID:acmorrow,项目名称:mongo-c-driver,代码行数:12,代码来源:mongoc-handshake.c

示例14: ha_config_add_shard

static void
ha_config_add_shard (ha_node_t        *node,
                     ha_replica_set_t *replica_set)
{
   mongoc_collection_t *collection;
   mongoc_client_t *client;
   bson_string_t *shardstr;
   bson_error_t error;
   bson_bool_t r;
   bson_t reply;
   bson_t cmd = BSON_INITIALIZER;
   char *uristr;

   uristr = bson_strdup_printf ("mongodb://127.0.0.1:%hu/", node->port);
   client = mongoc_client_new (uristr);
   collection = mongoc_client_get_collection (client, "admin", "fake");

   shardstr = bson_string_new (NULL);
   bson_string_append_printf (shardstr, "%s/127.0.0.1:%hu",
                              replica_set->name,
                              replica_set->nodes->port);

   bson_append_utf8 (&cmd, "addShard", -1, shardstr->str, shardstr->len);

   bson_string_free (shardstr, TRUE);

again:
   sleep (1);

   r = mongoc_collection_command_simple (collection, &cmd, NULL, &reply, &error);

   if (!r) {
      fprintf (stderr, "%s\n", error.message);
      goto again;
   }

#if 1
   {
      char *str;

      str = bson_as_json (&reply, NULL);
      printf ("%s\n", str);
      bson_free (str);
   }
#endif

   bson_destroy (&reply);
   bson_destroy (&cmd);
   mongoc_collection_destroy (collection);
   mongoc_client_destroy (client);
   bson_free (uristr);
}
开发者ID:hy,项目名称:mongo-c-driver,代码行数:52,代码来源:ha-test.c

示例15: test_client_install

void
test_client_install (TestSuite *suite)
{
   bool local;

   gTestUri = bson_strdup_printf("mongodb://%s:27017/", MONGOC_TEST_HOST);
   gTestUriWithPassword = bson_strdup_printf("mongodb://testuser:[email protected]%s:27017/test", MONGOC_TEST_HOST);
   gTestUriWithBadPassword = bson_strdup_printf("mongodb://baduser:[email protected]%s:27017/test", MONGOC_TEST_HOST);

   local = !getenv ("MONGOC_DISABLE_MOCK_SERVER");

   if (!local) {
      TestSuite_Add (suite, "/Client/wire_version", test_wire_version);
      TestSuite_Add (suite, "/Client/read_prefs", test_mongoc_client_read_prefs);
   }
   TestSuite_Add (suite, "/Client/authenticate", test_mongoc_client_authenticate);
   TestSuite_Add (suite, "/Client/authenticate_failure", test_mongoc_client_authenticate_failure);
   TestSuite_Add (suite, "/Client/command", test_mongoc_client_command);
   TestSuite_Add (suite, "/Client/exhaust_cursor", test_exhaust_cursor);

   atexit (cleanup_globals);
}
开发者ID:glee314,项目名称:mongo-c-driver,代码行数:22,代码来源:test-mongoc-client.c


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