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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/*
* This program 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.
*
* This program 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 St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* $Id$
*
* @brief Couchbase wrapper function prototypes and datatypes.
* @file couchbase.h
*
* @author Aaron Hurt <ahurt@anbcs.com>
* @copyright 2013-2014 The FreeRADIUS Server Project.
*/
#ifndef _couchbase_h_
#define _couchbase_h_
RCSIDH(couchbase_h, "$Id$")
#ifdef HAVE_WDOCUMENTATION
DIAG_OFF(documentation)
#endif
#include <libcouchbase/couchbase.h>
#ifdef HAVE_WDOCUMENTATION
DIAG_ON(documentation)
#endif
#include "jsonc_missing.h"
/** Information relating to the parsing of Couchbase document payloads
*
* This structure holds various references to json-c objects used when parsing
* Couchbase document payloads.
*/
typedef struct cookie_t {
json_object *jobj; //!< JSON objects handled by the json-c library.
json_tokener *jtok; //!< JSON tokener objects handled by the json-c library.
enum json_tokener_error jerr; //!< Error values produced by the json-c library.
} cookie_t;
/** Union of constant and non-constant pointers
*
* This is used to squelch compiler warnings about casting when passing data
* between functions expecting different data types.
*/
typedef union cookie_u {
const void *cdata; //!< Constant pointer to cookie payload (@p cookie_t).
void *data; //!< Non-constant pointer to data payload (@p cookie_t).
} cookie_u;
/* couchbase statistics callback */
void couchbase_stat_callback(lcb_t instance, const void *cookie, lcb_error_t error,
const lcb_server_stat_resp_t *resp);
/* store a key/document in couchbase */
void couchbase_store_callback(lcb_t instance, const void *cookie, lcb_storage_t operation,
lcb_error_t error, const lcb_store_resp_t *item);
/* get a document by key from couchbase */
void couchbase_get_callback(lcb_t instance, const void *cookie, lcb_error_t error,
const lcb_get_resp_t *item);
/* couchbase http callback for data chunks */
void couchbase_http_data_callback(lcb_http_request_t request, lcb_t instance,
const void *cookie, lcb_error_t error, const lcb_http_resp_t *resp);
/* create a couchbase instance and connect to the cluster */
lcb_error_t couchbase_init_connection(lcb_t *instance, const char *host, const char *bucket, const char *pass);
/* get server statistics */
lcb_error_t couchbase_server_stats(lcb_t instance, const void *cookie);
/* store document/key in couchbase */
lcb_error_t couchbase_set_key(lcb_t instance, const char *key, const char *document, int expire);
/* pull document from couchbase by key */
lcb_error_t couchbase_get_key(lcb_t instance, const void *cookie, const char *key);
/* query a couchbase view via http */
lcb_error_t couchbase_query_view(lcb_t instance, const void *cookie, const char *path, const char *post);
#endif /* _couchbase_h_ */
|