mirror of
https://github.com/json-c/json-c.git
synced 2026-04-11 00:09:06 +08:00
* Fix bug in escaping of control characters
Johan Bj�rklund, johbjo09 at kth dot se
* Remove include "config.h" from headers (should only
be included from .c files)
Michael Clark <michael@metaparadigm.com>
git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@12 327403b1-1117-474d-bef2-5cb71233fd97
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
0.6
|
||||||
|
* Fix bug in escaping of control characters
|
||||||
|
Johan Bj<42>rklund, johbjo09 at kth dot se
|
||||||
|
* Remove include "config.h" from headers (should only
|
||||||
|
be included from .c files)
|
||||||
|
Michael Clark <michael@metaparadigm.com>
|
||||||
|
|
||||||
0.5
|
0.5
|
||||||
* Make headers C++ compatible by change *this to *obj
|
* Make headers C++ compatible by change *this to *obj
|
||||||
* Add ifdef C++ extern "C" to headers
|
* Add ifdef C++ extern "C" to headers
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h2>JSON-C - A JSON implementation in C</h2>
|
<h2>JSON-C - A JSON implementation in C</h2>
|
||||||
<p>Latest release: <a href="json-c-0.5.tar.gz">json-c-0.5.tar.gz</a></p>
|
<p>Latest release: <a href="json-c-0.6.tar.gz">json-c-0.6.tar.gz</a></p>
|
||||||
<p>JSON-C implements a reference counting object model that allows you to easily
|
<p>JSON-C implements a reference counting object model that allows you to easily
|
||||||
construct JSON objects in C, output them as JSON formatted strings and parse
|
construct JSON objects in C, output them as JSON formatted strings and parse
|
||||||
JSON formatted strings back into the C representation of JSON objects.</p>
|
JSON formatted strings back into the C representation of JSON objects.</p>
|
||||||
|
|||||||
13
bits.h
13
bits.h
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: bits.h,v 1.9 2006/01/26 02:16:28 mclark Exp $
|
* $Id: bits.h,v 1.10 2006/01/30 23:07:57 mclark Exp $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
||||||
* Michael Clark <michael@metaparadigm.com>
|
* Michael Clark <michael@metaparadigm.com>
|
||||||
@@ -12,17 +12,6 @@
|
|||||||
#ifndef _bits_h_
|
#ifndef _bits_h_
|
||||||
#define _bits_h_
|
#define _bits_h_
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#if STDC_HEADERS
|
|
||||||
# include <stddef.h>
|
|
||||||
#endif /* STDC_HEADERS */
|
|
||||||
|
|
||||||
/* CAW: wrapped in ifndef's to make win32 compliant
|
|
||||||
** this fails to take over GCC specifics, but this
|
|
||||||
** seems to be unimportant.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef min
|
#ifndef min
|
||||||
#define min(a,b) ((a) < (b) ? (a) : (b))
|
#define min(a,b) ((a) < (b) ? (a) : (b))
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
10
debug.h
10
debug.h
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: debug.h,v 1.4 2006/01/26 02:16:28 mclark Exp $
|
* $Id: debug.h,v 1.5 2006/01/30 23:07:57 mclark Exp $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
||||||
* Michael Clark <michael@metaparadigm.com>
|
* Michael Clark <michael@metaparadigm.com>
|
||||||
@@ -12,14 +12,6 @@
|
|||||||
#ifndef _DEBUG_H_
|
#ifndef _DEBUG_H_
|
||||||
#define _DEBUG_H_
|
#define _DEBUG_H_
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#if HAVE_STRERROR
|
|
||||||
#define errstr strerror(errno)
|
|
||||||
#else /* !HAVE_STRERROR */
|
|
||||||
#define errstr
|
|
||||||
#endif /* HAVE_STRERROR */
|
|
||||||
|
|
||||||
extern void mc_set_debug(int debug);
|
extern void mc_set_debug(int debug);
|
||||||
extern int mc_get_debug();
|
extern int mc_get_debug();
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: json_object.c,v 1.14 2006/01/26 02:16:28 mclark Exp $
|
* $Id: json_object.c,v 1.15 2006/01/30 23:07:57 mclark Exp $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
||||||
* Michael Clark <michael@metaparadigm.com>
|
* Michael Clark <michael@metaparadigm.com>
|
||||||
@@ -23,6 +23,10 @@
|
|||||||
#include "json_object_private.h"
|
#include "json_object_private.h"
|
||||||
#include "json_tokener.h"
|
#include "json_tokener.h"
|
||||||
|
|
||||||
|
#if !HAVE_STRNDUP
|
||||||
|
char* strndup(const char* str, size_t n);
|
||||||
|
#endif /* !HAVE_STRNDUP */
|
||||||
|
|
||||||
/* #define REFCOUNT_DEBUG 1 */
|
/* #define REFCOUNT_DEBUG 1 */
|
||||||
|
|
||||||
char *json_number_chars = "0123456789.+-e";
|
char *json_number_chars = "0123456789.+-e";
|
||||||
@@ -78,10 +82,12 @@ static void json_object_fini() {
|
|||||||
static int json_escape_str(struct printbuf *pb, char *str)
|
static int json_escape_str(struct printbuf *pb, char *str)
|
||||||
{
|
{
|
||||||
int pos = 0, start_offset = 0;
|
int pos = 0, start_offset = 0;
|
||||||
char c;
|
unsigned char c;
|
||||||
do {
|
do {
|
||||||
c = str[pos];
|
c = str[pos];
|
||||||
switch(c) {
|
switch(c) {
|
||||||
|
case '\0':
|
||||||
|
break;
|
||||||
case '\b':
|
case '\b':
|
||||||
case '\n':
|
case '\n':
|
||||||
case '\r':
|
case '\r':
|
||||||
@@ -97,14 +103,14 @@ static int json_escape_str(struct printbuf *pb, char *str)
|
|||||||
start_offset = ++pos;
|
start_offset = ++pos;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if(c && c < ' ') {
|
if(c < ' ') {
|
||||||
if(pos - start_offset > 0)
|
if(pos - start_offset > 0)
|
||||||
printbuf_memappend(pb, str + start_offset, pos - start_offset);
|
printbuf_memappend(pb, str + start_offset, pos - start_offset);
|
||||||
sprintbuf(pb, "\\u00%c%c",
|
sprintbuf(pb, "\\u00%c%c",
|
||||||
json_hex_chars[c >> 4],
|
json_hex_chars[c >> 4],
|
||||||
json_hex_chars[c & 0xf]);
|
json_hex_chars[c & 0xf]);
|
||||||
start_offset = ++pos;
|
start_offset = ++pos;
|
||||||
} else if(c) pos++;
|
} else pos++;
|
||||||
}
|
}
|
||||||
} while(c);
|
} while(c);
|
||||||
if(pos - start_offset > 0)
|
if(pos - start_offset > 0)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: json_object.h,v 1.11 2006/01/26 02:16:28 mclark Exp $
|
* $Id: json_object.h,v 1.12 2006/01/30 23:07:57 mclark Exp $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
||||||
* Michael Clark <michael@metaparadigm.com>
|
* Michael Clark <michael@metaparadigm.com>
|
||||||
@@ -12,8 +12,6 @@
|
|||||||
#ifndef _json_object_h_
|
#ifndef _json_object_h_
|
||||||
#define _json_object_h_
|
#define _json_object_h_
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#define JSON_OBJECT_DEF_HASH_ENTIRES 16
|
#define JSON_OBJECT_DEF_HASH_ENTIRES 16
|
||||||
|
|
||||||
#undef FALSE
|
#undef FALSE
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: json_tokener.c,v 1.18 2006/01/26 02:16:28 mclark Exp $
|
* $Id: json_tokener.c,v 1.19 2006/01/30 23:07:57 mclark Exp $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
||||||
* Michael Clark <michael@metaparadigm.com>
|
* Michael Clark <michael@metaparadigm.com>
|
||||||
@@ -23,6 +23,14 @@
|
|||||||
#include "json_object.h"
|
#include "json_object.h"
|
||||||
#include "json_tokener.h"
|
#include "json_tokener.h"
|
||||||
|
|
||||||
|
#if !HAVE_STRNCASECMP && defined(_MSC_VER)
|
||||||
|
/* MSC has the version as _strnicmp */
|
||||||
|
# define strncasecmp _strnicmp
|
||||||
|
#elif !HAVE_STRNCASECMP
|
||||||
|
# error You do not have strncasecmp on your system.
|
||||||
|
#endif /* HAVE_STRNCASECMP */
|
||||||
|
|
||||||
|
|
||||||
static struct json_object* json_tokener_do_parse(struct json_tokener *this);
|
static struct json_object* json_tokener_do_parse(struct json_tokener *this);
|
||||||
|
|
||||||
struct json_object* json_tokener_parse(char * s)
|
struct json_object* json_tokener_parse(char * s)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: json_tokener.h,v 1.8 2006/01/26 02:16:28 mclark Exp $
|
* $Id: json_tokener.h,v 1.9 2006/01/30 23:07:57 mclark Exp $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
||||||
* Michael Clark <michael@metaparadigm.com>
|
* Michael Clark <michael@metaparadigm.com>
|
||||||
@@ -12,7 +12,6 @@
|
|||||||
#ifndef _json_tokener_h_
|
#ifndef _json_tokener_h_
|
||||||
#define _json_tokener_h_
|
#define _json_tokener_h_
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "json_object.h"
|
#include "json_object.h"
|
||||||
|
|
||||||
enum json_tokener_error {
|
enum json_tokener_error {
|
||||||
@@ -59,17 +58,6 @@ struct json_tokener
|
|||||||
struct printbuf *pb;
|
struct printbuf *pb;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !HAVE_STRNCASECMP && defined(_MSC_VER)
|
|
||||||
/* MSC has the version as _strnicmp */
|
|
||||||
# define strncasecmp _strnicmp
|
|
||||||
#elif !HAVE_STRNCASECMP
|
|
||||||
# error You do not have strncasecmp on your system.
|
|
||||||
#endif /* HAVE_STRNCASECMP */
|
|
||||||
|
|
||||||
#if !HAVE_STRNDUP
|
|
||||||
char* strndup(const char* str, size_t n);
|
|
||||||
#endif /* !HAVE_STRNDUP */
|
|
||||||
|
|
||||||
extern struct json_object* json_tokener_parse(char *s);
|
extern struct json_object* json_tokener_parse(char *s);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: json_util.c,v 1.3 2006/01/26 02:16:28 mclark Exp $
|
* $Id: json_util.c,v 1.4 2006/01/30 23:07:57 mclark Exp $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
||||||
* Michael Clark <michael@metaparadigm.com>
|
* Michael Clark <michael@metaparadigm.com>
|
||||||
@@ -39,6 +39,11 @@
|
|||||||
# include <io.h>
|
# include <io.h>
|
||||||
#endif /* defined(WIN32) */
|
#endif /* defined(WIN32) */
|
||||||
|
|
||||||
|
#if !HAVE_OPEN && defined(WIN32)
|
||||||
|
# define open _open
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include "bits.h"
|
#include "bits.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "printbuf.h"
|
#include "printbuf.h"
|
||||||
|
|||||||
14
json_util.h
14
json_util.h
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: json_util.h,v 1.3 2006/01/26 02:16:28 mclark Exp $
|
* $Id: json_util.h,v 1.4 2006/01/30 23:07:57 mclark Exp $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
||||||
* Michael Clark <michael@metaparadigm.com>
|
* Michael Clark <michael@metaparadigm.com>
|
||||||
@@ -12,20 +12,8 @@
|
|||||||
#ifndef _json_util_h_
|
#ifndef _json_util_h_
|
||||||
#define _json_util_h_
|
#define _json_util_h_
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
# define WIN32_LEAN_AND_MEAN
|
|
||||||
# include <windows.h>
|
|
||||||
# include <io.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "json_object.h"
|
#include "json_object.h"
|
||||||
|
|
||||||
#if !HAVE_OPEN && defined(WIN32)
|
|
||||||
# define open _open
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define JSON_FILE_BUF_SIZE 4096
|
#define JSON_FILE_BUF_SIZE 4096
|
||||||
|
|
||||||
/* utlitiy functions */
|
/* utlitiy functions */
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: linkhash.h,v 1.5 2006/01/26 02:16:28 mclark Exp $
|
* $Id: linkhash.h,v 1.6 2006/01/30 23:07:57 mclark Exp $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
* Copyright (c) 2004, 2005 Metaparadigm Pte. Ltd.
|
||||||
* Michael Clark <michael@metaparadigm.com>
|
* Michael Clark <michael@metaparadigm.com>
|
||||||
@@ -12,8 +12,6 @@
|
|||||||
#ifndef _linkhash_h_
|
#ifndef _linkhash_h_
|
||||||
#define _linkhash_h_
|
#define _linkhash_h_
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* golden prime used in hash functions
|
* golden prime used in hash functions
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user