3
* Decoder for JSON format.
4
*//* Libee - An Event Expression Library inspired by CEE
5
* Copyright 2012 by Rainer Gerhards and Adiscon GmbH.
7
* This file is part of libee.
9
* This library is free software; you can redistribute it and/or
10
* modify it under the terms of the GNU Lesser General Public
11
* License as published by the Free Software Foundation; either
12
* version 2.1 of the License, or (at your option) any later version.
14
* This library is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
* Lesser General Public License for more details.
19
* You should have received a copy of the GNU Lesser General Public
20
* License along with this library; if not, write to the Free Software
21
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
* A copy of the LGPL v2.1 can be found in the file "COPYING" in this distribution.
31
#include "libee/libee.h"
32
#include "libee/internal.h"
38
* @returns 0 on success, something else otherwise.
41
processLn(ee_ctx ctx, es_str_t *ln,
42
int (*cbNewEvt)(struct ee_event *event))
45
struct ee_event *event;
48
str = es_str2cstr(ln, NULL);
49
CHKN(event = ee_newEventFromJSON(ctx, str));
51
CHKR(cbNewEvt(event));
59
ee_jsonDec(ee_ctx ctx, int (*cbGetLine)(es_str_t **ln),
60
int (*cbNewEvt)(struct ee_event *event),
72
if((r = processLn(ctx, ln, cbNewEvt)) != 0) {
73
errlen = snprintf(errMsgBuf, sizeof(errMsgBuf),
74
"error processing line %d", lnNbr);
75
*errMsg = es_newStrFromCStr(errMsgBuf, errlen);
82
/* when we are done with the file, we need to check if there are
83
* any objects to submit (usually there are!)