Nyx Node
Toggle main menu visibility
Loading...
Searching...
No Matches
indi_message.c
1
/* NyxNode
2
* Author: Jérôme ODIER <jerome.odier@lpsc.in2p3.fr>
3
* SPDX-License-Identifier: GPL-2.0-only (Mongoose backend) or GPL-3.0+
4
*/
5
6
/*--------------------------------------------------------------------------------------------------------------------*/
7
8
#include "../nyx_node_internal.h"
9
10
/*--------------------------------------------------------------------------------------------------------------------*/
11
12
nyx_dict_t
*nyx_message_new(
STR_t
device,
STR_t
message)
13
{
14
if
(message == NULL)
15
{
16
message =
""
;
17
}
18
19
/*----------------------------------------------------------------------------------------------------------------*/
20
21
nyx_dict_t
*result = nyx_dict_new();
22
23
/*----------------------------------------------------------------------------------------------------------------*/
24
25
char
timestamp[32];
26
27
internal_get_timestamp(
sizeof
(timestamp), timestamp);
28
29
/*----------------------------------------------------------------------------------------------------------------*/
30
31
nyx_dict_set_string_unref(result,
"<>"
,
"message"
,
false
);
32
33
/*----------------------------------------------------------------------------------------------------------------*/
34
35
nyx_dict_set_string_unref(result,
"@client"
,
"unknown"
,
false
);
36
nyx_dict_set_string_unref(result,
"@device"
,
nyx_string_dup
(device),
true
);
37
nyx_dict_set_string_unref(result,
"@message"
,
nyx_string_dup
(message),
true
);
38
nyx_dict_set_string_unref(result,
"@timestamp"
,
nyx_string_dup
(timestamp),
true
);
39
40
/*----------------------------------------------------------------------------------------------------------------*/
41
42
return
result;
43
}
44
45
/*--------------------------------------------------------------------------------------------------------------------*/
nyx_dict_t
Struct describing a JSON dict object.
STR_t
#define STR_t
Alias for const char *.
Definition
nyx_node.h:71
nyx_string_dup
__NYX_NULLABLE__ str_t nyx_string_dup(__NYX_NULLABLE__ STR_t s)
Similar to libc strdup.
Author:
Jérôme ODIER
License:
LGPL-3.0-or-later
Copyright:
LPSC / CNRS