rpm
5.4.15
|
#include "system.h"
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <fcntl.h>
#include <rpmiotypes.h>
#include <rpmio.h>
#include <rpmlog.h>
#include <rpmurl.h>
#include <mongo.h>
#include "debug.h"
Go to the source code of this file.
Data Structures | |
struct | gridfs |
struct | gridfile |
Macros | |
#define | _RPMMGO_INTERNAL |
#define | INVALID_SOCKET (-1) |
#define | NI_MAXSERV 32 |
#define | INDEX_NAME_BUFFER_SIZE 255 |
#define | INDEX_NAME_MAX_LENGTH (INDEX_NAME_BUFFER_SIZE - 1) |
Typedefs | |
typedef uint64_t | gridfs_offset |
typedef int(* | gridfs_chunk_filter_func )(char **targetBuf, size_t *targetLen, const char *srcBuf, size_t srcLen, int flags) |
typedef size_t(* | gridfs_pending_data_size_func )(int flags) |
Enumerations | |
enum | { DEFAULT_CHUNK_SIZE = 256 * 1024 } |
enum | gridfile_storage_type { GRIDFILE_DEFAULT = 0, GRIDFILE_NOMD5 = ( 1<<0 ) } |
Variables | |
int | _rpmmgo_debug = 0 |
rpmmgo | _rpmmgoI |
static const int | zero = 0 |
static const int | one = 1 |
static gridfs_chunk_filter_func | gridfs_write_filter = gridfs_default_chunk_filter |
static gridfs_chunk_filter_func | gridfs_read_filter = gridfs_default_chunk_filter |
static gridfs_pending_data_size_func | gridfs_pending_data_size = gridfs_default_pending_data_size |
static const int | ZERO = 0 |
static const int | ONE = 1 |
static char | WC1_data [] = {23,0,0,0,16,103,101,116,108,97,115,116,101,114,114,111,114,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0} |
static bson | WC1_cmd |
static mongo_write_concern | WC1 = { 1, 0, 0, 0, 0, &WC1_cmd } |
rpmioPool | _rpmmgoPool = NULL |
#define INDEX_NAME_BUFFER_SIZE 255 |
Definition at line 3194 of file mongo.c.
Referenced by mongo_create_index().
#define INDEX_NAME_MAX_LENGTH (INDEX_NAME_BUFFER_SIZE - 1) |
Definition at line 3195 of file mongo.c.
Referenced by mongo_create_index().
#define INVALID_SOCKET (-1) |
Definition at line 1582 of file mongo.c.
Referenced by mongo_env_socket_connect(), and mongo_env_unix_socket_connect().
#define NI_MAXSERV 32 |
Definition at line 1588 of file mongo.c.
Referenced by ftpReq(), mongo_env_socket_connect(), and tcpConnect().
typedef int( * gridfs_chunk_filter_func)(char **targetBuf, size_t *targetLen, const char *srcBuf, size_t srcLen, int flags) |
typedef uint64_t gridfs_offset |
MONGO_EXPORT void __mongo_set_error | ( | mongo * | conn, |
mongo_error_t | err, | ||
const char * | str, | ||
int | errcode | ||
) |
Definition at line 1868 of file mongo.c.
References mongo::err, err, mongo::errcode, mongo::errstr, and MONGO_ERR_LEN.
Referenced by mongo_check_last_error(), mongo_choose_write_concern(), mongo_env_read_socket(), mongo_env_set_socket_op_timeout(), mongo_env_socket_connect(), mongo_env_write_socket(), and mongo_validate_ns().
|
static |
Definition at line 1794 of file mongo.c.
References bson_sprintf, mongo_host_port::host, and mongo_host_port::port.
Referenced by mongo_get_host(), and mongo_get_primary().
|
static |
Definition at line 462 of file mongo.c.
References str.
Referenced by bson_append_string_uppercase().
|
static |
Definition at line 644 of file mongo.c.
References _strupr().
Referenced by gridfs_find_filename(), gridfs_insert_file(), and gridfs_remove_filename().
|
static |
Definition at line 544 of file mongo.c.
Referenced by gridfile_flush_pendingchunk(), and gridfile_write_buffer().
|
static |
Definition at line 529 of file mongo.c.
References b, BSON_BIN_BINARY, bson_init_size(), and gridfs_write_filter.
Referenced by gridfile_flush_pendingchunk(), and gridfile_write_buffer().
MONGO_EXPORT gridfile * gridfile_create | ( | void | ) |
MONGO_EXPORT void gridfile_dealloc | ( | gridfile * | gf | ) |
MONGO_EXPORT void gridfile_destroy | ( | gridfile * | gfile | ) |
Destroys the GridFile.
oGridFIle | - the GridFile being destroyed |
Definition at line 1005 of file mongo.c.
References gridfile::meta.
Referenced by gridfile_writer_init(), gridfs_store_buffer(), and gridfs_store_file().
MONGO_EXPORT bson_bool_t gridfile_exists | ( | const gridfile * | gfile | ) |
Returns whether or not the GridFile exists.
gfile | - the GridFile being examined |
Definition at line 1027 of file mongo.c.
References gridfile::meta.
Referenced by gridfile_writer_init().
MONGO_EXPORT gridfs_offset gridfile_expand | ( | gridfile * | gfile, |
gridfs_offset | bytesToExpand | ||
) |
gfile | - the working GridFile |
bytesToExpand | - number of bytes the file will be expanded |
Definition at line 1541 of file mongo.c.
References gridfile_get_chunksize(), gridfile_get_contentlength(), gridfile_seek(), and gridfile_write_buffer().
Referenced by gridfile_set_size().
|
static |
Definition at line 1432 of file mongo.c.
References BSON_EOO, bson_fatal_msg(), gridfile::flags, gridfs_read_filter, and gridfile::pos.
Referenced by gridfile_load_from_chunks().
|
static |
Definition at line 1159 of file mongo.c.
References chunk_free(), chunk_new(), gridfile::chunk_num, gridfs::chunks_ns, gridfile::chunkSize, gridfs::client, gridfile::flags, gridfile::gfs, gridfile_prepare_chunk_key_bson(), gridfile::id, gridfile::length, MONGO_OK, mongo_update(), MONGO_UPDATE_UPSERT, gridfile::pending_data, and gridfile::pending_len.
Referenced by gridfile_read_buffer(), gridfile_seek(), gridfile_truncate(), gridfile_write_buffer(), and gridfile_writer_done().
MONGO_EXPORT bson_bool_t gridfile_get_boolean | ( | const gridfile * | gfile, |
const char * | name | ||
) |
Returns a boolean field in GridFile specified by name.
gfile | - the working GridFile |
name | - the name of the field to be returned |
Definition at line 1104 of file mongo.c.
References BSON_EOO, and gridfile::meta.
MONGO_EXPORT void gridfile_get_chunk | ( | gridfile * | gfile, |
int | n, | ||
bson * | out | ||
) |
Returns chunk n of GridFile.
gfile | - the working GridFile |
Definition at line 1287 of file mongo.c.
References gridfs::chunks_ns, gridfs::client, gridfile::gfs, gridfile_get_id(), mongo_find_one(), MONGO_OK, and query.
Referenced by gridfile_load_pending_data_with_pos_chunk().
MONGO_EXPORT mongo_cursor * gridfile_get_chunks | ( | gridfile * | gfile, |
size_t | start, | ||
size_t | size | ||
) |
Returns a mongo_cursor of size chunks starting with chunk start
gfile | - the working GridFile |
start | - the first chunk in the cursor |
size | - the number of chunks to be returned |
Definition at line 1305 of file mongo.c.
References BSON_EOO, gridfs::chunks_ns, gridfs::client, command, gridfile::gfs, gridfile::id, gridfile::meta, mongo_find(), and query.
Referenced by gridfile_read_buffer().
MONGO_EXPORT int gridfile_get_chunksize | ( | const gridfile * | gfile | ) |
Returns the size of the chunks of the GridFile.
gfile | - the working GridFile |
Definition at line 1043 of file mongo.c.
References BSON_EOO, gridfile::chunkSize, DEFAULT_CHUNK_SIZE, and gridfile::meta.
Referenced by gridfile_expand(), gridfile_get_contentlength(), gridfile_read_buffer(), gridfile_read_from_pending_buffer(), gridfile_seek(), gridfile_truncate(), and gridfile_writer_init().
MONGO_EXPORT gridfs_offset gridfile_get_contentlength | ( | const gridfile * | gfile | ) |
Returns the length of GridFile's data.
gfile | - the working GridFile |
Definition at line 1054 of file mongo.c.
References gridfile::chunk_num, gridfile_get_chunksize(), gridfile::length, MAX, and gridfile::pending_len.
Referenced by gridfile_expand(), gridfile_read_buffer(), gridfile_seek(), gridfile_set_size(), and gridfile_truncate().
MONGO_EXPORT const char * gridfile_get_contenttype | ( | const gridfile * | gfile | ) |
Returns the MIME type of the GridFile.
gfile | - the working GridFile |
Definition at line 1060 of file mongo.c.
References BSON_EOO, and gridfile::meta.
MONGO_EXPORT void gridfile_get_descriptor | ( | gridfile * | gf, |
bson * | out | ||
) |
Definition at line 503 of file mongo.c.
References gridfile::meta.
MONGO_EXPORT const char * gridfile_get_field | ( | gridfile * | gfile, |
const char * | name | ||
) |
Returns the field in GridFile specified by name.
gfile | - the working GridFile |
name | - the name of the field to be returned |
Definition at line 1095 of file mongo.c.
References BSON_EOO, and gridfile::meta.
MONGO_EXPORT const char * gridfile_get_filename | ( | const gridfile * | gfile | ) |
Returns the filename of GridFile.
gfile | - the working GridFile |
Definition at line 1032 of file mongo.c.
References BSON_EOO, gridfs::caseInsensitive, gridfile::gfs, gridfile::meta, and gridfile::remote_name.
MONGO_EXPORT int gridfile_get_flags | ( | const gridfile * | gfile | ) |
gets the flags of the GridFile
gfile | - the working GridFile |
Definition at line 1091 of file mongo.c.
References gridfile::flags.
MONGO_EXPORT bson_oid_t gridfile_get_id | ( | const gridfile * | gfile | ) |
Returns the _id in GridFile specified by name.
gfile | - the working GridFile |
Definition at line 1015 of file mongo.c.
References BSON_EOO, BSON_OID, gridfile::id, and gridfile::meta.
Referenced by gridfile_get_chunk(), gridfile_remove_chunks(), and gridfile_writer_init().
MONGO_EXPORT const char * gridfile_get_md5 | ( | const gridfile * | gfile | ) |
Returns the MD5 of GridFile.
gfile | - the working GridFile |
Definition at line 1078 of file mongo.c.
References BSON_EOO, and gridfile::meta.
MONGO_EXPORT void gridfile_get_metadata | ( | const gridfile * | gfile, |
bson * | metadata, | ||
bson_bool_t | copyData | ||
) |
Returns the metadata of GridFile.
Calls bson_init_empty on metadata if none exits.
gfile | - the working GridFile |
metadata | an uninitialized BSON object to receive the metadata. |
copyData | when true, makes a copy of the scope data which will remain valid when the grid file is deallocated. |
Definition at line 1113 of file mongo.c.
References BSON_EOO, and gridfile::meta.
MONGO_EXPORT int gridfile_get_numchunks | ( | const gridfile * | gfile | ) |
Returns the number of chunks in the GridFile.
gfile | - the working GridFile |
Definition at line 1126 of file mongo.c.
References BSON_EOO, BSON_INT, DEFAULT_CHUNK_SIZE, and gridfile::meta.
MONGO_EXPORT bson_date_t gridfile_get_uploaddate | ( | const gridfile * | gfile | ) |
Returns the upload date of GridFile.
gfile | - the working GridFile |
Definition at line 1069 of file mongo.c.
References BSON_EOO, and gridfile::meta.
MONGO_EXPORT int gridfile_init | ( | gridfs * | gfs, |
const bson * | meta, | ||
gridfile * | gfile | ||
) |
Initializes a GridFile containing the GridFS and file bson.
gfs | - the GridFS where the GridFile is located |
meta | - the file object |
gfile | - the output GridFile that is being initialized |
Definition at line 878 of file mongo.c.
References gridfile::gfs, gridfile_init_chunkSize(), gridfile_init_flags(), gridfile_init_length(), gridfile::meta, MONGO_ERROR, MONGO_OK, gridfile::pending_data, gridfile::pending_len, and gridfile::pos.
Referenced by gridfs_find_query(), gridfs_store_buffer(), and gridfs_store_file().
|
static |
Definition at line 925 of file mongo.c.
References BSON_EOO, BSON_INT, gridfile::chunkSize, DEFAULT_CHUNK_SIZE, and gridfile::meta.
Referenced by gridfile_init().
|
static |
Definition at line 949 of file mongo.c.
References BSON_EOO, gridfile::flags, and gridfile::meta.
Referenced by gridfile_init(), and gridfile_writer_init().
|
static |
Definition at line 937 of file mongo.c.
References BSON_EOO, BSON_INT, gridfile::length, and gridfile::meta.
Referenced by gridfile_init(), and gridfile_writer_init().
|
static |
Definition at line 1412 of file mongo.c.
References mongo_cursor::current, gridfile_fill_buf_from_chunk(), i, mongo_cursor_next(), and MONGO_OK.
Referenced by gridfile_read_buffer().
|
static |
Definition at line 1185 of file mongo.c.
References BSON_EOO, gridfile::chunk_num, bson::data, bson::dataSize, DEFAULT_CHUNK_SIZE, gridfile::flags, gridfile_get_chunk(), gridfs_read_filter, MONGO_ERROR, MONGO_OK, gridfile::pending_data, gridfile::pending_len, and gridfile::pos.
Referenced by gridfile_truncate(), and gridfile_write_buffer().
|
static |
Definition at line 1152 of file mongo.c.
Referenced by gridfile_flush_pendingchunk(), and gridfile_write_buffer().
MONGO_EXPORT gridfs_offset gridfile_read_buffer | ( | gridfile * | gfile, |
char * | buf, | ||
gridfs_offset | size | ||
) |
Reads length bytes from the GridFile to a buffer and updates the position in the file.
(assumes the buffer is large enough) (if size is greater than EOF gridfile_read reads until EOF)
gfile | - the working GridFile |
size | - the amount of bytes to be read |
buf | - the buffer to read to |
Definition at line 1354 of file mongo.c.
References gridfile_flush_pendingchunk(), gridfile_get_chunks(), gridfile_get_chunksize(), gridfile_get_contentlength(), gridfile_load_from_chunks(), gridfile_read_from_pending_buffer(), mongo_cursor_destroy(), MONGO_OK, gridfile::pos, and size.
Referenced by gridfile_write_file().
|
static |
Definition at line 1394 of file mongo.c.
References gridfile::chunk_num, gridfile_get_chunksize(), gridfile::pending_data, gridfile::pending_len, and gridfile::pos.
Referenced by gridfile_read_buffer().
|
static |
Definition at line 1495 of file mongo.c.
References gridfs::chunks_ns, gridfs::client, gridfile::gfs, gridfile_get_id(), and mongo_remove().
Referenced by gridfile_truncate().
MONGO_EXPORT gridfs_offset gridfile_seek | ( | gridfile * | gfile, |
gridfs_offset | offset | ||
) |
Updates the position in the file (If the offset goes beyond the contentlength, the position is updated to the end of the file.)
gfile | - the working GridFile |
offset | - the position to update to |
Definition at line 1463 of file mongo.c.
References gridfile::chunk_num, gridfile_flush_pendingchunk(), gridfile_get_chunksize(), gridfile_get_contentlength(), MONGO_OK, gridfile::pending_len, and gridfile::pos.
Referenced by gridfile_expand(), and gridfile_truncate().
MONGO_EXPORT void gridfile_set_flags | ( | gridfile * | gfile, |
int | flags | ||
) |
Sets the flags of the GridFile.
gfile | - the working GridFile |
flags | - the value of the flags to set on the provided GridFile |
Definition at line 1087 of file mongo.c.
References gridfile::flags, and flags.
MONGO_EXPORT gridfs_offset gridfile_set_size | ( | gridfile * | gfile, |
gridfs_offset | newSize | ||
) |
gfile | - the working GridFile |
newSize | - the new size of file |
Definition at line 1569 of file mongo.c.
References gridfile_expand(), gridfile_get_contentlength(), and gridfile_truncate().
MONGO_EXPORT gridfs_offset gridfile_truncate | ( | gridfile * | gfile, |
gridfs_offset | newSize | ||
) |
gfile | - the working GridFile |
newSize | - the new size after truncation |
Definition at line 1513 of file mongo.c.
References gridfile_flush_pendingchunk(), gridfile_get_chunksize(), gridfile_get_contentlength(), gridfile_load_pending_data_with_pos_chunk(), gridfile_remove_chunks(), gridfile_seek(), gridfile::length, MONGO_OK, gridfile::pending_len, and gridfile::pos.
Referenced by gridfile_set_size().
MONGO_EXPORT gridfs_offset gridfile_write_buffer | ( | gridfile * | gfile, |
const char * | data, | ||
gridfs_offset | length | ||
) |
Write to a GridFS file incrementally.
You can call this function any number of times with a new buffer each time. This allows you to effectively stream to a GridFS file. When finished, be sure to call gridfs_writer_done.
gfile | - GridFile to write to |
data | - Pointer to buffer with data to be written |
length | - Size of buffer with data to be written |
Definition at line 1220 of file mongo.c.
References chunk_free(), chunk_new(), gridfile::chunk_num, gridfs::chunks_ns, gridfs::client, data, DEFAULT_CHUNK_SIZE, gridfile::flags, gridfile::gfs, gridfile_flush_pendingchunk(), gridfile_load_pending_data_with_pos_chunk(), gridfile_prepare_chunk_key_bson(), gridfile::id, gridfile::length, MONGO_OK, mongo_update(), MONGO_UPDATE_UPSERT, gridfile::pending_data, gridfile::pending_len, and gridfile::pos.
Referenced by gridfile_expand(), gridfs_store_buffer(), and gridfs_store_file().
MONGO_EXPORT gridfs_offset gridfile_write_file | ( | gridfile * | gfile, |
FILE * | stream | ||
) |
Writes the GridFile to a stream.
gfile | - the working GridFile |
stream | - the file stream to write to |
Definition at line 1479 of file mongo.c.
References buffer, DEFAULT_CHUNK_SIZE, and gridfile_read_buffer().
MONGO_EXPORT int gridfile_writer_done | ( | gridfile * | gfile | ) |
Signal that writing of this gridfile is complete by writing any buffered chunks along with the entry in the files collection.
Definition at line 897 of file mongo.c.
References gridfile::chunkSize, gridfile::content_type, gridfile::flags, gridfile::gfs, gridfile_flush_pendingchunk(), gridfs_insert_file(), gridfile::id, gridfile::length, MONGO_OK, gridfile::pending_data, gridfile::pending_len, and gridfile::remote_name.
Referenced by gridfs_store_buffer(), and gridfs_store_file().
MONGO_EXPORT int gridfile_writer_init | ( | gridfile * | gfile, |
gridfs * | gfs, | ||
const char * | remote_name, | ||
const char * | content_type, | ||
int | flags | ||
) |
Initializes a gridfile for writing incrementally with gridfs_write_buffer.
Once initialized, you can write any number of buffers with gridfs_write_buffer. When done, you must call gridfs_writer_done to save the file metadata. +-+-+-+- This modified version of GridFS allows the file to read/write randomly +-+-+-+- when using this function
Definition at line 958 of file mongo.c.
References gridfile::chunk_num, gridfile::chunkSize, gridfile::content_type, gridfile::flags, flags, gridfile::gfs, GRIDFILE_DEFAULT, gridfile_destroy(), gridfile_exists(), gridfile_get_chunksize(), gridfile_get_id(), gridfile_init_flags(), gridfile_init_length(), gridfs_find_filename(), gridfs_pending_data_size, gridfile::id, gridfile::length, MONGO_OK, gridfile::pending_data, gridfile::pending_len, gridfile::pos, and gridfile::remote_name.
Referenced by gridfs_store_buffer(), and gridfs_store_file().
MONGO_EXPORT gridfs * gridfs_alloc | ( | void | ) |
MONGO_EXPORT void gridfs_dealloc | ( | gridfs * | gfs | ) |
|
static |
|
static |
Definition at line 514 of file mongo.c.
References DEFAULT_CHUNK_SIZE.
MONGO_EXPORT void gridfs_destroy | ( | gridfs * | gfs | ) |
Destroys a GridFS object.
Call this when finished with the object..
gfs | a grid |
Definition at line 614 of file mongo.c.
References gridfs::chunks_ns, gridfs::dbname, gridfs::files_ns, and gridfs::prefix.
Referenced by gridfs_init().
MONGO_EXPORT int gridfs_find_filename | ( | gridfs * | gfs, |
const char * | filename, | ||
gridfile * | gfile | ||
) |
Find the first file referenced by filename within the GridFS and return it as a GridFile.
gfs | - the working GridFS |
filename | - filename of the file to find |
gfile | - the output GridFile to be intialized |
Definition at line 854 of file mongo.c.
References bson_append_string_uppercase(), gridfs::caseInsensitive, gridfs_find_query(), and query.
Referenced by gridfile_writer_init().
MONGO_EXPORT int gridfs_find_query | ( | gridfs * | gfs, |
const bson * | query, | ||
gridfile * | gfile | ||
) |
Find the first file matching the provided query within the GridFS files collection, and return the file as a GridFile.
gfs | - the working GridFS |
query | - a pointer to the bson with the query data |
gfile | - the output GridFile to be initialized |
Definition at line 826 of file mongo.c.
References gridfs::client, gridfs::files_ns, gridfile_init(), i, MONGO_ERROR, mongo_find_one(), MONGO_OK, and out.
Referenced by gridfs_find_filename().
MONGO_EXPORT bson_bool_t gridfs_get_caseInsensitive | ( | const gridfs * | gfs | ) |
Returns the caseInsensitive flag value of gfs.
gfile | - the working GridFile |
Definition at line 636 of file mongo.c.
References gridfs::caseInsensitive.
MONGO_EXPORT int gridfs_init | ( | mongo * | client, |
const char * | dbname, | ||
const char * | prefix, | ||
gridfs * | gfs | ||
) |
Initializes a GridFS object.
client | - db connection |
dbname | - database name |
prefix | - collection prefix, default is fs if NULL or empty |
gfs | - the GridFS object to initialize |
Definition at line 557 of file mongo.c.
References b, gridfs::caseInsensitive, gridfs::chunks_ns, gridfs::client, gridfs::dbname, gridfs::files_ns, gridfs_destroy(), mongo_create_index(), MONGO_ERROR, MONGO_INDEX_UNIQUE, MONGO_OK, and gridfs::prefix.
|
static |
Definition at line 659 of file mongo.c.
References bson_append_string_uppercase(), BSON_EOO, gridfs::caseInsensitive, gridfs::client, command, d, gridfs::dbname, gridfs::files_ns, GRIDFILE_NOMD5, MONGO_OK, mongo_run_command(), mongo_update(), MONGO_UPDATE_UPSERT, gridfs::prefix, and time.
Referenced by gridfile_writer_done().
MONGO_EXPORT int gridfs_remove_filename | ( | gridfs * | gfs, |
const char * | filename | ||
) |
Removes the files referenced by filename from the db.
gfs | - the working GridFS |
filename | - the filename of the file/s to be removed |
Definition at line 783 of file mongo.c.
References b, bson_append_string_uppercase(), gridfs::caseInsensitive, gridfs::chunks_ns, gridfs::client, mongo_cursor::current, file, gridfs::files_ns, mongo_cursor_destroy(), mongo_cursor_next(), MONGO_ERROR, mongo_find(), MONGO_OK, mongo_remove(), and query.
MONGO_EXPORT void gridfs_set_caseInsensitive | ( | gridfs * | gfs, |
bson_bool_t | newValue | ||
) |
Sets the caseInsensitive flag value of gfs.
gfs | - the working gfs |
newValue | - the new value for the caseInsensitive flag of gfs |
Definition at line 640 of file mongo.c.
References gridfs::caseInsensitive.
MONGO_EXPORT void gridfs_set_chunk_filter_funcs | ( | gridfs_chunk_filter_func | writeFilter, |
gridfs_chunk_filter_func | readFilter, | ||
gridfs_pending_data_size_func | pendingDataNeededSize | ||
) |
MONGO_EXPORT int gridfs_store_buffer | ( | gridfs * | gfs, |
const char * | data, | ||
gridfs_offset | length, | ||
const char * | remotename, | ||
const char * | contenttype, | ||
int | flags | ||
) |
Store a buffer as a GridFS file.
gfs | - the working GridFS |
data | - pointer to buffer to store in GridFS |
length | - length of the buffer |
remotename | - filename for use in the database |
contenttype | - optional MIME type for this object |
Definition at line 723 of file mongo.c.
References gridfile_destroy(), gridfile_init(), gridfile_write_buffer(), gridfile_writer_done(), gridfile_writer_init(), MONGO_ERROR, and MONGO_OK.
MONGO_EXPORT int gridfs_store_file | ( | gridfs * | gfs, |
const char * | filename, | ||
const char * | remotename, | ||
const char * | contenttype, | ||
int | flags | ||
) |
Open the file referenced by filename and store it as a GridFS file.
gfs | - the working GridFS |
filename | - local filename relative to the process |
remotename | - optional filename for use in the database |
contenttype | - optional MIME type for this object |
Definition at line 738 of file mongo.c.
References buffer, DEFAULT_CHUNK_SIZE, gridfile_destroy(), gridfile_init(), gridfile_write_buffer(), gridfile_writer_done(), gridfile_writer_init(), MONGO_ERROR, and MONGO_OK.
MONGO_EXPORT mongo* mongo_alloc | ( | void | ) |
Definition at line 2491 of file mongo.c.
References BSON_FIELD_HAS_DOT, BSON_FIELD_INIT_DOLLAR, BSON_NOT_UTF8, bson::err, mongo::err, bson::finished, mongo::max_bson_size, MONGO_BSON_INVALID, MONGO_BSON_NOT_FINISHED, MONGO_BSON_TOO_LARGE, MONGO_CONN_SUCCESS, MONGO_ERROR, MONGO_OK, and size.
Referenced by mongo_insert(), mongo_insert_batch(), mongo_remove(), and mongo_update().
MONGO_EXPORT int mongo_check_connection | ( | mongo * | conn | ) |
Definition at line 2451 of file mongo.c.
References mongo::connected, MONGO_ERROR, and mongo_simple_int_command().
|
static |
Definition at line 2131 of file mongo.c.
References mongo::err, mongo::max_bson_size, MONGO_CONN_NOT_MASTER, MONGO_DEFAULT_MAX_BSON_SIZE, MONGO_ERROR, MONGO_OK, mongo_simple_int_command(), and out.
Referenced by mongo_client().
|
static |
Definition at line 2542 of file mongo.c.
References __mongo_set_error(), BSON_STRING, mongo_write_concern::cmd, MONGO_ERROR, mongo_find_one(), mongo_ns_to_cmd_db(), MONGO_OK, mongo_set_last_error(), and MONGO_WRITE_ERROR.
Referenced by mongo_message_send_and_check_write_concern().
|
static |
Definition at line 2566 of file mongo.c.
References __mongo_set_error(), custom_write_concern, MONGO_ERROR, MONGO_OK, MONGO_WRITE_CONCERN_INVALID, mongo_write_concern::w, and mongo::write_concern.
Referenced by mongo_insert(), mongo_insert_batch(), mongo_remove(), and mongo_update().
MONGO_EXPORT void mongo_clear_errors | ( | mongo * | conn | ) |
Definition at line 1881 of file mongo.c.
References mongo::err, mongo::errcode, mongo::errstr, mongo::lasterrcode, mongo::lasterrstr, and MONGO_CONN_SUCCESS.
Referenced by mongo_cmd_get_error_helper(), mongo_cursor_op_query(), and mongo_destroy().
MONGO_EXPORT int mongo_client | ( | mongo * | conn, |
const char * | host, | ||
int | port | ||
) |
Definition at line 2173 of file mongo.c.
References mongo_host_port::host, MAXHOSTNAMELEN, mongo_check_is_master(), mongo_env_socket_connect(), MONGO_ERROR, mongo_init(), MONGO_OK, mongo_host_port::next, mongo_host_port::port, port, mongo::primary, and snprintf().
Referenced by mongo_connect().
MONGO_EXPORT int mongo_cmd_add_user | ( | mongo * | conn, |
const char * | db, | ||
const char * | user, | ||
const char * | pass | ||
) |
Definition at line 3456 of file mongo.c.
References MONGO_OK, mongo_pass_digest(), mongo_update(), MONGO_UPDATE_UPSERT, and ns.
MONGO_EXPORT bson_bool_t mongo_cmd_authenticate | ( | mongo * | conn, |
const char * | db, | ||
const char * | user, | ||
const char * | pass | ||
) |
Definition at line 3491 of file mongo.c.
References _free(), BSON_EOO, cmd, mongo::err, MONGO_BSON_TOO_LARGE, MONGO_ERROR, MONGO_OK, mongo_pass_digest(), mongo_run_command(), mongo_simple_int_command(), PGPHASHALGO_MD5, RPMDIGEST_NONE, rpmDigestFinal(), rpmDigestInit(), and rpmDigestUpdate().
MONGO_EXPORT int mongo_cmd_drop_collection | ( | mongo * | conn, |
const char * | db, | ||
const char * | collection, | ||
bson * | out | ||
) |
Definition at line 3372 of file mongo.c.
References mongo_simple_str_command().
MONGO_EXPORT int mongo_cmd_drop_db | ( | mongo * | conn, |
const char * | db | ||
) |
Definition at line 3368 of file mongo.c.
References mongo_simple_int_command().
|
static |
Definition at line 3380 of file mongo.c.
References BSON_NULL, mongo_clear_errors(), MONGO_ERROR, MONGO_OK, mongo_set_last_error(), mongo_simple_int_command(), and out.
Referenced by mongo_cmd_get_last_error(), and mongo_cmd_get_prev_error().
MONGO_EXPORT int mongo_cmd_get_last_error | ( | mongo * | conn, |
const char * | db, | ||
bson * | out | ||
) |
Definition at line 3412 of file mongo.c.
References mongo_cmd_get_error_helper().
Referenced by mongo_create_index().
MONGO_EXPORT int mongo_cmd_get_prev_error | ( | mongo * | conn, |
const char * | db, | ||
bson * | out | ||
) |
Definition at line 3408 of file mongo.c.
References mongo_cmd_get_error_helper().
MONGO_EXPORT bson_bool_t mongo_cmd_ismaster | ( | mongo * | conn, |
bson * | realout | ||
) |
MONGO_EXPORT void mongo_cmd_reset_error | ( | mongo * | conn, |
const char * | db | ||
) |
Definition at line 3376 of file mongo.c.
References mongo_simple_int_command().
MONGO_EXPORT int mongo_connect | ( | mongo * | conn, |
const char * | host, | ||
int | port | ||
) |
Definition at line 2187 of file mongo.c.
References bson_errprintf, mongo_client(), and mongo_set_write_concern().
MONGO_EXPORT double mongo_count | ( | mongo * | conn, |
const char * | db, | ||
const char * | coll, | ||
const bson * | query | ||
) |
Definition at line 3283 of file mongo.c.
References cmd, MONGO_ERROR, MONGO_OK, mongo_run_command(), and out.
MONGO_EXPORT int mongo_create_capped_collection | ( | mongo * | conn, |
const char * | db, | ||
const char * | collection, | ||
int | size, | ||
int | max, | ||
bson * | out | ||
) |
Definition at line 3262 of file mongo.c.
References b, and mongo_run_command().
MONGO_EXPORT int mongo_create_index | ( | mongo * | conn, |
const char * | ns, | ||
const bson * | key, | ||
const char * | name, | ||
int | options, | ||
bson * | out | ||
) |
Definition at line 3197 of file mongo.c.
References b, INDEX_NAME_BUFFER_SIZE, INDEX_NAME_MAX_LENGTH, len, mongo_cmd_get_last_error(), MONGO_ERROR, MONGO_INDEX_BACKGROUND, MONGO_INDEX_DROP_DUPS, MONGO_INDEX_SPARSE, MONGO_INDEX_UNIQUE, mongo_insert(), and MONGO_OK.
Referenced by gridfs_init(), and mongo_create_simple_index().
MONGO_EXPORT bson_bool_t mongo_create_simple_index | ( | mongo * | conn, |
const char * | ns, | ||
const char * | field, | ||
int | options, | ||
bson * | out | ||
) |
Definition at line 3249 of file mongo.c.
References b, and mongo_create_index().
MONGO_EXPORT mongo_cursor* mongo_cursor_alloc | ( | void | ) |
Definition at line 1849 of file mongo.c.
Referenced by mongo_find().
MONGO_EXPORT const bson* mongo_cursor_bson | ( | mongo_cursor * | cursor | ) |
Definition at line 3094 of file mongo.c.
References mongo_cursor::current.
|
static |
Definition at line 2526 of file mongo.c.
References BSON_NOT_UTF8, mongo_cursor::conn, bson::err, mongo::err, mongo_cursor::err, bson::finished, MONGO_BSON_INVALID, MONGO_BSON_NOT_FINISHED, MONGO_CURSOR_BSON_ERROR, MONGO_ERROR, and MONGO_OK.
Referenced by mongo_cursor_op_query().
MONGO_EXPORT const char* mongo_cursor_data | ( | mongo_cursor * | cursor | ) |
Definition at line 3090 of file mongo.c.
References mongo_cursor::current, and bson::data.
MONGO_EXPORT void mongo_cursor_dealloc | ( | mongo_cursor * | cursor | ) |
MONGO_EXPORT int mongo_cursor_destroy | ( | mongo_cursor * | cursor | ) |
Definition at line 3158 of file mongo.c.
References mongo_cursor::conn, conn, mongo_reply_fields::cursorID, mongo_message::data, data, mongo_reply::fields, mongo_cursor::flags, MONGO_CURSOR_MUST_FREE, mongo_data_append32(), mongo_data_append64(), MONGO_ERROR, mongo_message_create(), mongo_message_send(), MONGO_OK, MONGO_OP_KILL_CURSORS, mongo_cursor::ns, and mongo_cursor::reply.
Referenced by gridfile_read_buffer(), gridfs_remove_filename(), mongo_cursor_get_more(), mongo_find(), and mongo_find_one().
|
static |
Definition at line 2963 of file mongo.c.
References mongo_cursor::conn, mongo_cursor::current, mongo_reply_fields::cursorID, bson::data, mongo_message::data, data, mongo_cursor::err, mongo_reply::fields, mongo_cursor::limit, limit, mongo_cursor_destroy(), MONGO_CURSOR_EXHAUSTED, MONGO_CURSOR_INVALID, mongo_data_append(), mongo_data_append32(), mongo_data_append64(), MONGO_ERROR, mongo_message_create(), mongo_message_send(), MONGO_OK, MONGO_OP_GET_MORE, mongo_read_response(), mongo_cursor::ns, mongo_reply_fields::num, mongo_cursor::reply, and mongo_cursor::seen.
Referenced by mongo_cursor_next().
MONGO_EXPORT void mongo_cursor_init | ( | mongo_cursor * | cursor, |
mongo * | conn, | ||
const char * | ns | ||
) |
Definition at line 3062 of file mongo.c.
References mongo_cursor::conn, conn, mongo_cursor::current, bson::data, and mongo_cursor::ns.
Referenced by mongo_find(), and mongo_find_one().
MONGO_EXPORT int mongo_cursor_next | ( | mongo_cursor * | cursor | ) |
Definition at line 3098 of file mongo.c.
References bson_init_finished_data(), mongo_cursor::current, mongo_reply_fields::cursorID, bson::data, mongo_cursor::err, mongo_reply::fields, mongo_cursor::flags, mongo_reply::head, mongo_header::len, mongo_cursor_get_more(), mongo_cursor_op_query(), MONGO_CURSOR_PENDING, MONGO_CURSOR_QUERY_SENT, MONGO_ERROR, MONGO_OK, mongo_reply_fields::num, mongo_reply::objs, and mongo_cursor::reply.
Referenced by gridfile_load_from_chunks(), gridfs_remove_filename(), and mongo_find_one().
|
static |
Definition at line 2896 of file mongo.c.
References bson_fatal_msg(), bson_init_finished_data(), mongo_cursor::conn, bson::data, mongo_message::data, data, mongo_cursor::err, mongo_reply::fields, mongo_cursor::fields, mongo_cursor::flags, mongo_message::head, mongo_header::len, mongo_cursor::limit, mongo_clear_errors(), mongo_cursor_bson_valid(), MONGO_CURSOR_QUERY_FAIL, MONGO_CURSOR_QUERY_SENT, mongo_data_append(), mongo_data_append32(), MONGO_ERROR, mongo_message_create(), mongo_message_send(), MONGO_OK, MONGO_OP_QUERY, mongo_read_response(), mongo_set_last_error(), mongo_cursor::ns, mongo_reply_fields::num, mongo_reply::objs, mongo_cursor::options, mongo_cursor::query, mongo_cursor::reply, mongo_cursor::seen, and mongo_cursor::skip.
Referenced by mongo_cursor_next(), and mongo_find().
MONGO_EXPORT void mongo_cursor_set_fields | ( | mongo_cursor * | cursor, |
const bson * | fields | ||
) |
Definition at line 3074 of file mongo.c.
References mongo_cursor::fields, and fields.
Referenced by mongo_find(), and mongo_find_one().
MONGO_EXPORT void mongo_cursor_set_limit | ( | mongo_cursor * | cursor, |
int | limit | ||
) |
Definition at line 3082 of file mongo.c.
References mongo_cursor::limit, and limit.
Referenced by mongo_find(), and mongo_find_one().
MONGO_EXPORT void mongo_cursor_set_options | ( | mongo_cursor * | cursor, |
int | options | ||
) |
Definition at line 3086 of file mongo.c.
References mongo_cursor::options, and options.
Referenced by mongo_find().
MONGO_EXPORT void mongo_cursor_set_query | ( | mongo_cursor * | cursor, |
const bson * | query | ||
) |
Definition at line 3070 of file mongo.c.
References mongo_cursor::query, and query.
Referenced by mongo_find(), and mongo_find_one().
MONGO_EXPORT void mongo_cursor_set_skip | ( | mongo_cursor * | cursor, |
int | skip | ||
) |
Definition at line 3078 of file mongo.c.
References mongo_cursor::skip, and skip.
Referenced by mongo_find().
|
static |
Definition at line 2114 of file mongo.c.
References len.
Referenced by mongo_cursor_get_more(), mongo_cursor_op_query(), mongo_insert(), mongo_insert_batch(), mongo_remove(), and mongo_update().
|
static |
Definition at line 2119 of file mongo.c.
References bson_little_endian32().
Referenced by mongo_cursor_destroy(), mongo_cursor_get_more(), mongo_cursor_op_query(), mongo_insert(), mongo_insert_batch(), mongo_remove(), and mongo_update().
|
static |
Definition at line 2124 of file mongo.c.
References bson_little_endian64().
Referenced by mongo_cursor_destroy(), and mongo_cursor_get_more().
MONGO_EXPORT void mongo_dealloc | ( | mongo * | conn | ) |
MONGO_EXPORT void mongo_destroy | ( | mongo * | conn | ) |
Definition at line 2474 of file mongo.c.
References mongo_replica_set::hosts, mongo_clear_errors(), mongo_disconnect(), mongo_replica_set_free_list(), mongo_replica_set::name, mongo::primary, mongo::replica_set, and mongo_replica_set::seeds.
MONGO_EXPORT void mongo_disconnect | ( | mongo * | conn | ) |
Definition at line 2458 of file mongo.c.
References mongo::connected, mongo_replica_set::hosts, mongo_env_close_socket(), mongo_replica_set_free_list(), mongo_replica_set::primary_connected, mongo::replica_set, and mongo::sock.
Referenced by mongo_destroy(), and mongo_reconnect().
int mongo_env_close_socket | ( | SOCKET | socket | ) |
Definition at line 1591 of file mongo.c.
Referenced by mongo_disconnect(), mongo_env_socket_connect(), mongo_env_unix_socket_connect(), mongo_replica_set_check_host(), mongo_replica_set_check_seed(), and mongo_replica_set_client().
|
static |
Definition at line 1622 of file mongo.c.
References __mongo_set_error(), errno, MONGO_ERROR, MONGO_IO_ERROR, MONGO_OK, and mongo::sock.
Referenced by mongo_read_response().
|
static |
Definition at line 1637 of file mongo.c.
References __mongo_set_error(), mongo::err, errno, MONGO_ERROR, MONGO_IO_ERROR, MONGO_OK, and mongo::sock.
Referenced by mongo_env_socket_connect(), and mongo_set_op_timeout().
|
static |
Definition at line 1595 of file mongo.c.
Referenced by mongo_init_sockets().
|
static |
Definition at line 1685 of file mongo.c.
References __mongo_set_error(), bson_errprintf, bson_sprintf, mongo::connected, mongo::err, errno, INVALID_SOCKET, MONGO_CONN_ADDR_FAIL, MONGO_CONN_FAIL, mongo_env_close_socket(), mongo_env_set_socket_op_timeout(), mongo_env_unix_socket_connect(), MONGO_ERROR, MONGO_IO_ERROR, MONGO_OK, NI_MAXSERV, mongo::op_timeout_ms, and mongo::sock.
Referenced by mongo_client(), mongo_reconnect(), and mongo_replica_set_client().
|
static |
Definition at line 1656 of file mongo.c.
References mongo::connected, mongo::err, INVALID_SOCKET, len, MONGO_CONN_FAIL, mongo_env_close_socket(), MONGO_ERROR, MONGO_OK, and mongo::sock.
Referenced by mongo_env_socket_connect().
|
static |
Definition at line 1599 of file mongo.c.
References __mongo_set_error(), mongo::connected, errno, flags, MONGO_ERROR, MONGO_IO_ERROR, MONGO_OK, and mongo::sock.
Referenced by mongo_message_send().
MONGO_EXPORT mongo_cursor* mongo_find | ( | mongo * | conn, |
const char * | ns, | ||
const bson * | query, | ||
const bson * | fields, | ||
int | limit, | ||
int | skip, | ||
int | options | ||
) |
Definition at line 3022 of file mongo.c.
References mongo_cursor::flags, mongo_cursor_alloc(), mongo_cursor_destroy(), mongo_cursor_init(), MONGO_CURSOR_MUST_FREE, mongo_cursor_op_query(), mongo_cursor_set_fields(), mongo_cursor_set_limit(), mongo_cursor_set_options(), mongo_cursor_set_query(), mongo_cursor_set_skip(), and MONGO_OK.
Referenced by gridfile_get_chunks(), and gridfs_remove_filename().
MONGO_EXPORT int mongo_find_one | ( | mongo * | conn, |
const char * | ns, | ||
const bson * | query, | ||
const bson * | fields, | ||
bson * | out | ||
) |
Definition at line 3043 of file mongo.c.
References mongo_cursor::current, mongo_cursor_destroy(), mongo_cursor_init(), mongo_cursor_next(), mongo_cursor_set_fields(), mongo_cursor_set_limit(), mongo_cursor_set_query(), and MONGO_OK.
Referenced by gridfile_get_chunk(), gridfs_find_query(), mongo_check_last_error(), and mongo_run_command().
MONGO_EXPORT int mongo_get_err | ( | mongo * | conn | ) |
Definition at line 1779 of file mongo.c.
References mongo::err.
MONGO_EXPORT const char* mongo_get_host | ( | mongo * | conn, |
int | i | ||
) |
Definition at line 1826 of file mongo.c.
References _get_host_port(), mongo_replica_set::hosts, mongo_host_port::next, and mongo::replica_set.
MONGO_EXPORT int mongo_get_host_count | ( | mongo * | conn | ) |
Definition at line 1815 of file mongo.c.
References mongo_replica_set::hosts, mongo_host_port::next, and mongo::replica_set.
MONGO_EXPORT int mongo_get_op_timeout | ( | mongo * | conn | ) |
Definition at line 1789 of file mongo.c.
References mongo::op_timeout_ms.
MONGO_EXPORT const char* mongo_get_primary | ( | mongo * | conn | ) |
Definition at line 1801 of file mongo.c.
References _get_host_port(), mongo::connected, mongo_host_port::host, and mongo::primary.
MONGO_EXPORT int mongo_get_server_err | ( | mongo * | conn | ) |
Definition at line 1859 of file mongo.c.
References mongo::lasterrcode.
MONGO_EXPORT const char* mongo_get_server_err_string | ( | mongo * | conn | ) |
Definition at line 1864 of file mongo.c.
References mongo::lasterrstr.
MONGO_EXPORT SOCKET mongo_get_socket | ( | mongo * | conn | ) |
Definition at line 1809 of file mongo.c.
References mongo::sock.
MONGO_EXPORT void mongo_init | ( | mongo * | conn | ) |
Definition at line 2167 of file mongo.c.
References mongo::max_bson_size, MONGO_DEFAULT_MAX_BSON_SIZE, and mongo_set_write_concern().
Referenced by mongo_client(), and mongo_replica_set_init().
MONGO_EXPORT void mongo_init_sockets | ( | void | ) |
Definition at line 2156 of file mongo.c.
References mongo_env_sock_init().
MONGO_EXPORT int mongo_insert | ( | mongo * | conn, |
const char * | ns, | ||
const bson * | bson, | ||
mongo_write_concern * | custom_write_concern | ||
) |
Definition at line 2606 of file mongo.c.
References bson::data, mongo_message::data, data, mongo::err, MONGO_BSON_TOO_LARGE, mongo_bson_valid(), mongo_choose_write_concern(), mongo_data_append(), mongo_data_append32(), MONGO_ERROR, mongo_message_create(), mongo_message_send_and_check_write_concern(), MONGO_OK, MONGO_OP_INSERT, mongo_validate_ns(), and write_concern.
Referenced by mongo_create_index().
MONGO_EXPORT int mongo_insert_batch | ( | mongo * | conn, |
const char * | ns, | ||
const bson ** | bsons, | ||
int | count, | ||
mongo_write_concern * | custom_write_concern, | ||
int | flags | ||
) |
Definition at line 2643 of file mongo.c.
References mongo_message::data, data, mongo::err, i, mongo::max_bson_size, MONGO_BSON_TOO_LARGE, mongo_bson_valid(), mongo_choose_write_concern(), MONGO_CONTINUE_ON_ERROR, mongo_data_append(), mongo_data_append32(), MONGO_ERROR, mongo_message_create(), mongo_message_send_and_check_write_concern(), MONGO_OK, MONGO_OP_INSERT, mongo_validate_ns(), size, and write_concern.
MONGO_EXPORT int mongo_is_connected | ( | mongo * | conn | ) |
Definition at line 1784 of file mongo.c.
References mongo::connected.
|
static |
Definition at line 2022 of file mongo.c.
References mongo_message::head, mongo_header::id, mongo_header::len, mongo_header::op, op, and mongo_header::responseTo.
Referenced by mongo_cursor_destroy(), mongo_cursor_get_more(), mongo_cursor_op_query(), mongo_insert(), mongo_insert_batch(), mongo_remove(), and mongo_update().
|
static |
Definition at line 2042 of file mongo.c.
References bson_little_endian32(), mongo_message::data, mongo_message::head, mongo_header::id, mongo_header::len, mongo_env_write_socket(), MONGO_OK, mongo_header::op, and mongo_header::responseTo.
Referenced by mongo_cursor_destroy(), mongo_cursor_get_more(), mongo_cursor_op_query(), and mongo_message_send_and_check_write_concern().
|
static |
Definition at line 2593 of file mongo.c.
References mongo_check_last_error(), MONGO_ERROR, and mongo_message_send().
Referenced by mongo_insert(), mongo_insert_batch(), mongo_remove(), and mongo_update().
|
static |
Definition at line 1890 of file mongo.c.
Referenced by mongo_check_last_error().
void mongo_parse_host | ( | const char * | host_string, |
mongo_host_port * | host_port | ||
) |
Utility function for converting a host-port string to a mongo_host_port.
host_string | a string containing either a host or a host and port separated by a colon. |
host_port | the mongo_host_port object to write the result to. |
Definition at line 2253 of file mongo.c.
References mongo_host_port::host, len, MONGO_DEFAULT_PORT, and mongo_host_port::port.
Referenced by mongo_replica_set_check_seed().
|
static |
Definition at line 3435 of file mongo.c.
References _free(), mongo::err, MONGO_BSON_TOO_LARGE, MONGO_ERROR, MONGO_OK, PGPHASHALGO_MD5, RPMDIGEST_NONE, rpmDigestFinal(), rpmDigestInit(), and rpmDigestUpdate().
Referenced by mongo_cmd_add_user(), and mongo_cmd_authenticate().
|
static |
Definition at line 2066 of file mongo.c.
References bson_little_endian32(), bson_little_endian64(), mongo_reply_fields::cursorID, mongo_reply::fields, fields, mongo_reply_fields::flag, mongo_reply::head, mongo_header::id, mongo_header::len, len, mongo_env_read_socket(), MONGO_OK, MONGO_READ_SIZE_ERROR, mongo_reply_fields::num, mongo_reply::objs, mongo_header::op, out, mongo_header::responseTo, and mongo_reply_fields::start.
Referenced by mongo_cursor_get_more(), and mongo_cursor_op_query().
MONGO_EXPORT int mongo_reconnect | ( | mongo * | conn | ) |
Definition at line 2436 of file mongo.c.
References mongo_host_port::host, mongo_replica_set::hosts, mongo_disconnect(), mongo_env_socket_connect(), mongo_replica_set_client(), mongo_replica_set_free_list(), mongo_host_port::port, mongo::primary, mongo_replica_set::primary_connected, and mongo::replica_set.
MONGO_EXPORT int mongo_remove | ( | mongo * | conn, |
const char * | ns, | ||
const bson * | cond, | ||
mongo_write_concern * | custom_write_concern | ||
) |
Definition at line 2734 of file mongo.c.
References bson::data, mongo_message::data, data, mongo::err, MONGO_BSON_TOO_LARGE, mongo_bson_valid(), mongo_choose_write_concern(), mongo_data_append(), mongo_data_append32(), MONGO_ERROR, mongo_message_create(), mongo_message_send_and_check_write_concern(), MONGO_OK, MONGO_OP_DELETE, and write_concern.
Referenced by gridfile_remove_chunks(), and gridfs_remove_filename().
|
static |
Definition at line 2215 of file mongo.c.
References mongo_host_port::host, MAXHOSTNAMELEN, mongo_host_port::next, mongo_host_port::port, port, and snprintf().
Referenced by mongo_replica_set_add_seed(), mongo_replica_set_check_seed(), and mongo_replset_add_seed().
MONGO_EXPORT void mongo_replica_set_add_seed | ( | mongo * | conn, |
const char * | host, | ||
int | port | ||
) |
Definition at line 2244 of file mongo.c.
References mongo_replica_set_add_node(), mongo::replica_set, and mongo_replica_set::seeds.
|
static |
Definition at line 2320 of file mongo.c.
References mongo::err, mongo::max_bson_size, MONGO_CONN_BAD_SET_NAME, MONGO_DEFAULT_MAX_BSON_SIZE, mongo_env_close_socket(), MONGO_ERROR, MONGO_OK, mongo_simple_int_command(), mongo_replica_set::name, out, mongo_replica_set::primary_connected, mongo::replica_set, and mongo::sock.
Referenced by mongo_replica_set_client().
|
static |
Definition at line 2278 of file mongo.c.
References mongo::connected, data, mongo_host_port::host, mongo_replica_set::hosts, mongo_env_close_socket(), MONGO_OK, mongo_parse_host(), mongo_replica_set_add_node(), mongo_simple_int_command(), out, mongo_host_port::port, mongo::replica_set, and mongo::sock.
Referenced by mongo_replica_set_client().
MONGO_EXPORT int mongo_replica_set_client | ( | mongo * | conn | ) |
Definition at line 2358 of file mongo.c.
References mongo::connected, mongo::err, mongo_host_port::host, mongo_replica_set::hosts, MAXHOSTNAMELEN, MONGO_CONN_NO_PRIMARY, mongo_env_close_socket(), mongo_env_socket_connect(), MONGO_ERROR, MONGO_OK, mongo_replica_set_check_host(), mongo_replica_set_check_seed(), mongo_host_port::next, mongo_host_port::port, mongo::primary, mongo_replica_set::primary_connected, mongo::replica_set, mongo_replica_set::seeds, snprintf(), and mongo::sock.
Referenced by mongo_reconnect(), and mongo_replset_connect().
|
static |
Definition at line 2231 of file mongo.c.
References mongo_host_port::next.
Referenced by mongo_destroy(), mongo_disconnect(), and mongo_reconnect().
MONGO_EXPORT void mongo_replica_set_init | ( | mongo * | conn, |
const char * | name | ||
) |
Definition at line 2195 of file mongo.c.
References mongo_host_port::host, mongo_replica_set::hosts, mongo_init(), mongo_replica_set::name, mongo_host_port::next, mongo::primary, mongo_replica_set::primary_connected, mongo::replica_set, and mongo_replica_set::seeds.
Referenced by mongo_replset_init().
MONGO_EXPORT void mongo_replset_add_seed | ( | mongo * | conn, |
const char * | host, | ||
int | port | ||
) |
Definition at line 2248 of file mongo.c.
References bson_errprintf, mongo_replica_set_add_node(), mongo::replica_set, and mongo_replica_set::seeds.
MONGO_EXPORT int mongo_replset_connect | ( | mongo * | conn | ) |
Definition at line 2420 of file mongo.c.
References bson_errprintf, mongo_replica_set_client(), and mongo_set_write_concern().
MONGO_EXPORT void mongo_replset_init | ( | mongo * | conn, |
const char * | name | ||
) |
Definition at line 2210 of file mongo.c.
References bson_errprintf, and mongo_replica_set_init().
MONGO_EXPORT int mongo_run_command | ( | mongo * | conn, |
const char * | db, | ||
const bson * | command, | ||
bson * | out | ||
) |
Definition at line 3304 of file mongo.c.
References mongo::err, MONGO_COMMAND_FAILED, MONGO_ERROR, mongo_find_one(), MONGO_OK, and ns.
Referenced by gridfs_insert_file(), mongo_cmd_authenticate(), mongo_count(), mongo_create_capped_collection(), mongo_simple_int_command(), and mongo_simple_str_command().
|
static |
Definition at line 2009 of file mongo.c.
References bson_iterator_string_len(), BSON_NULL, mongo::lasterrcode, mongo::lasterrstr, len, and MONGO_ERR_LEN.
Referenced by mongo_check_last_error(), mongo_cmd_get_error_helper(), and mongo_cursor_op_query().
MONGO_EXPORT int mongo_set_op_timeout | ( | mongo * | conn, |
int | millis | ||
) |
Definition at line 2428 of file mongo.c.
References mongo::connected, millis, mongo_env_set_socket_op_timeout(), MONGO_OK, mongo::op_timeout_ms, and mongo::sock.
MONGO_EXPORT void mongo_set_write_concern | ( | mongo * | conn, |
mongo_write_concern * | write_concern | ||
) |
Definition at line 2844 of file mongo.c.
References mongo::write_concern, and write_concern.
Referenced by mongo_connect(), mongo_init(), and mongo_replset_connect().
MONGO_EXPORT int mongo_simple_int_command | ( | mongo * | conn, |
const char * | db, | ||
const char * | cmdstr, | ||
int | arg, | ||
bson * | out | ||
) |
Definition at line 3335 of file mongo.c.
References cmd, and mongo_run_command().
Referenced by mongo_check_connection(), mongo_check_is_master(), mongo_cmd_authenticate(), mongo_cmd_drop_db(), mongo_cmd_get_error_helper(), mongo_cmd_ismaster(), mongo_cmd_reset_error(), mongo_replica_set_check_host(), and mongo_replica_set_check_seed().
MONGO_EXPORT int mongo_simple_str_command | ( | mongo * | conn, |
const char * | db, | ||
const char * | cmdstr, | ||
const char * | arg, | ||
bson * | out | ||
) |
Definition at line 3352 of file mongo.c.
References cmd, and mongo_run_command().
Referenced by mongo_cmd_drop_collection().
MONGO_EXPORT int mongo_update | ( | mongo * | conn, |
const char * | ns, | ||
const bson * | cond, | ||
const bson * | op, | ||
int | flags, | ||
mongo_write_concern * | custom_write_concern | ||
) |
Definition at line 2693 of file mongo.c.
References bson::data, mongo_message::data, data, mongo::err, MONGO_BSON_TOO_LARGE, mongo_bson_valid(), mongo_choose_write_concern(), mongo_data_append(), mongo_data_append32(), MONGO_ERROR, mongo_message_create(), mongo_message_send_and_check_write_concern(), MONGO_OK, MONGO_OP_UPDATE, and write_concern.
Referenced by gridfile_flush_pendingchunk(), gridfile_write_buffer(), gridfs_insert_file(), and mongo_cmd_add_user().
MONGO_EXPORT int mongo_validate_ns | ( | mongo * | conn, |
const char * | ns | ||
) |
Definition at line 1906 of file mongo.c.
References __mongo_set_error(), bson_sprintf, current, MONGO_ERROR, MONGO_NS_INVALID, MONGO_OK, and ns.
Referenced by mongo_insert(), and mongo_insert_batch().
MONGO_EXPORT mongo_write_concern* mongo_write_concern_alloc | ( | void | ) |
MONGO_EXPORT void mongo_write_concern_dealloc | ( | mongo_write_concern * | write_concern | ) |
MONGO_EXPORT void mongo_write_concern_destroy | ( | mongo_write_concern * | write_concern | ) |
Free the write_concern object (specifically, the BSON object that it holds).
Definition at line 2833 of file mongo.c.
References mongo_write_concern::cmd.
MONGO_EXPORT int mongo_write_concern_finish | ( | mongo_write_concern * | write_concern | ) |
Definition at line 2782 of file mongo.c.
References mongo_write_concern::cmd, command, mongo_write_concern::fsync, mongo_write_concern::j, mongo_write_concern::mode, MONGO_ERROR, MONGO_OK, mongo_write_concern::w, and mongo_write_concern::wtimeout.
MONGO_EXPORT bson* mongo_write_concern_get_cmd | ( | mongo_write_concern * | write_concern | ) |
Definition at line 2870 of file mongo.c.
References mongo_write_concern::cmd.
MONGO_EXPORT int mongo_write_concern_get_fsync | ( | mongo_write_concern * | write_concern | ) |
Definition at line 2862 of file mongo.c.
References mongo_write_concern::fsync.
MONGO_EXPORT int mongo_write_concern_get_j | ( | mongo_write_concern * | write_concern | ) |
Definition at line 2858 of file mongo.c.
References mongo_write_concern::j.
MONGO_EXPORT const char* mongo_write_concern_get_mode | ( | mongo_write_concern * | write_concern | ) |
Definition at line 2866 of file mongo.c.
References mongo_write_concern::mode.
MONGO_EXPORT int mongo_write_concern_get_w | ( | mongo_write_concern * | write_concern | ) |
Definition at line 2850 of file mongo.c.
References mongo_write_concern::w.
MONGO_EXPORT int mongo_write_concern_get_wtimeout | ( | mongo_write_concern * | write_concern | ) |
Definition at line 2854 of file mongo.c.
References mongo_write_concern::wtimeout.
MONGO_EXPORT void mongo_write_concern_init | ( | mongo_write_concern * | write_concern | ) |
MONGO_EXPORT void mongo_write_concern_set_fsync | ( | mongo_write_concern * | write_concern, |
int | fsync | ||
) |
Definition at line 2887 of file mongo.c.
References mongo_write_concern::fsync, and fsync.
MONGO_EXPORT void mongo_write_concern_set_j | ( | mongo_write_concern * | write_concern, |
int | j | ||
) |
Definition at line 2883 of file mongo.c.
References mongo_write_concern::j, and j.
MONGO_EXPORT void mongo_write_concern_set_mode | ( | mongo_write_concern * | write_concern, |
const char * | mode | ||
) |
Definition at line 2892 of file mongo.c.
References mongo_write_concern::mode, and mode.
MONGO_EXPORT void mongo_write_concern_set_w | ( | mongo_write_concern * | write_concern, |
int | w | ||
) |
Definition at line 2874 of file mongo.c.
References mongo_write_concern::w, and w.
MONGO_EXPORT void mongo_write_concern_set_wtimeout | ( | mongo_write_concern * | write_concern, |
int | wtimeout | ||
) |
Definition at line 2878 of file mongo.c.
References mongo_write_concern::wtimeout, and wtimeout.
|
static |
Definition at line 3560 of file mongo.c.
References _rpmmgo_debug, _rpmmgoPool, rpmioGetPool(), rpmioNewPool(), and rpmmgoFini().
Referenced by rpmmgoNew().
rpmmgo rpmmgoNew | ( | const char * | fn, |
int | flags | ||
) |
Create and load a mongo wrapper.
fn | mongo file |
flags | mongo flags |
Definition at line 3576 of file mongo.c.
References rpmmgoGetPool(), rpmmgoLink(), and xstrdup().
int _rpmmgo_debug = 0 |
Definition at line 42 of file mongo.c.
Referenced by rpmmgoGetPool().
rpmmgo _rpmmgoI |
Definition at line 45 of file mongo.c.
Referenced by rpmioClean().
rpmioPool _rpmmgoPool = NULL |
Definition at line 3558 of file mongo.c.
Referenced by rpmioClean(), and rpmmgoGetPool().
|
static |
Definition at line 521 of file mongo.c.
Referenced by gridfile_writer_init().
|
static |
Definition at line 520 of file mongo.c.
Referenced by gridfile_fill_buf_from_chunk(), and gridfile_load_pending_data_with_pos_chunk().
|
static |
Definition at line 519 of file mongo.c.
Referenced by chunk_new().
|
static |
Definition at line 49 of file mongo.c.
Referenced by orderListIndexCmp(), rpmHeadersIdentical(), and rpmVersionCompare().
|
static |
|
static |
|
static |
|
static |
Definition at line 2020 of file mongo.c.
Referenced by rpmgitCmdStatus().