From 7d7a40a8b659b9c95b4ed0e6824324f4eb698f98 Mon Sep 17 00:00:00 2001 From: vvaltman Date: Sun, 7 Sep 2014 19:17:35 +0400 Subject: [PATCH] Fixed configure. Added fwd_media command --- Makefile.in | 8 +- config.h.in | 9 +- configure | 1100 +++++++++++++++++++++++++--------------- configure.ac | 15 +- interface.c | 9 + lua-tg.c | 6 + m4_ax_check_openssl.m4 | 124 +++++ m4_ax_check_zlib.m4 | 142 ++++++ queries.c | 60 +++ tgl.h | 1 + 10 files changed, 1063 insertions(+), 411 deletions(-) create mode 100644 m4_ax_check_openssl.m4 create mode 100644 m4_ax_check_zlib.m4 diff --git a/Makefile.in b/Makefile.in index 19f1d81..e866d61 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,12 +1,12 @@ srcdir=@srcdir@ CFLAGS=@CFLAGS@ -LDFLAGS=@LDFLAGS@ -CPPFLAGS=@CPPFLAGS@ +LDFLAGS=@LDFLAGS@ @OPENSSL_LDFLAGS@ +CPPFLAGS=@CPPFLAGS@ @OPENSSL_INCLUDES@ DEFS=@DEFS@ -COMPILE_FLAGS=${CFLAGS} ${CPPFLAGS} ${DEFS} -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC +COMPILE_FLAGS=${CFLAGS} ${CPFLAGS} ${CPPFLAGS} ${DEFS} -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -EXTRA_LIBS=@LIBS@ @EXTRA_LIBS@ +EXTRA_LIBS=@LIBS@ @EXTRA_LIBS@ @OPENSSL_LIBS@ LOCAL_LDFLAGS=-rdynamic -ggdb -levent ${EXTRA_LIBS} LINK_FLAGS=${LDFLAGS} ${LOCAL_LDFLAGS} diff --git a/config.h.in b/config.h.in index dd0d841..a753380 100644 --- a/config.h.in +++ b/config.h.in @@ -21,16 +21,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LAUXLIB_H -/* Define to 1 if you have the `AES_set_encrypt_key' library - (-lAES_set_encrypt_key). */ -#undef HAVE_LIBAES_SET_ENCRYPT_KEY - /* Define to 1 if you have the `config' library (-lconfig). */ #undef HAVE_LIBCONFIG -/* Define to 1 if you have the `crypto' library (-lcrypto). */ -#undef HAVE_LIBCRYPTO - /* Define to 1 if you have the `edit' library (-ledit). */ #undef HAVE_LIBEDIT @@ -40,7 +33,7 @@ /* Define to 1 if you have the `m' library (-lm). */ #undef HAVE_LIBM -/* Define to 1 if you have the `z' library (-lz). */ +/* Define to 1 if you have `z' library (-lz) */ #undef HAVE_LIBZ /* Define to 1 if you have the header file. */ diff --git a/configure b/configure index 1809eef..1393f6e 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for telegram 0.1. +# Generated by GNU Autoconf 2.69 for telegram-cli 1.0. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -575,10 +575,10 @@ MFLAGS= MAKEFLAGS= # Identity of this package. -PACKAGE_NAME='telegram' -PACKAGE_TARNAME='telegram' -PACKAGE_VERSION='0.1' -PACKAGE_STRING='telegram 0.1' +PACKAGE_NAME='telegram-cli' +PACKAGE_TARNAME='telegram-cli' +PACKAGE_VERSION='1.0' +PACKAGE_STRING='telegram-cli 1.0' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -623,9 +623,6 @@ ac_subst_vars='LTLIBOBJS EXTRA_LIBS LIBOBJS LUA_LIB -EGREP -GREP -CPP LUA_INCLUDE pkgluaexecdir luaexecdir @@ -637,6 +634,13 @@ LUA_PLATFORM LUA_SHORT_VERSION LUA_VERSION LUA +EGREP +GREP +CPP +OPENSSL_LDFLAGS +OPENSSL_LIBS +OPENSSL_INCLUDES +PKG_CONFIG OBJEXT EXEEXT ac_ct_CC @@ -685,6 +689,8 @@ SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking +with_openssl +with_zlib enable_libconfig enable_liblua with_progname @@ -697,9 +703,9 @@ CFLAGS LDFLAGS LIBS CPPFLAGS +CPP LUA LUA_INCLUDE -CPP LUA_LIB' @@ -1241,7 +1247,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures telegram 0.1 to adapt to many kinds of systems. +\`configure' configures telegram-cli 1.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1289,7 +1295,7 @@ Fine tuning of the installation directories: --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] - --docdir=DIR documentation root [DATAROOTDIR/doc/telegram] + --docdir=DIR documentation root [DATAROOTDIR/doc/telegram-cli] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] @@ -1302,7 +1308,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of telegram 0.1:";; + short | recursive ) echo "Configuration of telegram-cli 1.0:";; esac cat <<\_ACEOF @@ -1316,6 +1322,10 @@ Optional Features: Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-openssl=DIR root of the OpenSSL directory + --with-zlib=DIR root directory path of zlib installation [defaults to + /usr/local or /usr if not found in /usr/local] + --without-zlib to disable zlib usage completely --with-progname= Some influential environment variables: @@ -1326,9 +1336,9 @@ Some influential environment variables: LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory + CPP C preprocessor LUA The Lua interpreter, e.g. /usr/bin/lua5.1 LUA_INCLUDE The Lua includes, e.g. -I/usr/include/lua5.1 - CPP C preprocessor LUA_LIB The Lua library, e.g. -llua5.1 Use these variables to override the choices made by `configure' or to help @@ -1397,7 +1407,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -telegram configure 0.1 +telegram-cli configure 1.0 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1816,7 +1826,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by telegram $as_me 0.1, which was +It was created by telegram-cli $as_me 1.0, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2376,6 +2386,150 @@ ac_config_headers="$ac_config_headers config.h" + + + +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_openssl.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_OPENSSL([action-if-found[, action-if-not-found]]) +# +# DESCRIPTION +# +# Look for OpenSSL in a number of default spots, or in a user-selected +# spot (via --with-openssl). Sets +# +# OPENSSL_INCLUDES to the include directives required +# OPENSSL_LIBS to the -l directives required +# OPENSSL_LDFLAGS to the -L or -R flags required +# +# and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately +# +# This macro sets OPENSSL_INCLUDES such that source files should use the +# openssl/ directory in include directives: +# +# #include +# +# LICENSE +# +# Copyright (c) 2009,2010 Zmanda Inc. +# Copyright (c) 2009,2010 Dustin J. Mitchell +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 8 + +# This is what autoupdate's m4 run will expand. It fires +# the warning (with _au_warn_XXX), outputs it into the +# updated configure.ac (with AC_DIAGNOSE), and then outputs +# the replacement expansion. + + +# This is an auxiliary macro that is also run when +# autoupdate runs m4. It simply calls m4_warning, but +# we need a wrapper so that each warning is emitted only +# once. We break the quoting in m4_warning's argument in +# order to expand this macro's arguments, not AU_DEFUN's. + + +# Finally, this is the expansion that is picked up by +# autoconf. It tells the user to run autoupdate, and +# then outputs the replacement expansion. We do not care +# about autoupdate's warning because that contains +# information on what to do *after* running autoupdate. + + + +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_zlib.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_ZLIB([action-if-found], [action-if-not-found]) +# +# DESCRIPTION +# +# This macro searches for an installed zlib library. If nothing was +# specified when calling configure, it searches first in /usr/local and +# then in /usr, /opt/local and /sw. If the --with-zlib=DIR is specified, +# it will try to find it in DIR/include/zlib.h and DIR/lib/libz.a. If +# --without-zlib is specified, the library is not searched at all. +# +# If either the header file (zlib.h) or the library (libz) is not found, +# shell commands 'action-if-not-found' is run. If 'action-if-not-found' is +# not specified, the configuration exits on error, asking for a valid zlib +# installation directory or --without-zlib. +# +# If both header file and library are found, shell commands +# 'action-if-found' is run. If 'action-if-found' is not specified, the +# default action appends '-I${ZLIB_HOME}/include' to CPFLAGS, appends +# '-L$ZLIB_HOME}/lib' to LDFLAGS, prepends '-lz' to LIBS, and calls +# AC_DEFINE(HAVE_LIBZ). You should use autoheader to include a definition +# for this symbol in a config.h file. Sample usage in a C/C++ source is as +# follows: +# +# #ifdef HAVE_LIBZ +# #include +# #endif /* HAVE_LIBZ */ +# +# LICENSE +# +# Copyright (c) 2008 Loic Dachary +# Copyright (c) 2010 Bastien Chevreux +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 14 + +# This is what autoupdate's m4 run will expand. It fires +# the warning (with _au_warn_XXX), outputs it into the +# updated configure.ac (with AC_DIAGNOSE), and then outputs +# the replacement expansion. + + +# This is an auxiliary macro that is also run when +# autoupdate runs m4. It simply calls m4_warning, but +# we need a wrapper so that each warning is emitted only +# once. We break the quoting in m4_warning's argument in +# order to expand this macro's arguments, not AU_DEFUN's. + + +# Finally, this is the expansion that is picked up by +# autoconf. It tells the user to run autoupdate, and +# then outputs the replacement expansion. We do not care +# about autoupdate's warning because that contains +# information on what to do *after* running autoupdate. @@ -3334,96 +3488,6 @@ if test "$ac_res" != no; then : fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inflate in -lz" >&5 -$as_echo_n "checking for inflate in -lz... " >&6; } -if ${ac_cv_lib_z_inflate+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lz $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 inflate (); -int -main () -{ -return inflate (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_z_inflate=yes -else - ac_cv_lib_z_inflate=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_z_inflate" >&5 -$as_echo "$ac_cv_lib_z_inflate" >&6; } -if test "x$ac_cv_lib_z_inflate" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBZ 1 -_ACEOF - - LIBS="-lz $LIBS" - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for AES_set_encrypt_key in -lcrypto" >&5 -$as_echo_n "checking for AES_set_encrypt_key in -lcrypto... " >&6; } -if ${ac_cv_lib_crypto_AES_set_encrypt_key+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lcrypto $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 AES_set_encrypt_key (); -int -main () -{ -return AES_set_encrypt_key (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_crypto_AES_set_encrypt_key=yes -else - ac_cv_lib_crypto_AES_set_encrypt_key=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_crypto_AES_set_encrypt_key" >&5 -$as_echo "$ac_cv_lib_crypto_AES_set_encrypt_key" >&6; } -if test "x$ac_cv_lib_crypto_AES_set_encrypt_key" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBCRYPTO 1 -_ACEOF - - LIBS="-lcrypto $LIBS" - -fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for event_base_new in -levent" >&5 $as_echo_n "checking for event_base_new in -levent... " >&6; } if ${ac_cv_lib_event_event_base_new+:} false; then : @@ -3467,327 +3531,167 @@ _ACEOF LIBS="-levent $LIBS" -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ssl in -lAES_set_encrypt_key" >&5 -$as_echo_n "checking for ssl in -lAES_set_encrypt_key... " >&6; } -if ${ac_cv_lib_AES_set_encrypt_key_ssl+:} false; then : - $as_echo_n "(cached) " >&6 else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lAES_set_encrypt_key $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 ssl (); -int -main () -{ -return ssl (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_AES_set_encrypt_key_ssl=yes -else - ac_cv_lib_AES_set_encrypt_key_ssl=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_AES_set_encrypt_key_ssl" >&5 -$as_echo "$ac_cv_lib_AES_set_encrypt_key_ssl" >&6; } -if test "x$ac_cv_lib_AES_set_encrypt_key_ssl" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBAES_SET_ENCRYPT_KEY 1 -_ACEOF - - LIBS="-lAES_set_encrypt_key $LIBS" - + as_fn_error $? "no libevent found" "$LINENO" 5 fi EXTRA_LIBS="" -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_save_prompt in -lreadline" >&5 -$as_echo_n "checking for rl_save_prompt in -lreadline... " >&6; } -if ${ac_cv_lib_readline_rl_save_prompt+:} false; then : +# OPENSSL_INCLUDES to the include directives required +# OPENSSL_LIBS to the -l directives required +# OPENSSL_LDFLAGS to the -L or -R flags required + + + found=false + +# Check whether --with-openssl was given. +if test "${with_openssl+set}" = set; then : + withval=$with_openssl; + case "$withval" in + "" | y | ye | yes | n | no) + as_fn_error $? "Invalid --with-openssl value" "$LINENO" 5 + ;; + *) ssldirs="$withval" + ;; + esac + +else + + # if pkg-config is installed and openssl has installed a .pc file, + # then use that information and don't search ssldirs + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lreadline $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 rl_save_prompt (); -int -main () -{ -return rl_save_prompt (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_readline_rl_save_prompt=yes -else - ac_cv_lib_readline_rl_save_prompt=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_readline_rl_save_prompt" >&5 -$as_echo "$ac_cv_lib_readline_rl_save_prompt" >&6; } -if test "x$ac_cv_lib_readline_rl_save_prompt" = xyes; then : - - -$as_echo "#define READLINE_GNU 1" >>confdefs.h - - EXTRA_LIBS="${EXTRA_LIBS} -lreadline" ; - -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetnum" >&5 -$as_echo_n "checking for library containing tgetnum... " >&6; } -if ${ac_cv_search_tgetnum+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$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 tgetnum (); -int -main () -{ -return tgetnum (); - ; - return 0; -} -_ACEOF -for ac_lib in '' ncursesw ncurses curses; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" + case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_tgetnum=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_tgetnum+:} false; then : - break -fi done -if ${ac_cv_search_tgetnum+:} false; then : + done +IFS=$as_save_IFS + ;; +esac +fi +PKG_CONFIG=$ac_cv_path_PKG_CONFIG +if test -n "$PKG_CONFIG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 +$as_echo "$PKG_CONFIG" >&6; } else - ac_cv_search_tgetnum=no + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_tgetnum" >&5 -$as_echo "$ac_cv_search_tgetnum" >&6; } -ac_res=$ac_cv_search_tgetnum -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + + + if test x"$PKG_CONFIG" != x""; then + OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null` + if test $? = 0; then + OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null` + OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null` + found=true + fi + fi + + # no such luck; use some default ssldirs + if ! $found; then + ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr" + fi + fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_set_prompt in -ledit" >&5 -$as_echo_n "checking for rl_set_prompt in -ledit... " >&6; } -if ${ac_cv_lib_edit_rl_set_prompt+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-ledit $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext + + + # note that we #include , so the OpenSSL headers have to be in + # an 'openssl' subdirectory + + if ! $found; then + OPENSSL_INCLUDES= + for ssldir in $ssldirs; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for openssl/ssl.h in $ssldir" >&5 +$as_echo_n "checking for openssl/ssl.h in $ssldir... " >&6; } + if test -f "$ssldir/include/openssl/ssl.h"; then + OPENSSL_INCLUDES="-I$ssldir/include" + OPENSSL_LDFLAGS="-L$ssldir/lib" + OPENSSL_LIBS="-lssl -lcrypto" + found=true + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + break + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi + done + + # if the file wasn't found, well, go ahead and try the link anyway -- maybe + # it will just work! + fi + + # try the preprocessor and linker with our new flags, + # being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiling and linking against OpenSSL works" >&5 +$as_echo_n "checking whether compiling and linking against OpenSSL works... " >&6; } + echo "Trying link with OPENSSL_LDFLAGS=$OPENSSL_LDFLAGS;" \ + "OPENSSL_LIBS=$OPENSSL_LIBS; OPENSSL_INCLUDES=$OPENSSL_INCLUDES" >&5 + + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + save_CPPFLAGS="$CPPFLAGS" + LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS" + LIBS="$OPENSSL_LIBS $LIBS" + CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS" + 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 rl_set_prompt (); +#include int main () { -return rl_set_prompt (); +SSL_new(NULL) ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_edit_rl_set_prompt=yes + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + + else - ac_cv_lib_edit_rl_set_prompt=no + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + as_fn_error $? "No openssl found" "$LINENO" 5 + 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_edit_rl_set_prompt" >&5 -$as_echo "$ac_cv_lib_edit_rl_set_prompt" >&6; } -if test "x$ac_cv_lib_edit_rl_set_prompt" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBEDIT 1 -_ACEOF - - LIBS="-ledit $LIBS" - -fi + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" -$as_echo "#define READLINE_EDIT 1" >>confdefs.h - - EXTRA_LIBS="${EXTRA_LIBS} -ledit" ; -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libconfig" >&5 -$as_echo_n "checking for libconfig... " >&6; } -# Check whether --enable-libconfig was given. -if test "${enable_libconfig+set}" = set; then : - enableval=$enable_libconfig; - 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 config_init in -lconfig" >&5 -$as_echo_n "checking for config_init in -lconfig... " >&6; } -if ${ac_cv_lib_config_config_init+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lconfig $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 config_init (); -int -main () -{ -return config_init (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_config_config_init=yes -else - ac_cv_lib_config_config_init=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_config_config_init" >&5 -$as_echo "$ac_cv_lib_config_config_init" >&6; } -if test "x$ac_cv_lib_config_config_init" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBCONFIG 1 -_ACEOF - - LIBS="-lconfig $LIBS" - -else - as_fn_error $? "No libconfig found. Try --disable-libconfig" "$LINENO" 5 -fi - - 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 config_init in -lconfig" >&5 -$as_echo_n "checking for config_init in -lconfig... " >&6; } -if ${ac_cv_lib_config_config_init+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_check_lib_save_LIBS=$LIBS -LIBS="-lconfig $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 config_init (); -int -main () -{ -return config_init (); - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_lib_config_config_init=yes -else - ac_cv_lib_config_config_init=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_config_config_init" >&5 -$as_echo "$ac_cv_lib_config_config_init" >&6; } -if test "x$ac_cv_lib_config_config_init" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBCONFIG 1 -_ACEOF - - LIBS="-lconfig $LIBS" - -else - as_fn_error $? "No libconfig found. Try --disable-libconfig" "$LINENO" 5 -fi - - -fi - - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for liblua" >&5 -$as_echo_n "checking for liblua... " >&6; } ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -4185,6 +4089,412 @@ fi done +# +# Handle user hints +# +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if zlib is wanted" >&5 +$as_echo_n "checking if zlib is wanted... " >&6; } +zlib_places="/usr/local /usr /opt/local /sw" + +# Check whether --with-zlib was given. +if test "${with_zlib+set}" = set; then : + withval=$with_zlib; if test "$withval" != no ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + if test -d "$withval" + then + zlib_places="$withval $zlib_places" + else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Sorry, $withval does not exist, checking usual places" >&5 +$as_echo "$as_me: WARNING: Sorry, $withval does not exist, checking usual places" >&2;} + fi +else + zlib_places= + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi + + +# +# Locate zlib, if wanted +# +if test -n "${zlib_places}" +then + # check the user supplied or any other more or less 'standard' place: + # Most UNIX systems : /usr/local and /usr + # MacPorts / Fink on OSX : /opt/local respectively /sw + for ZLIB_HOME in ${zlib_places} ; do + if test -f "${ZLIB_HOME}/include/zlib.h"; then break; fi + ZLIB_HOME="" + done + + ZLIB_OLD_LDFLAGS=$LDFLAGS + ZLIB_OLD_CPPFLAGS=$CPPFLAGS + if test -n "${ZLIB_HOME}"; then + LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" + CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" + fi + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inflateEnd in -lz" >&5 +$as_echo_n "checking for inflateEnd in -lz... " >&6; } +if ${ac_cv_lib_z_inflateEnd+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lz $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 inflateEnd (); +int +main () +{ +return inflateEnd (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_z_inflateEnd=yes +else + ac_cv_lib_z_inflateEnd=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_z_inflateEnd" >&5 +$as_echo "$ac_cv_lib_z_inflateEnd" >&6; } +if test "x$ac_cv_lib_z_inflateEnd" = xyes; then : + zlib_cv_libz=yes +else + zlib_cv_libz=no +fi + + ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default" +if test "x$ac_cv_header_zlib_h" = xyes; then : + zlib_cv_zlib_h=yes +else + zlib_cv_zlib_h=no +fi + + + ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + if test "$zlib_cv_libz" = "yes" && test "$zlib_cv_zlib_h" = "yes" + then + # + # If both library and header were found, action-if-found + # + + CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" + LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" + LIBS="-lz $LIBS" + +$as_echo "#define HAVE_LIBZ 1" >>confdefs.h + + + else + # + # If either header or library was not found, action-if-not-found + # + as_fn_error $? "No zlib found" "$LINENO" 5 + fi +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_save_prompt in -lreadline" >&5 +$as_echo_n "checking for rl_save_prompt in -lreadline... " >&6; } +if ${ac_cv_lib_readline_rl_save_prompt+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lreadline $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 rl_save_prompt (); +int +main () +{ +return rl_save_prompt (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_readline_rl_save_prompt=yes +else + ac_cv_lib_readline_rl_save_prompt=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_readline_rl_save_prompt" >&5 +$as_echo "$ac_cv_lib_readline_rl_save_prompt" >&6; } +if test "x$ac_cv_lib_readline_rl_save_prompt" = xyes; then : + + +$as_echo "#define READLINE_GNU 1" >>confdefs.h + + EXTRA_LIBS="${EXTRA_LIBS} -lreadline" ; + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetnum" >&5 +$as_echo_n "checking for library containing tgetnum... " >&6; } +if ${ac_cv_search_tgetnum+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$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 tgetnum (); +int +main () +{ +return tgetnum (); + ; + return 0; +} +_ACEOF +for ac_lib in '' ncursesw ncurses curses; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_tgetnum=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_tgetnum+:} false; then : + break +fi +done +if ${ac_cv_search_tgetnum+:} false; then : + +else + ac_cv_search_tgetnum=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_tgetnum" >&5 +$as_echo "$ac_cv_search_tgetnum" >&6; } +ac_res=$ac_cv_search_tgetnum +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_set_prompt in -ledit" >&5 +$as_echo_n "checking for rl_set_prompt in -ledit... " >&6; } +if ${ac_cv_lib_edit_rl_set_prompt+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ledit $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 rl_set_prompt (); +int +main () +{ +return rl_set_prompt (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_edit_rl_set_prompt=yes +else + ac_cv_lib_edit_rl_set_prompt=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_edit_rl_set_prompt" >&5 +$as_echo "$ac_cv_lib_edit_rl_set_prompt" >&6; } +if test "x$ac_cv_lib_edit_rl_set_prompt" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBEDIT 1 +_ACEOF + + LIBS="-ledit $LIBS" + +fi + + +$as_echo "#define READLINE_EDIT 1" >>confdefs.h + + EXTRA_LIBS="${EXTRA_LIBS} -ledit" ; + + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for libconfig" >&5 +$as_echo_n "checking for libconfig... " >&6; } +# Check whether --enable-libconfig was given. +if test "${enable_libconfig+set}" = set; then : + enableval=$enable_libconfig; + 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 config_init in -lconfig" >&5 +$as_echo_n "checking for config_init in -lconfig... " >&6; } +if ${ac_cv_lib_config_config_init+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lconfig $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 config_init (); +int +main () +{ +return config_init (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_config_config_init=yes +else + ac_cv_lib_config_config_init=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_config_config_init" >&5 +$as_echo "$ac_cv_lib_config_config_init" >&6; } +if test "x$ac_cv_lib_config_config_init" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBCONFIG 1 +_ACEOF + + LIBS="-lconfig $LIBS" + +else + as_fn_error $? "No libconfig found. Try --disable-libconfig" "$LINENO" 5 +fi + + 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 config_init in -lconfig" >&5 +$as_echo_n "checking for config_init in -lconfig... " >&6; } +if ${ac_cv_lib_config_config_init+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lconfig $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 config_init (); +int +main () +{ +return config_init (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_config_config_init=yes +else + ac_cv_lib_config_config_init=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_config_config_init" >&5 +$as_echo "$ac_cv_lib_config_config_init" >&6; } +if test "x$ac_cv_lib_config_config_init" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBCONFIG 1 +_ACEOF + + LIBS="-lconfig $LIBS" + +else + as_fn_error $? "No libconfig found. Try --disable-libconfig" "$LINENO" 5 +fi + + +fi + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for liblua" >&5 +$as_echo_n "checking for liblua... " >&6; } # Check whether --enable-liblua was given. if test "${enable_liblua+set}" = set; then : enableval=$enable_liblua; @@ -6316,7 +6626,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by telegram $as_me 0.1, which was +This file was extended by telegram-cli $as_me 1.0, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -6378,7 +6688,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -telegram config.status 0.1 +telegram-cli config.status 1.0 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index d257359..d52cad7 100644 --- a/configure.ac +++ b/configure.ac @@ -1,9 +1,11 @@ AC_PREREQ([2.68]) -AC_INIT([telegram], [0.1]) +AC_INIT([telegram-cli], [1.0]) AC_CONFIG_SRCDIR([config.h.in]) AC_CONFIG_HEADERS([config.h]) m4_include([ax_lua.m4]) +m4_include([m4_ax_check_openssl.m4]) +m4_include([m4_ax_check_zlib.m4]) # Checks for programs. AC_PROG_CC @@ -16,11 +18,16 @@ LDFLAGS="$LDFLAGS -L/usr/local/lib" AC_CHECK_LIB([m], [sqrt]) AC_SEARCH_LIBS([clock_gettime], [rt]) AC_SEARCH_LIBS([backtrace], [execinfo]) -AC_CHECK_LIB([z], [inflate]) -AC_CHECK_LIB([crypto], [AES_set_encrypt_key]) -AC_CHECK_LIB([event], [event_base_new]) +AC_CHECK_LIB([event], [event_base_new], [], [AC_MSG_ERROR([no libevent found])]) EXTRA_LIBS="" +# OPENSSL_INCLUDES to the include directives required +# OPENSSL_LIBS to the -l directives required +# OPENSSL_LDFLAGS to the -L or -R flags required + +AX_CHECK_OPENSSL(,[AC_MSG_ERROR([No openssl found])]) +AX_CHECK_ZLIB(, [AC_MSG_ERROR([No zlib found])]) + AC_CHECK_LIB([readline], [rl_save_prompt], [ AC_DEFINE([READLINE_GNU], [1], [Use gnu libreadline]) diff --git a/interface.c b/interface.c index 3aa8054..422723a 100644 --- a/interface.c +++ b/interface.c @@ -354,6 +354,7 @@ struct command commands[] = { {"chat_info", {ca_chat, ca_none}}, {"user_info", {ca_user, ca_none}}, {"fwd", {ca_peer, ca_number, ca_none}}, + {"fwd_media", {ca_peer, ca_number, ca_none}}, {"msg", {ca_peer, ca_string_end}}, {"rename_chat", {ca_peer, ca_string_end}}, {"load_photo", {ca_number, ca_none}}, @@ -1180,6 +1181,14 @@ void interpreter (char *line UU) { RET; } tgl_do_forward_message (id, num, 0, 0); + } else if (IS_WORD ("fwd_media")) { + GET_PEER; + int num = next_token_int (); + if (num == NOT_FOUND || num <= 0) { + printf ("Bad msg id\n"); + RET; + } + tgl_do_forward_media (id, num, 0, 0); } else if (IS_WORD ("load_photo")) { long long num = next_token_int (); if (num == NOT_FOUND) { diff --git a/lua-tg.c b/lua-tg.c index f878928..0bb5c56 100644 --- a/lua-tg.c +++ b/lua-tg.c @@ -455,6 +455,7 @@ enum lua_query_type { lq_send_video, lq_send_text, lq_fwd, + lq_fwd_media, lq_load_photo, lq_load_video_thumb, lq_load_video, @@ -922,6 +923,10 @@ void lua_do_all (void) { tgl_do_forward_message (((tgl_peer_t *)lua_ptr[p + 1])->id, ((struct tgl_message *)lua_ptr[p + 2])->id, lua_msg_cb, lua_ptr[p]); p += 3; break; + case lq_fwd_media: + tgl_do_forward_media (((tgl_peer_t *)lua_ptr[p + 1])->id, ((struct tgl_message *)lua_ptr[p + 2])->id, lua_msg_cb, lua_ptr[p]); + p += 3; + break; case lq_chat_info: tgl_do_get_chat_info (((tgl_peer_t *)lua_ptr[p + 1])->id, 0, lua_chat_cb, lua_ptr[p]); p += 2; @@ -1077,6 +1082,7 @@ struct lua_function functions[] = { {"load_document", lq_load_document, { lfp_msg, lfp_none }}, {"load_document_thumb", lq_load_document_thumb, { lfp_msg, lfp_none }}, {"fwd_msg", lq_fwd, { lfp_peer, lfp_msg, lfp_none }}, + {"fwd_media", lq_fwd_media, { lfp_peer, lfp_msg, lfp_none }}, {"chat_info", lq_chat_info, { lfp_chat, lfp_none }}, {"user_info", lq_user_info, { lfp_user, lfp_none }}, {"get_history", lq_history, { lfp_peer, lfp_nonnegative_number, lfp_none }}, diff --git a/m4_ax_check_openssl.m4 b/m4_ax_check_openssl.m4 new file mode 100644 index 0000000..a87c5a6 --- /dev/null +++ b/m4_ax_check_openssl.m4 @@ -0,0 +1,124 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_openssl.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_OPENSSL([action-if-found[, action-if-not-found]]) +# +# DESCRIPTION +# +# Look for OpenSSL in a number of default spots, or in a user-selected +# spot (via --with-openssl). Sets +# +# OPENSSL_INCLUDES to the include directives required +# OPENSSL_LIBS to the -l directives required +# OPENSSL_LDFLAGS to the -L or -R flags required +# +# and calls ACTION-IF-FOUND or ACTION-IF-NOT-FOUND appropriately +# +# This macro sets OPENSSL_INCLUDES such that source files should use the +# openssl/ directory in include directives: +# +# #include +# +# LICENSE +# +# Copyright (c) 2009,2010 Zmanda Inc. +# Copyright (c) 2009,2010 Dustin J. Mitchell +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 8 + +AU_ALIAS([CHECK_SSL], [AX_CHECK_OPENSSL]) +AC_DEFUN([AX_CHECK_OPENSSL], [ + found=false + AC_ARG_WITH([openssl], + [AS_HELP_STRING([--with-openssl=DIR], + [root of the OpenSSL directory])], + [ + case "$withval" in + "" | y | ye | yes | n | no) + AC_MSG_ERROR([Invalid --with-openssl value]) + ;; + *) ssldirs="$withval" + ;; + esac + ], [ + # if pkg-config is installed and openssl has installed a .pc file, + # then use that information and don't search ssldirs + AC_PATH_PROG([PKG_CONFIG], [pkg-config]) + if test x"$PKG_CONFIG" != x""; then + OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null` + if test $? = 0; then + OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null` + OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null` + found=true + fi + fi + + # no such luck; use some default ssldirs + if ! $found; then + ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr" + fi + ] + ) + + + # note that we #include , so the OpenSSL headers have to be in + # an 'openssl' subdirectory + + if ! $found; then + OPENSSL_INCLUDES= + for ssldir in $ssldirs; do + AC_MSG_CHECKING([for openssl/ssl.h in $ssldir]) + if test -f "$ssldir/include/openssl/ssl.h"; then + OPENSSL_INCLUDES="-I$ssldir/include" + OPENSSL_LDFLAGS="-L$ssldir/lib" + OPENSSL_LIBS="-lssl -lcrypto" + found=true + AC_MSG_RESULT([yes]) + break + else + AC_MSG_RESULT([no]) + fi + done + + # if the file wasn't found, well, go ahead and try the link anyway -- maybe + # it will just work! + fi + + # try the preprocessor and linker with our new flags, + # being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS + + AC_MSG_CHECKING([whether compiling and linking against OpenSSL works]) + echo "Trying link with OPENSSL_LDFLAGS=$OPENSSL_LDFLAGS;" \ + "OPENSSL_LIBS=$OPENSSL_LIBS; OPENSSL_INCLUDES=$OPENSSL_INCLUDES" >&AS_MESSAGE_LOG_FD + + save_LIBS="$LIBS" + save_LDFLAGS="$LDFLAGS" + save_CPPFLAGS="$CPPFLAGS" + LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS" + LIBS="$OPENSSL_LIBS $LIBS" + CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([#include ], [SSL_new(NULL)])], + [ + AC_MSG_RESULT([yes]) + $1 + ], [ + AC_MSG_RESULT([no]) + $2 + ]) + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + + AC_SUBST([OPENSSL_INCLUDES]) + AC_SUBST([OPENSSL_LIBS]) + AC_SUBST([OPENSSL_LDFLAGS]) +]) diff --git a/m4_ax_check_zlib.m4 b/m4_ax_check_zlib.m4 new file mode 100644 index 0000000..ae5705f --- /dev/null +++ b/m4_ax_check_zlib.m4 @@ -0,0 +1,142 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_zlib.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_ZLIB([action-if-found], [action-if-not-found]) +# +# DESCRIPTION +# +# This macro searches for an installed zlib library. If nothing was +# specified when calling configure, it searches first in /usr/local and +# then in /usr, /opt/local and /sw. If the --with-zlib=DIR is specified, +# it will try to find it in DIR/include/zlib.h and DIR/lib/libz.a. If +# --without-zlib is specified, the library is not searched at all. +# +# If either the header file (zlib.h) or the library (libz) is not found, +# shell commands 'action-if-not-found' is run. If 'action-if-not-found' is +# not specified, the configuration exits on error, asking for a valid zlib +# installation directory or --without-zlib. +# +# If both header file and library are found, shell commands +# 'action-if-found' is run. If 'action-if-found' is not specified, the +# default action appends '-I${ZLIB_HOME}/include' to CPFLAGS, appends +# '-L$ZLIB_HOME}/lib' to LDFLAGS, prepends '-lz' to LIBS, and calls +# AC_DEFINE(HAVE_LIBZ). You should use autoheader to include a definition +# for this symbol in a config.h file. Sample usage in a C/C++ source is as +# follows: +# +# #ifdef HAVE_LIBZ +# #include +# #endif /* HAVE_LIBZ */ +# +# LICENSE +# +# Copyright (c) 2008 Loic Dachary +# Copyright (c) 2010 Bastien Chevreux +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 14 + +AU_ALIAS([CHECK_ZLIB], [AX_CHECK_ZLIB]) +AC_DEFUN([AX_CHECK_ZLIB], +# +# Handle user hints +# +[AC_MSG_CHECKING(if zlib is wanted) +zlib_places="/usr/local /usr /opt/local /sw" +AC_ARG_WITH([zlib], +[ --with-zlib=DIR root directory path of zlib installation @<:@defaults to + /usr/local or /usr if not found in /usr/local@:>@ + --without-zlib to disable zlib usage completely], +[if test "$withval" != no ; then + AC_MSG_RESULT(yes) + if test -d "$withval" + then + zlib_places="$withval $zlib_places" + else + AC_MSG_WARN([Sorry, $withval does not exist, checking usual places]) + fi +else + zlib_places= + AC_MSG_RESULT(no) +fi], +[AC_MSG_RESULT(yes)]) + +# +# Locate zlib, if wanted +# +if test -n "${zlib_places}" +then + # check the user supplied or any other more or less 'standard' place: + # Most UNIX systems : /usr/local and /usr + # MacPorts / Fink on OSX : /opt/local respectively /sw + for ZLIB_HOME in ${zlib_places} ; do + if test -f "${ZLIB_HOME}/include/zlib.h"; then break; fi + ZLIB_HOME="" + done + + ZLIB_OLD_LDFLAGS=$LDFLAGS + ZLIB_OLD_CPPFLAGS=$CPPFLAGS + if test -n "${ZLIB_HOME}"; then + LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" + CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" + fi + AC_LANG_SAVE + AC_LANG_C + AC_CHECK_LIB([z], [inflateEnd], [zlib_cv_libz=yes], [zlib_cv_libz=no]) + AC_CHECK_HEADER([zlib.h], [zlib_cv_zlib_h=yes], [zlib_cv_zlib_h=no]) + AC_LANG_RESTORE + if test "$zlib_cv_libz" = "yes" && test "$zlib_cv_zlib_h" = "yes" + then + # + # If both library and header were found, action-if-found + # + m4_ifblank([$1],[ + CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" + LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" + LIBS="-lz $LIBS" + AC_DEFINE([HAVE_LIBZ], [1], + [Define to 1 if you have `z' library (-lz)]) + ],[ + # Restore variables + LDFLAGS="$ZLIB_OLD_LDFLAGS" + CPPFLAGS="$ZLIB_OLD_CPPFLAGS" + $1 + ]) + else + # + # If either header or library was not found, action-if-not-found + # + m4_default([$2],[ + AC_MSG_ERROR([either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib]) + ]) + fi +fi +]) diff --git a/queries.c b/queries.c index b896e49..9e41f44 100644 --- a/queries.c +++ b/queries.c @@ -1858,6 +1858,66 @@ void tgl_do_send_contact (tgl_peer_id_t id, const char *phone, int phone_len, co tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &fwd_msg_methods, 0, callback, callback_extra); } + +void tgl_do_forward_media (tgl_peer_id_t id, int n, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra) { + if (tgl_get_peer_type (id) == TGL_PEER_ENCR_CHAT) { + vlogprintf (E_WARNING, "Can not forward messages from secret chat\n"); + callback (callback_extra, 0, 0); + return; + } + struct tgl_message *M = tgl_message_get (n); + if (!M) { + vlogprintf (E_WARNING, "No such message\n"); + callback (callback_extra, 0, 0); + return; + } + if (M->flags & FLAG_ENCRYPTED) { + vlogprintf (E_WARNING, "Can not forward media from encrypted message\n"); + callback (callback_extra, 0, 0); + return; + } + if (M->media.type != tgl_message_media_photo && M->media.type != tgl_message_media_video && M->media.type != tgl_message_media_audio && M->media.type != tgl_message_media_document) { + vlogprintf (E_WARNING, "Can only forward photo/audio/video/document\n"); + callback (callback_extra, 0, 0); + return; + } + clear_packet (); + out_int (CODE_messages_send_media); + out_peer_id (id); + switch (M->media.type) { + case tgl_message_media_photo: + out_int (CODE_input_media_photo); + out_int (CODE_input_photo); + out_long (M->media.photo.id); + out_long (M->media.photo.access_hash); + break; + case tgl_message_media_video: + out_int (CODE_input_media_video); + out_int (CODE_input_video); + out_long (M->media.video.id); + out_long (M->media.video.access_hash); + break; + case tgl_message_media_audio: + out_int (CODE_input_media_audio); + out_int (CODE_input_audio); + out_long (M->media.audio.id); + out_long (M->media.audio.access_hash); + break; + case tgl_message_media_document: + out_int (CODE_input_media_document); + out_int (CODE_input_document); + out_long (M->media.document.id); + out_long (M->media.document.access_hash); + break; + default: + assert (0); + } + long long r; + tglt_secure_random (&r, 8); + out_long (r); + + tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &fwd_msg_methods, 0, callback, callback_extra); +} /* }}} */ /* {{{ Rename chat */ diff --git a/tgl.h b/tgl.h index 1088964..1ca4163 100644 --- a/tgl.h +++ b/tgl.h @@ -280,6 +280,7 @@ void tgl_do_help_get_config_dc (struct tgl_dc *D, void (*callback)(void *, int), void tgl_do_export_card (void (*callback)(void *callback_extra, int success, int size, int *card), void *callback_extra); void tgl_do_import_card (int size, int *card, void (*callback)(void *callback_extra, int success, struct tgl_user *U), void *callback_extra); void tgl_do_send_contact (tgl_peer_id_t id, const char *phone, int phone_len, const char *first_name, int first_name_len, const char *last_name, int last_name_len, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra); +void tgl_do_forward_media (tgl_peer_id_t id, int n, void (*callback)(void *callback_extra, int success, struct tgl_message *M), void *callback_extra); void tgl_do_visualize_key (tgl_peer_id_t id, unsigned char buf[16]);