libmongo-client 0.1.4
src/libmongo-private.h
Go to the documentation of this file.
00001 /* libmongo-private.h - private headers for libmongo-client
00002  * Copyright 2011 Gergely Nagy <algernon@balabit.hu>
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00022 #ifndef LIBMONGO_PRIVATE_H
00023 #define LIBMONGO_PRIVATE_H 1
00024 
00025 #include "mongo.h"
00026 #include "compat.h"
00027 
00030 struct _bson
00031 {
00032   GByteArray *data; 
00033   gboolean finished; 
00035 };
00036 
00038 struct _mongo_connection
00039 {
00040   gint fd; 
00041   gint32 request_id; 
00042 };
00043 
00045 struct _mongo_sync_connection
00046 {
00047   mongo_connection super; 
00048   gboolean slaveok; 
00050   gboolean safe_mode; 
00051   gboolean auto_reconnect; 
00053   struct
00054   {
00055     GList *seeds; 
00056     GList *hosts; 
00057     gchar *primary; 
00058   } rs;  
00060   gchar *last_error; 
00062   gint32 max_insert_size; 
00065 };
00066 
00072 struct _mongo_sync_cursor
00073 {
00074   mongo_sync_connection *conn; 
00076   gchar *ns; 
00077   mongo_packet *results; 
00080   gint32 offset; 
00082   mongo_reply_packet_header ph; 
00084 };
00085 
00087 struct _mongo_sync_pool_connection
00088 {
00089   mongo_sync_connection super; 
00091   gint pool_id; 
00092   gboolean in_use; 
00093 };
00094 
00096 struct _mongo_sync_gridfs
00097 {
00098   mongo_sync_connection *conn; 
00101   struct
00102   {
00103     gchar *prefix; 
00104     gchar *files; 
00105     gchar *chunks; 
00107     gchar *db; 
00108   } ns; 
00110   gint32 chunk_size; 
00111 };
00112 
00114 typedef enum
00115 {
00116   LMC_GRIDFS_FILE_CHUNKED, 
00117   LMC_GRIDFS_FILE_STREAM_READER, 
00118   LMC_GRIDFS_FILE_STREAM_WRITER, 
00119 } _mongo_gridfs_type;
00120 
00125 typedef struct
00126 {
00127   gint32 chunk_size; 
00128   gint64 length; 
00130   union
00131   {
00133     struct
00134     {
00135       const guint8 *oid; 
00136       const gchar *md5; 
00137       gint64 date; 
00138       bson *metadata; 
00140     };
00141 
00143     struct
00144     {
00145       gint64 offset; 
00146       gint64 current_chunk; 
00147       guint8 *id; 
00148     };
00149   };
00150 
00151   _mongo_gridfs_type type; 
00152 } mongo_sync_gridfs_file_common;
00153 
00155 struct _mongo_sync_gridfs_chunked_file
00156 {
00157   mongo_sync_gridfs_file_common meta; 
00158   mongo_sync_gridfs *gfs; 
00159 };
00160 
00162 struct _mongo_sync_gridfs_stream
00163 {
00164   mongo_sync_gridfs_file_common file; 
00165   mongo_sync_gridfs *gfs; 
00169   union
00170   {
00173     struct
00174     {
00175       bson *bson; 
00179       struct
00180       {
00181         const guint8 *data; 
00183         gint32 size; 
00184         gint32 offset; 
00185       } chunk;
00186     } reader;
00187 
00190     struct
00191     {
00192       bson *metadata; 
00193       guint8 *buffer; 
00194       gint32 buffer_offset; 
00196       GChecksum *checksum; 
00198     } writer;
00199   };
00200 };
00201 
00214 mongo_packet *mongo_wire_cmd_kill_cursors_va (gint32 id, gint32 n,
00215                                               va_list ap);
00216 
00230 gboolean
00231 mongo_wire_packet_get_header_raw (const mongo_packet *p,
00232                                   mongo_packet_header *header);
00233 
00247 gboolean
00248 mongo_wire_packet_set_header_raw (mongo_packet *p,
00249                                   const mongo_packet_header *header);
00250 
00251 #endif
 All Data Structures Files Functions Variables Enumerations Enumerator Defines