~ubuntu-branches/ubuntu/trusty/syslog-ng/trusty-proposed

« back to all changes in this revision

Viewing changes to modules/afmongodb/libmongo-client/docs/tutorial/examples/tut_mongo_sync_cmd_create.c

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS), Gergely Nagy
  • Date: 2011-10-11 14:30:48 UTC
  • mfrom: (1.3.7)
  • Revision ID: package-import@ubuntu.com-20111011143048-r1iljux9xbvj3lwh
Tags: 3.3.1.dfsg-1
* New upstream release with important fixes from upstream git tree with
  non-free manpages removed.
* Drop syslog-ng.conf(5) (closes: #496521).
* syslog-ng(8) is generated, and does not mention -Q anymore
  (closes: #616069).
* Supports CAP_SYSLOG on recent kernels (closes: #630172).
* Does not use g_timeout_add_seconds anymore (closes: #609154).

[ Gergely Nagy <algernon@madhouse-project.org> ]
* Update debian/copyright to DEP-5 format.
* Simplified the logrotate file by merging identical entries.
* Include local configuration files from /etc/syslog-ng/conf.d/ (Closes:
  #609050).
* Update syslog-ng.conf to be fully 3.3 compliant.
* Compress both source and binaries (except the syslog-ng meta
  package) with xz, instead of gzip.
* Use dpkg triggers to restart syslog-ng when appropriate.
* Include DFSG-free manual pages for all binaries.
* Build with Hardening enabled.
* Mention syslog(3) in /etc/default/syslog-ng, instead of
  <linux/kernel.h> (Closes: #608605)
* Support 'status' in the init script.
  Patch from Peter Eisentraut <petere@debian.org> (Closes: #644458)
* Build-Depend on libevtlog-dev (>= 0.2.12-5~) for correct shlibs.
* Use [linux-any] in Build-Depends instead of hardcoded links.
  (Closes: #634715)
* Use $SYSLOGNG_OPTS in the init script when reloading syslog-ng.
  (Closes: #589081)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <mongo.h>
 
2
 
 
3
#include <errno.h>
 
4
#include <stdio.h>
 
5
 
 
6
static void
 
7
print_coll_info (bson *info)
 
8
{
 
9
  bson_cursor *c = NULL;
 
10
  bson *options = NULL;
 
11
 
 
12
  const gchar *name;
 
13
  gboolean capped = FALSE;
 
14
  gint64 size = -1;
 
15
  gint64 max = -1;
 
16
 
 
17
  c = bson_find (info, "name");
 
18
  bson_cursor_get_string (c, &name);
 
19
  bson_cursor_find (c, "options");
 
20
 
 
21
  bson_cursor_get_document (c, &options);
 
22
 
 
23
  printf ("Options for %s:\n", name);
 
24
 
 
25
  bson_cursor_free (c);
 
26
  bson_free (info);
 
27
 
 
28
  c = bson_find (options, "capped");
 
29
  bson_cursor_get_boolean (c, &capped);
 
30
  bson_cursor_free (c);
 
31
 
 
32
  c = bson_find (options, "size");
 
33
  bson_cursor_get_int64 (c, &size);
 
34
  bson_cursor_free (c);
 
35
 
 
36
  c = bson_find (options, "max");
 
37
  bson_cursor_get_int64 (c, &max);
 
38
  bson_cursor_free (c);
 
39
 
 
40
  bson_free (options);
 
41
 
 
42
  printf ("\tCapped: %s\n", (capped) ? "yes" : "no");
 
43
  if (size > 0)
 
44
    printf ("\tSize  : %lu\n", size);
 
45
  if (max > 0)
 
46
    printf ("\tMax   : %lu\n", max);
 
47
  printf ("\n");
 
48
}
 
49
 
 
50
int
 
51
main (void)
 
52
{
 
53
  mongo_sync_connection *conn;
 
54
 
 
55
  conn = mongo_sync_connect ("localhost", 27017, FALSE);
 
56
  if (!conn)
 
57
    {
 
58
      fprintf (stderr, "Connection failed: %s\n", strerror (errno));
 
59
      return 1;
 
60
    }
 
61
 
 
62
  mongo_sync_cmd_create (conn, "lmc", "cmd_create", MONGO_COLLECTION_DEFAULTS);
 
63
  print_coll_info (mongo_sync_cmd_exists (conn, "lmc", "cmd_create"));
 
64
 
 
65
  mongo_sync_cmd_create (conn, "lmc", "cmd_create_capped",
 
66
                         MONGO_COLLECTION_CAPPED, 655360);
 
67
  print_coll_info (mongo_sync_cmd_exists (conn, "lmc", "cmd_create_capped"));
 
68
 
 
69
  mongo_sync_cmd_create (conn, "lmc", "cmd_create_capped_max",
 
70
                         MONGO_COLLECTION_CAPPED | MONGO_COLLECTION_CAPPED_MAX,
 
71
                         655360, 100);
 
72
  print_coll_info (mongo_sync_cmd_exists (conn, "lmc",
 
73
                                          "cmd_create_capped_max"));
 
74
 
 
75
  mongo_sync_cmd_create (conn, "lmc", "cmd_create_sized",
 
76
                         MONGO_COLLECTION_SIZED, 655360);
 
77
  print_coll_info (mongo_sync_cmd_exists (conn, "lmc", "cmd_create_sized"));
 
78
 
 
79
  mongo_sync_disconnect (conn);
 
80
 
 
81
  return 0;
 
82
}