1 /*
2 BAREOS® - Backup Archiving REcovery Open Sourced
3
4 Copyright (C) 2015-2019 Bareos GmbH & Co. KG
5
6 This program is Free Software; you can redistribute it and/or
7 modify it under the terms of version three of the GNU Affero General Public
8 License as published by the Free Software Foundation and included
9 in the file LICENSE.
10
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Affero General Public License for more details.
15
16 You should have received a copy of the GNU Affero General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301, USA.
20 */
21
22 /*
23 * JSON Glue layer.
24 *
25 * This file is the glue between JANSSON and BAREOS.
26 *
27 * Joerg Steffens, April 2015
28 */
29
30 #define NEED_JANSSON_NAMESPACE 1
31 #include "include/bareos.h"
32 #include "lib/output_formatter.h"
33
34 #if HAVE_JANSSON
35 static pthread_once_t json_setup = PTHREAD_ONCE_INIT;
36
json_malloc(size_t size)37 static void* json_malloc(size_t size) { return malloc(size); }
38
json_free(void * ptr)39 static void json_free(void* ptr) { free(ptr); }
40
set_alloc_funcs()41 static void set_alloc_funcs() { json_set_alloc_funcs(json_malloc, json_free); }
42
InitializeJson()43 void InitializeJson() { pthread_once(&json_setup, set_alloc_funcs); }
44 #else
InitializeJson()45 void InitializeJson() {}
46 #endif /* HAVE_JANSSON */
47