1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
/**
* Copyright (C) 2014 Daniel-Constantin Mierla (asipto.com)
*
* This file is part of Kamailio, a free SIP server.
*
* Kamailio is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version
*
* Kamailio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef _MONGODB_CLIENT_H_
#define _MONGODB_CLIENT_H_
#include <mongoc.h>
#include <bson.h>
#include "../../str.h"
#include "../../parser/parse_param.h"
#include "../../mod_fix.h"
int mongodbc_init(void);
int mongodbc_destroy(void);
int mongodbc_add_server(char *spec);
int mongodbc_exec_simple(str *srv, str *dname, str *cname, str *cmd, str *res);
int mongodbc_exec(str *srv, str *dname, str *cname, str *cmd, str *res);
int mongodbc_find(str *srv, str *dname, str *cname, str *cmd, str *res);
typedef struct mongodbc_server {
str *sname;
str *uri;
unsigned int hname;
param_t *attrs;
mongoc_client_t *client;
struct mongodbc_server *next;
} mongodbc_server_t;
typedef struct mongodbc_reply {
str rname;
unsigned int hname;
mongoc_collection_t *collection;
mongoc_cursor_t *cursor;
str jsonrpl;
struct mongodbc_reply *next;
} mongodbc_reply_t;
typedef struct mongodbc_pv {
str rname;
mongodbc_reply_t *reply;
str rkey;
int rkeyid;
} mongodbc_pv_t;
/* Server related functions */
mongodbc_server_t* mongodbc_get_server(str *name);
int mongodbc_reconnect_server(mongodbc_server_t *rsrv);
/* Command related functions */
mongodbc_reply_t *mongodbc_get_reply(str *name);
int mongodbc_free_reply(str *name);
int mongodbc_next_reply(str *name);
#endif
|