From 240b769d44fe6c50cabbf311f8e9fb1fae7cd80e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 23 Jun 2012 17:15:01 +0000 Subject: libjson interface added to the core git-svn-id: http://svn.miranda-ng.org/main/trunk@573 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/json/json.cpp | 134 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 src/modules/json/json.cpp (limited to 'src/modules/json/json.cpp') diff --git a/src/modules/json/json.cpp b/src/modules/json/json.cpp new file mode 100644 index 0000000000..ee71ee4ef7 --- /dev/null +++ b/src/modules/json/json.cpp @@ -0,0 +1,134 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM 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 + +#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; +} -- cgit v1.2.3