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

« back to all changes in this revision

Viewing changes to modules/afmongodb/libmongo-client/src/libmongo-private.h

  • 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
/* libmongo-private.h - private headers for libmongo-client
 
2
 * Copyright 2011 Gergely Nagy <algernon@balabit.hu>
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 *
 
8
 *     http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
/** @file libmongo-private.h
 
18
 *
 
19
 * Private types and functions, for internal use in libmongo-client only.
 
20
 */
 
21
 
 
22
#ifndef LIBMONGO_PRIVATE_H
 
23
#define LIBMONGO_PRIVATE_H 1
 
24
 
 
25
#include "mongo.h"
 
26
#include "compat.h"
 
27
 
 
28
/** @internal BSON structure.
 
29
 */
 
30
struct _bson
 
31
{
 
32
  GByteArray *data; /**< The actual data of the BSON object. */
 
33
  gboolean finished; /**< Flag to indicate whether the object is open
 
34
                        or finished. */
 
35
};
 
36
 
 
37
/** @internal Mongo Connection state object. */
 
38
struct _mongo_connection
 
39
{
 
40
  gint fd; /**< The file descriptor associated with the connection. */
 
41
  gint32 request_id; /**< The last sent command's requestID. */
 
42
};
 
43
 
 
44
/** @internal Synchronous connection object. */
 
45
struct _mongo_sync_connection
 
46
{
 
47
  mongo_connection super; /**< The parent object. */
 
48
  gboolean slaveok; /**< Whether queries against slave nodes are
 
49
                       acceptable. */
 
50
  gboolean safe_mode; /**< Safe-mode signal flag. */
 
51
  gboolean auto_reconnect; /**< Auto-reconnect flag. */
 
52
 
 
53
  struct
 
54
  {
 
55
    GList *seeds; /**< Replica set seeds, as a list of strings. */
 
56
    GList *hosts; /**< Replica set members, as a list of strings. */
 
57
    gchar *primary; /**< The replica master, if any. */
 
58
  } rs;  /**< Replica Set properties. */
 
59
 
 
60
  gchar *last_error; /**< The last error from the server, caught
 
61
                        during queries. */
 
62
  gint32 max_insert_size; /**< Maximum number of bytes an insert
 
63
                             command can be before being split to
 
64
                             smaller chunks. Used for bulk inserts. */
 
65
};
 
66
 
 
67
/** @internal MongoDB cursor object.
 
68
 *
 
69
 * The cursor object can be used to conveniently iterate over a query
 
70
 * result set.
 
71
 */
 
72
struct _mongo_sync_cursor
 
73
{
 
74
  mongo_sync_connection *conn; /**< The connection associated with
 
75
                                  the cursor. Owned by the caller. */
 
76
  gchar *ns; /**< The namespace of the cursor. */
 
77
  mongo_packet *results; /**< The current result set, as a mongo
 
78
                            packet. */
 
79
 
 
80
  gint32 offset; /**< Offset of the cursor within the active result
 
81
                    set. */
 
82
  mongo_reply_packet_header ph; /**< The reply headers extracted from
 
83
                                   the active result set. */
 
84
};
 
85
 
 
86
/** @internal Synchronous pool connection object. */
 
87
struct _mongo_sync_pool_connection
 
88
{
 
89
  mongo_sync_connection super; /**< The parent object. */
 
90
 
 
91
  gint pool_id; /**< ID of the connection. */
 
92
  gboolean in_use; /**< Whether the object is in use or not. */
 
93
};
 
94
 
 
95
/** @internal GridFS object */
 
96
struct _mongo_sync_gridfs
 
97
{
 
98
  mongo_sync_connection *conn; /**< Connection the object is
 
99
                                  associated to. */
 
100
 
 
101
  struct
 
102
  {
 
103
    gchar *prefix; /**< The namespace prefix. */
 
104
    gchar *files; /**< The file metadata namespace. */
 
105
    gchar *chunks; /**< The chunk namespace. */
 
106
 
 
107
    gchar *db; /**< The database part of the namespace. */
 
108
  } ns; /**< Namespaces */
 
109
 
 
110
  gint32 chunk_size; /**< The default chunk size. */
 
111
};
 
112
 
 
113
/** @internal GridFS file types. */
 
114
typedef enum
 
115
{
 
116
  LMC_GRIDFS_FILE_CHUNKED, /**< Chunked file. */
 
117
  LMC_GRIDFS_FILE_STREAM_READER, /**< Streamed file, reader. */
 
118
  LMC_GRIDFS_FILE_STREAM_WRITER, /**< Streamed file, writer. */
 
119
} _mongo_gridfs_type;
 
120
 
 
121
/** @internal GridFS common file properties.
 
122
 *
 
123
 * This is shared between chunked and streamed files.
 
124
 */
 
125
typedef struct
 
126
{
 
127
  gint32 chunk_size; /**< Maximum chunk size for this file. */
 
128
  gint64 length; /**< Total length of the file. */
 
129
 
 
130
  union
 
131
  {
 
132
    /** Chunked file data. */
 
133
    struct
 
134
    {
 
135
      const guint8 *oid; /**< The file's ObjectID. */
 
136
      const gchar *md5; /**< MD5 sum of the file. */
 
137
      gint64 date; /**< The upload date. */
 
138
      bson *metadata; /**< Full file metadata, including user-set
 
139
                         keys. */
 
140
    };
 
141
 
 
142
    /** Streamed file data */
 
143
    struct
 
144
    {
 
145
      gint64 offset; /**< Offset we're into the file. */
 
146
      gint64 current_chunk; /**< The current chunk we're on. */
 
147
      guint8 *id; /**< A copy of the file's ObjectID. */
 
148
    };
 
149
  };
 
150
 
 
151
  _mongo_gridfs_type type; /**< The type of the GridFS file. */
 
152
} mongo_sync_gridfs_file_common;
 
153
 
 
154
/** @internal GridFS file object. */
 
155
struct _mongo_sync_gridfs_chunked_file
 
156
{
 
157
  mongo_sync_gridfs_file_common meta; /**< The file metadata. */
 
158
  mongo_sync_gridfs *gfs; /**< The GridFS the file is on. */
 
159
};
 
160
 
 
161
/** @internal GridFS file stream object. */
 
162
struct _mongo_sync_gridfs_stream
 
163
{
 
164
  mongo_sync_gridfs_file_common file; /**< Common file data. */
 
165
  mongo_sync_gridfs *gfs; /**< The GridFS the file is on. */
 
166
 
 
167
  /** Reader & Writer structure union.
 
168
   */
 
169
  union
 
170
  {
 
171
    /** Reader-specific data.
 
172
     */
 
173
    struct
 
174
    {
 
175
      bson *bson; /**< The current chunk as BSON. */
 
176
 
 
177
      /** Chunk state information.
 
178
       */
 
179
      struct
 
180
      {
 
181
        const guint8 *data; /**< The current chunk data, pointing
 
182
                               into ->reader.bson. */
 
183
        gint32 size; /**< Size of the current chunk. */
 
184
        gint32 offset; /**< Offset we're into the chunk. */
 
185
      } chunk;
 
186
    } reader;
 
187
 
 
188
    /** Writer-specific data.
 
189
     */
 
190
    struct
 
191
    {
 
192
      bson *metadata; /**< Copy of the user-supplied metadata. */
 
193
      guint8 *buffer; /**< The current output buffer. */
 
194
      gint32 buffer_offset; /**< Offset into the output buffer. */
 
195
 
 
196
      GChecksum *checksum; /**< The running checksum of the output
 
197
                              file. */
 
198
    } writer;
 
199
  };
 
200
};
 
201
 
 
202
/** @internal Construct a kill cursors command, using a va_list.
 
203
 *
 
204
 * @param id is the sequence id.
 
205
 * @param n is the number of cursors to delete.
 
206
 * @param ap is the va_list of cursors to kill.
 
207
 *
 
208
 * @note One must supply exaclty @a n number of cursor IDs.
 
209
 *
 
210
 * @returns A newly allocated packet, or NULL on error. It is the
 
211
 * responsibility of the caller to free the packet once it is not used
 
212
 * anymore.
 
213
 */
 
214
mongo_packet *mongo_wire_cmd_kill_cursors_va (gint32 id, gint32 n,
 
215
                                              va_list ap);
 
216
 
 
217
/** @internal Get the header data of a packet, without conversion.
 
218
 *
 
219
 * Retrieve the mongo packet's header data, but do not convert the
 
220
 * values from little-endian. Use only when the source has the data in
 
221
 * the right byte order already.
 
222
 *
 
223
 * @param p is the packet which header we seek.
 
224
 * @param header is a pointer to a variable which will hold the data.
 
225
 *
 
226
 * @note Allocating the @a header is the responsibility of the caller.
 
227
 *
 
228
 * @returns TRUE on success, FALSE otherwise.
 
229
 */
 
230
gboolean
 
231
mongo_wire_packet_get_header_raw (const mongo_packet *p,
 
232
                                  mongo_packet_header *header);
 
233
 
 
234
/** @internal Set the header data of a packet, without conversion.
 
235
 *
 
236
 * Override the mongo packet's header data, but do not convert the
 
237
 * values from little-endian. Use only when the source has the data in
 
238
 * the right byte order already.
 
239
 *
 
240
 * @note No sanity checks are done, use this function with great care.
 
241
 *
 
242
 * @param p is the packet whose header we want to override.
 
243
 * @param header is the header structure to use.
 
244
 *
 
245
 * @returns TRUE on success, FALSE otherwise.
 
246
 */
 
247
gboolean
 
248
mongo_wire_packet_set_header_raw (mongo_packet *p,
 
249
                                  const mongo_packet_header *header);
 
250
 
 
251
#endif