Skip to content

Commit 402375e

Browse files
author
vvaltman
committed
added json support
1 parent 76aec0b commit 402375e

File tree

8 files changed

+856
-106
lines changed

8 files changed

+856
-106
lines changed

‎Makefile.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ DIR_LIST=${DEP} ${AUTO} ${EXE} ${OBJ} ${LIB} ${DEP}/auto ${OBJ}/auto
1919

2020
EXE_LIST=${EXE}/telegram-cli
2121

22-
TG_OBJECTS=${OBJ}/main.o ${OBJ}/loop.o ${OBJ}/interface.o ${OBJ}/lua-tg.o
22+
TG_OBJECTS=${OBJ}/main.o ${OBJ}/loop.o ${OBJ}/interface.o ${OBJ}/lua-tg.o ${OBJ}/json-tg.o
2323

2424
INCLUDE=-I. -I${srcdir} -I${srcdir}/tgl
2525
CC=@CC@

‎config.h.in

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
/* Define to 1 if you have the `event' library (-levent). */
3737
#undef HAVE_LIBEVENT
3838

39+
/* Define to 1 if you have the `jansson' library (-ljansson). */
40+
#undef HAVE_LIBJANSSON
41+
3942
/* Define to 1 if you have the `m' library (-lm). */
4043
#undef HAVE_LIBM
4144

@@ -155,6 +158,9 @@
155158
/* Define to 1 if you have the ANSI C header files. */
156159
#undef STDC_HEADERS
157160

161+
/* use json */
162+
#undef USE_JSON
163+
158164
/* use lua */
159165
#undef USE_LUA
160166

‎configure

+125
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ with_zlib
694694
enable_libconfig
695695
enable_extf
696696
enable_liblua
697+
enable_json
697698
with_progname
698699
enable_valgrind
699700
'
@@ -1321,6 +1322,7 @@ Optional Features:
13211322
--enable-libconfig/--disable-libconfig
13221323
--enable-extf/--disable-extf
13231324
--enable-liblua/--disable-liblua
1325+
--enable-json/--disable-json
13241326
--enable-valgrind/--disable-valgrind
13251327
13261328
Optional Packages:
@@ -5865,7 +5867,130 @@ fi
58655867
fi
58665868

58675869

5870+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libjansson" >&5
5871+
$as_echo_n "checking for libjansson... " >&6; }
5872+
# Check whether --enable-json was given.
5873+
if test "${enable_json+set}" = set; then :
5874+
enableval=$enable_json;
5875+
if test "x$enableval" = "xno" ; then
5876+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
5877+
$as_echo "disabled" >&6; }
5878+
else
5879+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5
5880+
$as_echo "enabled" >&6; }
5881+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for json_array_set_new in -ljansson" >&5
5882+
$as_echo_n "checking for json_array_set_new in -ljansson... " >&6; }
5883+
if ${ac_cv_lib_jansson_json_array_set_new+:} false; then :
5884+
$as_echo_n "(cached) " >&6
5885+
else
5886+
ac_check_lib_save_LIBS=$LIBS
5887+
LIBS="-ljansson $LIBS"
5888+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5889+
/* end confdefs.h. */
5890+
5891+
/* Override any GCC internal prototype to avoid an error.
5892+
Use char because int might match the return type of a GCC
5893+
builtin and then its argument prototype would still apply. */
5894+
#ifdef __cplusplus
5895+
extern "C"
5896+
#endif
5897+
char json_array_set_new ();
5898+
int
5899+
main ()
5900+
{
5901+
return json_array_set_new ();
5902+
;
5903+
return 0;
5904+
}
5905+
_ACEOF
5906+
if ac_fn_c_try_link "$LINENO"; then :
5907+
ac_cv_lib_jansson_json_array_set_new=yes
5908+
else
5909+
ac_cv_lib_jansson_json_array_set_new=no
5910+
fi
5911+
rm -f core conftest.err conftest.$ac_objext \
5912+
conftest$ac_exeext conftest.$ac_ext
5913+
LIBS=$ac_check_lib_save_LIBS
5914+
fi
5915+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jansson_json_array_set_new" >&5
5916+
$as_echo "$ac_cv_lib_jansson_json_array_set_new" >&6; }
5917+
if test "x$ac_cv_lib_jansson_json_array_set_new" = xyes; then :
5918+
cat >>confdefs.h <<_ACEOF
5919+
#define HAVE_LIBJANSSON 1
5920+
_ACEOF
5921+
5922+
LIBS="-ljansson $LIBS"
5923+
5924+
else
5925+
as_fn_error $? "No libjansson found. Try --disable-json" "$LINENO" 5
5926+
fi
5927+
5928+
5929+
$as_echo "#define USE_JSON 1" >>confdefs.h
5930+
5931+
fi
5932+
5933+
else
5934+
5935+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5
5936+
$as_echo "enabled" >&6; }
5937+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for json_array_set_new in -ljansson" >&5
5938+
$as_echo_n "checking for json_array_set_new in -ljansson... " >&6; }
5939+
if ${ac_cv_lib_jansson_json_array_set_new+:} false; then :
5940+
$as_echo_n "(cached) " >&6
5941+
else
5942+
ac_check_lib_save_LIBS=$LIBS
5943+
LIBS="-ljansson $LIBS"
5944+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5945+
/* end confdefs.h. */
5946+
5947+
/* Override any GCC internal prototype to avoid an error.
5948+
Use char because int might match the return type of a GCC
5949+
builtin and then its argument prototype would still apply. */
5950+
#ifdef __cplusplus
5951+
extern "C"
5952+
#endif
5953+
char json_array_set_new ();
5954+
int
5955+
main ()
5956+
{
5957+
return json_array_set_new ();
5958+
;
5959+
return 0;
5960+
}
5961+
_ACEOF
5962+
if ac_fn_c_try_link "$LINENO"; then :
5963+
ac_cv_lib_jansson_json_array_set_new=yes
5964+
else
5965+
ac_cv_lib_jansson_json_array_set_new=no
5966+
fi
5967+
rm -f core conftest.err conftest.$ac_objext \
5968+
conftest$ac_exeext conftest.$ac_ext
5969+
LIBS=$ac_check_lib_save_LIBS
5970+
fi
5971+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_jansson_json_array_set_new" >&5
5972+
$as_echo "$ac_cv_lib_jansson_json_array_set_new" >&6; }
5973+
if test "x$ac_cv_lib_jansson_json_array_set_new" = xyes; then :
5974+
cat >>confdefs.h <<_ACEOF
5975+
#define HAVE_LIBJANSSON 1
5976+
_ACEOF
5977+
5978+
LIBS="-ljansson $LIBS"
5979+
5980+
else
5981+
as_fn_error $? "No libjansson found. Try --disable-json" "$LINENO" 5
5982+
fi
5983+
5984+
5985+
$as_echo "#define USE_JSON 1" >>confdefs.h
5986+
5987+
5988+
fi
5989+
5990+
58685991
#check for custom prog name
5992+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking progname" >&5
5993+
$as_echo_n "checking progname... " >&6; }
58695994

58705995
# Check whether --with-progname was given.
58715996
if test "${with_progname+set}" = set; then :

‎configure.ac

+17
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,24 @@ AC_ARG_ENABLE(liblua,[--enable-liblua/--disable-liblua],
9494
])
9595
])
9696

97+
AC_MSG_CHECKING([for libjansson])
98+
AC_ARG_ENABLE(json,[--enable-json/--disable-json],
99+
[
100+
if test "x$enableval" = "xno" ; then
101+
AC_MSG_RESULT([disabled])
102+
else
103+
AC_MSG_RESULT([enabled])
104+
AC_CHECK_LIB([jansson],[json_array_set_new],[],AC_MSG_ERROR([No libjansson found. Try --disable-json]))
105+
AC_DEFINE(USE_JSON,1,[use json])
106+
fi
107+
],[
108+
AC_MSG_RESULT([enabled])
109+
AC_CHECK_LIB([jansson],[json_array_set_new],[],AC_MSG_ERROR([No libjansson found. Try --disable-json]))
110+
AC_DEFINE(USE_JSON,1,[use json])
111+
])
112+
97113
#check for custom prog name
114+
AC_MSG_CHECKING([progname])
98115
AC_ARG_WITH(progname,[--with-progname=<name>],
99116
[
100117
if test "x$with_progname" = "xno" ; then

0 commit comments

Comments
 (0)