~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_bson_build.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 <string.h>
 
4
#include <stdio.h>
 
5
 
 
6
int
 
7
main (void)
 
8
{
 
9
  bson *b_new, *b_builder, *b_builder_full;
 
10
  bson *page1, *page2, *pages;
 
11
 
 
12
  page1 = bson_new ();
 
13
  bson_append_string (page1, "title", "BSON tutorial", -1);
 
14
  bson_append_string (page1, "content", "...", -1);
 
15
  bson_append_int32 (page1, "importance", 1);
 
16
  bson_finish (page1);
 
17
 
 
18
  page2 = bson_new ();
 
19
  bson_append_string (page2, "title", "Some other thing", -1);
 
20
  bson_append_string (page2, "content", "...", -1);
 
21
  bson_append_int32 (page2, "importance", 0);
 
22
  bson_finish (page2);
 
23
 
 
24
  pages = bson_new ();
 
25
  bson_append_document (pages, "1", page1);
 
26
  bson_append_document (pages, "2", page2);
 
27
  bson_finish (pages);
 
28
 
 
29
  b_new = bson_new ();
 
30
  bson_append_string (b_new, "author", "Gergely Nagy", -1);
 
31
  bson_append_array (b_new, "pages", pages);
 
32
  bson_append_boolean (b_new, "inline", TRUE);
 
33
  bson_finish (b_new);
 
34
 
 
35
  b_builder = bson_build (BSON_TYPE_STRING, "author", "Gergely Nagy", -1,
 
36
                          BSON_TYPE_ARRAY, "pages", pages,
 
37
                          BSON_TYPE_BOOLEAN, "inline", TRUE,
 
38
                          BSON_TYPE_NONE);
 
39
  bson_finish (b_builder);
 
40
 
 
41
  b_builder_full = bson_build_full
 
42
    (BSON_TYPE_STRING, "author", FALSE, "Gergely Nagy", -1,
 
43
     BSON_TYPE_ARRAY, "pages", TRUE,
 
44
       bson_build_full (BSON_TYPE_DOCUMENT, "1", TRUE,
 
45
                        bson_build (BSON_TYPE_STRING, "title", "BSON tutorial", -1,
 
46
                                    BSON_TYPE_STRING, "content", "...", -1,
 
47
                                    BSON_TYPE_INT32, "importance", 1,
 
48
                                    BSON_TYPE_NONE),
 
49
                        BSON_TYPE_DOCUMENT, "2", TRUE,
 
50
                        bson_build (BSON_TYPE_STRING, "title", "Some other thing", -1,
 
51
                                    BSON_TYPE_STRING, "content", "...", -1,
 
52
                                    BSON_TYPE_INT32, "importance", 0,
 
53
                                    BSON_TYPE_NONE),
 
54
                        BSON_TYPE_NONE),
 
55
     BSON_TYPE_BOOLEAN, "inline", FALSE, TRUE,
 
56
     BSON_TYPE_NONE);
 
57
  bson_finish (b_builder_full);
 
58
 
 
59
  if (bson_size (b_new) != bson_size (b_builder) ||
 
60
      bson_size (b_new) != bson_size (b_builder_full))
 
61
    {
 
62
      fprintf (stderr, "There's something fishy: the three BSON objects have different sizes");
 
63
      return 1;
 
64
    }
 
65
 
 
66
  if (memcmp (bson_data (b_new), bson_data (b_builder), bson_size (b_new)) != 0 ||
 
67
      memcmp (bson_data (b_new), bson_data (b_builder_full), bson_size (b_new)) != 0)
 
68
    {
 
69
      fprintf (stderr, "The BSON objects do not match. Something smells.");
 
70
      return 1;
 
71
    }
 
72
 
 
73
  bson_free (b_builder_full);
 
74
  bson_free (b_builder);
 
75
  bson_free (b_new);
 
76
  bson_free (pages);
 
77
  bson_free (page2);
 
78
  bson_free (page1);
 
79
 
 
80
  return 0;
 
81
}