Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
402375ec
Commit
402375ec
authored
May 11, 2015
by
vvaltman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added json support
parent
76aec0bf
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
856 additions
and
106 deletions
+856
-106
Makefile.in
Makefile.in
+1
-1
config.h.in
config.h.in
+6
-0
configure
configure
+125
-0
configure.ac
configure.ac
+17
-0
interface.c
interface.c
+318
-104
json-tg.c
json-tg.c
+369
-0
json-tg.h
json-tg.h
+12
-0
main.c
main.c
+8
-1
No files found.
Makefile.in
View file @
402375ec
...
...
@@ -19,7 +19,7 @@ DIR_LIST=${DEP} ${AUTO} ${EXE} ${OBJ} ${LIB} ${DEP}/auto ${OBJ}/auto
EXE_LIST
=
${
EXE
}
/telegram-cli
TG_OBJECTS
=
${
OBJ
}
/main.o
${
OBJ
}
/loop.o
${
OBJ
}
/interface.o
${
OBJ
}
/lua-tg.o
TG_OBJECTS
=
${
OBJ
}
/main.o
${
OBJ
}
/loop.o
${
OBJ
}
/interface.o
${
OBJ
}
/lua-tg.o
${
OBJ
}
/json-tg.o
INCLUDE
=
-I
.
-I
${
srcdir
}
-I
${
srcdir
}
/tgl
CC
=
@CC@
...
...
config.h.in
View file @
402375ec
...
...
@@ -36,6 +36,9 @@
/* Define to 1 if you have the `event' library (-levent). */
#undef HAVE_LIBEVENT
/* Define to 1 if you have the `jansson' library (-ljansson). */
#undef HAVE_LIBJANSSON
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM
...
...
@@ -155,6 +158,9 @@
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* use json */
#undef USE_JSON
/* use lua */
#undef USE_LUA
...
...
configure
View file @
402375ec
...
...
@@ -694,6 +694,7 @@ with_zlib
enable_libconfig
enable_extf
enable_liblua
enable_json
with_progname
enable_valgrind
'
...
...
@@ -1321,6 +1322,7 @@ Optional Features:
--enable-libconfig/--disable-libconfig
--enable-extf/--disable-extf
--enable-liblua/--disable-liblua
--enable-json/--disable-json
--enable-valgrind/--disable-valgrind
Optional Packages:
...
...
@@ -5865,7 +5867,130 @@ fi
fi
{
$as_echo
"
$as_me
:
${
as_lineno
-
$LINENO
}
: checking for libjansson"
>
&5
$as_echo_n
"checking for libjansson... "
>
&6
;
}
# Check whether --enable-json was given.
if
test
"
${
enable_json
+set
}
"
=
set
;
then
:
enableval
=
$enable_json
;
if
test
"x
$enableval
"
=
"xno"
;
then
{
$as_echo
"
$as_me
:
${
as_lineno
-
$LINENO
}
: result: disabled"
>
&5
$as_echo
"disabled"
>
&6
;
}
else
{
$as_echo
"
$as_me
:
${
as_lineno
-
$LINENO
}
: result: enabled"
>
&5
$as_echo
"enabled"
>
&6
;
}
{
$as_echo
"
$as_me
:
${
as_lineno
-
$LINENO
}
: checking for json_array_set_new in -ljansson"
>
&5
$as_echo_n
"checking for json_array_set_new in -ljansson... "
>
&6
;
}
if
${
ac_cv_lib_jansson_json_array_set_new
+
:
}
false
;
then
:
$as_echo_n
"(cached) "
>
&6
else
ac_check_lib_save_LIBS
=
$LIBS
LIBS
=
"-ljansson
$LIBS
"
cat
confdefs.h -
<<
_ACEOF
>conftest.
$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char json_array_set_new ();
int
main ()
{
return json_array_set_new ();
;
return 0;
}
_ACEOF
if
ac_fn_c_try_link
"
$LINENO
"
;
then
:
ac_cv_lib_jansson_json_array_set_new
=
yes
else
ac_cv_lib_jansson_json_array_set_new
=
no
fi
rm
-f
core conftest.err conftest.
$ac_objext
\
conftest
$ac_exeext
conftest.
$ac_ext
LIBS
=
$ac_check_lib_save_LIBS
fi
{
$as_echo
"
$as_me
:
${
as_lineno
-
$LINENO
}
: result:
$ac_cv_lib_jansson_json_array_set_new
"
>
&5
$as_echo
"
$ac_cv_lib_jansson_json_array_set_new
"
>
&6
;
}
if
test
"x
$ac_cv_lib_jansson_json_array_set_new
"
=
xyes
;
then
:
cat
>>
confdefs.h
<<
_ACEOF
#define HAVE_LIBJANSSON 1
_ACEOF
LIBS
=
"-ljansson
$LIBS
"
else
as_fn_error
$?
"No libjansson found. Try --disable-json"
"
$LINENO
"
5
fi
$as_echo
"#define USE_JSON 1"
>>
confdefs.h
fi
else
{
$as_echo
"
$as_me
:
${
as_lineno
-
$LINENO
}
: result: enabled"
>
&5
$as_echo
"enabled"
>
&6
;
}
{
$as_echo
"
$as_me
:
${
as_lineno
-
$LINENO
}
: checking for json_array_set_new in -ljansson"
>
&5
$as_echo_n
"checking for json_array_set_new in -ljansson... "
>
&6
;
}
if
${
ac_cv_lib_jansson_json_array_set_new
+
:
}
false
;
then
:
$as_echo_n
"(cached) "
>
&6
else
ac_check_lib_save_LIBS
=
$LIBS
LIBS
=
"-ljansson
$LIBS
"
cat
confdefs.h -
<<
_ACEOF
>conftest.
$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char json_array_set_new ();
int
main ()
{
return json_array_set_new ();
;
return 0;
}
_ACEOF
if
ac_fn_c_try_link
"
$LINENO
"
;
then
:
ac_cv_lib_jansson_json_array_set_new
=
yes
else
ac_cv_lib_jansson_json_array_set_new
=
no
fi
rm
-f
core conftest.err conftest.
$ac_objext
\
conftest
$ac_exeext
conftest.
$ac_ext
LIBS
=
$ac_check_lib_save_LIBS
fi
{
$as_echo
"
$as_me
:
${
as_lineno
-
$LINENO
}
: result:
$ac_cv_lib_jansson_json_array_set_new
"
>
&5
$as_echo
"
$ac_cv_lib_jansson_json_array_set_new
"
>
&6
;
}
if
test
"x
$ac_cv_lib_jansson_json_array_set_new
"
=
xyes
;
then
:
cat
>>
confdefs.h
<<
_ACEOF
#define HAVE_LIBJANSSON 1
_ACEOF
LIBS
=
"-ljansson
$LIBS
"
else
as_fn_error
$?
"No libjansson found. Try --disable-json"
"
$LINENO
"
5
fi
$as_echo
"#define USE_JSON 1"
>>
confdefs.h
fi
#check for custom prog name
{
$as_echo
"
$as_me
:
${
as_lineno
-
$LINENO
}
: checking progname"
>
&5
$as_echo_n
"checking progname... "
>
&6
;
}
# Check whether --with-progname was given.
if
test
"
${
with_progname
+set
}
"
=
set
;
then
:
...
...
configure.ac
View file @
402375ec
...
...
@@ -94,7 +94,24 @@ AC_ARG_ENABLE(liblua,[--enable-liblua/--disable-liblua],
])
])
AC_MSG_CHECKING([for libjansson])
AC_ARG_ENABLE(json,[--enable-json/--disable-json],
[
if test "x$enableval" = "xno" ; then
AC_MSG_RESULT([disabled])
else
AC_MSG_RESULT([enabled])
AC_CHECK_LIB([jansson],[json_array_set_new],[],AC_MSG_ERROR([No libjansson found. Try --disable-json]))
AC_DEFINE(USE_JSON,1,[use json])
fi
],[
AC_MSG_RESULT([enabled])
AC_CHECK_LIB([jansson],[json_array_set_new],[],AC_MSG_ERROR([No libjansson found. Try --disable-json]))
AC_DEFINE(USE_JSON,1,[use json])
])
#check for custom prog name
AC_MSG_CHECKING([progname])
AC_ARG_WITH(progname,[--with-progname=<name>],
[
if test "x$with_progname" = "xno" ; then
...
...
interface.c
View file @
402375ec
This diff is collapsed.
Click to expand it.
json-tg.c
0 → 100644
View file @
402375ec
This diff is collapsed.
Click to expand it.
json-tg.h
0 → 100644
View file @
402375ec
#ifndef __JSON_TG_H__
#define __JSON_TG_H__
#include "config.h"
#ifdef USE_JSON
#include <jansson.h>
#include <tgl.h>
#include <tgl-layout.h>
json_t
*
json_pack_message
(
struct
tgl_message
*
M
);
json_t
*
json_pack_updates
(
unsigned
flags
);
json_t
*
json_pack_peer
(
tgl_peer_id_t
id
,
tgl_peer_t
*
P
);
#endif
#endif
main.c
View file @
402375ec
...
...
@@ -120,6 +120,7 @@ int use_ids;
int
ipv6_enabled
;
char
*
start_command
;
int
disable_link_preview
;
int
enable_json
;
struct
tgl_state
*
TLS
;
...
...
@@ -480,7 +481,9 @@ void usage (void) {
printf
(
" --help/-h prints this help
\n
"
);
printf
(
" --accept-any-tcp accepts tcp connections from any src (only loopback by default)
\n
"
);
printf
(
" --disable-link-preview disables server-side previews to links
\n
"
);
#ifdef USE_JSON
printf
(
" --json prints answers and values in json format
\n
"
);
#endif
exit
(
1
);
}
...
...
@@ -625,6 +628,7 @@ void args_parse (int argc, char **argv) {
{
"help"
,
no_argument
,
0
,
'h'
},
{
"accept-any-tcp"
,
no_argument
,
0
,
1001
},
{
"disable-link-preview"
,
no_argument
,
0
,
1002
},
{
"json"
,
no_argument
,
0
,
1003
},
{
0
,
0
,
0
,
0
}
};
...
...
@@ -738,6 +742,9 @@ void args_parse (int argc, char **argv) {
case
1002
:
disable_link_preview
=
2
;
break
;
case
1003
:
enable_json
=
1
;
break
;
case
'h'
:
default:
usage
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment