[asterisk-commits] dlee: trunk r378915 - in /trunk: ./ build_tools/ contrib/scripts/ include/ast...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jan 11 16:31:48 CST 2013


Author: dlee
Date: Fri Jan 11 16:31:42 2013
New Revision: 378915

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=378915
Log:
Add JSON API for Asterisk.

This provides a JSON API by pulling in and wrapping the Jansson JSON
library[1]. The Asterisk API basically mirrors the Jansson
functionality, with a few minor tweaks.

 * Some names have been asteriskified to protect the innocent.
 * Jansson provides both reference-stealing and reference-borrowing
   versions of several API's. The Asterisk API is exclusively
   reference-stealing for operations that put elements into arrays and
   objects.
 * No support for doubles, since we usually don't need that.
 * Coming along for the ride is the ast_test_validate macro, which made
   the unit tests much easier to write.

 [1]: http://www.digip.org/jansson/

(issue ASTERISK-20887)
(closes issue ASTERISK-20888)
Review: https://reviewboard.asterisk.org/r/2264/

Added:
    trunk/include/asterisk/json.h
      - copied unchanged from r378914, team/dlee/jansson/include/asterisk/json.h
    trunk/res/res_json.c
      - copied unchanged from r378914, team/dlee/jansson/res/res_json.c
    trunk/res/res_json.exports.in
      - copied unchanged from r378914, team/dlee/jansson/res/res_json.exports.in
    trunk/tests/test_json.c
      - copied unchanged from r378914, team/dlee/jansson/tests/test_json.c
Modified:
    trunk/build_tools/menuselect-deps.in
    trunk/configure
    trunk/configure.ac
    trunk/contrib/scripts/install_prereq
    trunk/include/asterisk/autoconfig.h.in
    trunk/include/asterisk/test.h
    trunk/main/Makefile
    trunk/makeopts.in

Modified: trunk/build_tools/menuselect-deps.in
URL: http://svnview.digium.com/svn/asterisk/trunk/build_tools/menuselect-deps.in?view=diff&rev=378915&r1=378914&r2=378915
==============================================================================
--- trunk/build_tools/menuselect-deps.in (original)
+++ trunk/build_tools/menuselect-deps.in Fri Jan 11 16:31:42 2013
@@ -25,6 +25,7 @@
 ISDNNET=@PBX_ISDNNET@
 IXJUSER=@PBX_IXJUSER@
 JACK=@PBX_JACK@
+JANSSON=@PBX_JANSSON@
 KQUEUE=@PBX_KQUEUE@
 LDAP=@PBX_LDAP@
 LIBEDIT=@PBX_LIBEDIT@

Modified: trunk/configure.ac
URL: http://svnview.digium.com/svn/asterisk/trunk/configure.ac?view=diff&rev=378915&r1=378914&r2=378915
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Fri Jan 11 16:31:42 2013
@@ -406,6 +406,7 @@
 AST_EXT_LIB_SETUP([IODBC], [iODBC], [iodbc])
 AST_EXT_LIB_SETUP([ISDNNET], [ISDN4Linux], [isdnnet])
 AST_EXT_LIB_SETUP([JACK], [Jack Audio Connection Kit], [jack])
+AST_EXT_LIB_SETUP([JANSSON], [Jansson JSON library], [jansson])
 AST_EXT_LIB_SETUP([KQUEUE], [kqueue support], [kqueue])
 AST_EXT_LIB_SETUP([LDAP], [OpenLDAP], [ldap])
 AST_LIBCURL_CHECK_CONFIG([], [7.10.1])
@@ -1846,6 +1847,8 @@
 
 AST_EXT_LIB_CHECK([JACK], [jack], [jack_activate], [jack/jack.h])
 
+AST_EXT_LIB_CHECK([JANSSON], [jansson], [json_dumps], [jansson.h])
+
 # BSD (and OS X) equivalent of inotify
 AST_EXT_LIB_CHECK([KQUEUE], [c], [kqueue], [sys/event.h])
 

Modified: trunk/contrib/scripts/install_prereq
URL: http://svnview.digium.com/svn/asterisk/trunk/contrib/scripts/install_prereq?view=diff&rev=378915&r1=378914&r2=378915
==============================================================================
--- trunk/contrib/scripts/install_prereq (original)
+++ trunk/contrib/scripts/install_prereq Fri Jan 11 16:31:42 2013
@@ -27,7 +27,7 @@
 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libpq-dev unixodbc-dev libsqlite0-dev libmysqlclient15-dev libneon27-dev libgmime-dev libusb-dev liblua5.1-0-dev lua5.1"
 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libopenh323-dev libvpb-dev libgtk2.0-dev libmysqlclient-dev libbluetooth-dev libradiusclient-ng-dev freetds-dev"
 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libsnmp-dev libiksemel-dev libcorosync-dev libnewt-dev libpopt-dev libical-dev libspandsp-dev libjack-dev"
-PACKAGES_DEBIAN="$PACKAGES_DEBIAN libresample-dev libc-client-dev binutils-dev libsrtp-dev libgsm1-dev libedit-dev doxygen"
+PACKAGES_DEBIAN="$PACKAGES_DEBIAN libresample-dev libc-client-dev binutils-dev libsrtp-dev libgsm1-dev libedit-dev doxygen libjansson-dev"
 PACKAGES_RH="automake gcc gcc-c++ ncurses-devel openssl-devel libxml2-devel unixODBC-devel libcurl-devel libogg-devel libvorbis-devel speex-devel"
 PACKAGES_RH="$PACKAGES_RH spandsp-devel freetds-devel net-snmp-devel iksemel-devel corosynclib-devel newt-devel popt-devel libtool-ltdl-devel lua-devel"
 PACKAGES_RH="$PACKAGES_RH libsqlite3x-devel radiusclient-ng-devel portaudio-devel postgresql-devel libresample-devel neon-devel libical-devel"

Modified: trunk/include/asterisk/autoconfig.h.in
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/autoconfig.h.in?view=diff&rev=378915&r1=378914&r2=378915
==============================================================================
--- trunk/include/asterisk/autoconfig.h.in (original)
+++ trunk/include/asterisk/autoconfig.h.in Fri Jan 11 16:31:42 2013
@@ -363,6 +363,9 @@
 
 /* Define to 1 if you have the Jack Audio Connection Kit library. */
 #undef HAVE_JACK
+
+/* Define to 1 if you have the Jansson JSON library library. */
+#undef HAVE_JANSSON
 
 /* Define to 1 if you have the `kevent64' function. */
 #undef HAVE_KEVENT64

Modified: trunk/include/asterisk/test.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/test.h?view=diff&rev=378915&r1=378914&r2=378915
==============================================================================
--- trunk/include/asterisk/test.h (original)
+++ trunk/include/asterisk/test.h Fri Jan 11 16:31:42 2013
@@ -1,7 +1,7 @@
 /*
  * Asterisk -- An open source telephony toolkit.
  *
- * Copyright (C) 2009-2010, Digium, Inc.
+ * Copyright (C) 2009-2013, Digium, Inc.
  *
  * David Vossel <dvossel at digium.com>
  * Russell Bryant <russell at digium.com>
@@ -283,5 +283,31 @@
  */
 #define ast_test_status_update(t, f, ...) __ast_test_status_update(__FILE__, __PRETTY_FUNCTION__, __LINE__, (t), (f), ## __VA_ARGS__)
 
+/*!
+ * \brief Check a test condition, failing the test if it's not true.
+ *
+ * \since 12.0.0
+ *
+ * This macro evaluates \a condition. If the condition evaluates to true (non-zero),
+ * nothing happens. If it evaluates to false (zero), then the failure is printed
+ * using \ref ast_test_status_update, and the current test is ended with AST_TEST_FAIL.
+ *
+ * Sadly, the name 'ast_test_assert' was already taken.
+ *
+ * Note that since this macro returns from the current test, there must not be any
+ * cleanup work to be done before returning. Use \ref RAII_VAR for test cleanup.
+ *
+ * \param \a test Currently executing test
+ * \param \a condition Boolean condition to check.
+ */
+#define ast_test_validate(test, condition)				\
+	do {								\
+		if (!(condition)) {					\
+			__ast_test_status_update(__FILE__, __PRETTY_FUNCTION__, __LINE__, (test), "Condition failed: %s\n", #condition); \
+			return AST_TEST_FAIL;				\
+		}							\
+	} while(0)
+
+
 #endif /* TEST_FRAMEWORK */
 #endif /* _AST_TEST_H */

Modified: trunk/main/Makefile
URL: http://svnview.digium.com/svn/asterisk/trunk/main/Makefile?view=diff&rev=378915&r1=378914&r2=378915
==============================================================================
--- trunk/main/Makefile (original)
+++ trunk/main/Makefile Fri Jan 11 16:31:42 2013
@@ -35,6 +35,7 @@
 AST_LIBS+=$(LIBXML2_LIB)
 AST_LIBS+=$(SQLITE3_LIB)
 AST_LIBS+=$(ASTSSL_LIBS)
+AST_LIBS+=$(JANSSON_LIB)
 
 ifneq ($(findstring $(OSARCH), linux-gnu uclinux linux-uclibc linux-gnueabi kfreebsd-gnu linux-gnueabihf),)
   ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)

Modified: trunk/makeopts.in
URL: http://svnview.digium.com/svn/asterisk/trunk/makeopts.in?view=diff&rev=378915&r1=378914&r2=378915
==============================================================================
--- trunk/makeopts.in (original)
+++ trunk/makeopts.in Fri Jan 11 16:31:42 2013
@@ -169,6 +169,9 @@
 JACK_INCLUDE=@JACK_INCLUDE@
 JACK_LIB=@JACK_LIB@
 
+JANSSON_INCLUDE=@JANSSON_INCLUDE@
+JANSSON_LIB=@JANSSON_LIB@
+
 LDAP_INCLUDE=@LDAP_INCLUDE@
 LDAP_LIB=@LDAP_LIB@
 




More information about the asterisk-commits mailing list