~ubuntu-branches/debian/sid/openchange/sid

« back to all changes in this revision

Viewing changes to mapiproxy/libmapistore/mapistore_tdb_wrap.c

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2012-04-12 20:07:57 UTC
  • mfrom: (11 sid)
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20120412200757-k933d9trljmxj1l4
Tags: 1:1.0-4
* openchangeserver: Add dependency on openchangeproxy.
* Rebuild against newer version of Samba 4.
* Use dpkg-buildflags.
* Migrate to Git, update Vcs-Git header.
* Switch to debhelper 9.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
20
*/
21
21
 
22
 
#include "mapistore_errors.h"
 
22
#include "config.h"
 
23
#include <stdio.h>
 
24
#include <string.h>
 
25
 
23
26
#include "mapistore.h"
24
27
#include "mapistore_private.h"
25
28
#include <dlinklist.h>
26
29
 
27
 
#include <stdio.h>
28
 
#include <string.h>
29
 
 
30
30
static struct tdb_wrap *tdb_list;
31
31
 
32
32
/* destroy the last connection to a tdb */
33
 
static int tdb_wrap_destructor(struct tdb_wrap *w)
 
33
static int mapistore_tdb_wrap_destructor(struct tdb_wrap *w)
34
34
{
35
35
        tdb_close(w->tdb);
36
36
        DLIST_REMOVE(tdb_list, w);
40
40
/*
41
41
 Log tdb messages via DEBUG().
42
42
*/
43
 
static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, 
44
 
                         const char *format, ...) PRINTF_ATTRIBUTE(3,4);
 
43
static void mapistore_tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, 
 
44
                                   const char *format, ...) PRINTF_ATTRIBUTE(3,4);
45
45
 
46
 
static void tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, 
47
 
                         const char *format, ...)
 
46
static void mapistore_tdb_wrap_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, 
 
47
                                   const char *format, ...)
48
48
{
49
49
        va_list ap;
50
50
        char    *ptr = NULL;
51
51
        int     dl;
52
 
        int     ret;
53
52
 
54
53
        va_start(ap, format);
55
 
        ret = vasprintf(&ptr, format, ap);
 
54
        vasprintf(&ptr, format, ap);
56
55
        va_end(ap);
57
56
        
58
57
        switch (level) {
95
94
   \return pointer to an allocated tdb_wrap structure on success,
96
95
   otherwise NULL
97
96
 */
98
 
struct tdb_wrap *tdb_wrap_open(TALLOC_CTX *mem_ctx, const char *name, 
99
 
                               int hash_size, int tdb_flags,
100
 
                               int open_flags, mode_t mode)
 
97
struct tdb_wrap *mapistore_tdb_wrap_open(TALLOC_CTX *mem_ctx, const char *name, 
 
98
                                         int hash_size, int tdb_flags,
 
99
                                         int open_flags, mode_t mode)
101
100
{
102
101
        struct tdb_wrap                 *w;
103
102
        struct tdb_logging_context      log_ctx;
104
103
 
105
 
        log_ctx.log_fn = tdb_wrap_log;
 
104
        log_ctx.log_fn = mapistore_tdb_wrap_log;
106
105
 
107
106
        for (w = tdb_list; w; w = w->next) {
108
107
                if (strcmp(name, w->name) == 0) {
124
123
                return NULL;
125
124
        }
126
125
 
127
 
        talloc_set_destructor(w, tdb_wrap_destructor);
 
126
        talloc_set_destructor(w, mapistore_tdb_wrap_destructor);
128
127
 
129
128
        DLIST_ADD(tdb_list, w);
130
129