<p>George Joseph <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/9525">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved; Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">Enable bundling of jansson, require 2.11.<br><br>Change-Id: Ib3111b151d37cbda40768cf2a8a9c6cf6c5c7cbd<br>---<br>M CHANGES<br>M UPGRADE.txt<br>M configure<br>M configure.ac<br>M include/asterisk/json.h<br>M main/json.c<br>M makeopts.in<br>M third-party/Makefile<br>M third-party/Makefile.rules<br>R third-party/apply_patches<br>M third-party/configure.m4<br>A third-party/jansson/.gitignore<br>A third-party/jansson/Makefile<br>A third-party/jansson/Makefile.rules<br>A third-party/jansson/configure.m4<br>A third-party/jansson/jansson-2.11.tar.bz2.md5<br>A third-party/jansson/patches/0001-Improve-test-coverage.patch<br>A third-party/jansson/patches/0017-Fix-error-handling-in-json_pack.patch<br>M third-party/pjproject/Makefile<br>M third-party/pjproject/Makefile.rules<br>A third-party/pjproject/pjproject-2.7.2.tar.bz2.md5<br>M third-party/versions.mak<br>22 files changed, 642 insertions(+), 354 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/CHANGES b/CHANGES</span><br><span>index cb3dd7a..c1cd83f 100644</span><br><span>--- a/CHANGES</span><br><span>+++ b/CHANGES</span><br><span>@@ -31,6 +31,9 @@</span><br><span> MALLOC_DEBUG and vice versa. Third-party pre-compiled modules no longer</span><br><span> need to have a special build with it enabled.</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ * Asterisk now depends on libjansson >= 2.11. If this version is not</span><br><span style="color: hsl(120, 100%, 40%);">+ available on your distro you can use `./configure --with-jansson-bundled`.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> app_macro</span><br><span> ------------------</span><br><span> * The app_macro module is now deprecated and by default it is no longer</span><br><span>diff --git a/UPGRADE.txt b/UPGRADE.txt</span><br><span>index 154a9b7..8b4fdf7 100644</span><br><span>--- a/UPGRADE.txt</span><br><span>+++ b/UPGRADE.txt</span><br><span>@@ -50,6 +50,9 @@</span><br><span> MALLOC_DEBUG and vice versa. Third-party pre-compiled modules no longer</span><br><span> need to have a special build with it enabled.</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ - Asterisk now depends on libjansson >= 2.11. If this version is not</span><br><span style="color: hsl(120, 100%, 40%);">+ available on your distro you can use `./configure --with-jansson-bundled`.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> chan_dahdi:</span><br><span> - Timeouts for reading digits from analog phones are now configurable in</span><br><span> chan_dahdi.conf: firstdigit_timeout, interdigit_timeout, matchdigit_timeout.</span><br><span>diff --git a/configure b/configure</span><br><span>index 088a142..c79d87a 100755</span><br><span>--- a/configure</span><br><span>+++ b/configure</span><br><span>@@ -1072,10 +1072,7 @@</span><br><span> URIPARSER_DIR</span><br><span> URIPARSER_INCLUDE</span><br><span> URIPARSER_LIB</span><br><span style="color: hsl(0, 100%, 40%);">-PBX_JANSSON</span><br><span> JANSSON_DIR</span><br><span style="color: hsl(0, 100%, 40%);">-JANSSON_INCLUDE</span><br><span style="color: hsl(0, 100%, 40%);">-JANSSON_LIB</span><br><span> PBX_JACK</span><br><span> JACK_DIR</span><br><span> JACK_INCLUDE</span><br><span>@@ -1186,6 +1183,11 @@</span><br><span> PJPROJECT_DIR</span><br><span> PJPROJECT_BUNDLED</span><br><span> PJPROJECT_CONFIGURE_OPTS</span><br><span style="color: hsl(120, 100%, 40%);">+JANSSON_INCLUDE</span><br><span style="color: hsl(120, 100%, 40%);">+JANSSON_LIB</span><br><span style="color: hsl(120, 100%, 40%);">+PBX_JANSSON</span><br><span style="color: hsl(120, 100%, 40%);">+JANSSON_BUNDLED</span><br><span style="color: hsl(120, 100%, 40%);">+JANSSON_CONFIGURE_OPTS</span><br><span> AST_C_COMPILER_FAMILY</span><br><span> AST_CLANG_BLOCKS</span><br><span> AST_CLANG_BLOCKS_LIBS</span><br><span>@@ -1352,6 +1354,7 @@</span><br><span> with_sounds_cache</span><br><span> with_externals_cache</span><br><span> enable_coverage</span><br><span style="color: hsl(120, 100%, 40%);">+with_jansson_bundled</span><br><span> with_pjproject_bundled</span><br><span> with_asound</span><br><span> with_bfd</span><br><span>@@ -1448,6 +1451,7 @@</span><br><span> CXXFLAGS</span><br><span> CCC</span><br><span> CXXCPP</span><br><span style="color: hsl(120, 100%, 40%);">+JANSSON_CONFIGURE_OPTS</span><br><span> PJPROJECT_CONFIGURE_OPTS</span><br><span> PKG_CONFIG</span><br><span> PKG_CONFIG_PATH</span><br><span>@@ -2100,6 +2104,7 @@</span><br><span> use cached sound tarfiles in PATH</span><br><span> --with-externals-cache=PATH</span><br><span> use cached external module tarfiles in PATH</span><br><span style="color: hsl(120, 100%, 40%);">+ --with-jansson-bundled Use bundled jansson library</span><br><span> --with-pjproject-bundled</span><br><span> Use bundled pjproject libraries (default)</span><br><span> --with-asound=PATH use Advanced Linux Sound Architecture files in PATH</span><br><span>@@ -2195,6 +2200,8 @@</span><br><span> CXX C++ compiler command</span><br><span> CXXFLAGS C++ compiler flags</span><br><span> CXXCPP C++ preprocessor</span><br><span style="color: hsl(120, 100%, 40%);">+ JANSSON_CONFIGURE_OPTS</span><br><span style="color: hsl(120, 100%, 40%);">+ Additional configure options to pass to bundled jansson</span><br><span> PJPROJECT_CONFIGURE_OPTS</span><br><span> Additional configure options to pass to bundled pjproject</span><br><span> PKG_CONFIG path to pkg-config utility</span><br><span>@@ -9145,6 +9152,17 @@</span><br><span> CFLAGS="$save_CFLAGS"</span><br><span> </span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+JANSSON_BUNDLED=no</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# Check whether --with-jansson-bundled was given.</span><br><span style="color: hsl(120, 100%, 40%);">+if test "${with_jansson_bundled+set}" = set; then :</span><br><span style="color: hsl(120, 100%, 40%);">+ withval=$with_jansson_bundled; case "${withval}" in</span><br><span style="color: hsl(120, 100%, 40%);">+ y|yes) JANSSON_BUNDLED=yes ;;</span><br><span style="color: hsl(120, 100%, 40%);">+ *) JANSSON_BUNDLED=no ;;</span><br><span style="color: hsl(120, 100%, 40%);">+ esac</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> PJPROJECT_BUNDLED=yes</span><br><span> </span><br><span> </span><br><span>@@ -9160,6 +9178,92 @@</span><br><span> </span><br><span> </span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+ if test "$JANSSON_BUNDLED" = "yes" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${ac_mandatory_list#*JANSSON*}" != "$ac_mandatory_list" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ as_fn_error $? "--with-jansson and --with-jansson-bundled can't both be specified" "$LINENO" 5</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ac_mandatory_list="$ac_mandatory_list JANSSON"</span><br><span style="color: hsl(120, 100%, 40%);">+ JANSSON_DIR="${ac_pwd}/third-party/jansson"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for embedded jansson (may have to download)" >&5</span><br><span style="color: hsl(120, 100%, 40%);">+$as_echo_n "checking for embedded jansson (may have to download)... " >&6; }</span><br><span style="color: hsl(120, 100%, 40%);">+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: configuring" >&5</span><br><span style="color: hsl(120, 100%, 40%);">+$as_echo "configuring" >&6; }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "x${DOWNLOAD_TO_STDOUT}" = "x" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ as_fn_error $? "A download utility (wget, curl, or fetch) is required to download bundled jansson" "$LINENO" 5</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${BZIP2}" = ":" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ as_fn_error $? "bzip2 is required to extract the jansson tar file" "$LINENO" 5</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${TAR}" = ":" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ as_fn_error $? "tar is required to extract the jansson tar file" "$LINENO" 5</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${PATCH}" = ":" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ as_fn_error $? "patch is required to configure bundled jansson" "$LINENO" 5</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${SED}" = ":" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ as_fn_error $? "sed is required to configure bundled jansson" "$LINENO" 5</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${NM}" = ":" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ as_fn_error $? "nm is required to build bundled jansson" "$LINENO" 5</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${MD5}" = ":" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ as_fn_error $? "md5sum is required to build bundled jansson" "$LINENO" 5</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${CAT}" = ":" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ as_fn_error $? "cat is required to build bundled jansson" "$LINENO" 5</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${CUT}" = ":" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ as_fn_error $? "cut is required to build bundled jansson" "$LINENO" 5</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${GREP}" = ":" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ as_fn_error $? "grep is required to build bundled jansson" "$LINENO" 5</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ this_host=$(./config.sub $(./config.guess))</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "$build" != "$this_host" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ JANSSON_CONFIGURE_OPTS+=" --build=$build"</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "$host" != "$this_host" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ JANSSON_CONFIGURE_OPTS+=" --host=$host"</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ export TAR PATCH SED NM EXTERNALS_CACHE_DIR AST_DOWNLOAD_CACHE DOWNLOAD_TO_STDOUT DOWNLOAD_TIMEOUT DOWNLOAD MD5 CAT CUT GREP</span><br><span style="color: hsl(120, 100%, 40%);">+ export NOISY_BUILD</span><br><span style="color: hsl(120, 100%, 40%);">+ ${GNU_MAKE} --quiet --no-print-directory -C ${JANSSON_DIR} \</span><br><span style="color: hsl(120, 100%, 40%);">+ JANSSON_CONFIGURE_OPTS="$JANSSON_CONFIGURE_OPTS" \</span><br><span style="color: hsl(120, 100%, 40%);">+ EXTERNALS_CACHE_DIR="${EXTERNALS_CACHE_DIR:-${AST_DOWNLOAD_CACHE}}" \</span><br><span style="color: hsl(120, 100%, 40%);">+ configure</span><br><span style="color: hsl(120, 100%, 40%);">+ if test $? -ne 0 ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5</span><br><span style="color: hsl(120, 100%, 40%);">+$as_echo "failed" >&6; }</span><br><span style="color: hsl(120, 100%, 40%);">+ { $as_echo "$as_me:${as_lineno-$LINENO}: Unable to configure ${JANSSON_DIR}" >&5</span><br><span style="color: hsl(120, 100%, 40%);">+$as_echo "$as_me: Unable to configure ${JANSSON_DIR}" >&6;}</span><br><span style="color: hsl(120, 100%, 40%);">+ as_fn_error $? "Re-run the ./configure command with 'NOISY_BUILD=yes' appended to see error details." "$LINENO" 5</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bundled jansson" >&5</span><br><span style="color: hsl(120, 100%, 40%);">+$as_echo_n "checking for bundled jansson... " >&6; }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ JANSSON_INCLUDE=-I${JANSSON_DIR}/dest/include</span><br><span style="color: hsl(120, 100%, 40%);">+ JANSSON_CFLAGS="$JANSSON_INCLUDE"</span><br><span style="color: hsl(120, 100%, 40%);">+ JANSSON_LIB="-L${JANSSON_DIR}/dest/lib -ljansson"</span><br><span style="color: hsl(120, 100%, 40%);">+ PBX_JANSSON=1</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5</span><br><span style="color: hsl(120, 100%, 40%);">+$as_echo "yes" >&6; }</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> if test "$PJPROJECT_BUNDLED" = "yes" ; then</span><br><span> </span><br><span> if test "${ac_mandatory_list#*PJPROJECT*}" != "$ac_mandatory_list" ; then</span><br><span>@@ -13825,7 +13929,9 @@</span><br><span> </span><br><span> </span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-# Find required JSON support.</span><br><span style="color: hsl(120, 100%, 40%);">+# Find required JSON support if bundled is not enabled.</span><br><span style="color: hsl(120, 100%, 40%);">+if test "$JANSSON_BUNDLED" = "no" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ # json_sprintf is available in 2.11+</span><br><span> </span><br><span> if test "x${PBX_JANSSON}" != "x1" -a "${USE_JANSSON}" != "no"; then</span><br><span> pbxlibdir=""</span><br><span>@@ -13840,9 +13946,9 @@</span><br><span> </span><br><span> ast_ext_lib_check_save_CFLAGS="${CFLAGS}"</span><br><span> CFLAGS="${CFLAGS} "</span><br><span style="color: hsl(0, 100%, 40%);">- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for json_dumps in -ljansson" >&5</span><br><span style="color: hsl(0, 100%, 40%);">-$as_echo_n "checking for json_dumps in -ljansson... " >&6; }</span><br><span style="color: hsl(0, 100%, 40%);">-if ${ac_cv_lib_jansson_json_dumps+:} false; then :</span><br><span style="color: hsl(120, 100%, 40%);">+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for json_sprintf in -ljansson" >&5</span><br><span style="color: hsl(120, 100%, 40%);">+$as_echo_n "checking for json_sprintf in -ljansson... " >&6; }</span><br><span style="color: hsl(120, 100%, 40%);">+if ${ac_cv_lib_jansson_json_sprintf+:} false; then :</span><br><span> $as_echo_n "(cached) " >&6</span><br><span> else</span><br><span> ac_check_lib_save_LIBS=$LIBS</span><br><span>@@ -13856,27 +13962,27 @@</span><br><span> #ifdef __cplusplus</span><br><span> extern "C"</span><br><span> #endif</span><br><span style="color: hsl(0, 100%, 40%);">-char json_dumps ();</span><br><span style="color: hsl(120, 100%, 40%);">+char json_sprintf ();</span><br><span> int</span><br><span> main ()</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-return json_dumps ();</span><br><span style="color: hsl(120, 100%, 40%);">+return json_sprintf ();</span><br><span> ;</span><br><span> return 0;</span><br><span> }</span><br><span> _ACEOF</span><br><span> if ac_fn_c_try_link "$LINENO"; then :</span><br><span style="color: hsl(0, 100%, 40%);">- ac_cv_lib_jansson_json_dumps=yes</span><br><span style="color: hsl(120, 100%, 40%);">+ ac_cv_lib_jansson_json_sprintf=yes</span><br><span> else</span><br><span style="color: hsl(0, 100%, 40%);">- ac_cv_lib_jansson_json_dumps=no</span><br><span style="color: hsl(120, 100%, 40%);">+ ac_cv_lib_jansson_json_sprintf=no</span><br><span> fi</span><br><span> rm -f core conftest.err conftest.$ac_objext \</span><br><span> conftest$ac_exeext conftest.$ac_ext</span><br><span> LIBS=$ac_check_lib_save_LIBS</span><br><span> fi</span><br><span style="color: hsl(0, 100%, 40%);">-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jansson_json_dumps" >&5</span><br><span style="color: hsl(0, 100%, 40%);">-$as_echo "$ac_cv_lib_jansson_json_dumps" >&6; }</span><br><span style="color: hsl(0, 100%, 40%);">-if test "x$ac_cv_lib_jansson_json_dumps" = xyes; then :</span><br><span style="color: hsl(120, 100%, 40%);">+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jansson_json_sprintf" >&5</span><br><span style="color: hsl(120, 100%, 40%);">+$as_echo "$ac_cv_lib_jansson_json_sprintf" >&6; }</span><br><span style="color: hsl(120, 100%, 40%);">+if test "x$ac_cv_lib_jansson_json_sprintf" = xyes; then :</span><br><span> AST_JANSSON_FOUND=yes</span><br><span> else</span><br><span> AST_JANSSON_FOUND=no</span><br><span>@@ -13923,8 +14029,17 @@</span><br><span> </span><br><span> </span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-if test "${PBX_JANSSON}" != 1; then</span><br><span style="color: hsl(0, 100%, 40%);">- as_fn_error $? "*** JSON support not found (this typically means the libjansson development package is missing)" "$LINENO" 5</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${PBX_JANSSON}" != 1; then</span><br><span style="color: hsl(120, 100%, 40%);">+ { $as_echo "$as_me:${as_lineno-$LINENO}: *** Asterisk requires libjansson >= 2.11 and no system copy was found." >&5</span><br><span style="color: hsl(120, 100%, 40%);">+$as_echo "$as_me: *** Asterisk requires libjansson >= 2.11 and no system copy was found." >&6;}</span><br><span style="color: hsl(120, 100%, 40%);">+ { $as_echo "$as_me:${as_lineno-$LINENO}: *** Please install the 'libjansson' development package or" >&5</span><br><span style="color: hsl(120, 100%, 40%);">+$as_echo "$as_me: *** Please install the 'libjansson' development package or" >&6;}</span><br><span style="color: hsl(120, 100%, 40%);">+ { $as_echo "$as_me:${as_lineno-$LINENO}: *** use './configure --with-jansson-bundled'" >&5</span><br><span style="color: hsl(120, 100%, 40%);">+$as_echo "$as_me: *** use './configure --with-jansson-bundled'" >&6;}</span><br><span style="color: hsl(120, 100%, 40%);">+ exit 1</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+else</span><br><span style="color: hsl(120, 100%, 40%);">+ PBX_JANSSON=1</span><br><span> fi</span><br><span> </span><br><span> # See if clock_gettime is in librt</span><br><span>diff --git a/configure.ac b/configure.ac</span><br><span>index 9b517b1..fc26925 100644</span><br><span>--- a/configure.ac</span><br><span>+++ b/configure.ac</span><br><span>@@ -423,6 +423,15 @@</span><br><span> AST_CHECK_RAII()</span><br><span> AST_CHECK_STRSEP_ARRAY_BOUNDS()</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+JANSSON_BUNDLED=no</span><br><span style="color: hsl(120, 100%, 40%);">+AC_ARG_WITH([jansson-bundled],</span><br><span style="color: hsl(120, 100%, 40%);">+ [AS_HELP_STRING([--with-jansson-bundled],</span><br><span style="color: hsl(120, 100%, 40%);">+ [Use bundled jansson library])],</span><br><span style="color: hsl(120, 100%, 40%);">+ [case "${withval}" in</span><br><span style="color: hsl(120, 100%, 40%);">+ y|yes) JANSSON_BUNDLED=yes ;;</span><br><span style="color: hsl(120, 100%, 40%);">+ *) JANSSON_BUNDLED=no ;;</span><br><span style="color: hsl(120, 100%, 40%);">+ esac])</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> PJPROJECT_BUNDLED=yes</span><br><span> AH_TEMPLATE(m4_bpatsubst([[HAVE_PJPROJECT_BUNDLED]], [(.*)]), [Define to 1 when using the bundled pjproject.])</span><br><span> </span><br><span>@@ -652,11 +661,19 @@</span><br><span> AC_SUBST(UUID_INCLUDE)</span><br><span> AC_SUBST(UUID_LIB)</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-# Find required JSON support.</span><br><span style="color: hsl(0, 100%, 40%);">-AST_EXT_LIB_CHECK([JANSSON], [jansson], [json_dumps], [jansson.h])</span><br><span style="color: hsl(120, 100%, 40%);">+# Find required JSON support if bundled is not enabled.</span><br><span style="color: hsl(120, 100%, 40%);">+if test "$JANSSON_BUNDLED" = "no" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ # json_sprintf is available in 2.11+</span><br><span style="color: hsl(120, 100%, 40%);">+ AST_EXT_LIB_CHECK([JANSSON], [jansson], [json_sprintf], [jansson.h])</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-if test "${PBX_JANSSON}" != 1; then</span><br><span style="color: hsl(0, 100%, 40%);">- AC_MSG_ERROR([*** JSON support not found (this typically means the libjansson development package is missing)])</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${PBX_JANSSON}" != 1; then</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_NOTICE(*** Asterisk requires libjansson >= 2.11 and no system copy was found.)</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_NOTICE(*** Please install the 'libjansson' development package or)</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_NOTICE(*** use './configure --with-jansson-bundled')</span><br><span style="color: hsl(120, 100%, 40%);">+ exit 1</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+else</span><br><span style="color: hsl(120, 100%, 40%);">+ PBX_JANSSON=1</span><br><span> fi</span><br><span> </span><br><span> # See if clock_gettime is in librt</span><br><span>diff --git a/include/asterisk/json.h b/include/asterisk/json.h</span><br><span>index bd6ba86..3da7165 100644</span><br><span>--- a/include/asterisk/json.h</span><br><span>+++ b/include/asterisk/json.h</span><br><span>@@ -27,7 +27,7 @@</span><br><span> * \since 12.0.0</span><br><span> *</span><br><span> * This is a very thin wrapper around the Jansson API. For more details on it,</span><br><span style="color: hsl(0, 100%, 40%);">- * see its docs at http://www.digip.org/jansson/doc/2.4/apiref.html.</span><br><span style="color: hsl(120, 100%, 40%);">+ * see its docs at http://www.digip.org/jansson/doc/2.11/apiref.html.</span><br><span> *</span><br><span> * Rather than provide the multiple ways of doing things that the Jansson API</span><br><span> * does, the Asterisk wrapper is always reference-stealing, and always NULL</span><br><span>@@ -43,35 +43,6 @@</span><br><span> * wrap them with json_ref() when passing them to other \c ast_json_*()</span><br><span> * functions.</span><br><span> *</span><br><span style="color: hsl(0, 100%, 40%);">- * \par Thread Safety</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * Jansson (as of 2.4) provides fairly weak thread safety guarantees. The</span><br><span style="color: hsl(0, 100%, 40%);">- * Asterisk wrapper improves upon that slightly. The remaining refcounting</span><br><span style="color: hsl(0, 100%, 40%);">- * problems are issues when slicing/sharing/mixing instances between JSON</span><br><span style="color: hsl(0, 100%, 40%);">- * objects and arrays, which we avoid.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * The \c ast_json_dump_* functions are thread safe for multiple concurrent</span><br><span style="color: hsl(0, 100%, 40%);">- * dumps of the same object, so long as the concurrent dumps start from the same</span><br><span style="color: hsl(0, 100%, 40%);">- * \c root object. But if an object is shared by other JSON objects/arrays, then</span><br><span style="color: hsl(0, 100%, 40%);">- * concurrent dumps of the outer objects/arrays are not thread safe. This can be</span><br><span style="color: hsl(0, 100%, 40%);">- * avoided by using ast_json_deep_copy() when sharing JSON instances between</span><br><span style="color: hsl(0, 100%, 40%);">- * objects.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * The ast_json_ref() and ast_json_unref() functions are thread safe. Since the</span><br><span style="color: hsl(0, 100%, 40%);">- * Asterisk wrapper exclusively uses the reference stealing API, Jansson won't</span><br><span style="color: hsl(0, 100%, 40%);">- * be performing many refcount modifications behind our backs. There are a few</span><br><span style="color: hsl(0, 100%, 40%);">- * exceptions.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * The first is the transitive json_decref() that occurs when \ref</span><br><span style="color: hsl(0, 100%, 40%);">- * AST_JSON_OBJECT and \ref AST_JSON_ARRAY instances are deleted. This can be</span><br><span style="color: hsl(0, 100%, 40%);">- * avoided by using ast_json_deep_copy() when sharing JSON instances between</span><br><span style="color: hsl(0, 100%, 40%);">- * objects.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * The second is when using the reference borrowing specifier in</span><br><span style="color: hsl(0, 100%, 40%);">- * ast_json_pack() (capital \c O). This can be avoided by using the reference</span><br><span style="color: hsl(0, 100%, 40%);">- * stealing specifier (lowercase \c o) and wrapping the JSON object parameter</span><br><span style="color: hsl(0, 100%, 40%);">- * with ast_json_ref() for an explicit ref-bump.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span> * \par Example code</span><br><span> *</span><br><span> * \code</span><br><span>@@ -907,7 +878,7 @@</span><br><span> * \brief Helper for creating complex JSON values.</span><br><span> * \since 12.0.0</span><br><span> *</span><br><span style="color: hsl(0, 100%, 40%);">- * See original Jansson docs at http://www.digip.org/jansson/doc/2.4/apiref.html#apiref-pack</span><br><span style="color: hsl(120, 100%, 40%);">+ * See original Jansson docs at http://www.digip.org/jansson/doc/2.11/apiref.html#apiref-pack</span><br><span> * for more details.</span><br><span> */</span><br><span> struct ast_json *ast_json_pack(char const *format, ...);</span><br><span>@@ -916,7 +887,7 @@</span><br><span> * \brief Helper for creating complex JSON values simply.</span><br><span> * \since 12.0.0</span><br><span> *</span><br><span style="color: hsl(0, 100%, 40%);">- * See original Jansson docs at http://www.digip.org/jansson/doc/2.4/apiref.html#apiref-pack</span><br><span style="color: hsl(120, 100%, 40%);">+ * See original Jansson docs at http://www.digip.org/jansson/doc/2.11/apiref.html#apiref-pack</span><br><span> * for more details.</span><br><span> */</span><br><span> struct ast_json *ast_json_vpack(char const *format, va_list ap);</span><br><span>diff --git a/main/json.c b/main/json.c</span><br><span>index 7d7bd1d..e780c01 100644</span><br><span>--- a/main/json.c</span><br><span>+++ b/main/json.c</span><br><span>@@ -44,7 +44,6 @@</span><br><span> #include <jansson.h></span><br><span> #include <time.h></span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-#if defined(JANSSON_THREAD_SAFE_REFCOUNT)</span><br><span> void *ast_json_malloc(size_t size)</span><br><span> {</span><br><span> return ast_malloc(size);</span><br><span>@@ -55,155 +54,6 @@</span><br><span> ast_free(p);</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/* No need to lock since jansson is thread safe. */</span><br><span style="color: hsl(0, 100%, 40%);">-#define SCOPED_JSON_LOCK(json)</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-#else</span><br><span style="color: hsl(0, 100%, 40%);">-/*! \brief Magic number, for safety checks. */</span><br><span style="color: hsl(0, 100%, 40%);">-#define JSON_MAGIC 0x1541992</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/*! \brief Internal structure for allocated memory blocks */</span><br><span style="color: hsl(0, 100%, 40%);">-struct json_mem {</span><br><span style="color: hsl(0, 100%, 40%);">- /*! Magic number, for safety checks */</span><br><span style="color: hsl(0, 100%, 40%);">- uint32_t magic;</span><br><span style="color: hsl(0, 100%, 40%);">- /*! Mutext for locking this memory block */</span><br><span style="color: hsl(0, 100%, 40%);">- ast_mutex_t mutex;</span><br><span style="color: hsl(0, 100%, 40%);">- /*! Linked list pointer for the free list */</span><br><span style="color: hsl(0, 100%, 40%);">- AST_LIST_ENTRY(json_mem) list;</span><br><span style="color: hsl(0, 100%, 40%);">- /*! Data section of the allocation; void pointer for proper alignment */</span><br><span style="color: hsl(0, 100%, 40%);">- void *data[];</span><br><span style="color: hsl(0, 100%, 40%);">-};</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/*! \brief Free a \ref json_mem block. */</span><br><span style="color: hsl(0, 100%, 40%);">-static void json_mem_free(struct json_mem *mem)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- mem->magic = 0;</span><br><span style="color: hsl(0, 100%, 40%);">- ast_mutex_destroy(&mem->mutex);</span><br><span style="color: hsl(0, 100%, 40%);">- ast_free(mem);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/*!</span><br><span style="color: hsl(0, 100%, 40%);">- * \brief Get the \ref json_mem block for a pointer allocated via</span><br><span style="color: hsl(0, 100%, 40%);">- * ast_json_malloc().</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * This function properly handles Jansson singletons (null, true, false), and</span><br><span style="color: hsl(0, 100%, 40%);">- * \c NULL.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * \param p Pointer, usually to a \c json_t or \ref ast_json.</span><br><span style="color: hsl(0, 100%, 40%);">- * \return \ref json_mem object with extra allocation info.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-static inline struct json_mem *to_json_mem(void *p)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- struct json_mem *mem;</span><br><span style="color: hsl(0, 100%, 40%);">- /* Avoid ref'ing the singleton values */</span><br><span style="color: hsl(0, 100%, 40%);">- if (p == NULL || p == json_null() || p == json_true() ||</span><br><span style="color: hsl(0, 100%, 40%);">- p == json_false()) {</span><br><span style="color: hsl(0, 100%, 40%);">- return NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- mem = (struct json_mem *)((char *) (p) - sizeof(*mem));</span><br><span style="color: hsl(0, 100%, 40%);">- ast_assert(mem->magic == JSON_MAGIC);</span><br><span style="color: hsl(0, 100%, 40%);">- return mem;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/*!</span><br><span style="color: hsl(0, 100%, 40%);">- * \brief Lock an \ref ast_json instance.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * If \a json is an immutable singleton (null, true, false), this function</span><br><span style="color: hsl(0, 100%, 40%);">- * safely ignores it and returns \c NULL. Otherwise, \a json must have been</span><br><span style="color: hsl(0, 100%, 40%);">- * allocates using ast_json_malloc().</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * \param json JSON instance to lock.</span><br><span style="color: hsl(0, 100%, 40%);">- * \return \ref Corresponding \ref json_mem block.</span><br><span style="color: hsl(0, 100%, 40%);">- * \return \c NULL if \a json was not allocated.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-static struct json_mem *json_mem_lock(struct ast_json *json)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- struct json_mem *mem = to_json_mem(json);</span><br><span style="color: hsl(0, 100%, 40%);">- if (!mem) {</span><br><span style="color: hsl(0, 100%, 40%);">- return NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- ast_mutex_lock(&mem->mutex);</span><br><span style="color: hsl(0, 100%, 40%);">- return mem;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/*!</span><br><span style="color: hsl(0, 100%, 40%);">- * \brief Unlock a \ref json_mem instance.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * \param mem \ref json_mem, usually returned from json_mem_lock().</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-static void json_mem_unlock(struct json_mem *mem)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- if (!mem) {</span><br><span style="color: hsl(0, 100%, 40%);">- return;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- ast_mutex_unlock(&mem->mutex);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/*!</span><br><span style="color: hsl(0, 100%, 40%);">- * \brief Scoped lock for a \ref ast_json instance.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * \param json JSON instance to lock.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-#define SCOPED_JSON_LOCK(json) \</span><br><span style="color: hsl(0, 100%, 40%);">- RAII_VAR(struct json_mem *, __mem_ ## __LINE__, \</span><br><span style="color: hsl(0, 100%, 40%);">- json_mem_lock(json), json_mem_unlock)</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-void *ast_json_malloc(size_t size)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- struct json_mem *mem = ast_malloc(size + sizeof(*mem));</span><br><span style="color: hsl(0, 100%, 40%);">- if (!mem) {</span><br><span style="color: hsl(0, 100%, 40%);">- return NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- mem->magic = JSON_MAGIC;</span><br><span style="color: hsl(0, 100%, 40%);">- ast_mutex_init(&mem->mutex);</span><br><span style="color: hsl(0, 100%, 40%);">- return mem->data;</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-AST_THREADSTORAGE(json_free_list_ts);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/*!</span><br><span style="color: hsl(0, 100%, 40%);">- * \brief Struct for a linked list of \ref json_mem.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-AST_LIST_HEAD_NOLOCK(json_mem_list, json_mem);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/*!</span><br><span style="color: hsl(0, 100%, 40%);">- * \brief Thread local list of \ref json_mem blocks to free at the end of an</span><br><span style="color: hsl(0, 100%, 40%);">- * unref.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-static struct json_mem_list *json_free_list(void)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- return ast_threadstorage_get(&json_free_list_ts,</span><br><span style="color: hsl(0, 100%, 40%);">- sizeof(struct json_mem_list));</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-void ast_json_free(void *p)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- struct json_mem *mem;</span><br><span style="color: hsl(0, 100%, 40%);">- struct json_mem_list *free_list;</span><br><span style="color: hsl(0, 100%, 40%);">- mem = to_json_mem(p);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (!mem) {</span><br><span style="color: hsl(0, 100%, 40%);">- return;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /* Since the unref is holding a lock in mem, we can't free it</span><br><span style="color: hsl(0, 100%, 40%);">- * immediately. Store it off on a thread local list to be freed by</span><br><span style="color: hsl(0, 100%, 40%);">- * ast_json_unref().</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- free_list = json_free_list();</span><br><span style="color: hsl(0, 100%, 40%);">- if (!free_list) {</span><br><span style="color: hsl(0, 100%, 40%);">- ast_log(LOG_ERROR, "Error allocating free list\n");</span><br><span style="color: hsl(0, 100%, 40%);">- ast_assert(0);</span><br><span style="color: hsl(0, 100%, 40%);">- /* It's not ideal to free the memory immediately, but that's the</span><br><span style="color: hsl(0, 100%, 40%);">- * best we can do if the threadlocal allocation fails */</span><br><span style="color: hsl(0, 100%, 40%);">- json_mem_free(mem);</span><br><span style="color: hsl(0, 100%, 40%);">- return;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- AST_LIST_INSERT_HEAD(free_list, mem, list);</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-#endif</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> void ast_json_set_alloc_funcs(void *(*malloc_fn)(size_t), void (*free_fn)(void*))</span><br><span> {</span><br><span> json_set_alloc_funcs(malloc_fn, free_fn);</span><br><span>@@ -216,42 +66,13 @@</span><br><span> </span><br><span> struct ast_json *ast_json_ref(struct ast_json *json)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- /* If Jansson refcounting is non-atomic; lock it. */</span><br><span style="color: hsl(0, 100%, 40%);">- SCOPED_JSON_LOCK(json);</span><br><span> json_incref((json_t *)json);</span><br><span> return json;</span><br><span> }</span><br><span> </span><br><span> void ast_json_unref(struct ast_json *json)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-#if defined(JANSSON_THREAD_SAFE_REFCOUNT)</span><br><span> json_decref((json_t *) json);</span><br><span style="color: hsl(0, 100%, 40%);">-#else</span><br><span style="color: hsl(0, 100%, 40%);">- struct json_mem_list *free_list;</span><br><span style="color: hsl(0, 100%, 40%);">- struct json_mem *mem;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (!json) {</span><br><span style="color: hsl(0, 100%, 40%);">- return;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /* Jansson refcounting is non-atomic; lock it. */</span><br><span style="color: hsl(0, 100%, 40%);">- {</span><br><span style="color: hsl(0, 100%, 40%);">- SCOPED_JSON_LOCK(json);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- json_decref((json_t *) json);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /* Now free any objects that were ast_json_free()'s while the lock was</span><br><span style="color: hsl(0, 100%, 40%);">- * held */</span><br><span style="color: hsl(0, 100%, 40%);">- free_list = json_free_list();</span><br><span style="color: hsl(0, 100%, 40%);">- if (!free_list) {</span><br><span style="color: hsl(0, 100%, 40%);">- return;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- while ((mem = AST_LIST_REMOVE_HEAD(free_list, list))) {</span><br><span style="color: hsl(0, 100%, 40%);">- json_mem_free(mem);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-#endif</span><br><span> }</span><br><span> </span><br><span> enum ast_json_type ast_json_typeof(const struct ast_json *json)</span><br><span>@@ -421,11 +242,7 @@</span><br><span> </span><br><span> struct ast_json *ast_json_boolean(int value)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-#if JANSSON_VERSION_HEX >= 0x020400</span><br><span> return (struct ast_json *)json_boolean(value);</span><br><span style="color: hsl(0, 100%, 40%);">-#else</span><br><span style="color: hsl(0, 100%, 40%);">- return value ? ast_json_true() : ast_json_false();</span><br><span style="color: hsl(0, 100%, 40%);">-#endif</span><br><span> }</span><br><span> </span><br><span> struct ast_json *ast_json_null(void)</span><br><span>@@ -593,57 +410,11 @@</span><br><span> }</span><br><span> int ast_json_object_update_existing(struct ast_json *object, struct ast_json *other)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-#if JANSSON_VERSION_HEX >= 0x020300</span><br><span> return json_object_update_existing((json_t *)object, (json_t *)other);</span><br><span style="color: hsl(0, 100%, 40%);">-#else</span><br><span style="color: hsl(0, 100%, 40%);">- struct ast_json_iter *iter = ast_json_object_iter(other);</span><br><span style="color: hsl(0, 100%, 40%);">- int ret = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (object == NULL || other == NULL) {</span><br><span style="color: hsl(0, 100%, 40%);">- return -1;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- while (iter != NULL && ret == 0) {</span><br><span style="color: hsl(0, 100%, 40%);">- const char *key = ast_json_object_iter_key(iter);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_json_object_get(object, key) != NULL) {</span><br><span style="color: hsl(0, 100%, 40%);">- struct ast_json *value = ast_json_object_iter_value(iter);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (!value || ast_json_object_set(object, key, ast_json_ref(value))) {</span><br><span style="color: hsl(0, 100%, 40%);">- ret = -1;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- iter = ast_json_object_iter_next(other, iter);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- return ret;</span><br><span style="color: hsl(0, 100%, 40%);">-#endif</span><br><span> }</span><br><span> int ast_json_object_update_missing(struct ast_json *object, struct ast_json *other)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-#if JANSSON_VERSION_HEX >= 0x020300</span><br><span> return json_object_update_missing((json_t *)object, (json_t *)other);</span><br><span style="color: hsl(0, 100%, 40%);">-#else</span><br><span style="color: hsl(0, 100%, 40%);">- struct ast_json_iter *iter = ast_json_object_iter(other);</span><br><span style="color: hsl(0, 100%, 40%);">- int ret = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (object == NULL || other == NULL) {</span><br><span style="color: hsl(0, 100%, 40%);">- return -1;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- while (iter != NULL && ret == 0) {</span><br><span style="color: hsl(0, 100%, 40%);">- const char *key = ast_json_object_iter_key(iter);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (ast_json_object_get(object, key) == NULL) {</span><br><span style="color: hsl(0, 100%, 40%);">- struct ast_json *value = ast_json_object_iter_value(iter);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- if (!value || ast_json_object_set(object, key, ast_json_ref(value))) {</span><br><span style="color: hsl(0, 100%, 40%);">- ret = -1;</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- iter = ast_json_object_iter_next(other, iter);</span><br><span style="color: hsl(0, 100%, 40%);">- }</span><br><span style="color: hsl(0, 100%, 40%);">- return ret;</span><br><span style="color: hsl(0, 100%, 40%);">-#endif</span><br><span> }</span><br><span> </span><br><span> struct ast_json_iter *ast_json_object_iter(struct ast_json *object)</span><br><span>@@ -682,14 +453,6 @@</span><br><span> </span><br><span> char *ast_json_dump_string_format(struct ast_json *root, enum ast_json_encoding_format format)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- /* Jansson's json_dump*, even though it's a read operation, isn't</span><br><span style="color: hsl(0, 100%, 40%);">- * thread safe for concurrent reads. Locking is necessary.</span><br><span style="color: hsl(0, 100%, 40%);">- * See http://www.digip.org/jansson/doc/2.4/portability.html#thread-safety.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * This comment does not apply when JANSSON_THREAD_SAFE_REFCOUNT is defined,</span><br><span style="color: hsl(0, 100%, 40%);">- * in that case SCOPED_JSON_LOCK is a no-op.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- SCOPED_JSON_LOCK(root);</span><br><span> return json_dumps((json_t *)root, dump_flags(format));</span><br><span> }</span><br><span> </span><br><span>@@ -726,28 +489,12 @@</span><br><span> </span><br><span> int ast_json_dump_str_format(struct ast_json *root, struct ast_str **dst, enum ast_json_encoding_format format)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- /* Jansson's json_dump*, even though it's a read operation, isn't</span><br><span style="color: hsl(0, 100%, 40%);">- * thread safe for concurrent reads. Locking is necessary.</span><br><span style="color: hsl(0, 100%, 40%);">- * See http://www.digip.org/jansson/doc/2.4/portability.html#thread-safety.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * This comment does not apply when JANSSON_THREAD_SAFE_REFCOUNT is defined,</span><br><span style="color: hsl(0, 100%, 40%);">- * in that case SCOPED_JSON_LOCK is a no-op.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- SCOPED_JSON_LOCK(root);</span><br><span> return json_dump_callback((json_t *)root, write_to_ast_str, dst, dump_flags(format));</span><br><span> }</span><br><span> </span><br><span> </span><br><span> int ast_json_dump_file_format(struct ast_json *root, FILE *output, enum ast_json_encoding_format format)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- /* Jansson's json_dump*, even though it's a read operation, isn't</span><br><span style="color: hsl(0, 100%, 40%);">- * thread safe for concurrent reads. Locking is necessary.</span><br><span style="color: hsl(0, 100%, 40%);">- * See http://www.digip.org/jansson/doc/2.4/portability.html#thread-safety.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * This comment does not apply when JANSSON_THREAD_SAFE_REFCOUNT is defined,</span><br><span style="color: hsl(0, 100%, 40%);">- * in that case SCOPED_JSON_LOCK is a no-op.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- SCOPED_JSON_LOCK(root);</span><br><span> if (!root || !output) {</span><br><span> return -1;</span><br><span> }</span><br><span>@@ -755,14 +502,6 @@</span><br><span> }</span><br><span> int ast_json_dump_new_file_format(struct ast_json *root, const char *path, enum ast_json_encoding_format format)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">- /* Jansson's json_dump*, even though it's a read operation, isn't</span><br><span style="color: hsl(0, 100%, 40%);">- * thread safe for concurrent reads. Locking is necessary.</span><br><span style="color: hsl(0, 100%, 40%);">- * See http://www.digip.org/jansson/doc/2.4/portability.html#thread-safety.</span><br><span style="color: hsl(0, 100%, 40%);">- *</span><br><span style="color: hsl(0, 100%, 40%);">- * This comment does not apply when JANSSON_THREAD_SAFE_REFCOUNT is defined,</span><br><span style="color: hsl(0, 100%, 40%);">- * in that case SCOPED_JSON_LOCK is a no-op.</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">- SCOPED_JSON_LOCK(root);</span><br><span> if (!root || !path) {</span><br><span> return -1;</span><br><span> }</span><br><span>diff --git a/makeopts.in b/makeopts.in</span><br><span>index b52eda7..cb98726 100644</span><br><span>--- a/makeopts.in</span><br><span>+++ b/makeopts.in</span><br><span>@@ -183,6 +183,7 @@</span><br><span> JACK_INCLUDE=@JACK_INCLUDE@</span><br><span> JACK_LIB=@JACK_LIB@</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+JANSSON_BUNDLED=@JANSSON_BUNDLED@</span><br><span> JANSSON_INCLUDE=@JANSSON_INCLUDE@</span><br><span> JANSSON_LIB=@JANSSON_LIB@</span><br><span> </span><br><span>diff --git a/third-party/Makefile b/third-party/Makefile</span><br><span>index 3ea84d1..7b2afda 100644</span><br><span>--- a/third-party/Makefile</span><br><span>+++ b/third-party/Makefile</span><br><span>@@ -1,10 +1,10 @@</span><br><span> </span><br><span> include Makefile.rules</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-TP_SUBDIRS := pjproject</span><br><span style="color: hsl(120, 100%, 40%);">+TP_SUBDIRS := pjproject jansson</span><br><span> # Sub directories that contain special install/uninstall targets must be explicitly listed</span><br><span> # to prevent accidentally running the package's default install target.</span><br><span style="color: hsl(0, 100%, 40%);">-TP_INSTALL_SUBDIRS := pjproject</span><br><span style="color: hsl(120, 100%, 40%);">+TP_INSTALL_SUBDIRS := pjproject jansson</span><br><span> </span><br><span> .PHONY: all dist-clean distclean install clean moduleinfo makeopts uninstall $(TP_SUBDIRS)</span><br><span> </span><br><span>diff --git a/third-party/Makefile.rules b/third-party/Makefile.rules</span><br><span>index 8306869..f02ddb1 100644</span><br><span>--- a/third-party/Makefile.rules</span><br><span>+++ b/third-party/Makefile.rules</span><br><span>@@ -33,3 +33,25 @@</span><br><span> export DOWNLOAD</span><br><span> export DOWNLOAD_TO_STDOUT</span><br><span> export DOWNLOAD_TIMEOUT</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+DOWNLOAD_DIR := $(or $(EXTERNALS_CACHE_DIR),$(TMPDIR),$(wildcard /tmp),.)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# These depend on the subpackage defining TARBALL_FILE.</span><br><span style="color: hsl(120, 100%, 40%);">+TARBALL_EXISTS = test -f $(DOWNLOAD_DIR)/$(TARBALL_FILE) -a -f $(TARBALL_MD5)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+define TARBALL_VERIFY</span><br><span style="color: hsl(120, 100%, 40%);">+ ($(SHELL_ECHO_PREFIX) Verifying $(DOWNLOAD_DIR)/$(TARBALL_FILE) &&\</span><br><span style="color: hsl(120, 100%, 40%);">+ tarball_sum=$$($(CAT) $(DOWNLOAD_DIR)/$(TARBALL_FILE) | $(MD5) | $(CUT) -d' ' -f1) ;\</span><br><span style="color: hsl(120, 100%, 40%);">+ required_sum=$$($(GREP) -e $(TARBALL_FILE) $(TARBALL_MD5) | $(CUT) -d' ' -f1) ;\</span><br><span style="color: hsl(120, 100%, 40%);">+ if [ -z "$$required_sum" -o "$$tarball_sum" != "$$required_sum" ] ; then $(SHELL_ECHO_PREFIX) Verify failed ; exit 1 ;\</span><br><span style="color: hsl(120, 100%, 40%);">+ else $(SHELL_ECHO_PREFIX) Verify successful ; exit 0 ; fi; )</span><br><span style="color: hsl(120, 100%, 40%);">+endef</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+define TARBALL_DOWNLOAD</span><br><span style="color: hsl(120, 100%, 40%);">+ ($(SHELL_ECHO_PREFIX) Downloading $(TARBALL_URL) to $(DOWNLOAD_DIR)/$(TARBALL_FILE) ;\</span><br><span style="color: hsl(120, 100%, 40%);">+ $(DOWNLOAD_TO_STDOUT) $(call DOWNLOAD_TIMEOUT,5,60) $(TARBALL_URL) > $(DOWNLOAD_DIR)/$(TARBALL_FILE) &&\</span><br><span style="color: hsl(120, 100%, 40%);">+ $(TARBALL_VERIFY))</span><br><span style="color: hsl(120, 100%, 40%);">+endef</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+TARBALL_URL = $(PACKAGE_URL)/$(TARBALL_FILE)</span><br><span style="color: hsl(120, 100%, 40%);">+TARBALL_MD5 = $(TARBALL_FILE).md5</span><br><span>diff --git a/third-party/pjproject/apply_patches b/third-party/apply_patches</span><br><span>similarity index 100%</span><br><span>rename from third-party/pjproject/apply_patches</span><br><span>rename to third-party/apply_patches</span><br><span>diff --git a/third-party/configure.m4 b/third-party/configure.m4</span><br><span>index 6367722..fa4736d 100644</span><br><span>--- a/third-party/configure.m4</span><br><span>+++ b/third-party/configure.m4</span><br><span>@@ -5,5 +5,6 @@</span><br><span> </span><br><span> AC_DEFUN([THIRD_PARTY_CONFIGURE],</span><br><span> [</span><br><span style="color: hsl(120, 100%, 40%);">+ JANSSON_CONFIGURE()</span><br><span> PJPROJECT_CONFIGURE()</span><br><span> ])</span><br><span>diff --git a/third-party/jansson/.gitignore b/third-party/jansson/.gitignore</span><br><span>new file mode 100644</span><br><span>index 0000000..b7bfd2b</span><br><span>--- /dev/null</span><br><span>+++ b/third-party/jansson/.gitignore</span><br><span>@@ -0,0 +1,4 @@</span><br><span style="color: hsl(120, 100%, 40%);">+source/</span><br><span style="color: hsl(120, 100%, 40%);">+dest/</span><br><span style="color: hsl(120, 100%, 40%);">+**.bz2</span><br><span style="color: hsl(120, 100%, 40%);">+.rebuild_needed</span><br><span>diff --git a/third-party/jansson/Makefile b/third-party/jansson/Makefile</span><br><span>new file mode 100644</span><br><span>index 0000000..a85efa0</span><br><span>--- /dev/null</span><br><span>+++ b/third-party/jansson/Makefile</span><br><span>@@ -0,0 +1,99 @@</span><br><span style="color: hsl(120, 100%, 40%);">+.PHONY: _all all _install install clean distclean configure</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+.NOTPARALLEL:</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+include ../versions.mak</span><br><span style="color: hsl(120, 100%, 40%);">+export JANSSON_DIR := $(shell pwd -P)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+SPECIAL_TARGETS :=</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ifneq ($(findstring configure,$(MAKECMDGOALS)),)</span><br><span style="color: hsl(120, 100%, 40%);">+# Run from $(ASTTOPDIR)/configure</span><br><span style="color: hsl(120, 100%, 40%);">+ SPECIAL_TARGETS += configure</span><br><span style="color: hsl(120, 100%, 40%);">+endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ifeq ($(findstring clean,$(MAKECMDGOALS)),clean)</span><br><span style="color: hsl(120, 100%, 40%);">+# clean or distclean</span><br><span style="color: hsl(120, 100%, 40%);">+ SPECIAL_TARGETS += clean</span><br><span style="color: hsl(120, 100%, 40%);">+endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ifeq ($(findstring uninstall,$(MAKECMDGOALS)),uninstall)</span><br><span style="color: hsl(120, 100%, 40%);">+ SPECIAL_TARGETS += uninstall</span><br><span style="color: hsl(120, 100%, 40%);">+endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ifneq ($(wildcard ../../makeopts),)</span><br><span style="color: hsl(120, 100%, 40%);">+ include ../../makeopts</span><br><span style="color: hsl(120, 100%, 40%);">+endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ifeq ($(SPECIAL_TARGETS),)</span><br><span style="color: hsl(120, 100%, 40%);">+# Run locally or from $(ASTTOPDIR)/Makefile. All include files should be present</span><br><span style="color: hsl(120, 100%, 40%);">+ ifeq ($(wildcard ../../makeopts),)</span><br><span style="color: hsl(120, 100%, 40%);">+ $(error ASTTOPDIR/configure hasn't been run)</span><br><span style="color: hsl(120, 100%, 40%);">+ endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ifeq ($(JANSSON_BUNDLED),yes)</span><br><span style="color: hsl(120, 100%, 40%);">+ ifneq ($(wildcard ../../menuselect.makeopts),)</span><br><span style="color: hsl(120, 100%, 40%);">+ include ../../menuselect.makeopts</span><br><span style="color: hsl(120, 100%, 40%);">+ else</span><br><span style="color: hsl(120, 100%, 40%);">+ $(warning ASTTOPDIR/menuselect hasn't been run yet. Can't find debug options.)</span><br><span style="color: hsl(120, 100%, 40%);">+ endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ all: _all</span><br><span style="color: hsl(120, 100%, 40%);">+ install: _install</span><br><span style="color: hsl(120, 100%, 40%);">+ else</span><br><span style="color: hsl(120, 100%, 40%);">+ all install:</span><br><span style="color: hsl(120, 100%, 40%);">+ endif</span><br><span style="color: hsl(120, 100%, 40%);">+endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+include ../../Makefile.rules</span><br><span style="color: hsl(120, 100%, 40%);">+include ../Makefile.rules</span><br><span style="color: hsl(120, 100%, 40%);">+include Makefile.rules</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ECHO_PREFIX := $(ECHO_PREFIX) echo '[jansson] '</span><br><span style="color: hsl(120, 100%, 40%);">+SHELL_ECHO_PREFIX := echo '[jansson] '</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+_all: source/config.status</span><br><span style="color: hsl(120, 100%, 40%);">+ $(ECHO_PREFIX) Building bundled jansson.</span><br><span style="color: hsl(120, 100%, 40%);">+ $(CMD_PREFIX) (cd source; make)</span><br><span style="color: hsl(120, 100%, 40%);">+ $(CMD_PREFIX) (cd source; make install)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+.DELETE_ON_ERROR:</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+$(DOWNLOAD_DIR)/$(TARBALL_FILE): ../versions.mak</span><br><span style="color: hsl(120, 100%, 40%);">+ $(CMD_PREFIX) ($(TARBALL_EXISTS) && $(TARBALL_VERIFY) && touch $@) || (rm -rf $@ ;\</span><br><span style="color: hsl(120, 100%, 40%);">+ $(TARBALL_DOWNLOAD)) || (rm -rf $@ ;\</span><br><span style="color: hsl(120, 100%, 40%);">+ $(SHELL_ECHO_PREFIX) Retrying download ; $(TARBALL_DOWNLOAD))</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+source/.unpacked: $(DOWNLOAD_DIR)/$(TARBALL_FILE)</span><br><span style="color: hsl(120, 100%, 40%);">+ $(CMD_PREFIX) $(TARBALL_VERIFY) || (rm -rf $@ ;\</span><br><span style="color: hsl(120, 100%, 40%);">+ $(SHELL_ECHO_PREFIX) Retrying download ; $(TARBALL_DOWNLOAD))</span><br><span style="color: hsl(120, 100%, 40%);">+ $(ECHO_PREFIX) Unpacking $<</span><br><span style="color: hsl(120, 100%, 40%);">+ -@rm -rf source jansson-*/ >/dev/null 2>&1</span><br><span style="color: hsl(120, 100%, 40%);">+ $(CMD_PREFIX) $(TAR) -xjf $<</span><br><span style="color: hsl(120, 100%, 40%);">+ @mv jansson-$(JANSSON_VERSION) source</span><br><span style="color: hsl(120, 100%, 40%);">+ $(ECHO_PREFIX) Applying patches "$(realpath patches)" "$(realpath .)/source"</span><br><span style="color: hsl(120, 100%, 40%);">+ $(CMD_PREFIX) ../apply_patches $(QUIET_CONFIGURE) "$(realpath patches)" "$(realpath .)/source"</span><br><span style="color: hsl(120, 100%, 40%);">+ -@touch source/.unpacked</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+.rebuild_needed: $(wildcard ../../.lastclean)</span><br><span style="color: hsl(120, 100%, 40%);">+ $(ECHO_PREFIX) Rebuilding</span><br><span style="color: hsl(120, 100%, 40%);">+ $(CMD_PREFIX) $(MAKE) clean $(REALLY_QUIET)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+source/config.status: source/.unpacked Makefile.rules .rebuild_needed</span><br><span style="color: hsl(120, 100%, 40%);">+ $(ECHO_PREFIX) Configuring</span><br><span style="color: hsl(120, 100%, 40%);">+ $(CMD_PREFIX) (cd source ; ./configure $(QUIET_CONFIGURE) $(JANSSON_CONFIG_OPTS) --disable-shared --enable-static --prefix=$(JANSSON_DIR)/dest)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+configure: source/config.status</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+_install: _all</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+uninstall:</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+clean:</span><br><span style="color: hsl(120, 100%, 40%);">+ $(ECHO_PREFIX) Cleaning</span><br><span style="color: hsl(120, 100%, 40%);">+ +-$(CMD_PREFIX) test -d source dest && $(SUBMAKE) -C source clean || :</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+distclean:</span><br><span style="color: hsl(120, 100%, 40%);">+ $(ECHO_PREFIX) Distcleaning</span><br><span style="color: hsl(120, 100%, 40%);">+ -$(CMD_PREFIX) rm -rf source jansson-*.tar.bz2 .rebuild_needed</span><br><span>diff --git a/third-party/jansson/Makefile.rules b/third-party/jansson/Makefile.rules</span><br><span>new file mode 100644</span><br><span>index 0000000..39112eb</span><br><span>--- /dev/null</span><br><span>+++ b/third-party/jansson/Makefile.rules</span><br><span>@@ -0,0 +1,16 @@</span><br><span style="color: hsl(120, 100%, 40%);">+# We switched download locations so Asterisk users don't bombard the Digip</span><br><span style="color: hsl(120, 100%, 40%);">+# site with download requests.</span><br><span style="color: hsl(120, 100%, 40%);">+#</span><br><span style="color: hsl(120, 100%, 40%);">+# For future reference when upgrading bundled JANSSON the next time</span><br><span style="color: hsl(120, 100%, 40%);">+# JANSSON is released.</span><br><span style="color: hsl(120, 100%, 40%);">+# Digip's download URL.</span><br><span style="color: hsl(120, 100%, 40%);">+# PACKAGE_URL ?= http://www.digip.org/jansson/releases/</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+PACKAGE_URL ?= https://raw.githubusercontent.com/asterisk/third-party/master/jansson/$(JANSSON_VERSION)</span><br><span style="color: hsl(120, 100%, 40%);">+TARBALL_FILE = jansson-$(JANSSON_VERSION).tar.bz2</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# JANSSON_CONFIGURE_OPTS could come from the command line or could be</span><br><span style="color: hsl(120, 100%, 40%);">+# set/modified by configure.m4 if the build or host tuples aren't the same</span><br><span style="color: hsl(120, 100%, 40%);">+# as the current build environment (cross-compile).</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+JANSSON_CONFIG_OPTS = $(JANSSON_CONFIGURE_OPTS)</span><br><span>diff --git a/third-party/jansson/configure.m4 b/third-party/jansson/configure.m4</span><br><span>new file mode 100644</span><br><span>index 0000000..d59d861</span><br><span>--- /dev/null</span><br><span>+++ b/third-party/jansson/configure.m4</span><br><span>@@ -0,0 +1,89 @@</span><br><span style="color: hsl(120, 100%, 40%);">+#</span><br><span style="color: hsl(120, 100%, 40%);">+# If this file is changed, be sure to run ASTTOPDIR/bootstrap.sh</span><br><span style="color: hsl(120, 100%, 40%);">+# before committing.</span><br><span style="color: hsl(120, 100%, 40%);">+#</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+AC_DEFUN([_JANSSON_CONFIGURE],</span><br><span style="color: hsl(120, 100%, 40%);">+[</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${ac_mandatory_list#*JANSSON*}" != "$ac_mandatory_list" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_ERROR(--with-jansson and --with-jansson-bundled can't both be specified)</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ ac_mandatory_list="$ac_mandatory_list JANSSON"</span><br><span style="color: hsl(120, 100%, 40%);">+ JANSSON_DIR="${ac_pwd}/third-party/jansson"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_CHECKING(for embedded jansson (may have to download))</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_RESULT(configuring)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "x${DOWNLOAD_TO_STDOUT}" = "x" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_ERROR(A download utility (wget, curl, or fetch) is required to download bundled jansson)</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${BZIP2}" = ":" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_ERROR(bzip2 is required to extract the jansson tar file)</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${TAR}" = ":" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_ERROR(tar is required to extract the jansson tar file)</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${PATCH}" = ":" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_ERROR(patch is required to configure bundled jansson)</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${SED}" = ":" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_ERROR(sed is required to configure bundled jansson)</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${NM}" = ":" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_ERROR(nm is required to build bundled jansson)</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${MD5}" = ":" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_ERROR(md5sum is required to build bundled jansson)</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${CAT}" = ":" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_ERROR(cat is required to build bundled jansson)</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${CUT}" = ":" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_ERROR(cut is required to build bundled jansson)</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "${GREP}" = ":" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_ERROR(grep is required to build bundled jansson)</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_ARG_VAR([JANSSON_CONFIGURE_OPTS],[Additional configure options to pass to bundled jansson])</span><br><span style="color: hsl(120, 100%, 40%);">+ this_host=$(./config.sub $(./config.guess))</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "$build" != "$this_host" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ JANSSON_CONFIGURE_OPTS+=" --build=$build"</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "$host" != "$this_host" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ JANSSON_CONFIGURE_OPTS+=" --host=$host"</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ export TAR PATCH SED NM EXTERNALS_CACHE_DIR AST_DOWNLOAD_CACHE DOWNLOAD_TO_STDOUT DOWNLOAD_TIMEOUT DOWNLOAD MD5 CAT CUT GREP</span><br><span style="color: hsl(120, 100%, 40%);">+ export NOISY_BUILD</span><br><span style="color: hsl(120, 100%, 40%);">+ ${GNU_MAKE} --quiet --no-print-directory -C ${JANSSON_DIR} \</span><br><span style="color: hsl(120, 100%, 40%);">+ JANSSON_CONFIGURE_OPTS="$JANSSON_CONFIGURE_OPTS" \</span><br><span style="color: hsl(120, 100%, 40%);">+ EXTERNALS_CACHE_DIR="${EXTERNALS_CACHE_DIR:-${AST_DOWNLOAD_CACHE}}" \</span><br><span style="color: hsl(120, 100%, 40%);">+ configure</span><br><span style="color: hsl(120, 100%, 40%);">+ if test $? -ne 0 ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_RESULT(failed)</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_NOTICE(Unable to configure ${JANSSON_DIR})</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_ERROR(Re-run the ./configure command with 'NOISY_BUILD=yes' appended to see error details.)</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_CHECKING(for bundled jansson)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ JANSSON_INCLUDE=-I${JANSSON_DIR}/dest/include</span><br><span style="color: hsl(120, 100%, 40%);">+ JANSSON_CFLAGS="$JANSSON_INCLUDE"</span><br><span style="color: hsl(120, 100%, 40%);">+ JANSSON_LIB="-L${JANSSON_DIR}/dest/lib -ljansson"</span><br><span style="color: hsl(120, 100%, 40%);">+ PBX_JANSSON=1</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_SUBST([JANSSON_BUNDLED])</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_SUBST([PBX_JANSSON])</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_SUBST([JANSSON_LIB])</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_SUBST([JANSSON_INCLUDE])</span><br><span style="color: hsl(120, 100%, 40%);">+ AC_MSG_RESULT(yes)</span><br><span style="color: hsl(120, 100%, 40%);">+])</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+AC_DEFUN([JANSSON_CONFIGURE],</span><br><span style="color: hsl(120, 100%, 40%);">+[</span><br><span style="color: hsl(120, 100%, 40%);">+ if test "$JANSSON_BUNDLED" = "yes" ; then</span><br><span style="color: hsl(120, 100%, 40%);">+ _JANSSON_CONFIGURE()</span><br><span style="color: hsl(120, 100%, 40%);">+ fi</span><br><span style="color: hsl(120, 100%, 40%);">+])</span><br><span>diff --git a/third-party/jansson/jansson-2.11.tar.bz2.md5 b/third-party/jansson/jansson-2.11.tar.bz2.md5</span><br><span>new file mode 100644</span><br><span>index 0000000..db4326c</span><br><span>--- /dev/null</span><br><span>+++ b/third-party/jansson/jansson-2.11.tar.bz2.md5</span><br><span>@@ -0,0 +1 @@</span><br><span style="color: hsl(120, 100%, 40%);">+289ca8cbd2df31de9bda7e5220754d25 jansson-2.11.tar.bz2</span><br><span>diff --git a/third-party/jansson/patches/0001-Improve-test-coverage.patch b/third-party/jansson/patches/0001-Improve-test-coverage.patch</span><br><span>new file mode 100644</span><br><span>index 0000000..226c404</span><br><span>--- /dev/null</span><br><span>+++ b/third-party/jansson/patches/0001-Improve-test-coverage.patch</span><br><span>@@ -0,0 +1,128 @@</span><br><span style="color: hsl(120, 100%, 40%);">+From 73c22de51672cb40fdc29c95331923d4dcebb6fa Mon Sep 17 00:00:00 2001</span><br><span style="color: hsl(120, 100%, 40%);">+From: Corey Farrell <git@cfware.com></span><br><span style="color: hsl(120, 100%, 40%);">+Date: Tue, 13 Feb 2018 04:35:37 -0500</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: [PATCH 01/22] Improve test coverage.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Changes to test/ removed for bundled use in Asterisk.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+* Test equality of different length strings.</span><br><span style="color: hsl(120, 100%, 40%);">+* Add tab to json_pack whitespace test.</span><br><span style="color: hsl(120, 100%, 40%);">+* Test json_sprintf with empty result and invalid UTF.</span><br><span style="color: hsl(120, 100%, 40%);">+* Test json_get_alloc_funcs with NULL arguments.</span><br><span style="color: hsl(120, 100%, 40%);">+* Test invalid arguments.</span><br><span style="color: hsl(120, 100%, 40%);">+* Add test_chaos to test allocation failure code paths.</span><br><span style="color: hsl(120, 100%, 40%);">+* Remove redundant json_is_string checks from json_string_equal and</span><br><span style="color: hsl(120, 100%, 40%);">+ json_string_copy. Both functions are static and can only be called</span><br><span style="color: hsl(120, 100%, 40%);">+ with a json string.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Fixes to issues found by test_chaos:</span><br><span style="color: hsl(120, 100%, 40%);">+* Fix crash on OOM in pack_unpack.c:read_string().</span><br><span style="color: hsl(120, 100%, 40%);">+* Unconditionally free string in string_create upon allocation failure.</span><br><span style="color: hsl(120, 100%, 40%);">+ Update load.c:parse_value() to reflect this. This resolves a leak on</span><br><span style="color: hsl(120, 100%, 40%);">+ allocation failure for pack_unpack.c:pack_string() and</span><br><span style="color: hsl(120, 100%, 40%);">+ value.c:json_sprintf().</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Although not visible from CodeCoverage these changes significantly</span><br><span style="color: hsl(120, 100%, 40%);">+increase branch coverage. Especially in src/value.c where we previously</span><br><span style="color: hsl(120, 100%, 40%);">+covered 67.4% of branches and now cover 96.3% of branches.</span><br><span style="color: hsl(120, 100%, 40%);">+---</span><br><span style="color: hsl(120, 100%, 40%);">+ CMakeLists.txt | 1 +</span><br><span style="color: hsl(120, 100%, 40%);">+ src/load.c | 6 +-</span><br><span style="color: hsl(120, 100%, 40%);">+ src/pack_unpack.c | 5 +-</span><br><span style="color: hsl(120, 100%, 40%);">+ src/value.c | 9 +-</span><br><span style="color: hsl(120, 100%, 40%);">+ test/.gitignore | 1 +</span><br><span style="color: hsl(120, 100%, 40%);">+ test/suites/api/Makefile.am | 2 +</span><br><span style="color: hsl(120, 100%, 40%);">+ test/suites/api/test_array.c | 73 +++++++++++++++++</span><br><span style="color: hsl(120, 100%, 40%);">+ test/suites/api/test_chaos.c | 115 ++++++++++++++++++++++++++</span><br><span style="color: hsl(120, 100%, 40%);">+ test/suites/api/test_equal.c | 7 ++</span><br><span style="color: hsl(120, 100%, 40%);">+ test/suites/api/test_memory_funcs.c | 7 ++</span><br><span style="color: hsl(120, 100%, 40%);">+ test/suites/api/test_number.c | 36 ++++++++</span><br><span style="color: hsl(120, 100%, 40%);">+ test/suites/api/test_object.c | 122 ++++++++++++++++++++++++++++</span><br><span style="color: hsl(120, 100%, 40%);">+ test/suites/api/test_pack.c | 10 ++-</span><br><span style="color: hsl(120, 100%, 40%);">+ test/suites/api/test_simple.c | 52 ++++++++++++</span><br><span style="color: hsl(120, 100%, 40%);">+ test/suites/api/test_sprintf.c | 12 +++</span><br><span style="color: hsl(120, 100%, 40%);">+ 15 files changed, 444 insertions(+), 14 deletions(-)</span><br><span style="color: hsl(120, 100%, 40%);">+ create mode 100644 test/suites/api/test_chaos.c</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/CMakeLists.txt b/CMakeLists.txt</span><br><span style="color: hsl(120, 100%, 40%);">+index 16cf552..2f6cfec 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/CMakeLists.txt</span><br><span>++++ b/CMakeLists.txt</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -487,6 +487,7 @@ if (NOT JANSSON_WITHOUT_TESTS)</span><br><span style="color: hsl(120, 100%, 40%);">+ set(api_tests</span><br><span style="color: hsl(120, 100%, 40%);">+ test_array</span><br><span style="color: hsl(120, 100%, 40%);">+ test_copy</span><br><span style="color: hsl(120, 100%, 40%);">++ test_chaos</span><br><span style="color: hsl(120, 100%, 40%);">+ test_dump</span><br><span style="color: hsl(120, 100%, 40%);">+ test_dump_callback</span><br><span style="color: hsl(120, 100%, 40%);">+ test_equal</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/src/load.c b/src/load.c</span><br><span style="color: hsl(120, 100%, 40%);">+index deb36f3..25efe2e 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/src/load.c</span><br><span>++++ b/src/load.c</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -829,10 +829,8 @@ static json_t *parse_value(lex_t *lex, size_t flags, json_error_t *error)</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ json = jsonp_stringn_nocheck_own(value, len);</span><br><span style="color: hsl(120, 100%, 40%);">+- if(json) {</span><br><span style="color: hsl(120, 100%, 40%);">+- lex->value.string.val = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+- lex->value.string.len = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+- }</span><br><span style="color: hsl(120, 100%, 40%);">++ lex->value.string.val = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">++ lex->value.string.len = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+ break;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/src/pack_unpack.c b/src/pack_unpack.c</span><br><span style="color: hsl(120, 100%, 40%);">+index 153f64d..19dbf93 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/src/pack_unpack.c</span><br><span>++++ b/src/pack_unpack.c</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -159,7 +159,10 @@ static char *read_string(scanner_t *s, va_list *ap,</span><br><span style="color: hsl(120, 100%, 40%);">+ return (char *)str;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+- strbuffer_init(&strbuff);</span><br><span style="color: hsl(120, 100%, 40%);">++ if(strbuffer_init(&strbuff)) {</span><br><span style="color: hsl(120, 100%, 40%);">++ set_error(s, "<internal>", json_error_out_of_memory, "Out of memory");</span><br><span style="color: hsl(120, 100%, 40%);">++ s->has_error = 1;</span><br><span style="color: hsl(120, 100%, 40%);">++ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ while(1) {</span><br><span style="color: hsl(120, 100%, 40%);">+ str = va_arg(*ap, const char *);</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/src/value.c b/src/value.c</span><br><span style="color: hsl(120, 100%, 40%);">+index b3b3141..29a978c 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/src/value.c</span><br><span>++++ b/src/value.c</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -652,8 +652,7 @@ static json_t *string_create(const char *value, size_t len, int own)</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ string = jsonp_malloc(sizeof(json_string_t));</span><br><span style="color: hsl(120, 100%, 40%);">+ if(!string) {</span><br><span style="color: hsl(120, 100%, 40%);">+- if(!own)</span><br><span style="color: hsl(120, 100%, 40%);">+- jsonp_free(v);</span><br><span style="color: hsl(120, 100%, 40%);">++ jsonp_free(v);</span><br><span style="color: hsl(120, 100%, 40%);">+ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ json_init(&string->json, JSON_STRING);</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -768,9 +767,6 @@ static int json_string_equal(const json_t *string1, const json_t *string2)</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+ json_string_t *s1, *s2;</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+- if(!json_is_string(string1) || !json_is_string(string2))</span><br><span style="color: hsl(120, 100%, 40%);">+- return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+-</span><br><span style="color: hsl(120, 100%, 40%);">+ s1 = json_to_string(string1);</span><br><span style="color: hsl(120, 100%, 40%);">+ s2 = json_to_string(string2);</span><br><span style="color: hsl(120, 100%, 40%);">+ return s1->length == s2->length && !memcmp(s1->value, s2->value, s1->length);</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -780,9 +776,6 @@ static json_t *json_string_copy(const json_t *string)</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+ json_string_t *s;</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+- if(!json_is_string(string))</span><br><span style="color: hsl(120, 100%, 40%);">+- return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+-</span><br><span style="color: hsl(120, 100%, 40%);">+ s = json_to_string(string);</span><br><span style="color: hsl(120, 100%, 40%);">+ return json_stringn_nocheck(s->value, s->length);</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+-- </span><br><span style="color: hsl(120, 100%, 40%);">+2.17.1</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>diff --git a/third-party/jansson/patches/0017-Fix-error-handling-in-json_pack.patch b/third-party/jansson/patches/0017-Fix-error-handling-in-json_pack.patch</span><br><span>new file mode 100644</span><br><span>index 0000000..affa6c9</span><br><span>--- /dev/null</span><br><span>+++ b/third-party/jansson/patches/0017-Fix-error-handling-in-json_pack.patch</span><br><span>@@ -0,0 +1,103 @@</span><br><span style="color: hsl(120, 100%, 40%);">+From 15105b66b4df387037b670ac713584194ea10c2f Mon Sep 17 00:00:00 2001</span><br><span style="color: hsl(120, 100%, 40%);">+From: Maxim Zhukov <mussitantesmortem@gmail.com></span><br><span style="color: hsl(120, 100%, 40%);">+Date: Mon, 12 Mar 2018 17:39:04 +0300</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: [PATCH 17/22] Fix error handling in json_pack</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Changes to test/ removed.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Fixed a bug where the error message was not filled if an empty object</span><br><span style="color: hsl(120, 100%, 40%);">+was passed to the json_pack.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Fixes #271</span><br><span style="color: hsl(120, 100%, 40%);">+---</span><br><span style="color: hsl(120, 100%, 40%);">+ src/pack_unpack.c | 64 ++++++++++++++++++-------------------</span><br><span style="color: hsl(120, 100%, 40%);">+ test/suites/api/test_pack.c | 8 +++++</span><br><span style="color: hsl(120, 100%, 40%);">+ 2 files changed, 40 insertions(+), 32 deletions(-)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/src/pack_unpack.c b/src/pack_unpack.c</span><br><span style="color: hsl(120, 100%, 40%);">+index 4026fd9..6461c06 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/src/pack_unpack.c</span><br><span>++++ b/src/pack_unpack.c</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -348,6 +348,36 @@ static json_t *pack_string(scanner_t *s, va_list *ap)</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++static json_t *pack_object_inter(scanner_t *s, va_list *ap, int need_incref)</span><br><span style="color: hsl(120, 100%, 40%);">++{</span><br><span style="color: hsl(120, 100%, 40%);">++ json_t *json;</span><br><span style="color: hsl(120, 100%, 40%);">++ char ntoken;</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ next_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">++ ntoken = token(s);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ if (ntoken != '?')</span><br><span style="color: hsl(120, 100%, 40%);">++ prev_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ json = va_arg(*ap, json_t *);</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ if (json)</span><br><span style="color: hsl(120, 100%, 40%);">++ return need_incref ? json_incref(json) : json;</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ switch (ntoken) {</span><br><span style="color: hsl(120, 100%, 40%);">++ case '?':</span><br><span style="color: hsl(120, 100%, 40%);">++ return json_null();</span><br><span style="color: hsl(120, 100%, 40%);">++ case '*':</span><br><span style="color: hsl(120, 100%, 40%);">++ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">++ default:</span><br><span style="color: hsl(120, 100%, 40%);">++ break;</span><br><span style="color: hsl(120, 100%, 40%);">++ }</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++ set_error(s, "<args>", json_error_null_value, "NULL object key");</span><br><span style="color: hsl(120, 100%, 40%);">++ s->has_error = 1;</span><br><span style="color: hsl(120, 100%, 40%);">++ return NULL;</span><br><span style="color: hsl(120, 100%, 40%);">++}</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+ static json_t *pack(scanner_t *s, va_list *ap)</span><br><span style="color: hsl(120, 100%, 40%);">+ {</span><br><span style="color: hsl(120, 100%, 40%);">+ switch(token(s)) {</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -376,40 +406,10 @@ static json_t *pack(scanner_t *s, va_list *ap)</span><br><span style="color: hsl(120, 100%, 40%);">+ return json_real(va_arg(*ap, double));</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ case 'O': /* a json_t object; increments refcount */</span><br><span style="color: hsl(120, 100%, 40%);">+- {</span><br><span style="color: hsl(120, 100%, 40%);">+- int nullable;</span><br><span style="color: hsl(120, 100%, 40%);">+- json_t *json;</span><br><span style="color: hsl(120, 100%, 40%);">+-</span><br><span style="color: hsl(120, 100%, 40%);">+- next_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">+- nullable = token(s) == '?';</span><br><span style="color: hsl(120, 100%, 40%);">+- if (!nullable)</span><br><span style="color: hsl(120, 100%, 40%);">+- prev_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">+-</span><br><span style="color: hsl(120, 100%, 40%);">+- json = va_arg(*ap, json_t *);</span><br><span style="color: hsl(120, 100%, 40%);">+- if (!json && nullable) {</span><br><span style="color: hsl(120, 100%, 40%);">+- return json_null();</span><br><span style="color: hsl(120, 100%, 40%);">+- } else {</span><br><span style="color: hsl(120, 100%, 40%);">+- return json_incref(json);</span><br><span style="color: hsl(120, 100%, 40%);">+- }</span><br><span style="color: hsl(120, 100%, 40%);">+- }</span><br><span style="color: hsl(120, 100%, 40%);">++ return pack_object_inter(s, ap, 1);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ case 'o': /* a json_t object; doesn't increment refcount */</span><br><span style="color: hsl(120, 100%, 40%);">+- {</span><br><span style="color: hsl(120, 100%, 40%);">+- int nullable;</span><br><span style="color: hsl(120, 100%, 40%);">+- json_t *json;</span><br><span style="color: hsl(120, 100%, 40%);">+-</span><br><span style="color: hsl(120, 100%, 40%);">+- next_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">+- nullable = token(s) == '?';</span><br><span style="color: hsl(120, 100%, 40%);">+- if (!nullable)</span><br><span style="color: hsl(120, 100%, 40%);">+- prev_token(s);</span><br><span style="color: hsl(120, 100%, 40%);">+-</span><br><span style="color: hsl(120, 100%, 40%);">+- json = va_arg(*ap, json_t *);</span><br><span style="color: hsl(120, 100%, 40%);">+- if (!json && nullable) {</span><br><span style="color: hsl(120, 100%, 40%);">+- return json_null();</span><br><span style="color: hsl(120, 100%, 40%);">+- } else {</span><br><span style="color: hsl(120, 100%, 40%);">+- return json;</span><br><span style="color: hsl(120, 100%, 40%);">+- }</span><br><span style="color: hsl(120, 100%, 40%);">+- }</span><br><span style="color: hsl(120, 100%, 40%);">++ return pack_object_inter(s, ap, 0);</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+ default:</span><br><span style="color: hsl(120, 100%, 40%);">+ set_error(s, "<format>", json_error_invalid_format, "Unexpected format character '%c'",</span><br><span style="color: hsl(120, 100%, 40%);">+-- </span><br><span style="color: hsl(120, 100%, 40%);">+2.17.1</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>diff --git a/third-party/pjproject/Makefile b/third-party/pjproject/Makefile</span><br><span>index 4669f39..476eb44 100644</span><br><span>--- a/third-party/pjproject/Makefile</span><br><span>+++ b/third-party/pjproject/Makefile</span><br><span>@@ -89,49 +89,22 @@</span><br><span> </span><br><span> _all: $(TARGETS)</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-define tarball_exists</span><br><span style="color: hsl(0, 100%, 40%);">- (if [ -f $(TARBALL) -a -f $(PJMD5SUM) ] ; then exit 0 ;\</span><br><span style="color: hsl(0, 100%, 40%);">- else exit 1; fi; )</span><br><span style="color: hsl(0, 100%, 40%);">-endef</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-define verify_tarball</span><br><span style="color: hsl(0, 100%, 40%);">- ($(SHELL_ECHO_PREFIX) Verifying $(TARBALL) &&\</span><br><span style="color: hsl(0, 100%, 40%);">- tarball_sum=$$($(CAT) $(TARBALL) | $(MD5) | $(CUT) -d' ' -f1) ;\</span><br><span style="color: hsl(0, 100%, 40%);">- required_sum=$$($(GREP) -e $(TARBALL_FILE) $(PJMD5SUM) | $(CUT) -d' ' -f1) ;\</span><br><span style="color: hsl(0, 100%, 40%);">- if [ -z "$$required_sum" -o "$$tarball_sum" != "$$required_sum" ] ; then $(SHELL_ECHO_PREFIX) Verify failed ; exit 1 ;\</span><br><span style="color: hsl(0, 100%, 40%);">- else $(SHELL_ECHO_PREFIX) Verify successful ; exit 0 ; fi; )</span><br><span style="color: hsl(0, 100%, 40%);">-endef</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-define download_from_pjproject</span><br><span style="color: hsl(0, 100%, 40%);">- ($(SHELL_ECHO_PREFIX) Downloading $(TARBALL_URL) to $(TARBALL) ;\</span><br><span style="color: hsl(0, 100%, 40%);">- $(DOWNLOAD_TO_STDOUT) $(call DOWNLOAD_TIMEOUT,5,60) $(TARBALL_URL) > $(TARBALL) &&\</span><br><span style="color: hsl(0, 100%, 40%);">- $(SHELL_ECHO_PREFIX) Downloading $(PJPROJECT_URL)/MD5SUM.TXT to $(PJMD5SUM) &&\</span><br><span style="color: hsl(0, 100%, 40%);">- $(DOWNLOAD_TO_STDOUT) $(call DOWNLOAD_TIMEOUT,5,60) $(PJPROJECT_URL)/MD5SUM.TXT > $(PJMD5SUM) &&\</span><br><span style="color: hsl(0, 100%, 40%);">- $(verify_tarball))</span><br><span style="color: hsl(0, 100%, 40%);">-endef</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> .DELETE_ON_ERROR:</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-DOWNLOAD_DIR := $(or $(EXTERNALS_CACHE_DIR),$(TMPDIR),$(wildcard /tmp),.)</span><br><span style="color: hsl(0, 100%, 40%);">-TARBALL_FILE = pjproject-$(PJPROJECT_VERSION).tar.bz2</span><br><span style="color: hsl(0, 100%, 40%);">-TARBALL = $(DOWNLOAD_DIR)/$(TARBALL_FILE)</span><br><span style="color: hsl(0, 100%, 40%);">-TARBALL_URL = $(PJPROJECT_URL)/$(TARBALL_FILE)</span><br><span style="color: hsl(0, 100%, 40%);">-PJMD5SUM = $(patsubst %.tar.bz2,%.md5,$(TARBALL))</span><br><span style="color: hsl(120, 100%, 40%);">+$(DOWNLOAD_DIR)/$(TARBALL_FILE): ../versions.mak</span><br><span style="color: hsl(120, 100%, 40%);">+ $(CMD_PREFIX) ($(TARBALL_EXISTS) && $(TARBALL_VERIFY) && touch $@) || (rm -rf $@ ;\</span><br><span style="color: hsl(120, 100%, 40%);">+ $(TARBALL_DOWNLOAD)) || (rm -rf $@ ;\</span><br><span style="color: hsl(120, 100%, 40%);">+ $(SHELL_ECHO_PREFIX) Retrying download ; $(TARBALL_DOWNLOAD))</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-$(TARBALL): ../versions.mak</span><br><span style="color: hsl(0, 100%, 40%);">- $(CMD_PREFIX) ($(tarball_exists) && $(verify_tarball) && touch $@) || (rm -rf $@ ;\</span><br><span style="color: hsl(0, 100%, 40%);">- $(download_from_pjproject)) || (rm -rf $@ ;\</span><br><span style="color: hsl(0, 100%, 40%);">- $(SHELL_ECHO_PREFIX) Retrying download ; $(download_from_pjproject))</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-source/.unpacked: $(DOWNLOAD_DIR)/pjproject-$(PJPROJECT_VERSION).tar.bz2</span><br><span style="color: hsl(0, 100%, 40%);">- $(CMD_PREFIX) $(verify_tarball) || (rm -rf $@ ;\</span><br><span style="color: hsl(0, 100%, 40%);">- $(SHELL_ECHO_PREFIX) Retrying download ; $(download_from_pjproject))</span><br><span style="color: hsl(120, 100%, 40%);">+source/.unpacked: $(DOWNLOAD_DIR)/$(TARBALL_FILE)</span><br><span style="color: hsl(120, 100%, 40%);">+ $(CMD_PREFIX) $(TARBALL_VERIFY) || (rm -rf $@ ;\</span><br><span style="color: hsl(120, 100%, 40%);">+ $(SHELL_ECHO_PREFIX) Retrying download ; $(TARBALL_DOWNLOAD))</span><br><span> $(ECHO_PREFIX) Unpacking $<</span><br><span style="color: hsl(0, 100%, 40%);">- -@rm -rf source pjproject-* >/dev/null 2>&1</span><br><span style="color: hsl(120, 100%, 40%);">+ -@rm -rf source pjproject-*/ >/dev/null 2>&1</span><br><span> $(CMD_PREFIX) $(TAR) -xjf $<</span><br><span> @mv pjproject-$(PJPROJECT_VERSION) source</span><br><span> $(ECHO_PREFIX) Applying patches "$(realpath patches)" "$(realpath .)/source"</span><br><span style="color: hsl(0, 100%, 40%);">- $(CMD_PREFIX) ./apply_patches $(QUIET_CONFIGURE) "$(realpath patches)" "$(realpath .)/source"</span><br><span style="color: hsl(120, 100%, 40%);">+ $(CMD_PREFIX) ../apply_patches $(QUIET_CONFIGURE) "$(realpath patches)" "$(realpath .)/source"</span><br><span> -@touch source/.unpacked</span><br><span> </span><br><span> source/version.mak: source/.unpacked</span><br><span>diff --git a/third-party/pjproject/Makefile.rules b/third-party/pjproject/Makefile.rules</span><br><span>index ef1a702..e38024a 100644</span><br><span>--- a/third-party/pjproject/Makefile.rules</span><br><span>+++ b/third-party/pjproject/Makefile.rules</span><br><span>@@ -4,9 +4,10 @@</span><br><span> # For future reference when upgrading bundled PJPROJECT the next time</span><br><span> # PJPROJECT is released.</span><br><span> # Teluu's download URL.</span><br><span style="color: hsl(0, 100%, 40%);">-# PJPROJECT_URL ?= http://www.pjsip.org/release/$(PJPROJECT_VERSION)</span><br><span style="color: hsl(120, 100%, 40%);">+# PACKAGE_URL ?= http://www.pjsip.org/release/$(PJPROJECT_VERSION)</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-PJPROJECT_URL ?= https://raw.githubusercontent.com/asterisk/third-party/master/pjproject/$(PJPROJECT_VERSION)</span><br><span style="color: hsl(120, 100%, 40%);">+PACKAGE_URL ?= https://raw.githubusercontent.com/asterisk/third-party/master/pjproject/$(PJPROJECT_VERSION)</span><br><span style="color: hsl(120, 100%, 40%);">+TARBALL_FILE = pjproject-$(PJPROJECT_VERSION).tar.bz2</span><br><span> </span><br><span> # PJPROJECT_CONFIGURE_OPTS could come from the command line or could be</span><br><span> # set/modified by configure.m4 if the build or host tuples aren't the same</span><br><span>diff --git a/third-party/pjproject/pjproject-2.7.2.tar.bz2.md5 b/third-party/pjproject/pjproject-2.7.2.tar.bz2.md5</span><br><span>new file mode 100644</span><br><span>index 0000000..2ea6b42</span><br><span>--- /dev/null</span><br><span>+++ b/third-party/pjproject/pjproject-2.7.2.tar.bz2.md5</span><br><span>@@ -0,0 +1,2 @@</span><br><span style="color: hsl(120, 100%, 40%);">+8119f0d91a00b6f553099e6ee5358ade *pjproject-2.7.2.zip</span><br><span style="color: hsl(120, 100%, 40%);">+fa3f0bc098c4bff48ddd92db1c016a7a pjproject-2.7.2.tar.bz2</span><br><span>diff --git a/third-party/versions.mak b/third-party/versions.mak</span><br><span>index b6daf19..faf7aec 100644</span><br><span>--- a/third-party/versions.mak</span><br><span>+++ b/third-party/versions.mak</span><br><span>@@ -1,2 +1,2 @@</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(120, 100%, 40%);">+JANSSON_VERSION = 2.11</span><br><span> PJPROJECT_VERSION = 2.7.2</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/9525">change 9525</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/9525"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Ib3111b151d37cbda40768cf2a8a9c6cf6c5c7cbd </div>
<div style="display:none"> Gerrit-Change-Number: 9525 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>