summaryrefslogtreecommitdiff
path: root/src/modules/json/json.cpp
blob: 267775e4eb9ae13649df134991f295367faca28e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*

Miranda IM: the free IM client for Microsoft* Windows*

Copyright 2000-12 Miranda IM, 2012-13 Miranda NG project,
all portions of this codebase are copyrighted to the people
listed in contributors.txt.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#include "..\..\core\commonheaders.h"
#include <m_json.h>

#include "libJSON.h"

///////////////////////////////////////////////////////////////////////////////
// Interface function

INT_PTR GetInterface(WPARAM wParam, LPARAM lParam)
{
	LPJSONSERVICEINTERFACE lpJSI = (LPJSONSERVICEINTERFACE)wParam;
	memset(lpJSI,0,sizeof(JSONSERVICEINTERFACE));

#define SETJSI(x) lpJSI->##x = json_##x
	SETJSI(free);
	lpJSI->delete_ = json_delete;
#ifdef JSON_MEMORY_MANAGE
	SETJSI(free_all);
	SETJSI(delete_all);
#endif
	SETJSI(parse);
	SETJSI(strip_white_space);
#ifdef JSON_VALIDATE
	SETJSI(validate);
#endif
	SETJSI(new_a);
	SETJSI(new_i);
	SETJSI(new_f);
	SETJSI(new_b);
	lpJSI->new_ = json_new;
	SETJSI(copy);
	SETJSI(duplicate);
	SETJSI(set_a);
	SETJSI(set_i);
	SETJSI(set_f);
	SETJSI(set_b);
	SETJSI(set_n);
	SETJSI(type);
	SETJSI(size);
	SETJSI(empty);
	SETJSI(name);
#ifdef JSON_COMMENTS
	SETJSI(get_comment);
#endif
	SETJSI(as_string);
	SETJSI(as_int);
	SETJSI(as_float);
	SETJSI(as_bool);
	SETJSI(as_node);
	SETJSI(as_array);
	#ifdef JSON_BINARY
	SETJSI(as_binary);
	#endif
	#ifdef JSON_WRITER
	SETJSI(write);
	SETJSI(write_formatted);
	#endif
	SETJSI(set_name);
	#ifdef JSON_COMMENTS
	SETJSI(set_comment);
	#endif
	SETJSI(clear);
	SETJSI(nullify);
	SETJSI(swap);
	SETJSI(merge);
	#ifndef JSON_PREPARSE
	SETJSI(preparse);
	#endif
	#ifdef JSON_BINARY
	SETJSI(set_binary);
	#endif
	SETJSI(cast);

	//children access
	SETJSI(reserve);
	SETJSI(at);
	SETJSI(get);
	#ifdef JSON_CASE_INSENSITIVE_FUNCTIONS
	SETJSI(get_nocase);
	SETJSI(pop_back_nocase);
	#endif
	SETJSI(push_back);
	SETJSI(pop_back_at);
	SETJSI(pop_back);
	#ifdef JSON_ITERATORS
	SETJSI(find);
	#ifdef JSON_CASE_INSENSITIVE_FUNCTIONS
	SETJSI(find_nocase);
	#endif
	SETJSI(erase);
	SETJSI(erase_multi);
	SETJSI(insert);
	SETJSI(insert_multi);

	//iterator functions
	SETJSI(begin);
	SETJSI(end);
	#endif

	SETJSI(equal);

	return 0;
}

int InitJson()
{
	CreateServiceFunction(MS_JSON_GETINTERFACE,GetInterface);

	json_register_memory_callbacks((json_malloc_t)mir_alloc,(json_realloc_t)mir_realloc,(json_free_t)mir_free);
	return 0;
}