aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2020-11-13 19:49:15 +0100
committerToni Uhlig <matzeton@googlemail.com>2020-11-13 19:55:54 +0100
commita03e0c8ba8c9230a3890d6fbd813fcf051086e7f (patch)
tree9ff50e41fb0720ad75332993cd54defba137237c /examples
parentaac0e77a2c050995f921e39e9927098c5f7054a4 (diff)
Fixed inconsistent callback function call if a token parsed.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/c-captured/c-captured.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/examples/c-captured/c-captured.c b/examples/c-captured/c-captured.c
index 8b6785aea..d2ca51c2c 100644
--- a/examples/c-captured/c-captured.c
+++ b/examples/c-captured/c-captured.c
@@ -17,7 +17,16 @@ static enum nDPIsrvd_callback_return nDPIsrvd_json_callback(struct nDPIsrvd_sock
{
(void)user_data;
- if (sock->jsmn.current_token % 2 == 1)
+ if (sock->jsmn.current_token == 0) {
+ /* Start of a JSON string. */
+ printf("JSON ");
+ }
+ else if (sock->jsmn.current_token == sock->jsmn.tokens_found)
+ {
+ /* End of a JSON string. */
+ printf(" EoF\n");
+ }
+ else if (sock->jsmn.current_token % 2 == 1)
{
printf("[%.*s : ",
sock->jsmn.tokens[sock->jsmn.current_token].end - sock->jsmn.tokens[sock->jsmn.current_token].start,
@@ -68,7 +77,6 @@ int main(int argc, char ** argv)
default:
break;
}
- printf("EoF\n");
}
return 0;