1
/* Libee - An Event Expression Library inspired by CEE
2
* Copyright 2010 by Rainer Gerhards and Adiscon GmbH.
4
* This file is part of libee.
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
* A copy of the LGPL v2.1 can be found in the file "COPYING" in this distribution.
27
#include "libee/libee.h"
28
#include "libee/internal.h"
29
#include "libee/ctx.h"
31
#define ERR_ABORT {r = 1; goto done; }
34
if(ctx->objID != ObjID_CTX) { \
50
if((ctx = calloc(1, sizeof(struct ee_ctx_s))) == NULL)
53
ctx->objID = ObjID_CTX;
55
ctx->tagBucketSize = EE_DFLT_TAG_BCKT_SIZE;
56
ctx->fieldBucketSize = EE_DFLT_FIELD_BCKT_SIZE;
63
ee_exitCtx(ee_ctx ctx)
69
ctx->objID = ObjID_None; /* prevent double free */
77
ee_setDebugCB(ee_ctx ctx, void (*cb)(void*, char*, size_t), void *cookie)
83
ctx->dbgCookie = cookie;
90
* Generate some debug message and call the caller provided callback.
92
* Will first check if a user callback is registered. If not, returns
96
ee_dbgprintf(ee_ctx ctx, char *fmt, ...)
102
if(ctx->dbgCB == NULL)
106
lenBuf = vsnprintf(buf, sizeof(buf), fmt, ap);
108
if(lenBuf >= sizeof(buf)) {
109
/* prevent buffer overrruns and garbagge display */
110
buf[sizeof(buf) - 5] = '.';
111
buf[sizeof(buf) - 4] = '.';
112
buf[sizeof(buf) - 3] = '.';
113
buf[sizeof(buf) - 2] = '\n';
114
buf[sizeof(buf) - 1] = '\0';
115
lenBuf = sizeof(buf) - 1;
118
ctx->dbgCB(ctx->dbgCookie, buf, lenBuf);