Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kdopen rename library #493

Closed
wants to merge 49 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
9885b30
Perform better error checking in json_tokener_parse_verbose and rewri…
hawicz Mar 31, 2012
d7db7e8
Ignore several more files, include .o's, .lo's, etc...
hawicz Mar 31, 2012
e6668b1
Adjust json_object_is_type and json_object_get_type so they return js…
hawicz Mar 31, 2012
7c4a964
Define a LH_LOAD_FACTOR constant and note the range that it can be se…
hawicz Mar 31, 2012
23d0da5
Mention json_type_to_name() in the docs for json_object_get_type().
hawicz Apr 1, 2012
bb7978c
For the prototype for json_tokener_error_desc().
hawicz Apr 1, 2012
30c6c4a
Split the json_tokener_parse tests off from test1 into their own test…
hawicz Apr 1, 2012
f30a9ac
Fix a bug in json_tokener_parse_ex when re-using the same tokener to …
hawicz Apr 1, 2012
a7bd85c
Remove a few more things in the distclean target to get rid of *all* …
hawicz Apr 1, 2012
2b5929b
Direct people to send bug reports to the json-c google group.
hawicz Apr 1, 2012
8310d36
Add a printbuf_memset() function to provide an effecient way to set a…
hawicz Apr 2, 2012
7f3298d
Remove the "#undef PRINTBUF_DEBUG" from printbuf.h so it can be more …
hawicz Apr 3, 2012
e0fa94b
Fix some bugs with how buffer sizes were being calcuated in printbuf_…
hawicz Apr 3, 2012
21d3706
Added explanatory notes to documentation.
Apr 6, 2012
30dd367
Modify install names for library and include files
Mar 30, 2012
65f649b
Ignoring additional build products
Mar 30, 2012
cb29a77
Add a pkgconfig file for uninstalled builds
ford-prefect Jan 20, 2012
17caddc
Run configure in the autogen.sh script
ford-prefect Jan 20, 2012
a1221eb
Add an Android-friendly build system
ford-prefect Jan 20, 2012
b6ff1c2
array_list_expand_internal needs length, not index.
bwijen May 9, 2012
a6f39a3
Replaced #if HAVE_X with #ifdef HAVE_X as the former test is troublem…
mloskot May 21, 2012
271c53e
Missing explicit casts from void* to specific pointers required. Adde…
mloskot May 22, 2012
837d685
Use "nodoc", not "doc", for the name of the tarball w/o docs.
hawicz May 31, 2012
c58386f
Merge pull request #29 from mloskot/msvc-port
hawicz May 31, 2012
a789601
Merge pull request #27 from OBI-1/master
hawicz May 31, 2012
984303d
Added a bunch of missing HAVE_* defines tested with ./configure scrip…
mloskot Jun 19, 2012
7bd49df
Merge pull request #33 from mloskot/master
hawicz Jul 9, 2012
eead1a7
Remove unnecessary comment from json_util.c
hawicz Jul 9, 2012
9791c38
Fix git commands for tagging a release.
hawicz Jul 9, 2012
4154c55
Add json_object_iterator.h to installed headers.
hawicz Jul 9, 2012
381f77c
Merge pull request #26 from ford-prefect/master
hawicz Jul 9, 2012
6d94377
autogen.sh: Add /bin/sh interpreter, honor NOCONFIGURE=1
cgwalters Jul 11, 2012
6988f53
Rewrite json_object_object_add to replace just the value if the key a…
hawicz Jul 25, 2012
2da148d
Merge pull request #37 from cgwalters/master
hawicz Jul 29, 2012
77c6239
Initialize errno before calling sscanf in json_parse_int64() so parsi…
hawicz Jul 29, 2012
8fcfeb6
Default autogen.sh to not running configure, unless some command line…
hawicz Jul 29, 2012
92f31bd
Handle the \f escape sequence (the two characters: backslash followed…
hawicz Jul 29, 2012
c2d3ccf
Merge branch 'rename_library' of https://github.com/kdopen/json-c int…
hawicz Jul 29, 2012
ba1c381
Remove test_parse from the top level directory. (accidentally re-int…
hawicz Jul 29, 2012
eb37094
Check for the sys/cdefs.h header which on some systems defines the __…
hawicz Jul 29, 2012
b98aa6e
Create an additional libjson.so library that simply links against lib…
hawicz Jul 29, 2012
082419e
Fix the Libs line in json-uninstalled.pc to use -ljson-c
hawicz Jul 29, 2012
c7a2120
Ignore a couple more generated files.
hawicz Jul 29, 2012
075b783
Add a --disable-oldname-compat option to configure to turn off the cr…
hawicz Jul 29, 2012
943b7a4
Add a compatibility symlink json->json-c in the include directory.
hawicz Jul 29, 2012
9f16e25
Bump the version of the new library since programs will need to be re…
hawicz Jul 29, 2012
1f9d199
Re-add the "json" pkg-config file as a compatibility shim.
hawicz Jul 29, 2012
2f2180b
Take a guess as to the rename changes changes needed to the Android p…
hawicz Jul 29, 2012
8ce53f9
Note the rename in the ChangeLog, and update the instructions in the …
hawicz Jul 29, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
/depcomp
/install-sh
/json.pc
/json-c.pc
/json-c-uninstalled.pc
/libtool
/ltmain.sh
/Makefile
Expand All @@ -36,4 +38,5 @@
/Release
*.lo
*.o
/libjson-c.la
/libjson.la
39 changes: 39 additions & 0 deletions Android.configure.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This file is the top android makefile for all sub-modules.

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

json_c_TOP := $(LOCAL_PATH)

JSON_C_BUILT_SOURCES := Android.mk

JSON_C_BUILT_SOURCES := $(patsubst %, $(abspath $(json_c_TOP))/%, $(JSON_C_BUILT_SOURCES))

.PHONY: json-c-configure json-c-configure-real
json-c-configure-real:
echo $(JSON_C_BUILT_SOURCES)
cd $(json_c_TOP) ; \
$(abspath $(json_c_TOP))/autogen.sh && \
CC="$(CONFIGURE_CC)" \
CFLAGS="$(CONFIGURE_CFLAGS)" \
LD=$(TARGET_LD) \
LDFLAGS="$(CONFIGURE_LDFLAGS)" \
CPP=$(CONFIGURE_CPP) \
CPPFLAGS="$(CONFIGURE_CPPFLAGS)" \
PKG_CONFIG_LIBDIR=$(CONFIGURE_PKG_CONFIG_LIBDIR) \
PKG_CONFIG_TOP_BUILD_DIR=/ \
ac_cv_func_malloc_0_nonnull=yes \
ac_cv_func_realloc_0_nonnull=yes \
$(abspath $(json_c_TOP))/$(CONFIGURE) --host=$(CONFIGURE_HOST) \
--prefix=/system \
&& \
for file in $(JSON_C_BUILT_SOURCES); do \
rm -f $$file && \
make -C $$(dirname $$file) $$(basename $$file) ; \
done

json-c-configure: json-c-configure-real

PA_CONFIGURE_TARGETS += json-c-configure

-include $(json_c_TOP)/Android.mk
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@

NEXT.VERSION

* IMPORTANT: the name of the library has changed to libjson-c.so and
the header files are now in include/json-c.
The pkgconfig name has also changed from json to json-c.
You should change your build to use appropriate -I and -l options.
A compatibility shim is in place so builds using the old name will
continue to work, but that will be removed in the next release.

0.10

* Add a json_object_to_json_string_ext() function to allow output to be
Expand Down
52 changes: 46 additions & 6 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@ include Makefile.am.inc
EXTRA_DIST = README.html README-WIN32.html config.h.win32 doc json-c.vcproj
SUBDIRS = . tests

lib_LTLIBRARIES = libjson.la
lib_LTLIBRARIES = libjson-c.la
if ENABLE_OLDNAME_COMPAT
lib_LTLIBRARIES+=libjson.la
endif

pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = json.pc
pkgconfig_DATA = json-c.pc
if ENABLE_OLDNAME_COMPAT
pkgconfig_DATA += json.pc
endif

libjsonincludedir = $(includedir)/json
libjsoninclude_HEADERS = \
libjson_cincludedir = $(includedir)/json-c
libjson_cinclude_HEADERS = \
arraylist.h \
bits.h \
debug.h \
json.h \
json_config.h \
json_inttypes.h \
json_object.h \
json_object_iterator.h \
json_object_private.h \
json_tokener.h \
json_util.h \
Expand All @@ -28,9 +35,17 @@ libjsoninclude_HEADERS = \
#libjsonx_include_HEADERS = \
# json_config.h

libjson_la_LDFLAGS = -version-info 1:0:1 -no-undefined
libjson_c_la_LDFLAGS = -version-info 2:0:0 -no-undefined

libjson_la_SOURCES = \
if ENABLE_OLDNAME_COMPAT
libjson_la_LDFLAGS = -version-info 1:0:1 -no-undefined -ljson-c

# Temporary libjson library. This will be removed after one release.
libjson_la_LIBADD = -ljson-c
endif


libjson_c_la_SOURCES = \
arraylist.c \
debug.c \
json_object.c \
Expand All @@ -44,3 +59,28 @@ distclean-local:
-rm -rf $(testsubdir)
-rm -rf config.h.in~ Makefile.in aclocal.m4 autom4te.cache/ config.guess config.sub configure depcomp install-sh ltmain.sh missing

if ENABLE_OLDNAME_COMPAT
install-data-hook:
test \! -d "$(includedir)/json" || rmdir "$(includedir)/json"
test \! -e "$(includedir)/json" || rm "$(includedir)/json"
$(LN_S) json-c "$(includedir)/json"

uninstall-local:
rm -f "$(includedir)/json"

endif

ANDROID_CFLAGS = -I$(top_srcdir) -DHAVE_CONFIG_H

Android.mk: Makefile.am
androgenizer -:PROJECT json-c \
-:SHARED libjson-c \
-:TAGS eng debug \
-:REL_TOP $(top_srcdir) -:ABS_TOP $(abs_top_srcdir) \
-:SOURCES $(libjson_c_la_SOURCES) $(nodist_libjson_c_la_SOURCES) \
-:CFLAGS $(DEFS) $(ANDROID_CFLAGS) $(libjson_c_la_CFLAGS) \
-:LDFLAGS $(libjson_c_la_LDFLAGS) $(libjson_c_la_LIBADD) \
-:HEADER_TARGET json-c \
-:HEADERS $(libjson_cinclude_HEADERS) \
-:PASSTHROUGH LOCAL_ARM_MODE:=arm \
> $@
14 changes: 11 additions & 3 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Building on Unix with git, gcc and autotools
Home page for json-c:
http://oss.metaparadigm.com/json-c/

Caution: do NOT use sources from svn.metaparadigm.com, they are old.

Github repo for json-c:
https://github.com/json-c/json-c

Expand All @@ -20,9 +22,15 @@ To build and run the test programs run

$ make check

Linking to libjson
Linking to libjson-c

If your system has pkgconfig then you can just add this to your makefile

CFLAGS += $(shell pkg-config --cflags json)
LDFLAGS += $(shell pkg-config --libs json)
CFLAGS += $(shell pkg-config --cflags json-c)
LDFLAGS += $(shell pkg-config --libs json-c)

Without pkgconfig, you would do something like this:

JSON_C_DIR=/path/to/json_c/install
CFLAGS += -I$(JSON_C_DIR)/include/json-c
LDFLAGS+= -L$(JSON_C_DIR)/lib -ljson-c
6 changes: 4 additions & 2 deletions RELEASE_CHECKLIST.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ echo autom4te.cache >> excludes
tar -czf json-c-${release}.tar.gz -X excludes json-c-${release}

echo doc >> excludes
tar -czf json-c-${release}-doc.tar.gz -X excludes json-c-${release}
tar -czf json-c-${release}-nodoc.tar.gz -X excludes json-c-${release}

Tag the branch:
cd json-c-${release}
git tag json-c-${release}-$(date +%Y%m%d)
git tag -a json-c-${release}-$(date +%Y%m%d)
git push
git push --tags

Go to https://github.com/json-c/json-c/downloads
Upload the two tarballs.
Expand Down
6 changes: 3 additions & 3 deletions arraylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

#include "config.h"

#if STDC_HEADERS
#ifdef STDC_HEADERS
# include <stdlib.h>
# include <string.h>
#endif /* STDC_HEADERS */

#if defined HAVE_STRINGS_H && !defined _STRING_H && !defined __USE_BSD
#if defined(HAVE_STRINGS_H) && !defined(_STRING_H) && !defined(__USE_BSD)
# include <strings.h>
#endif /* HAVE_STRINGS_H */

Expand Down Expand Up @@ -74,7 +74,7 @@ static int array_list_expand_internal(struct array_list *arr, int max)
int
array_list_put_idx(struct array_list *arr, int idx, void *data)
{
if(array_list_expand_internal(arr, idx)) return -1;
if(array_list_expand_internal(arr, idx+1)) return -1;
if(arr->array[idx]) arr->free_fn(arr->array[idx]);
arr->array[idx] = data;
if(arr->length <= idx) arr->length = idx + 1;
Expand Down
12 changes: 12 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
#!/bin/sh
autoreconf -v --install || exit 1

# If there are any options, assume the user wants to run configure.
# To run configure w/o any options, use ./autogen.sh --configure
if [ $# -gt 0 ] ; then
case "$1" in
--conf*)
shift 1
;;
esac
exec ./configure "$@"
fi
12 changes: 12 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
and to 0 otherwise. */
#undef HAVE_REALLOC

/* Define to 1 if you have the `snprintf' function. */
#undef HAVE_SNPRINTF

/* Define to 1 if you have the <stdarg.h> header file. */
#undef HAVE_STDARG_H

Expand All @@ -38,6 +41,12 @@
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H

/* Define to 1 if you have the `strcasecmp' function. */
#undef HAVE_STRCASECMP

/* Define to 1 if you have the `strdup' function. */
#undef HAVE_STRDUP

/* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR

Expand All @@ -56,6 +65,9 @@
/* Define to 1 if you have the <syslog.h> header file. */
#undef HAVE_SYSLOG_H

/* Define to 1 if you have the <sys/cdefs.h> header file. */
#undef HAVE_SYS_CDEFS_H

/* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H

Expand Down
14 changes: 12 additions & 2 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)

AC_PROG_MAKE_SET

AC_ARG_ENABLE(oldname-compat,
AS_HELP_STRING([--disable-oldname-compat],
[Don't include the old libjson.so library and include/json directory.]),
[],
[enable_oldname_compat=yes]
)
AM_CONDITIONAL(ENABLE_OLDNAME_COMPAT, [test "x${enable_oldname_compat}" != "xno"])

# Checks for programs.

# Checks for libraries.
Expand All @@ -15,7 +23,7 @@ AC_PROG_MAKE_SET
AM_CONFIG_HEADER(config.h)
AM_CONFIG_HEADER(json_config.h)
AC_HEADER_STDC
AC_CHECK_HEADERS(fcntl.h limits.h strings.h syslog.h unistd.h [sys/param.h] stdarg.h)
AC_CHECK_HEADERS(fcntl.h limits.h strings.h syslog.h unistd.h [sys/cdefs.h] [sys/param.h] stdarg.h)
AC_CHECK_HEADER(inttypes.h,[AC_DEFINE([JSON_C_HAVE_INTTYPES_H],[1],[Public define for json_inttypes.h])])

# Checks for typedefs, structures, and compiler characteristics.
Expand All @@ -27,14 +35,16 @@ AC_FUNC_VPRINTF
AC_FUNC_MEMCMP
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS(strndup strerror vsnprintf vasprintf open vsyslog strncasecmp)
AC_CHECK_FUNCS(strcasecmp strdup strndup strerror snprintf vsnprintf vasprintf open vsyslog strncasecmp)

AM_PROG_LIBTOOL

AC_CONFIG_FILES([
Makefile
json.pc
json-c.pc
tests/Makefile
json-c-uninstalled.pc
])

AC_OUTPUT
Expand Down
11 changes: 11 additions & 0 deletions json-c-uninstalled.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=
exec_prefix=
libdir=@abs_top_builddir@
includedir=@abs_top_srcdir@

Name: json
Description: JSON implementation in C
Version: @VERSION@
Requires:
Libs: -L@abs_top_builddir@ -ljson-c
Cflags: -I@abs_top_srcdir@
11 changes: 11 additions & 0 deletions json-c.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@

Name: json-c
Description: JSON implementation in C
Version: @VERSION@
Requires:
Libs: -L${libdir} -ljson-c
Cflags: -I${includedir}/json-c
10 changes: 5 additions & 5 deletions json.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@

Name: json
Description: JSON implementation in C
Name: json-c
Description: JSON implementation in C, compat shim. Use json-c instead.
Version: @VERSION@
Requires:
Libs: -L${libdir} -ljson
Cflags: -I${includedir}/json
Requires: json-c
Libs:
Cflags:
27 changes: 23 additions & 4 deletions json_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@
#include "json_object_private.h"
#include "json_util.h"

#if !HAVE_STRNDUP
#if !defined(HAVE_STRDUP) && defined(_MSC_VER)
/* MSC has the version as _strdup */
# define strdup _strdup
#elif !defined(HAVE_STRDUP)
# error You do not have strdup on your system.
#endif /* HAVE_STRDUP */

#if !defined(HAVE_STRNDUP)
char* strndup(const char* str, size_t n);
#endif /* !HAVE_STRNDUP */

Expand Down Expand Up @@ -299,8 +306,20 @@ struct lh_table* json_object_get_object(struct json_object *jso)
void json_object_object_add(struct json_object* jso, const char *key,
struct json_object *val)
{
lh_table_delete(jso->o.c_object, key);
lh_table_insert(jso->o.c_object, strdup(key), val);
// We lookup the entry and replace the value, rather than just deleting
// and re-adding it, so the existing key remains valid.
json_object *existing_value = NULL;
struct lh_entry *existing_entry;
existing_entry = lh_table_lookup_entry(jso->o.c_object, (void*)key);
if (!existing_entry)
{
lh_table_insert(jso->o.c_object, strdup(key), val);
return;
}
existing_value = (void *)existing_entry->v;
if (existing_value)
json_object_put(existing_value);
existing_entry->v = val;
}

struct json_object* json_object_object_get(struct json_object* jso, const char *key)
Expand Down Expand Up @@ -531,7 +550,7 @@ struct json_object* json_object_new_string_len(const char *s, int len)
if(!jso) return NULL;
jso->_delete = &json_object_string_delete;
jso->_to_json_string = &json_object_string_to_json_string;
jso->o.c_string.str = malloc(len);
jso->o.c_string.str = (char*)malloc(len);
memcpy(jso->o.c_string.str, (void *)s, len);
jso->o.c_string.len = len;
return jso;
Expand Down
Loading