diff --git a/App configuration.html b/App configuration.html deleted file mode 100644 index e416b66..0000000 --- a/App configuration.html +++ /dev/null @@ -1,177 +0,0 @@ - - - - - App configuration - - - - - - - - - - -
-
- -
-
-
-
-

App configuration

-
- -
- 16154 -
-
-
- -
- -
- 99428c722d0ed59b9cd844e4577cb4bb -
-
-
- -
- -
- -
-
- -
- -
- -

alphanumeric, 5-32 characters

-
-
- -
-

PUSH-notifications settings

- -
- - -
-
- -
-

- APNS certificates - -  Update -  Delete - -

- - - - -
- -

Available MTProto servers

- -
- -
- 173.240.5.253:443 -

First DC

-
-
-
- -
- 173.240.5.1:443 -

First DC

-
-
- -
- -
-
-----BEGIN RSA PUBLIC KEY-----
-MIIBCgKCAQEAwVACPi9w23mF3tBkdZz+zwrzKOaaQdr01vAbU4E1pvkfj4sqDsm6
-lyDONS789sVoD/xCS9Y0hkkC3gtL1tSfTlgCMOOul9lcixlEKzwKENj1Yz/s7daS
-an9tqw3bfUV/nqgbhGX81v/+7RFAEd+RwFnK7a+XYl9sluzHRyVVaTTveB2GazTw
-Efzk2DWgkBluml8OREmvfraX3bkHZJTKX4EQSjBbbdJ2ZXIsRrYOXfaA+xayEGB+
-8hdlLmAjbCVfaigxX0CDqWeR1yFL9kwd9P0NsZRPsmoqVwMbMu7mStFai6aIhc3n
-Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
------END RSA PUBLIC KEY-----
-
-
- - -
- - Cancel -
-
-
- -
-
-
- - - - - - - \ No newline at end of file diff --git a/Makefile.in b/Makefile.in index c0a9367..1255097 100644 --- a/Makefile.in +++ b/Makefile.in @@ -14,7 +14,7 @@ EXTRA_LIBS=@LIBS@ @EXTRA_LIBS@ LOCAL_LDFLAGS=-rdynamic -ggdb ${EXTRA_LIBS} LINK_FLAGS=${LDFLAGS} ${LOCAL_LDFLAGS} -HEADERS= ${srcdir}/constants.h ${srcdir}/include.h ${srcdir}/LICENSE.h ${srcdir}/loop.h ${srcdir}/mtproto-client.h ${srcdir}/net.h ${srcdir}/no-preview.h ${srcdir}/queries.h ${srcdir}/structures.h ${srcdir}/telegram.h ${srcdir}/tree.h ${srcdir}/config.h ${srcdir}/binlog.h ${srcdir}/tools.h ${srcdir}/msglog.h +HEADERS= ${srcdir}/constants.h ${srcdir}/include.h ${srcdir}/LICENSE.h ${srcdir}/loop.h ${srcdir}/mtproto-client.h ${srcdir}/net.h ${srcdir}/queries.h ${srcdir}/structures.h ${srcdir}/no-preview.h ${srcdir}/telegram.h ${srcdir}/tree.h ${srcdir}/binlog.h ${srcdir}/tools.h ${srcdir}/msglog.h INCLUDE=-I. -I${srcdir} CC=@CC@ diff --git a/ax_lua.m4 b/ax_lua.m4 deleted file mode 100644 index d9f4773..0000000 --- a/ax_lua.m4 +++ /dev/null @@ -1,614 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_lua.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PROG_LUA[([MINIMUM-VERSION], [TOO-BIG-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] -# AX_LUA_HEADERS[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] -# AX_LUA_LIBS[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] -# AX_LUA_READLINE[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] -# -# DESCRIPTION -# -# Detect a Lua interpreter, optionally specifying a minimum and maximum -# version number. Set up important Lua paths, such as the directories in -# which to install scripts and modules (shared libraries). -# -# Also detect Lua headers and libraries. The Lua version contained in the -# header is checked to match the Lua interpreter version exactly. When -# searching for Lua libraries, the version number is used as a suffix. -# This is done with the goal of supporting multiple Lua installs (5.1 and -# 5.2 side-by-side). -# -# A note on compatibility with previous versions: This file has been -# mostly rewritten for serial 18. Most developers should be able to use -# these macros without needing to modify configure.ac. Care has been taken -# to preserve each macro's behavior, but there are some differences: -# -# 1) AX_WITH_LUA is deprecated; it now expands to the exact same thing as -# AX_PROG_LUA with no arguments. -# -# 2) AX_LUA_HEADERS now checks that the version number defined in lua.h -# matches the interpreter version. AX_LUA_HEADERS_VERSION is therefore -# unnecessary, so it is deprecated and does not expand to anything. -# -# 3) The configure flag --with-lua-suffix no longer exists; the user -# should instead specify the LUA precious variable on the command line. -# See the AX_PROG_LUA description for details. -# -# Please read the macro descriptions below for more information. -# -# This file was inspired by Andrew Dalke's and James Henstridge's -# python.m4 and Tom Payne's, Matthieu Moy's, and Reuben Thomas's ax_lua.m4 -# (serial 17). Basically, this file is a mash-up of those two files. I -# like to think it combines the best of the two! -# -# AX_PROG_LUA: Search for the Lua interpreter, and set up important Lua -# paths. Adds precious variable LUA, which may contain the path of the Lua -# interpreter. If LUA is blank, the user's path is searched for an -# suitable interpreter. -# -# If MINIMUM-VERSION is supplied, then only Lua interpreters with a -# version number greater or equal to MINIMUM-VERSION will be accepted. If -# TOO-BIG- VERSION is also supplied, then only Lua interpreters with a -# version number greater or equal to MINIMUM-VERSION and less than -# TOO-BIG-VERSION will be accepted. -# -# Version comparisons require the AX_COMPARE_VERSION macro, which is -# provided by ax_compare_version.m4 from the Autoconf Archive. -# -# The Lua version number, LUA_VERSION, is found from the interpreter, and -# substituted. LUA_PLATFORM is also found, but not currently supported (no -# standard representation). -# -# Finally, the macro finds four paths: -# -# luadir Directory to install Lua scripts. -# pkgluadir $luadir/$PACKAGE -# luaexecdir Directory to install Lua modules. -# pkgluaexecdir $luaexecdir/$PACKAGE -# -# These paths a found based on $prefix, $exec_prefix, Lua's package.path, -# and package.cpath. The first path of package.path beginning with $prefix -# is selected as luadir. The first path of package.cpath beginning with -# $exec_prefix is used as luaexecdir. This should work on all reasonable -# Lua installations. If a path cannot be determined, a default path is -# used. Of course, the user can override these later when invoking make. -# -# luadir Default: $prefix/share/lua/$LUA_VERSION -# luaexecdir Default: $exec_prefix/lib/lua/$LUA_VERSION -# -# These directories can be used by Automake as install destinations. The -# variable name minus 'dir' needs to be used as a prefix to the -# appropriate Automake primary, e.g. lua_SCRIPS or luaexec_LIBRARIES. -# -# If an acceptable Lua interpreter is found, then ACTION-IF-FOUND is -# performed, otherwise ACTION-IF-NOT-FOUND is preformed. If ACTION-IF-NOT- -# FOUND is blank, then it will default to printing an error. To prevent -# the default behavior, give ':' as an action. -# -# AX_LUA_HEADERS: Search for Lua headers. Requires that AX_PROG_LUA be -# expanded before this macro. Adds precious variable LUA_INCLUDE, which -# may contain Lua specific include flags, e.g. -I/usr/include/lua5.1. If -# LUA_INCLUDE is blank, then this macro will attempt to find suitable -# flags. -# -# LUA_INCLUDE can be used by Automake to compile Lua modules or -# executables with embedded interpreters. The *_CPPFLAGS variables should -# be used for this purpose, e.g. myprog_CPPFLAGS = $(LUA_INCLUDE). -# -# This macro searches for the header lua.h (and others). The search is -# performed with a combination of CPPFLAGS, CPATH, etc, and LUA_INCLUDE. -# If the search is unsuccessful, then some common directories are tried. -# If the headers are then found, then LUA_INCLUDE is set accordingly. -# -# The paths automatically searched are: -# -# * /usr/include/luaX.Y -# * /usr/include/lua/X.Y -# * /usr/include/luaXY -# * /usr/local/include/luaX.Y -# * /usr/local/include/lua-X.Y -# * /usr/local/include/lua/X.Y -# * /usr/local/include/luaXY -# -# (Where X.Y is the Lua version number, e.g. 5.1.) -# -# The Lua version number found in the headers is always checked to match -# the Lua interpreter's version number. Lua headers with mismatched -# version numbers are not accepted. -# -# If headers are found, then ACTION-IF-FOUND is performed, otherwise -# ACTION-IF-NOT-FOUND is performed. If ACTION-IF-NOT-FOUND is blank, then -# it will default to printing an error. To prevent the default behavior, -# set the action to ':'. -# -# AX_LUA_LIBS: Search for Lua libraries. Requires that AX_PROG_LUA be -# expanded before this macro. Adds precious variable LUA_LIB, which may -# contain Lua specific linker flags, e.g. -llua5.1. If LUA_LIB is blank, -# then this macro will attempt to find suitable flags. -# -# LUA_LIB can be used by Automake to link Lua modules or executables with -# embedded interpreters. The *_LIBADD and *_LDADD variables should be used -# for this purpose, e.g. mymod_LIBADD = $(LUA_LIB). -# -# This macro searches for the Lua library. More technically, it searches -# for a library containing the function lua_load. The search is performed -# with a combination of LIBS, LIBRARY_PATH, and LUA_LIB. -# -# If the search determines that some linker flags are missing, then those -# flags will be added to LUA_LIB. -# -# If libraries are found, then ACTION-IF-FOUND is performed, otherwise -# ACTION-IF-NOT-FOUND is performed. If ACTION-IF-NOT-FOUND is blank, then -# it will default to printing an error. To prevent the default behavior, -# set the action to ':'. -# -# AX_LUA_READLINE: Search for readline headers and libraries. Requires the -# AX_LIB_READLINE macro, which is provided by ax_lib_readline.m4 from the -# Autoconf Archive. -# -# If a readline compatible library is found, then ACTION-IF-FOUND is -# performed, otherwise ACTION-IF-NOT-FOUND is performed. -# -# LICENSE -# -# Copyright (c) 2013 Tim Perkins -# Copyright (c) 2013 Reuben Thomas -# -# 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 3 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 21 - -dnl ========================================================================= -dnl AX_PROG_LUA([MINIMUM-VERSION], [TOO-BIG-VERSION], -dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -dnl ========================================================================= -AC_DEFUN([AX_PROG_LUA], -[ - dnl Make LUA a precious variable. - AC_ARG_VAR([LUA], [The Lua interpreter, e.g. /usr/bin/lua5.1]) - - dnl Find a Lua interpreter. - m4_define_default([_AX_LUA_INTERPRETER_LIST], - [lua lua5.2 lua52 lua5.1 lua51 lua50]) - - m4_if([$1], [], - [ dnl No version check is needed. Find any Lua interpreter. - AS_IF([test "x$LUA" = 'x'], - [AC_PATH_PROGS([LUA], [_AX_LUA_INTERPRETER_LIST], [:])]) - ax_display_LUA='lua' - - dnl At least check if this is a Lua interpreter. - AC_MSG_CHECKING([if $LUA is a Lua interpreter]) - _AX_LUA_CHK_IS_INTRP([$LUA], - [AC_MSG_RESULT([yes])], - [ AC_MSG_RESULT([no]) - AC_MSG_ERROR([not a Lua interpreter]) - ]) - ], - [ dnl A version check is needed. - AS_IF([test "x$LUA" != 'x'], - [ dnl Check if this is a Lua interpreter. - AC_MSG_CHECKING([if $LUA is a Lua interpreter]) - _AX_LUA_CHK_IS_INTRP([$LUA], - [AC_MSG_RESULT([yes])], - [ AC_MSG_RESULT([no]) - AC_MSG_ERROR([not a Lua interpreter]) - ]) - dnl Check the version. - m4_if([$2], [], - [_ax_check_text="whether $LUA version >= $1"], - [_ax_check_text="whether $LUA version >= $1, < $2"]) - AC_MSG_CHECKING([$_ax_check_text]) - _AX_LUA_CHK_VER([$LUA], [$1], [$2], - [AC_MSG_RESULT([yes])], - [ AC_MSG_RESULT([no]) - AC_MSG_ERROR([version is out of range for specified LUA])]) - ax_display_LUA=$LUA - ], - [ dnl Try each interpreter until we find one that satisfies VERSION. - m4_if([$2], [], - [_ax_check_text="for a Lua interpreter with version >= $1"], - [_ax_check_text="for a Lua interpreter with version >= $1, < $2"]) - AC_CACHE_CHECK([$_ax_check_text], - [ax_cv_pathless_LUA], - [ for ax_cv_pathless_LUA in _AX_LUA_INTERPRETER_LIST none; do - test "x$ax_cv_pathless_LUA" = 'xnone' && break - _AX_LUA_CHK_IS_INTRP([$ax_cv_pathless_LUA], [], [continue]) - _AX_LUA_CHK_VER([$ax_cv_pathless_LUA], [$1], [$2], [break]) - done - ]) - dnl Set $LUA to the absolute path of $ax_cv_pathless_LUA. - AS_IF([test "x$ax_cv_pathless_LUA" = 'xnone'], - [LUA=':'], - [AC_PATH_PROG([LUA], [$ax_cv_pathless_LUA])]) - ax_display_LUA=$ax_cv_pathless_LUA - ]) - ]) - - AS_IF([test "x$LUA" = 'x:'], - [ dnl Run any user-specified action, or abort. - m4_default([$4], [AC_MSG_ERROR([cannot find suitable Lua interpreter])]) - ], - [ dnl Query Lua for its version number. - AC_CACHE_CHECK([for $ax_display_LUA version], [ax_cv_lua_version], - [ ax_cv_lua_version=`$LUA -e "print(_VERSION)" | \ - sed "s|^Lua \(.*\)|\1|" | \ - grep -E -o "^@<:@0-9@:>@+\.@<:@0-9@:>@+"` - ]) - AS_IF([test "x$ax_cv_lua_version" = 'x'], - [AC_MSG_ERROR([invalid Lua version number])]) - AC_SUBST([LUA_VERSION], [$ax_cv_lua_version]) - AC_SUBST([LUA_SHORT_VERSION], [`echo "$LUA_VERSION" | sed 's|\.||'`]) - - dnl The following check is not supported: - dnl At times (like when building shared libraries) you may want to know - dnl which OS platform Lua thinks this is. - AC_CACHE_CHECK([for $ax_display_LUA platform], [ax_cv_lua_platform], - [ax_cv_lua_platform=`$LUA -e "print('unknown')"`]) - AC_SUBST([LUA_PLATFORM], [$ax_cv_lua_platform]) - - dnl Use the values of $prefix and $exec_prefix for the corresponding - dnl values of LUA_PREFIX and LUA_EXEC_PREFIX. These are made distinct - dnl variables so they can be overridden if need be. However, the general - dnl consensus is that you shouldn't need this ability. - AC_SUBST([LUA_PREFIX], ['${prefix}']) - AC_SUBST([LUA_EXEC_PREFIX], ['${exec_prefix}']) - - dnl Lua provides no way to query the script directory, and instead - dnl provides LUA_PATH. However, we should be able to make a safe educated - dnl guess. If the built-in search path contains a directory which is - dnl prefixed by $prefix, then we can store scripts there. The first - dnl matching path will be used. - AC_CACHE_CHECK([for $ax_display_LUA script directory], - [ax_cv_lua_luadir], - [ AS_IF([test "x$prefix" = 'xNONE'], - [ax_lua_prefix=$ac_default_prefix], - [ax_lua_prefix=$prefix]) - - dnl Initialize to the default path. - ax_cv_lua_luadir="$LUA_PREFIX/share/lua/$LUA_VERSION" - - dnl Try to find a path with the prefix. - _AX_LUA_FND_PRFX_PTH([$LUA], [$ax_lua_prefix], [package.path]) - AS_IF([test "x$ax_lua_prefixed_path" != 'x'], - [ dnl Fix the prefix. - _ax_strip_prefix=`echo "$ax_lua_prefix" | sed 's|.|.|g'` - ax_cv_lua_luadir=`echo "$ax_lua_prefixed_path" | \ - sed "s,^$_ax_strip_prefix,$LUA_PREFIX,"` - ]) - ]) - AC_SUBST([luadir], [$ax_cv_lua_luadir]) - AC_SUBST([pkgluadir], [\${luadir}/$PACKAGE]) - - dnl Lua provides no way to query the module directory, and instead - dnl provides LUA_PATH. However, we should be able to make a safe educated - dnl guess. If the built-in search path contains a directory which is - dnl prefixed by $exec_prefix, then we can store modules there. The first - dnl matching path will be used. - AC_CACHE_CHECK([for $ax_display_LUA module directory], - [ax_cv_lua_luaexecdir], - [ AS_IF([test "x$exec_prefix" = 'xNONE'], - [ax_lua_exec_prefix=$ax_lua_prefix], - [ax_lua_exec_prefix=$exec_prefix]) - - dnl Initialize to the default path. - ax_cv_lua_luaexecdir="$LUA_EXEC_PREFIX/lib/lua/$LUA_VERSION" - - dnl Try to find a path with the prefix. - _AX_LUA_FND_PRFX_PTH([$LUA], - [$ax_lua_exec_prefix], [package.cpathd]) - AS_IF([test "x$ax_lua_prefixed_path" != 'x'], - [ dnl Fix the prefix. - _ax_strip_prefix=`echo "$ax_lua_exec_prefix" | sed 's|.|.|g'` - ax_cv_lua_luaexecdir=`echo "$ax_lua_prefixed_path" | \ - sed "s,^$_ax_strip_prefix,$LUA_EXEC_PREFIX,"` - ]) - ]) - AC_SUBST([luaexecdir], [$ax_cv_lua_luaexecdir]) - AC_SUBST([pkgluaexecdir], [\${luaexecdir}/$PACKAGE]) - - dnl Run any user specified action. - $3 - ]) -]) - -dnl AX_WITH_LUA is now the same thing as AX_PROG_LUA. -AC_DEFUN([AX_WITH_LUA], -[ - AC_MSG_WARN([[$0 is deprecated, please use AX_PROG_LUA]]) - AX_PROG_LUA -]) - - -dnl ========================================================================= -dnl _AX_LUA_CHK_IS_INTRP(PROG, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) -dnl ========================================================================= -AC_DEFUN([_AX_LUA_CHK_IS_INTRP], -[ - dnl Just print _VERSION because all Lua interpreters have this global. - AS_IF([$1 -e "print('Hello ' .. _VERSION .. '!')" &>/dev/null], - [$2], [$3]) -]) - - -dnl ========================================================================= -dnl _AX_LUA_CHK_VER(PROG, MINIMUM-VERSION, [TOO-BIG-VERSION], -dnl [ACTION-IF-TRUE], [ACTION-IF-FALSE]) -dnl ========================================================================= -AC_DEFUN([_AX_LUA_CHK_VER], -[ - _ax_test_ver=`$1 -e "print(_VERSION)" 2>/dev/null | \ - sed "s|^Lua \(.*\)|\1|" | grep -E -o "^@<:@0-9@:>@+\.@<:@0-9@:>@+"` - AS_IF([test "x$_ax_test_ver" = 'x'], - [_ax_test_ver='0']) - AX_COMPARE_VERSION([$_ax_test_ver], [ge], [$2]) - m4_if([$3], [], [], - [ AS_IF([$ax_compare_version], - [AX_COMPARE_VERSION([$_ax_test_ver], [lt], [$3])]) - ]) - AS_IF([$ax_compare_version], [$4], [$5]) -]) - - -dnl ========================================================================= -dnl _AX_LUA_FND_PRFX_PTH(PROG, PREFIX, LUA-PATH-VARIABLE) -dnl ========================================================================= -AC_DEFUN([_AX_LUA_FND_PRFX_PTH], -[ - dnl Invokes the Lua interpreter PROG to print the path variable - dnl LUA-PATH-VARIABLE, usually package.path or package.cpath. Paths are - dnl then matched against PREFIX. The first path to begin with PREFIX is set - dnl to ax_lua_prefixed_path. - - ax_lua_prefixed_path='' - _ax_package_paths=`$1 -e 'print($3)' 2>/dev/null | sed 's|;|\n|g'` - dnl Try the paths in order, looking for the prefix. - for _ax_package_path in $_ax_package_paths; do - dnl Copy the path, up to the use of a Lua wildcard. - _ax_path_parts=`echo "$_ax_package_path" | sed 's|/|\n|g'` - _ax_reassembled='' - for _ax_path_part in $_ax_path_parts; do - echo "$_ax_path_part" | grep '\?' >/dev/null && break - _ax_reassembled="$_ax_reassembled/$_ax_path_part" - done - dnl Check the path against the prefix. - _ax_package_path=$_ax_reassembled - if echo "$_ax_package_path" | grep "^$2" >/dev/null; then - dnl Found it. - ax_lua_prefixed_path=$_ax_package_path - break - fi - done -]) - - -dnl ========================================================================= -dnl AX_LUA_HEADERS([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -dnl ========================================================================= -AC_DEFUN([AX_LUA_HEADERS], -[ - dnl Check for LUA_VERSION. - AC_MSG_CHECKING([if LUA_VERSION is defined]) - AS_IF([test "x$LUA_VERSION" != 'x'], - [AC_MSG_RESULT([yes])], - [ AC_MSG_RESULT([no]) - AC_MSG_ERROR([cannot check Lua headers without knowing LUA_VERSION]) - ]) - - dnl Make LUA_INCLUDE a precious variable. - AC_ARG_VAR([LUA_INCLUDE], [The Lua includes, e.g. -I/usr/include/lua5.1]) - - dnl Some default directories to search. - LUA_SHORT_VERSION=`echo "$LUA_VERSION" | sed 's|\.||'` - m4_define_default([_AX_LUA_INCLUDE_LIST], - [ /usr/include/lua$LUA_VERSION \ - /usr/include/lua/$LUA_VERSION \ - /usr/include/lua$LUA_SHORT_VERSION \ - /usr/local/include/lua$LUA_VERSION \ - /usr/local/include/lua-$LUA_VERSION \ - /usr/local/include/lua/$LUA_VERSION \ - /usr/local/include/lua$LUA_SHORT_VERSION \ - ]) - - dnl Try to find the headers. - _ax_lua_saved_cppflags=$CPPFLAGS - CPPFLAGS="$CPPFLAGS $LUA_INCLUDE" - AC_CHECK_HEADERS([lua.h lualib.h lauxlib.h luaconf.h]) - CPPFLAGS=$_ax_lua_saved_cppflags - - dnl Try some other directories if LUA_INCLUDE was not set. - AS_IF([test "x$LUA_INCLUDE" = 'x' && - test "x$ac_cv_header_lua_h" != 'xyes'], - [ dnl Try some common include paths. - for _ax_include_path in _AX_LUA_INCLUDE_LIST; do - test ! -d "$_ax_include_path" && continue - - AC_MSG_CHECKING([for Lua headers in]) - AC_MSG_RESULT([$_ax_include_path]) - - AS_UNSET([ac_cv_header_lua_h]) - AS_UNSET([ac_cv_header_lualib_h]) - AS_UNSET([ac_cv_header_lauxlib_h]) - AS_UNSET([ac_cv_header_luaconf_h]) - - _ax_lua_saved_cppflags=$CPPFLAGS - CPPFLAGS="$CPPFLAGS -I$_ax_include_path" - AC_CHECK_HEADERS([lua.h lualib.h lauxlib.h luaconf.h]) - CPPFLAGS=$_ax_lua_saved_cppflags - - AS_IF([test "x$ac_cv_header_lua_h" = 'xyes'], - [ LUA_INCLUDE="-I$_ax_include_path" - break - ]) - done - ]) - - AS_IF([test "x$ac_cv_header_lua_h" = 'xyes'], - [ dnl Make a program to print LUA_VERSION defined in the header. - dnl TODO This probably shouldn't be a runtime test. - - AC_CACHE_CHECK([for Lua header version], - [ax_cv_lua_header_version], - [ _ax_lua_saved_cppflags=$CPPFLAGS - CPPFLAGS="$CPPFLAGS $LUA_INCLUDE" - AC_RUN_IFELSE( - [ AC_LANG_SOURCE([[ -#include -#include -#include -int main(int argc, char ** argv) -{ - if(argc > 1) printf("%s", LUA_VERSION); - exit(EXIT_SUCCESS); -} -]]) - ], - [ ax_cv_lua_header_version=`./conftest$EXEEXT p | \ - sed "s|^Lua \(.*\)|\1|" | \ - grep -E -o "^@<:@0-9@:>@+\.@<:@0-9@:>@+"` - ], - [ax_cv_lua_header_version='unknown']) - CPPFLAGS=$_ax_lua_saved_cppflags - ]) - - dnl Compare this to the previously found LUA_VERSION. - AC_MSG_CHECKING([if Lua header version matches $LUA_VERSION]) - AS_IF([test "x$ax_cv_lua_header_version" = "x$LUA_VERSION"], - [ AC_MSG_RESULT([yes]) - ax_header_version_match='yes' - ], - [ AC_MSG_RESULT([no]) - ax_header_version_match='no' - ]) - ]) - - dnl Was LUA_INCLUDE specified? - AS_IF([test "x$ax_header_version_match" != 'xyes' && - test "x$LUA_INCLUDE" != 'x'], - [AC_MSG_ERROR([cannot find headers for specified LUA_INCLUDE])]) - - dnl Test the final result and run user code. - AS_IF([test "x$ax_header_version_match" = 'xyes'], [$1], - [m4_default([$2], [AC_MSG_ERROR([cannot find Lua includes])])]) -]) - -dnl AX_LUA_HEADERS_VERSION no longer exists, use AX_LUA_HEADERS. -AC_DEFUN([AX_LUA_HEADERS_VERSION], -[ - AC_MSG_WARN([[$0 is deprecated, please use AX_LUA_HEADERS]]) -]) - - -dnl ========================================================================= -dnl AX_LUA_LIBS([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -dnl ========================================================================= -AC_DEFUN([AX_LUA_LIBS], -[ - dnl TODO Should this macro also check various -L flags? - - dnl Check for LUA_VERSION. - AC_MSG_CHECKING([if LUA_VERSION is defined]) - AS_IF([test "x$LUA_VERSION" != 'x'], - [AC_MSG_RESULT([yes])], - [ AC_MSG_RESULT([no]) - AC_MSG_ERROR([cannot check Lua libs without knowing LUA_VERSION]) - ]) - - dnl Make LUA_LIB a precious variable. - AC_ARG_VAR([LUA_LIB], [The Lua library, e.g. -llua5.1]) - - AS_IF([test "x$LUA_LIB" != 'x'], - [ dnl Check that LUA_LIBS works. - _ax_lua_saved_libs=$LIBS - LIBS="$LIBS $LUA_LIB" - AC_SEARCH_LIBS([lua_load], [], - [_ax_found_lua_libs='yes'], - [_ax_found_lua_libs='no']) - LIBS=$_ax_lua_saved_libs - - dnl Check the result. - AS_IF([test "x$_ax_found_lua_libs" != 'xyes'], - [AC_MSG_ERROR([cannot find libs for specified LUA_LIB])]) - ], - [ dnl First search for extra libs. - _ax_lua_extra_libs='' - - _ax_lua_saved_libs=$LIBS - LIBS="$LIBS $LUA_LIB" - AC_SEARCH_LIBS([exp], [m]) - AC_SEARCH_LIBS([dlopen], [dl]) - LIBS=$_ax_lua_saved_libs - - AS_IF([test "x$ac_cv_search_exp" != 'xno' && - test "x$ac_cv_search_exp" != 'xnone required'], - [_ax_lua_extra_libs="$_ax_lua_extra_libs $ac_cv_search_exp"]) - - AS_IF([test "x$ac_cv_search_dlopen" != 'xno' && - test "x$ac_cv_search_dlopen" != 'xnone required'], - [_ax_lua_extra_libs="$_ax_lua_extra_libs $ac_cv_search_dlopen"]) - - dnl Try to find the Lua libs. - _ax_lua_saved_libs=$LIBS - LIBS="$LIBS $LUA_LIB" - AC_SEARCH_LIBS([lua_load], - [ lua$LUA_VERSION \ - lua$LUA_SHORT_VERSION \ - lua-$LUA_VERSION \ - lua-$LUA_SHORT_VERSION \ - lua], - [_ax_found_lua_libs='yes'], - [_ax_found_lua_libs='no'], - [$_ax_lua_extra_libs]) - LIBS=$_ax_lua_saved_libs - - AS_IF([test "x$ac_cv_search_lua_load" != 'xno' && - test "x$ac_cv_search_lua_load" != 'xnone required'], - [LUA_LIB="$ac_cv_search_lua_load $_ax_lua_extra_libs"]) - ]) - - dnl Test the result and run user code. - AS_IF([test "x$_ax_found_lua_libs" = 'xyes'], [$1], - [m4_default([$2], [AC_MSG_ERROR([cannot find Lua libs])])]) -]) - - -dnl ========================================================================= -dnl AX_LUA_READLINE([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -dnl ========================================================================= -AC_DEFUN([AX_LUA_READLINE], -[ - AX_LIB_READLINE - AS_IF([test "x$ac_cv_header_readline_readline_h" != 'x' && - test "x$ac_cv_header_readline_history_h" != 'x'], - [ LUA_LIBS_CFLAGS="-DLUA_USE_READLINE $LUA_LIBS_CFLAGS" - $1 - ], - [$2]) -]) diff --git a/binlog.c b/binlog.c index d8b7421..84915e6 100644 --- a/binlog.c +++ b/binlog.c @@ -17,10 +17,6 @@ Copyright Vitaly Valtman 2013 */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include #include #include @@ -55,8 +51,6 @@ char *get_binlog_file_name() return "/home/dev-jessie/.telegram/binlog"; } -//extern struct dc *DC_list[]; -//extern int dc_working_num; extern int our_id; int binlog_enabled = 0; extern int encr_root; diff --git a/config.h.in b/config.h.in deleted file mode 100644 index 1a20b5b..0000000 --- a/config.h.in +++ /dev/null @@ -1,177 +0,0 @@ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if you have the `alarm' function. */ -#undef HAVE_ALARM - -/* Define to 1 if you have the header file. */ -#undef HAVE_ARPA_INET_H - -/* Define to 1 if you have the `endpwent' function. */ -#undef HAVE_ENDPWENT - -/* Define to 1 if you have the header file. */ -#undef HAVE_EXECINFO_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_LAUXLIB_H - -/* 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 - -/* Define to 1 if you have the `m' library (-lm). */ -#undef HAVE_LIBM - -/* Define to 1 if you have the `z' library (-lz). */ -#undef HAVE_LIBZ - -/* Define to 1 if you have the header file. */ -#undef HAVE_LUACONF_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_LUALIB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_LUA_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_MACH_MACH_H - -/* Define to 1 if your system has a GNU libc compatible `malloc' function, and - to 0 otherwise. */ -#undef HAVE_MALLOC - -/* Define to 1 if you have the header file. */ -#undef HAVE_MALLOC_H - -/* Define to 1 if you have the `memmove' function. */ -#undef HAVE_MEMMOVE - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the `memset' function. */ -#undef HAVE_MEMSET - -/* Define to 1 if you have the `mkdir' function. */ -#undef HAVE_MKDIR - -/* Define to 1 if you have the header file. */ -#undef HAVE_NETDB_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_NETINET_IN_H - -/* Define to 1 if your system has a GNU libc compatible `realloc' function, - and to 0 otherwise. */ -#undef HAVE_REALLOC - -/* Define to 1 if you have the `select' function. */ -#undef HAVE_SELECT - -/* Define to 1 if you have the `socket' function. */ -#undef HAVE_SOCKET - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if you have the `strdup' function. */ -#undef HAVE_STRDUP - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the `strndup' function. */ -#undef HAVE_STRNDUP - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_FILE_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_SOCKET_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_TERMIOS_H - -/* Define to 1 if you have the `uname' function. */ -#undef HAVE_UNAME - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the home page for this package. */ -#undef PACKAGE_URL - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Use custom prog name */ -#undef PROG_NAME - -/* Use libedit */ -#undef READLINE_EDIT - -/* Use gnu libreadline */ -#undef READLINE_GNU - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* use lua */ -#undef USE_LUA - -/* Define to `int' if doesn't define. */ -#undef gid_t - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -#undef inline -#endif - -/* Define to rpl_malloc if the replacement function should be used. */ -#undef malloc - -/* Define to rpl_realloc if the replacement function should be used. */ -#undef realloc - -/* Define to `unsigned int' if does not define. */ -#undef size_t - -/* Define to `int' if doesn't define. */ -#undef uid_t diff --git a/config.sample b/config.sample deleted file mode 100644 index dffcc44..0000000 --- a/config.sample +++ /dev/null @@ -1,66 +0,0 @@ -# This is an empty config file -# Feel free to put something here - -default_profile = "binlog"; - -test_dc1 = { - config_directory = ".telegram/test_dc1"; - test = true; - msg_num = true; - binlog_enabled = true; -}; - -binlog = { - config_directory = ".telegram/binlog"; - test = false; - msg_num = true; - binlog_enabled = true; - log_level = 2; -}; - -binlog_mts = { - config_directory = ".telegram/binlog_mts"; - test = false; - msg_num = true; - binlog_enabled = true; - log_level = 2; -}; - -mega = { - config_directory = ".telegram/mega"; - test = false; - msg_num = true; - binlog_enabled = true; - log_level = 2; -}; - -new = { - config_directory = ".telegram/new"; - test = false; - msg_num = true; -}; - -production = { - config_directory = ".telegram/production"; - test = false; - msg_num = true; -}; - -test = { - config_directory = ".telegram/test"; - test = true; - msg_num = true; -}; - -test1 = { - config_directory = ".telegram/test1"; - msg_num = true; - binlog_enabled = true; -}; - -test2 = { - config_directory = ".telegram/test2"; - msg_num = true; - binlog_enabled = true; -}; - diff --git a/configure b/configure index 0a54e9f..ea2640d 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-purple 0.1. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -575,14 +575,13 @@ MFLAGS= MAKEFLAGS= # Identity of this package. -PACKAGE_NAME='telegram' -PACKAGE_TARNAME='telegram' +PACKAGE_NAME='telegram-purple' +PACKAGE_TARNAME='telegram-purple' PACKAGE_VERSION='0.1' -PACKAGE_STRING='telegram 0.1' +PACKAGE_STRING='telegram-purple 0.1' PACKAGE_BUGREPORT='' PACKAGE_URL='' -ac_unique_file="config.h.in" # Factoring default headers for most tests. ac_includes_default="\ #include @@ -622,21 +621,9 @@ ac_includes_default="\ ac_subst_vars='LTLIBOBJS EXTRA_LIBS LIBOBJS -LUA_LIB EGREP GREP CPP -LUA_INCLUDE -pkgluaexecdir -luaexecdir -pkgluadir -luadir -LUA_EXEC_PREFIX -LUA_PREFIX -LUA_PLATFORM -LUA_SHORT_VERSION -LUA_VERSION -LUA OBJEXT EXEEXT ac_ct_CC @@ -685,8 +672,6 @@ SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking -enable_libconfig -enable_liblua with_progname ' ac_precious_vars='build_alias @@ -697,10 +682,7 @@ CFLAGS LDFLAGS LIBS CPPFLAGS -LUA -LUA_INCLUDE -CPP -LUA_LIB' +CPP' # Initialize some variables set by options. @@ -1241,7 +1223,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-purple 0.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1289,7 +1271,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-purple] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] @@ -1302,17 +1284,10 @@ 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-purple 0.1:";; esac cat <<\_ACEOF -Optional Features: - --disable-option-checking ignore unrecognized --enable/--with options - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] ---enable-libconfig/--disable-libconfig ---enable-liblua/--disable-liblua - Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) @@ -1326,10 +1301,7 @@ 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 - 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 it to find libraries and programs with nonstandard names/locations. @@ -1397,7 +1369,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -telegram configure 0.1 +telegram-purple configure 0.1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1816,7 +1788,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-purple $as_me 0.1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2162,221 +2134,6 @@ 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 - - - -ac_config_headers="$ac_config_headers config.h" - - -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_lua.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PROG_LUA[([MINIMUM-VERSION], [TOO-BIG-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] -# AX_LUA_HEADERS[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] -# AX_LUA_LIBS[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] -# AX_LUA_READLINE[([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])] -# -# DESCRIPTION -# -# Detect a Lua interpreter, optionally specifying a minimum and maximum -# version number. Set up important Lua paths, such as the directories in -# which to install scripts and modules (shared libraries). -# -# Also detect Lua headers and libraries. The Lua version contained in the -# header is checked to match the Lua interpreter version exactly. When -# searching for Lua libraries, the version number is used as a suffix. -# This is done with the goal of supporting multiple Lua installs (5.1 and -# 5.2 side-by-side). -# -# A note on compatibility with previous versions: This file has been -# mostly rewritten for serial 18. Most developers should be able to use -# these macros without needing to modify configure.ac. Care has been taken -# to preserve each macro's behavior, but there are some differences: -# -# 1) AX_WITH_LUA is deprecated; it now expands to the exact same thing as -# AX_PROG_LUA with no arguments. -# -# 2) AX_LUA_HEADERS now checks that the version number defined in lua.h -# matches the interpreter version. AX_LUA_HEADERS_VERSION is therefore -# unnecessary, so it is deprecated and does not expand to anything. -# -# 3) The configure flag --with-lua-suffix no longer exists; the user -# should instead specify the LUA precious variable on the command line. -# See the AX_PROG_LUA description for details. -# -# Please read the macro descriptions below for more information. -# -# This file was inspired by Andrew Dalke's and James Henstridge's -# python.m4 and Tom Payne's, Matthieu Moy's, and Reuben Thomas's ax_lua.m4 -# (serial 17). Basically, this file is a mash-up of those two files. I -# like to think it combines the best of the two! -# -# AX_PROG_LUA: Search for the Lua interpreter, and set up important Lua -# paths. Adds precious variable LUA, which may contain the path of the Lua -# interpreter. If LUA is blank, the user's path is searched for an -# suitable interpreter. -# -# If MINIMUM-VERSION is supplied, then only Lua interpreters with a -# version number greater or equal to MINIMUM-VERSION will be accepted. If -# TOO-BIG- VERSION is also supplied, then only Lua interpreters with a -# version number greater or equal to MINIMUM-VERSION and less than -# TOO-BIG-VERSION will be accepted. -# -# Version comparisons require the AX_COMPARE_VERSION macro, which is -# provided by ax_compare_version.m4 from the Autoconf Archive. -# -# The Lua version number, LUA_VERSION, is found from the interpreter, and -# substituted. LUA_PLATFORM is also found, but not currently supported (no -# standard representation). -# -# Finally, the macro finds four paths: -# -# luadir Directory to install Lua scripts. -# pkgluadir $luadir/$PACKAGE -# luaexecdir Directory to install Lua modules. -# pkgluaexecdir $luaexecdir/$PACKAGE -# -# These paths a found based on $prefix, $exec_prefix, Lua's package.path, -# and package.cpath. The first path of package.path beginning with $prefix -# is selected as luadir. The first path of package.cpath beginning with -# $exec_prefix is used as luaexecdir. This should work on all reasonable -# Lua installations. If a path cannot be determined, a default path is -# used. Of course, the user can override these later when invoking make. -# -# luadir Default: $prefix/share/lua/$LUA_VERSION -# luaexecdir Default: $exec_prefix/lib/lua/$LUA_VERSION -# -# These directories can be used by Automake as install destinations. The -# variable name minus 'dir' needs to be used as a prefix to the -# appropriate Automake primary, e.g. lua_SCRIPS or luaexec_LIBRARIES. -# -# If an acceptable Lua interpreter is found, then ACTION-IF-FOUND is -# performed, otherwise ACTION-IF-NOT-FOUND is preformed. If ACTION-IF-NOT- -# FOUND is blank, then it will default to printing an error. To prevent -# the default behavior, give ':' as an action. -# -# AX_LUA_HEADERS: Search for Lua headers. Requires that AX_PROG_LUA be -# expanded before this macro. Adds precious variable LUA_INCLUDE, which -# may contain Lua specific include flags, e.g. -I/usr/include/lua5.1. If -# LUA_INCLUDE is blank, then this macro will attempt to find suitable -# flags. -# -# LUA_INCLUDE can be used by Automake to compile Lua modules or -# executables with embedded interpreters. The *_CPPFLAGS variables should -# be used for this purpose, e.g. myprog_CPPFLAGS = $(LUA_INCLUDE). -# -# This macro searches for the header lua.h (and others). The search is -# performed with a combination of CPPFLAGS, CPATH, etc, and LUA_INCLUDE. -# If the search is unsuccessful, then some common directories are tried. -# If the headers are then found, then LUA_INCLUDE is set accordingly. -# -# The paths automatically searched are: -# -# * /usr/include/luaX.Y -# * /usr/include/lua/X.Y -# * /usr/include/luaXY -# * /usr/local/include/luaX.Y -# * /usr/local/include/lua-X.Y -# * /usr/local/include/lua/X.Y -# * /usr/local/include/luaXY -# -# (Where X.Y is the Lua version number, e.g. 5.1.) -# -# The Lua version number found in the headers is always checked to match -# the Lua interpreter's version number. Lua headers with mismatched -# version numbers are not accepted. -# -# If headers are found, then ACTION-IF-FOUND is performed, otherwise -# ACTION-IF-NOT-FOUND is performed. If ACTION-IF-NOT-FOUND is blank, then -# it will default to printing an error. To prevent the default behavior, -# set the action to ':'. -# -# AX_LUA_LIBS: Search for Lua libraries. Requires that AX_PROG_LUA be -# expanded before this macro. Adds precious variable LUA_LIB, which may -# contain Lua specific linker flags, e.g. -llua5.1. If LUA_LIB is blank, -# then this macro will attempt to find suitable flags. -# -# LUA_LIB can be used by Automake to link Lua modules or executables with -# embedded interpreters. The *_LIBADD and *_LDADD variables should be used -# for this purpose, e.g. mymod_LIBADD = $(LUA_LIB). -# -# This macro searches for the Lua library. More technically, it searches -# for a library containing the function lua_load. The search is performed -# with a combination of LIBS, LIBRARY_PATH, and LUA_LIB. -# -# If the search determines that some linker flags are missing, then those -# flags will be added to LUA_LIB. -# -# If libraries are found, then ACTION-IF-FOUND is performed, otherwise -# ACTION-IF-NOT-FOUND is performed. If ACTION-IF-NOT-FOUND is blank, then -# it will default to printing an error. To prevent the default behavior, -# set the action to ':'. -# -# AX_LUA_READLINE: Search for readline headers and libraries. Requires the -# AX_LIB_READLINE macro, which is provided by ax_lib_readline.m4 from the -# Autoconf Archive. -# -# If a readline compatible library is found, then ACTION-IF-FOUND is -# performed, otherwise ACTION-IF-NOT-FOUND is performed. -# -# LICENSE -# -# Copyright (c) 2013 Tim Perkins -# Copyright (c) 2013 Reuben Thomas -# -# 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 3 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 21 - - - - - - - - - - - - - - - - - - - - - - - @@ -3581,123 +3338,36 @@ $as_echo "#define READLINE_EDIT 1" >>confdefs.h 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; } +#check for custom prog name + +# Check whether --with-progname was given. +if test "${with_progname+set}" = set; then : + withval=$with_progname; + if test "x$with_progname" = "xno" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: default" >&5 +$as_echo "default" >&6; } + elif test "x$with_progname" = "xyes" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: default" >&5 +$as_echo "default" >&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. */ + { $as_echo "$as_me:${as_lineno-$LINENO}: result: \"$with_progname\"" >&5 +$as_echo "\"$with_progname\"" >&6; } -/* 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; -} +cat >>confdefs.h <<_ACEOF +#define PROG_NAME "$with_progname" _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 - + { $as_echo "$as_me:${as_lineno-$LINENO}: result: default" >&5 +$as_echo "default" >&6; } fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for liblua" >&5 -$as_echo_n "checking for liblua... " >&6; } +# Checks for header files. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -4095,1381 +3765,6 @@ fi done -# Check whether --enable-liblua was given. -if test "${enable_liblua+set}" = set; then : - enableval=$enable_liblua; - 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; } - - - - - - if test "x$LUA" = 'x'; then : - for ac_prog in lua lua5.2 lua52 lua5.1 lua51 lua50 -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; 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_LUA+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $LUA in - [\\/]* | ?:[\\/]*) - ac_cv_path_LUA="$LUA" # 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_LUA="$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 -done - done -IFS=$as_save_IFS - - ;; -esac -fi -LUA=$ac_cv_path_LUA -if test -n "$LUA"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LUA" >&5 -$as_echo "$LUA" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$LUA" && break -done -test -n "$LUA" || LUA=":" - -fi - ax_display_LUA='lua' - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $LUA is a Lua interpreter" >&5 -$as_echo_n "checking if $LUA is a Lua interpreter... " >&6; } - - if $LUA -e "print('Hello ' .. _VERSION .. '!')" &>/dev/null; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - as_fn_error $? "not a Lua interpreter" "$LINENO" 5 - -fi - - - - if test "x$LUA" = 'x:'; then : - - as_fn_error $? "No lua found. Try --disable-liblua" "$LINENO" 5 - - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ax_display_LUA version" >&5 -$as_echo_n "checking for $ax_display_LUA version... " >&6; } -if ${ax_cv_lua_version+:} false; then : - $as_echo_n "(cached) " >&6 -else - ax_cv_lua_version=`$LUA -e "print(_VERSION)" | \ - sed "s|^Lua \(.*\)|\1|" | \ - grep -E -o "^[0-9]+\.[0-9]+"` - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_lua_version" >&5 -$as_echo "$ax_cv_lua_version" >&6; } - if test "x$ax_cv_lua_version" = 'x'; then : - as_fn_error $? "invalid Lua version number" "$LINENO" 5 -fi - LUA_VERSION=$ax_cv_lua_version - - LUA_SHORT_VERSION=`echo "$LUA_VERSION" | sed 's|\.||'` - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ax_display_LUA platform" >&5 -$as_echo_n "checking for $ax_display_LUA platform... " >&6; } -if ${ax_cv_lua_platform+:} false; then : - $as_echo_n "(cached) " >&6 -else - ax_cv_lua_platform=`$LUA -e "print('unknown')"` -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_lua_platform" >&5 -$as_echo "$ax_cv_lua_platform" >&6; } - LUA_PLATFORM=$ax_cv_lua_platform - - - LUA_PREFIX='${prefix}' - - LUA_EXEC_PREFIX='${exec_prefix}' - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ax_display_LUA script directory" >&5 -$as_echo_n "checking for $ax_display_LUA script directory... " >&6; } -if ${ax_cv_lua_luadir+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "x$prefix" = 'xNONE'; then : - ax_lua_prefix=$ac_default_prefix -else - ax_lua_prefix=$prefix -fi - - ax_cv_lua_luadir="$LUA_PREFIX/share/lua/$LUA_VERSION" - - - - ax_lua_prefixed_path='' - _ax_package_paths=`$LUA -e 'print(package.path)' 2>/dev/null | sed 's|;|\n|g'` - for _ax_package_path in $_ax_package_paths; do - _ax_path_parts=`echo "$_ax_package_path" | sed 's|/|\n|g'` - _ax_reassembled='' - for _ax_path_part in $_ax_path_parts; do - echo "$_ax_path_part" | grep '\?' >/dev/null && break - _ax_reassembled="$_ax_reassembled/$_ax_path_part" - done - _ax_package_path=$_ax_reassembled - if echo "$_ax_package_path" | grep "^$ax_lua_prefix" >/dev/null; then - ax_lua_prefixed_path=$_ax_package_path - break - fi - done - - if test "x$ax_lua_prefixed_path" != 'x'; then : - _ax_strip_prefix=`echo "$ax_lua_prefix" | sed 's|.|.|g'` - ax_cv_lua_luadir=`echo "$ax_lua_prefixed_path" | \ - sed "s,^$_ax_strip_prefix,$LUA_PREFIX,"` - -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_lua_luadir" >&5 -$as_echo "$ax_cv_lua_luadir" >&6; } - luadir=$ax_cv_lua_luadir - - pkgluadir=\${luadir}/$PACKAGE - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ax_display_LUA module directory" >&5 -$as_echo_n "checking for $ax_display_LUA module directory... " >&6; } -if ${ax_cv_lua_luaexecdir+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "x$exec_prefix" = 'xNONE'; then : - ax_lua_exec_prefix=$ax_lua_prefix -else - ax_lua_exec_prefix=$exec_prefix -fi - - ax_cv_lua_luaexecdir="$LUA_EXEC_PREFIX/lib/lua/$LUA_VERSION" - - - - ax_lua_prefixed_path='' - _ax_package_paths=`$LUA -e 'print(package.cpathd)' 2>/dev/null | sed 's|;|\n|g'` - for _ax_package_path in $_ax_package_paths; do - _ax_path_parts=`echo "$_ax_package_path" | sed 's|/|\n|g'` - _ax_reassembled='' - for _ax_path_part in $_ax_path_parts; do - echo "$_ax_path_part" | grep '\?' >/dev/null && break - _ax_reassembled="$_ax_reassembled/$_ax_path_part" - done - _ax_package_path=$_ax_reassembled - if echo "$_ax_package_path" | grep "^$ax_lua_exec_prefix" >/dev/null; then - ax_lua_prefixed_path=$_ax_package_path - break - fi - done - - if test "x$ax_lua_prefixed_path" != 'x'; then : - _ax_strip_prefix=`echo "$ax_lua_exec_prefix" | sed 's|.|.|g'` - ax_cv_lua_luaexecdir=`echo "$ax_lua_prefixed_path" | \ - sed "s,^$_ax_strip_prefix,$LUA_EXEC_PREFIX,"` - -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_lua_luaexecdir" >&5 -$as_echo "$ax_cv_lua_luaexecdir" >&6; } - luaexecdir=$ax_cv_lua_luaexecdir - - pkgluaexecdir=\${luaexecdir}/$PACKAGE - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if LUA_VERSION is defined" >&5 -$as_echo_n "checking if LUA_VERSION is defined... " >&6; } - if test "x$LUA_VERSION" != 'x'; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - as_fn_error $? "cannot check Lua headers without knowing LUA_VERSION" "$LINENO" 5 - -fi - - - - LUA_SHORT_VERSION=`echo "$LUA_VERSION" | sed 's|\.||'` - - - _ax_lua_saved_cppflags=$CPPFLAGS - CPPFLAGS="$CPPFLAGS $LUA_INCLUDE" - for ac_header in lua.h lualib.h lauxlib.h luaconf.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - CPPFLAGS=$_ax_lua_saved_cppflags - - if test "x$LUA_INCLUDE" = 'x' && - test "x$ac_cv_header_lua_h" != 'xyes'; then : - for _ax_include_path in /usr/include/lua$LUA_VERSION \ - /usr/include/lua/$LUA_VERSION \ - /usr/include/lua$LUA_SHORT_VERSION \ - /usr/local/include/lua$LUA_VERSION \ - /usr/local/include/lua-$LUA_VERSION \ - /usr/local/include/lua/$LUA_VERSION \ - /usr/local/include/lua$LUA_SHORT_VERSION \ - ; do - test ! -d "$_ax_include_path" && continue - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Lua headers in" >&5 -$as_echo_n "checking for Lua headers in... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_ax_include_path" >&5 -$as_echo "$_ax_include_path" >&6; } - - { ac_cv_header_lua_h=; unset ac_cv_header_lua_h;} - { ac_cv_header_lualib_h=; unset ac_cv_header_lualib_h;} - { ac_cv_header_lauxlib_h=; unset ac_cv_header_lauxlib_h;} - { ac_cv_header_luaconf_h=; unset ac_cv_header_luaconf_h;} - - _ax_lua_saved_cppflags=$CPPFLAGS - CPPFLAGS="$CPPFLAGS -I$_ax_include_path" - for ac_header in lua.h lualib.h lauxlib.h luaconf.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - CPPFLAGS=$_ax_lua_saved_cppflags - - if test "x$ac_cv_header_lua_h" = 'xyes'; then : - LUA_INCLUDE="-I$_ax_include_path" - break - -fi - done - -fi - - if test "x$ac_cv_header_lua_h" = 'xyes'; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Lua header version" >&5 -$as_echo_n "checking for Lua header version... " >&6; } -if ${ax_cv_lua_header_version+:} false; then : - $as_echo_n "(cached) " >&6 -else - _ax_lua_saved_cppflags=$CPPFLAGS - CPPFLAGS="$CPPFLAGS $LUA_INCLUDE" - if test "$cross_compiling" = yes; then : - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5; } -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -int main(int argc, char ** argv) -{ - if(argc > 1) printf("%s", LUA_VERSION); - exit(EXIT_SUCCESS); -} - - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ax_cv_lua_header_version=`./conftest$EXEEXT p | \ - sed "s|^Lua \(.*\)|\1|" | \ - grep -E -o "^[0-9]+\.[0-9]+"` - -else - ax_cv_lua_header_version='unknown' -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - CPPFLAGS=$_ax_lua_saved_cppflags - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_lua_header_version" >&5 -$as_echo "$ax_cv_lua_header_version" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if Lua header version matches $LUA_VERSION" >&5 -$as_echo_n "checking if Lua header version matches $LUA_VERSION... " >&6; } - if test "x$ax_cv_lua_header_version" = "x$LUA_VERSION"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - ax_header_version_match='yes' - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - ax_header_version_match='no' - -fi - -fi - - if test "x$ax_header_version_match" != 'xyes' && - test "x$LUA_INCLUDE" != 'x'; then : - as_fn_error $? "cannot find headers for specified LUA_INCLUDE" "$LINENO" 5 -fi - - if test "x$ax_header_version_match" = 'xyes'; then : - -else - as_fn_error $? "No lua headers found. Try --disable-liblua" "$LINENO" 5 -fi - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if LUA_VERSION is defined" >&5 -$as_echo_n "checking if LUA_VERSION is defined... " >&6; } - if test "x$LUA_VERSION" != 'x'; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - as_fn_error $? "cannot check Lua libs without knowing LUA_VERSION" "$LINENO" 5 - -fi - - - - if test "x$LUA_LIB" != 'x'; then : - _ax_lua_saved_libs=$LIBS - LIBS="$LIBS $LUA_LIB" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing lua_load" >&5 -$as_echo_n "checking for library containing lua_load... " >&6; } -if ${ac_cv_search_lua_load+:} 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 lua_load (); -int -main () -{ -return lua_load (); - ; - return 0; -} -_ACEOF -for ac_lib in '' ; 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_lua_load=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_lua_load+:} false; then : - break -fi -done -if ${ac_cv_search_lua_load+:} false; then : - -else - ac_cv_search_lua_load=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_lua_load" >&5 -$as_echo "$ac_cv_search_lua_load" >&6; } -ac_res=$ac_cv_search_lua_load -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - _ax_found_lua_libs='yes' -else - _ax_found_lua_libs='no' -fi - - LIBS=$_ax_lua_saved_libs - - if test "x$_ax_found_lua_libs" != 'xyes'; then : - as_fn_error $? "cannot find libs for specified LUA_LIB" "$LINENO" 5 -fi - -else - _ax_lua_extra_libs='' - - _ax_lua_saved_libs=$LIBS - LIBS="$LIBS $LUA_LIB" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing exp" >&5 -$as_echo_n "checking for library containing exp... " >&6; } -if ${ac_cv_search_exp+:} 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 exp (); -int -main () -{ -return exp (); - ; - return 0; -} -_ACEOF -for ac_lib in '' m; 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_exp=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_exp+:} false; then : - break -fi -done -if ${ac_cv_search_exp+:} false; then : - -else - ac_cv_search_exp=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_exp" >&5 -$as_echo "$ac_cv_search_exp" >&6; } -ac_res=$ac_cv_search_exp -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 library containing dlopen" >&5 -$as_echo_n "checking for library containing dlopen... " >&6; } -if ${ac_cv_search_dlopen+:} 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 dlopen (); -int -main () -{ -return dlopen (); - ; - return 0; -} -_ACEOF -for ac_lib in '' dl; 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_dlopen=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_dlopen+:} false; then : - break -fi -done -if ${ac_cv_search_dlopen+:} false; then : - -else - ac_cv_search_dlopen=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5 -$as_echo "$ac_cv_search_dlopen" >&6; } -ac_res=$ac_cv_search_dlopen -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - - LIBS=$_ax_lua_saved_libs - - if test "x$ac_cv_search_exp" != 'xno' && - test "x$ac_cv_search_exp" != 'xnone required'; then : - _ax_lua_extra_libs="$_ax_lua_extra_libs $ac_cv_search_exp" -fi - - if test "x$ac_cv_search_dlopen" != 'xno' && - test "x$ac_cv_search_dlopen" != 'xnone required'; then : - _ax_lua_extra_libs="$_ax_lua_extra_libs $ac_cv_search_dlopen" -fi - - _ax_lua_saved_libs=$LIBS - LIBS="$LIBS $LUA_LIB" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing lua_load" >&5 -$as_echo_n "checking for library containing lua_load... " >&6; } -if ${ac_cv_search_lua_load+:} 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 lua_load (); -int -main () -{ -return lua_load (); - ; - return 0; -} -_ACEOF -for ac_lib in '' lua$LUA_VERSION \ - lua$LUA_SHORT_VERSION \ - lua-$LUA_VERSION \ - lua-$LUA_SHORT_VERSION \ - lua; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $_ax_lua_extra_libs $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_lua_load=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_lua_load+:} false; then : - break -fi -done -if ${ac_cv_search_lua_load+:} false; then : - -else - ac_cv_search_lua_load=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_lua_load" >&5 -$as_echo "$ac_cv_search_lua_load" >&6; } -ac_res=$ac_cv_search_lua_load -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - _ax_found_lua_libs='yes' -else - _ax_found_lua_libs='no' -fi - - LIBS=$_ax_lua_saved_libs - - if test "x$ac_cv_search_lua_load" != 'xno' && - test "x$ac_cv_search_lua_load" != 'xnone required'; then : - LUA_LIB="$ac_cv_search_lua_load $_ax_lua_extra_libs" -fi - -fi - - if test "x$_ax_found_lua_libs" = 'xyes'; then : - -else - as_fn_error $? "No lua libs found. Try --disable-liblua" "$LINENO" 5 -fi - - EXTRA_LIBS="${EXTRA_LIBS} ${LUA_LIB}" ; - CPPFLAGS="${CPPFLAGS} ${LUA_INCLUDE}" ; - -$as_echo "#define USE_LUA 1" >>confdefs.h - - - -fi - - fi - -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5 -$as_echo "enabled" >&6; } - - - - - - if test "x$LUA" = 'x'; then : - for ac_prog in lua lua5.2 lua52 lua5.1 lua51 lua50 -do - # Extract the first word of "$ac_prog", so it can be a program name with args. -set dummy $ac_prog; 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_LUA+:} false; then : - $as_echo_n "(cached) " >&6 -else - case $LUA in - [\\/]* | ?:[\\/]*) - ac_cv_path_LUA="$LUA" # 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_LUA="$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 -done - done -IFS=$as_save_IFS - - ;; -esac -fi -LUA=$ac_cv_path_LUA -if test -n "$LUA"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LUA" >&5 -$as_echo "$LUA" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - - test -n "$LUA" && break -done -test -n "$LUA" || LUA=":" - -fi - ax_display_LUA='lua' - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $LUA is a Lua interpreter" >&5 -$as_echo_n "checking if $LUA is a Lua interpreter... " >&6; } - - if $LUA -e "print('Hello ' .. _VERSION .. '!')" &>/dev/null; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - as_fn_error $? "not a Lua interpreter" "$LINENO" 5 - -fi - - - - if test "x$LUA" = 'x:'; then : - - as_fn_error $? "No lua found. Try --disable-liblua" "$LINENO" 5 - - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ax_display_LUA version" >&5 -$as_echo_n "checking for $ax_display_LUA version... " >&6; } -if ${ax_cv_lua_version+:} false; then : - $as_echo_n "(cached) " >&6 -else - ax_cv_lua_version=`$LUA -e "print(_VERSION)" | \ - sed "s|^Lua \(.*\)|\1|" | \ - grep -E -o "^[0-9]+\.[0-9]+"` - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_lua_version" >&5 -$as_echo "$ax_cv_lua_version" >&6; } - if test "x$ax_cv_lua_version" = 'x'; then : - as_fn_error $? "invalid Lua version number" "$LINENO" 5 -fi - LUA_VERSION=$ax_cv_lua_version - - LUA_SHORT_VERSION=`echo "$LUA_VERSION" | sed 's|\.||'` - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ax_display_LUA platform" >&5 -$as_echo_n "checking for $ax_display_LUA platform... " >&6; } -if ${ax_cv_lua_platform+:} false; then : - $as_echo_n "(cached) " >&6 -else - ax_cv_lua_platform=`$LUA -e "print('unknown')"` -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_lua_platform" >&5 -$as_echo "$ax_cv_lua_platform" >&6; } - LUA_PLATFORM=$ax_cv_lua_platform - - - LUA_PREFIX='${prefix}' - - LUA_EXEC_PREFIX='${exec_prefix}' - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ax_display_LUA script directory" >&5 -$as_echo_n "checking for $ax_display_LUA script directory... " >&6; } -if ${ax_cv_lua_luadir+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "x$prefix" = 'xNONE'; then : - ax_lua_prefix=$ac_default_prefix -else - ax_lua_prefix=$prefix -fi - - ax_cv_lua_luadir="$LUA_PREFIX/share/lua/$LUA_VERSION" - - - - ax_lua_prefixed_path='' - _ax_package_paths=`$LUA -e 'print(package.path)' 2>/dev/null | sed 's|;|\n|g'` - for _ax_package_path in $_ax_package_paths; do - _ax_path_parts=`echo "$_ax_package_path" | sed 's|/|\n|g'` - _ax_reassembled='' - for _ax_path_part in $_ax_path_parts; do - echo "$_ax_path_part" | grep '\?' >/dev/null && break - _ax_reassembled="$_ax_reassembled/$_ax_path_part" - done - _ax_package_path=$_ax_reassembled - if echo "$_ax_package_path" | grep "^$ax_lua_prefix" >/dev/null; then - ax_lua_prefixed_path=$_ax_package_path - break - fi - done - - if test "x$ax_lua_prefixed_path" != 'x'; then : - _ax_strip_prefix=`echo "$ax_lua_prefix" | sed 's|.|.|g'` - ax_cv_lua_luadir=`echo "$ax_lua_prefixed_path" | \ - sed "s,^$_ax_strip_prefix,$LUA_PREFIX,"` - -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_lua_luadir" >&5 -$as_echo "$ax_cv_lua_luadir" >&6; } - luadir=$ax_cv_lua_luadir - - pkgluadir=\${luadir}/$PACKAGE - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ax_display_LUA module directory" >&5 -$as_echo_n "checking for $ax_display_LUA module directory... " >&6; } -if ${ax_cv_lua_luaexecdir+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test "x$exec_prefix" = 'xNONE'; then : - ax_lua_exec_prefix=$ax_lua_prefix -else - ax_lua_exec_prefix=$exec_prefix -fi - - ax_cv_lua_luaexecdir="$LUA_EXEC_PREFIX/lib/lua/$LUA_VERSION" - - - - ax_lua_prefixed_path='' - _ax_package_paths=`$LUA -e 'print(package.cpathd)' 2>/dev/null | sed 's|;|\n|g'` - for _ax_package_path in $_ax_package_paths; do - _ax_path_parts=`echo "$_ax_package_path" | sed 's|/|\n|g'` - _ax_reassembled='' - for _ax_path_part in $_ax_path_parts; do - echo "$_ax_path_part" | grep '\?' >/dev/null && break - _ax_reassembled="$_ax_reassembled/$_ax_path_part" - done - _ax_package_path=$_ax_reassembled - if echo "$_ax_package_path" | grep "^$ax_lua_exec_prefix" >/dev/null; then - ax_lua_prefixed_path=$_ax_package_path - break - fi - done - - if test "x$ax_lua_prefixed_path" != 'x'; then : - _ax_strip_prefix=`echo "$ax_lua_exec_prefix" | sed 's|.|.|g'` - ax_cv_lua_luaexecdir=`echo "$ax_lua_prefixed_path" | \ - sed "s,^$_ax_strip_prefix,$LUA_EXEC_PREFIX,"` - -fi - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_lua_luaexecdir" >&5 -$as_echo "$ax_cv_lua_luaexecdir" >&6; } - luaexecdir=$ax_cv_lua_luaexecdir - - pkgluaexecdir=\${luaexecdir}/$PACKAGE - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if LUA_VERSION is defined" >&5 -$as_echo_n "checking if LUA_VERSION is defined... " >&6; } - if test "x$LUA_VERSION" != 'x'; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - as_fn_error $? "cannot check Lua headers without knowing LUA_VERSION" "$LINENO" 5 - -fi - - - - LUA_SHORT_VERSION=`echo "$LUA_VERSION" | sed 's|\.||'` - - - _ax_lua_saved_cppflags=$CPPFLAGS - CPPFLAGS="$CPPFLAGS $LUA_INCLUDE" - for ac_header in lua.h lualib.h lauxlib.h luaconf.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - CPPFLAGS=$_ax_lua_saved_cppflags - - if test "x$LUA_INCLUDE" = 'x' && - test "x$ac_cv_header_lua_h" != 'xyes'; then : - for _ax_include_path in /usr/include/lua$LUA_VERSION \ - /usr/include/lua/$LUA_VERSION \ - /usr/include/lua$LUA_SHORT_VERSION \ - /usr/local/include/lua$LUA_VERSION \ - /usr/local/include/lua-$LUA_VERSION \ - /usr/local/include/lua/$LUA_VERSION \ - /usr/local/include/lua$LUA_SHORT_VERSION \ - ; do - test ! -d "$_ax_include_path" && continue - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Lua headers in" >&5 -$as_echo_n "checking for Lua headers in... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_ax_include_path" >&5 -$as_echo "$_ax_include_path" >&6; } - - { ac_cv_header_lua_h=; unset ac_cv_header_lua_h;} - { ac_cv_header_lualib_h=; unset ac_cv_header_lualib_h;} - { ac_cv_header_lauxlib_h=; unset ac_cv_header_lauxlib_h;} - { ac_cv_header_luaconf_h=; unset ac_cv_header_luaconf_h;} - - _ax_lua_saved_cppflags=$CPPFLAGS - CPPFLAGS="$CPPFLAGS -I$_ax_include_path" - for ac_header in lua.h lualib.h lauxlib.h luaconf.h -do : - as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF - -fi - -done - - CPPFLAGS=$_ax_lua_saved_cppflags - - if test "x$ac_cv_header_lua_h" = 'xyes'; then : - LUA_INCLUDE="-I$_ax_include_path" - break - -fi - done - -fi - - if test "x$ac_cv_header_lua_h" = 'xyes'; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Lua header version" >&5 -$as_echo_n "checking for Lua header version... " >&6; } -if ${ax_cv_lua_header_version+:} false; then : - $as_echo_n "(cached) " >&6 -else - _ax_lua_saved_cppflags=$CPPFLAGS - CPPFLAGS="$CPPFLAGS $LUA_INCLUDE" - if test "$cross_compiling" = yes; then : - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error $? "cannot run test program while cross compiling -See \`config.log' for more details" "$LINENO" 5; } -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include -#include -#include -int main(int argc, char ** argv) -{ - if(argc > 1) printf("%s", LUA_VERSION); - exit(EXIT_SUCCESS); -} - - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - ax_cv_lua_header_version=`./conftest$EXEEXT p | \ - sed "s|^Lua \(.*\)|\1|" | \ - grep -E -o "^[0-9]+\.[0-9]+"` - -else - ax_cv_lua_header_version='unknown' -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - - CPPFLAGS=$_ax_lua_saved_cppflags - -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_lua_header_version" >&5 -$as_echo "$ax_cv_lua_header_version" >&6; } - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if Lua header version matches $LUA_VERSION" >&5 -$as_echo_n "checking if Lua header version matches $LUA_VERSION... " >&6; } - if test "x$ax_cv_lua_header_version" = "x$LUA_VERSION"; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - ax_header_version_match='yes' - -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - ax_header_version_match='no' - -fi - -fi - - if test "x$ax_header_version_match" != 'xyes' && - test "x$LUA_INCLUDE" != 'x'; then : - as_fn_error $? "cannot find headers for specified LUA_INCLUDE" "$LINENO" 5 -fi - - if test "x$ax_header_version_match" = 'xyes'; then : - -else - as_fn_error $? "No lua headers found. Try --disable-liblua" "$LINENO" 5 -fi - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if LUA_VERSION is defined" >&5 -$as_echo_n "checking if LUA_VERSION is defined... " >&6; } - if test "x$LUA_VERSION" != 'x'; then : - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - as_fn_error $? "cannot check Lua libs without knowing LUA_VERSION" "$LINENO" 5 - -fi - - - - if test "x$LUA_LIB" != 'x'; then : - _ax_lua_saved_libs=$LIBS - LIBS="$LIBS $LUA_LIB" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing lua_load" >&5 -$as_echo_n "checking for library containing lua_load... " >&6; } -if ${ac_cv_search_lua_load+:} 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 lua_load (); -int -main () -{ -return lua_load (); - ; - return 0; -} -_ACEOF -for ac_lib in '' ; 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_lua_load=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_lua_load+:} false; then : - break -fi -done -if ${ac_cv_search_lua_load+:} false; then : - -else - ac_cv_search_lua_load=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_lua_load" >&5 -$as_echo "$ac_cv_search_lua_load" >&6; } -ac_res=$ac_cv_search_lua_load -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - _ax_found_lua_libs='yes' -else - _ax_found_lua_libs='no' -fi - - LIBS=$_ax_lua_saved_libs - - if test "x$_ax_found_lua_libs" != 'xyes'; then : - as_fn_error $? "cannot find libs for specified LUA_LIB" "$LINENO" 5 -fi - -else - _ax_lua_extra_libs='' - - _ax_lua_saved_libs=$LIBS - LIBS="$LIBS $LUA_LIB" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing exp" >&5 -$as_echo_n "checking for library containing exp... " >&6; } -if ${ac_cv_search_exp+:} 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 exp (); -int -main () -{ -return exp (); - ; - return 0; -} -_ACEOF -for ac_lib in '' m; 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_exp=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_exp+:} false; then : - break -fi -done -if ${ac_cv_search_exp+:} false; then : - -else - ac_cv_search_exp=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_exp" >&5 -$as_echo "$ac_cv_search_exp" >&6; } -ac_res=$ac_cv_search_exp -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 library containing dlopen" >&5 -$as_echo_n "checking for library containing dlopen... " >&6; } -if ${ac_cv_search_dlopen+:} 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 dlopen (); -int -main () -{ -return dlopen (); - ; - return 0; -} -_ACEOF -for ac_lib in '' dl; 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_dlopen=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_dlopen+:} false; then : - break -fi -done -if ${ac_cv_search_dlopen+:} false; then : - -else - ac_cv_search_dlopen=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5 -$as_echo "$ac_cv_search_dlopen" >&6; } -ac_res=$ac_cv_search_dlopen -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - - LIBS=$_ax_lua_saved_libs - - if test "x$ac_cv_search_exp" != 'xno' && - test "x$ac_cv_search_exp" != 'xnone required'; then : - _ax_lua_extra_libs="$_ax_lua_extra_libs $ac_cv_search_exp" -fi - - if test "x$ac_cv_search_dlopen" != 'xno' && - test "x$ac_cv_search_dlopen" != 'xnone required'; then : - _ax_lua_extra_libs="$_ax_lua_extra_libs $ac_cv_search_dlopen" -fi - - _ax_lua_saved_libs=$LIBS - LIBS="$LIBS $LUA_LIB" - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing lua_load" >&5 -$as_echo_n "checking for library containing lua_load... " >&6; } -if ${ac_cv_search_lua_load+:} 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 lua_load (); -int -main () -{ -return lua_load (); - ; - return 0; -} -_ACEOF -for ac_lib in '' lua$LUA_VERSION \ - lua$LUA_SHORT_VERSION \ - lua-$LUA_VERSION \ - lua-$LUA_SHORT_VERSION \ - lua; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $_ax_lua_extra_libs $ac_func_search_save_LIBS" - fi - if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_lua_load=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_lua_load+:} false; then : - break -fi -done -if ${ac_cv_search_lua_load+:} false; then : - -else - ac_cv_search_lua_load=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_lua_load" >&5 -$as_echo "$ac_cv_search_lua_load" >&6; } -ac_res=$ac_cv_search_lua_load -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - _ax_found_lua_libs='yes' -else - _ax_found_lua_libs='no' -fi - - LIBS=$_ax_lua_saved_libs - - if test "x$ac_cv_search_lua_load" != 'xno' && - test "x$ac_cv_search_lua_load" != 'xnone required'; then : - LUA_LIB="$ac_cv_search_lua_load $_ax_lua_extra_libs" -fi - -fi - - if test "x$_ax_found_lua_libs" = 'xyes'; then : - -else - as_fn_error $? "No lua libs found. Try --disable-liblua" "$LINENO" 5 -fi - - EXTRA_LIBS="${EXTRA_LIBS} ${LUA_LIB}" ; - CPPFLAGS="${CPPFLAGS} ${LUA_INCLUDE}" ; - -$as_echo "#define USE_LUA 1" >>confdefs.h - - - -fi - - -fi - - -#check for custom prog name - -# Check whether --with-progname was given. -if test "${with_progname+set}" = set; then : - withval=$with_progname; - if test "x$with_progname" = "xno" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: default" >&5 -$as_echo "default" >&6; } - elif test "x$with_progname" = "xyes" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: default" >&5 -$as_echo "default" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: \"$with_progname\"" >&5 -$as_echo "\"$with_progname\"" >&6; } - -cat >>confdefs.h <<_ACEOF -#define PROG_NAME "$with_progname" -_ACEOF - - fi - -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: default" >&5 -$as_echo "default" >&6; } - -fi - - -# Checks for header files. for ac_header in execinfo.h fcntl.h malloc.h netdb.h stdlib.h string.h unistd.h arpa/inet.h mach/mach.h netinet/in.h sys/file.h sys/socket.h termios.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` @@ -5810,7 +4105,43 @@ test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -DEFS=-DHAVE_CONFIG_H +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +# +# If the first sed substitution is executed (which looks for macros that +# take arguments), then branch to the quote section. Otherwise, +# look for a macro that doesn't take arguments. +ac_script=' +:mline +/\\$/{ + N + s,\\\n,, + b mline +} +t clear +:clear +s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g +t quote +s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g +t quote +b any +:quote +s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g +s/\[/\\&/g +s/\]/\\&/g +s/\$/$$/g +H +:any +${ + g + s/^\n// + s/\n/ /g + p +} +' +DEFS=`sed -n "$ac_script" confdefs.h` + ac_libobjs= ac_ltlibobjs= @@ -6226,7 +4557,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-purple $as_me 0.1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -6244,15 +4575,11 @@ case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac -case $ac_config_headers in *" -"*) set x $ac_config_headers; shift; ac_config_headers=$*;; -esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" -config_headers="$ac_config_headers" _ACEOF @@ -6273,22 +4600,17 @@ Usage: $0 [OPTION]... [TAG]... --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE - --header=FILE[:TEMPLATE] - instantiate the configuration header FILE Configuration files: $config_files -Configuration headers: -$config_headers - Report bugs to the package provider." _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-purple config.status 0.1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -6342,18 +4664,7 @@ do esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; - --header | --heade | --head | --hea ) - $ac_shift - case $ac_optarg in - *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; - esac - as_fn_append CONFIG_HEADERS " '$ac_optarg'" - ac_need_defaults=false;; - --he | --h) - # Conflict between --help and --header - as_fn_error $? "ambiguous option: \`$1' -Try \`$0 --help' for more information.";; - --help | --hel | -h ) + --he | --h | --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) @@ -6409,7 +4720,6 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 for ac_config_target in $ac_config_targets do case $ac_config_target in - "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; @@ -6423,7 +4733,6 @@ done # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files - test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree @@ -6611,116 +4920,8 @@ fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" -# Set up the scripts for CONFIG_HEADERS section. -# No need to generate them if there are no CONFIG_HEADERS. -# This happens for instance with `./config.status Makefile'. -if test -n "$CONFIG_HEADERS"; then -cat >"$ac_tmp/defines.awk" <<\_ACAWK || -BEGIN { -_ACEOF -# Transform confdefs.h into an awk script `defines.awk', embedded as -# here-document in config.status, that substitutes the proper values into -# config.h.in to produce config.h. - -# Create a delimiter string that does not exist in confdefs.h, to ease -# handling of long lines. -ac_delim='%!_!# ' -for ac_last_try in false false :; do - ac_tt=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_tt"; then - break - elif $ac_last_try; then - as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 - else - ac_delim="$ac_delim!$ac_delim _$ac_delim!! " - fi -done - -# For the awk script, D is an array of macro values keyed by name, -# likewise P contains macro parameters if any. Preserve backslash -# newline sequences. - -ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* -sed -n ' -s/.\{148\}/&'"$ac_delim"'/g -t rset -:rset -s/^[ ]*#[ ]*define[ ][ ]*/ / -t def -d -:def -s/\\$// -t bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3"/p -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p -d -:bsnl -s/["\\]/\\&/g -s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ -D["\1"]=" \3\\\\\\n"\\/p -t cont -s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p -t cont -d -:cont -n -s/.\{148\}/&'"$ac_delim"'/g -t clear -:clear -s/\\$// -t bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/"/p -d -:bsnlc -s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p -b cont -' >$CONFIG_STATUS || ac_write_fail=1 - -cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 - for (key in D) D_is_set[key] = 1 - FS = "" -} -/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { - line = \$ 0 - split(line, arg, " ") - if (arg[1] == "#") { - defundef = arg[2] - mac1 = arg[3] - } else { - defundef = substr(arg[1], 2) - mac1 = arg[2] - } - split(mac1, mac2, "(") #) - macro = mac2[1] - prefix = substr(line, 1, index(line, defundef) - 1) - if (D_is_set[macro]) { - # Preserve the white space surrounding the "#". - print prefix "define", macro P[macro] D[macro] - next - } else { - # Replace #undef with comments. This is necessary, for example, - # in the case of _POSIX_SOURCE, which is predefined and required - # on some systems where configure will not decide to define it. - if (defundef == "undef") { - print "/*", prefix defundef, macro, "*/" - next - } - } -} -{ print } -_ACAWK -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 -fi # test -n "$CONFIG_HEADERS" - - -eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " +eval set X " :F $CONFIG_FILES " shift for ac_tag do @@ -6928,30 +5129,7 @@ which seems to be undefined. Please make sure it is defined" >&2;} esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; - :H) - # - # CONFIG_HEADER - # - if test x"$ac_file" != x-; then - { - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" - } >"$ac_tmp/config.h" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then - { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 -$as_echo "$as_me: $ac_file is unchanged" >&6;} - else - rm -f "$ac_file" - mv "$ac_tmp/config.h" "$ac_file" \ - || as_fn_error $? "could not create $ac_file" "$LINENO" 5 - fi - else - $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ - || as_fn_error $? "could not create -" "$LINENO" 5 - fi - ;; + esac diff --git a/configure.ac b/configure.ac index 6b0f5d7..fbdb867 100644 --- a/configure.ac +++ b/configure.ac @@ -1,9 +1,5 @@ AC_PREREQ([2.68]) -AC_INIT([telegram], [0.1]) -AC_CONFIG_SRCDIR([config.h.in]) -AC_CONFIG_HEADERS([config.h]) - -m4_include([ax_lua.m4]) +AC_INIT([telegram-purple], [0.1]) # Checks for programs. AC_PROG_CC @@ -33,54 +29,6 @@ AC_CHECK_LIB([readline], [rl_save_prompt], ] ) -AC_MSG_CHECKING([for libconfig]) -AC_ARG_ENABLE(libconfig,[--enable-libconfig/--disable-libconfig], - [ - if test "x$enableval" = "xno" ; then - AC_MSG_RESULT([disabled]) - else - AC_MSG_RESULT([enabled]) - AC_CHECK_LIB([config],[config_init],[],AC_MSG_ERROR([No libconfig found. Try --disable-libconfig])) - fi - ],[ - AC_MSG_RESULT([enabled]) - AC_CHECK_LIB([config],[config_init],[],AC_MSG_ERROR([No libconfig found. Try --disable-libconfig])) - ]) - -AC_MSG_CHECKING([for liblua]) -AC_ARG_ENABLE(liblua,[--enable-liblua/--disable-liblua], - [ - if test "x$enableval" = "xno" ; then - AC_MSG_RESULT([disabled]) - else - AC_MSG_RESULT([enabled]) - AX_PROG_LUA([],[], - [ - AX_LUA_HEADERS([],[AC_MSG_ERROR([No lua headers found. Try --disable-liblua])]) - AX_LUA_LIBS([],[AC_MSG_ERROR([No lua libs found. Try --disable-liblua])]) - [EXTRA_LIBS="${EXTRA_LIBS} ${LUA_LIB}" ; ] - [CPPFLAGS="${CPPFLAGS} ${LUA_INCLUDE}" ; ] - AC_DEFINE(USE_LUA,1,[use lua]) - ], - [ - AC_MSG_ERROR([No lua found. Try --disable-liblua]) - ]) - fi - ],[ - AC_MSG_RESULT([enabled]) - AX_PROG_LUA([],[], - [ - AX_LUA_HEADERS([],[AC_MSG_ERROR([No lua headers found. Try --disable-liblua])]) - AX_LUA_LIBS([],[AC_MSG_ERROR([No lua libs found. Try --disable-liblua])]) - [EXTRA_LIBS="${EXTRA_LIBS} ${LUA_LIB}" ; ] - [CPPFLAGS="${CPPFLAGS} ${LUA_INCLUDE}" ; ] - AC_DEFINE(USE_LUA,1,[use lua]) - ], - [ - AC_MSG_ERROR([No lua found. Try --disable-liblua]) - ]) - ]) - #check for custom prog name AC_ARG_WITH(progname,[--with-progname=], [ diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index c83e5f7..0000000 --- a/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -telegram-cli (0.1-1) unstable; urgency=low - - * Initial release (Closes #737563) - - -- Cleto Martín Mon, 03 Feb 2014 20:00:03 +0000 diff --git a/debian/clean b/debian/clean deleted file mode 100644 index 33ceb8f..0000000 --- a/debian/clean +++ /dev/null @@ -1 +0,0 @@ -Makefile \ No newline at end of file diff --git a/debian/compat b/debian/compat deleted file mode 100644 index ec63514..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/debian/control b/debian/control deleted file mode 100644 index 5e7e1f0..0000000 --- a/debian/control +++ /dev/null @@ -1,36 +0,0 @@ -Source: telegram-cli -Section: net -Priority: optional -Maintainer: Cleto Martín -Build-Depends: debhelper (>= 8.0.0), - autotools-dev, - autoconf-archive, - libreadline-dev, - libconfig-dev, - libssl-dev, - lua5.2, - liblua5.2-dev -Standards-Version: 3.9.4 -Homepage: https://github.com/vysheng/tg -Vcs-Git: git://github.com/vysheng/tg.git -Vcs-Browser: https://github.com/vysheng/tg - -Package: telegram-cli -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends} -Description: Command-line interface for Telegram messenger - Telegram messenger is a cloud-based instant messaging designed for - smart phones and similar to Whatsapp but more flexible, and - powerful. You can send messages, photos, videos and documents to - people who are in your phone contacts (and have Telegram). Telegram - also supports secret chats whose provide a private (encrypted) way of - communication. - . - This package contains a command-line based client for Telegram with - the following features: - * Colored terminal messages. - * Message management: history, stats, etc. - * Group chat: create and manage groups. - * Secret chat: secured and encrypted conversations. - * Contact management: add/edit/remove contacts. - * Multimedia support: send/load photos and videos. diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index 2e46990..0000000 --- a/debian/copyright +++ /dev/null @@ -1,28 +0,0 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: telegram-cli -Source: https://github.com/vysheng/tg - -Files: * -Copyright: 2013 Vitaly Valtman -License: GPL-2.0+ - -Files: debian/* -Copyright: 2014 Cleto Martín -License: GPL-2.0+ - -License: GPL-2.0+ - This package 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 package 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 - . - On Debian systems, the complete text of the GNU General - Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". diff --git a/debian/docs b/debian/docs deleted file mode 100644 index b43bf86..0000000 --- a/debian/docs +++ /dev/null @@ -1 +0,0 @@ -README.md diff --git a/debian/install b/debian/install deleted file mode 100644 index f0f94de..0000000 --- a/debian/install +++ /dev/null @@ -1 +0,0 @@ -telegram usr/bin diff --git a/debian/rules b/debian/rules deleted file mode 100755 index 0f41aca..0000000 --- a/debian/rules +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- - -VERSION=$(shell dpkg-parsechangelog | sed -n 's/^Version: //p' | cut -f1 -d'-') -PACKAGE_NAME=$(shell dpkg-parsechangelog | sed -n 's/^Source: //p') - -%: - dh $@ --with autotools-dev - -build-orig: - mkdir -p $(PACKAGE_NAME)-$(VERSION) - tar --exclude=ax_lua.m4 --exclude=debian --exclude=\.pc \ - --exclude=$(PACKAGE_NAME)-$(VERSION) -cf - . \ - | ( cd $(PACKAGE_NAME)-$(VERSION) && tar xf - ) - tar -cf ../$(PACKAGE_NAME)_$(VERSION).orig.tar $(PACKAGE_NAME)-$(VERSION) - $(RM) -r $(PACKAGE_NAME)-$(VERSION) - xz ../$(PACKAGE_NAME)_$(VERSION).orig.tar diff --git a/debian/source/format b/debian/source/format deleted file mode 100644 index 163aaf8..0000000 --- a/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (quilt) diff --git a/debian/watch b/debian/watch deleted file mode 100644 index 2148331..0000000 --- a/debian/watch +++ /dev/null @@ -1,4 +0,0 @@ -version=3 - -opts=filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/tg-$1\.tar\.gz/ \ - https://github.com/vysheng/tg/tags .*/v?(\d\S*)\.tar\.gz diff --git a/gentoo/telegram-cli/Manifest b/gentoo/telegram-cli/Manifest deleted file mode 100644 index f39008c..0000000 --- a/gentoo/telegram-cli/Manifest +++ /dev/null @@ -1 +0,0 @@ -EBUILD telegram-cli-9999.ebuild 641 SHA256 4597e2f84c36b1ee02ecc415c399408bb8536b456e94370e996d57477db621be SHA512 287da263c9a4ba2058bf2f5844599432619053abc9249fd5725ed7b5e920c5c02e2493ad7b07f89177933b2c15394d939e7dc7dbf05d5873c32e55c9ec614d4c WHIRLPOOL 73dee37f91f1d4b747afc35c0a0cb2efb141d37702c71a7a9d188d2e1d727375c0ee3e7a1192e6c4c34f17ba1303f3a0be47b24272b5378ff255bce1a4a281be diff --git a/gentoo/telegram-cli/telegram-cli-9999.ebuild b/gentoo/telegram-cli/telegram-cli-9999.ebuild deleted file mode 100644 index 17e3288..0000000 --- a/gentoo/telegram-cli/telegram-cli-9999.ebuild +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 1999-2013 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Header: $ - -EAPI=5 - -EGIT_REPO_URI="https://github.com/vysheng/tg.git" -inherit git-2 -IUSE="lua" -DESCRIPTION="Command line interface client for Telegram" -HOMEPAGE="https://github.com/vysheng/tg" -LICENSE="GPL-2" -SLOT="0" -KEYWORDS="~amd64 ~x86" - -DEPEND="sys-libs/zlib - sys-libs/readline - dev-libs/libconfig - dev-libs/openssl - lua? ( dev-lang/lua )" - -src_configure() { - econf $(use_enable lua liblua ) --with-progname=telegram-cli -} - -src_install() { - newbin telegram telegram-cli - - insinto /etc/telegram-cli/ - newins tg-server.pub server.pub -} diff --git a/interface.c b/interface.c deleted file mode 100644 index 79a7a96..0000000 --- a/interface.c +++ /dev/null @@ -1,1577 +0,0 @@ -/* - This file is part of telegram-client. - - Telegram-client 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. - - Telegram-client 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 telegram-client. If not, see . - - Copyright Vitaly Valtman 2013 -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#define _GNU_SOURCE - -#include -#include -#include -#include -#include - -#ifdef READLINE_GNU -#include -#include -#else -#include -#include -#endif - -#include "include.h" -#include "queries.h" - -#include "telegram.h" -#include "structures.h" - - -// libpurple debugging-messages -#include "debug.h" -#include "purple-plugin/telegram-purple.h" -#include "msglog.h" - -#define ALLOW_MULT 1 -char *default_prompt = "> "; - -int unread_messages; -int msg_num_mode; -int alert_sound; - -int safe_quit; - -int in_readline; -int readline_active; - -int log_level = 1; - -long long cur_uploading_bytes; -long long cur_uploaded_bytes; -long long cur_downloading_bytes; -long long cur_downloaded_bytes; - -char *line_ptr; -extern peer_t *Peers[]; -extern int peer_num; - -int in_chat_mode; -peer_id_t chat_mode_id; - - -int is_same_word (const char *s, size_t l, const char *word) { - return s && word && strlen (word) == l && !memcmp (s, word, l); -} - -char *next_token (int *l) { - while (*line_ptr == ' ') { line_ptr ++; } - if (!*line_ptr) { - *l = 0; - return 0; - } - int neg = 0; - char *s = line_ptr; - int in_str = 0; - while (*line_ptr && (*line_ptr != ' ' || neg || in_str)) { -/* if (*line_ptr == '\\') { - neg = 1 - neg; - } else { - if (*line_ptr == '"' && !neg) { - in_str = !in_str; - } - neg = 0; - }*/ - line_ptr++; - } - *l = line_ptr - s; - return s; -} - -#define NOT_FOUND (int)0x80000000 -peer_id_t PEER_NOT_FOUND = {.id = NOT_FOUND}; - -long long next_token_int (void) { - int l; - char *s = next_token (&l); - if (!s) { return NOT_FOUND; } - char *r; - long long x = strtoll (s, &r, 10); - if (r == s + l) { - return x; - } else { - return NOT_FOUND; - } -} - -peer_id_t next_token_user (void) { - int l; - char *s = next_token (&l); - if (!s) { return PEER_NOT_FOUND; } - - if (l >= 6 && !memcmp (s, "user#", 5)) { - s += 5; - l -= 5; - int r = atoi (s); - if (r >= 0) { return set_peer_id (PEER_USER, r); } - else { return PEER_NOT_FOUND; } - } - - int index = 0; - while (index < peer_num && (!is_same_word (s, l, Peers[index]->print_name) || get_peer_type (Peers[index]->id) != PEER_USER)) { - index ++; - } - if (index < peer_num) { - return Peers[index]->id; - } else { - return PEER_NOT_FOUND; - } -} - -peer_id_t next_token_chat (void) { - int l; - char *s = next_token (&l); - if (!s) { return PEER_NOT_FOUND; } - - if (l >= 6 && !memcmp (s, "chat#", 5)) { - s += 5; - l -= 5; - int r = atoi (s); - if (r >= 0) { return set_peer_id (PEER_CHAT, r); } - else { return PEER_NOT_FOUND; } - } - - int index = 0; - while (index < peer_num && (!is_same_word (s, l, Peers[index]->print_name) || get_peer_type (Peers[index]->id) != PEER_CHAT)) { - index ++; - } - if (index < peer_num) { - return Peers[index]->id; - } else { - return PEER_NOT_FOUND; - } -} - -peer_id_t next_token_encr_chat (void) { - int l; - char *s = next_token (&l); - if (!s) { return PEER_NOT_FOUND; } - - int index = 0; - while (index < peer_num && (!is_same_word (s, l, Peers[index]->print_name) || get_peer_type (Peers[index]->id) != PEER_ENCR_CHAT)) { - index ++; - } - if (index < peer_num) { - return Peers[index]->id; - } else { - return PEER_NOT_FOUND; - } -} - -peer_id_t next_token_peer (void) { - int l; - char *s = next_token (&l); - if (!s) { return PEER_NOT_FOUND; } - - if (l >= 6 && !memcmp (s, "user#", 5)) { - s += 5; - l -= 5; - int r = atoi (s); - if (r >= 0) { return set_peer_id (PEER_USER, r); } - else { return PEER_NOT_FOUND; } - } - if (l >= 6 && !memcmp (s, "chat#", 5)) { - s += 5; - l -= 5; - int r = atoi (s); - if (r >= 0) { return set_peer_id (PEER_CHAT, r); } - else { return PEER_NOT_FOUND; } - } - - int index = 0; - while (index < peer_num && (!is_same_word (s, l, Peers[index]->print_name))) { - index ++; - } - if (index < peer_num) { - return Peers[index]->id; - } else { - return PEER_NOT_FOUND; - } -} - -char *get_default_prompt (void) { - static char buf[1000]; - int l = 0; - if (in_chat_mode) { - peer_t *U = user_chat_get (chat_mode_id); - assert (U && U->print_name); - l += tsnprintf (buf + l, 999 - l, COLOR_RED "%.*s " COLOR_NORMAL, 100, U->print_name); - } - if (unread_messages || cur_uploading_bytes || cur_downloading_bytes) { - l += tsnprintf (buf + l, 999 - l, COLOR_RED "["); - int ok = 0; - if (unread_messages) { - l += tsnprintf (buf + l, 999 - l, "%d unread", unread_messages); - ok = 1; - } - if (cur_uploading_bytes) { - if (ok) { *(buf + l) = ' '; l ++; } - ok = 1; - l += tsnprintf (buf + l, 999 - l, "%lld%%Up", 100 * cur_uploaded_bytes / cur_uploading_bytes); - } - if (cur_downloading_bytes) { - if (ok) { *(buf + l) = ' '; l ++; } - ok = 1; - l += tsnprintf (buf + l, 999 - l, "%lld%%Down", 100 * cur_downloaded_bytes / cur_downloading_bytes); - } - l += tsnprintf (buf + l, 999 - l, "]" COLOR_NORMAL); - return buf; - } - l += tsnprintf (buf + l, 999 - l, "%s", default_prompt); - return buf; -} - -char *complete_none (const char *text UU, int state UU) { - return 0; -} - - -void set_prompt (const char *s) { - rl_set_prompt (s); -} - -void update_prompt (void) { - print_start (); - set_prompt (get_default_prompt ()); - if (readline_active) { - rl_redisplay (); - } - print_end (); -} - -char *modifiers[] = { - "[offline]", - 0 -}; - -char *in_chat_commands[] = { - "/exit", - "/quit", - "/history", - "/read", - 0 -}; - -char *commands[] = { - "help", - "msg", - "contact_list", - "stats", - "history", - "dialog_list", - "send_photo", - "send_video", - "send_text", - "chat_info", - "user_info", - "fwd", - "rename_chat", - "load_photo", - "view_photo", - "load_video_thumb", - "view_video_thumb", - "load_video", - "view_video", - "add_contact", - "rename_contact", - "show_license", - "search", - "mark_read", - "visualize_key", - "create_secret_chat", - "suggested_contacts", - "global_search", - "chat_add_user", - "chat_del_user", - "status_online", - "status_offline", - "contacts_search", - "quit", - "safe_quit", - "send_audio", - "load_audio", - "view_audio", - "send_document", - "load_document_thumb", - "view_document_thumb", - "load_document", - "view_document", - "set", - "chat_with_peer", - "delete_msg", - "restore_msg", - "create_group_chat", - 0 }; - -int commands_flags[] = { - 070, - 072, - 07, - 07, - 072, - 07, - 0732, - 0732, - 0732, - 074, - 071, - 072, - 074, - 07, - 07, - 07, - 07, - 07, - 07, - 07, - 071, - 07, - 072, - 072, - 075, - 071, - 07, - 07, - 0724, - 0724, - 07, - 07, - 07, - 07, - 07, - 0732, - 07, - 07, - 0732, - 07, - 07, - 07, - 07, - 07, - 072, - 07, - 072, - 07 -}; - - - -int get_complete_mode (void) { - line_ptr = rl_line_buffer; - int l = 0; - char *r = next_token (&l); - if (!r) { return 0; } - while (r && r[0] == '[' && r[l - 1] == ']') { - r = next_token (&l); - if (!r) { return 0; } - } - if (*r == '[' && !r[l]) { - return 6; - } - - if (!*line_ptr) { return 0; } - char **command = commands; - int n = 0; - int flags = -1; - while (*command) { - if (is_same_word (r, l, *command)) { - flags = commands_flags[n]; - break; - } - n ++; - command ++; - } - if (flags == -1) { - return 7; - } - int s = 0; - while (1) { - if (!next_token (&l) || !*line_ptr) { - return flags ? flags & 7 : 7; - } - s ++; - if (s <= 4) { flags >>= 3; } - } -} - -int complete_user_list (int index, const char *text, int len, char **R) { - index ++; - while (index < peer_num && (!Peers[index]->print_name || strncmp (Peers[index]->print_name, text, len) || get_peer_type (Peers[index]->id) != PEER_USER)) { - index ++; - } - if (index < peer_num) { - *R = strdup (Peers[index]->print_name); - return index; - } else { - return -1; - } -} - -int complete_chat_list (int index, const char *text, int len, char **R) { - index ++; - while (index < peer_num && (!Peers[index]->print_name || strncmp (Peers[index]->print_name, text, len) || get_peer_type (Peers[index]->id) != PEER_CHAT)) { - index ++; - } - if (index < peer_num) { - *R = strdup (Peers[index]->print_name); - return index; - } else { - return -1; - } -} - -int complete_encr_chat_list (int index, const char *text, int len, char **R) { - index ++; - while (index < peer_num && (!Peers[index]->print_name || strncmp (Peers[index]->print_name, text, len) || get_peer_type (Peers[index]->id) != PEER_ENCR_CHAT)) { - index ++; - } - if (index < peer_num) { - *R = strdup (Peers[index]->print_name); - return index; - } else { - return -1; - } -} - -int complete_user_chat_list (int index, const char *text, int len, char **R) { - index ++; - while (index < peer_num && (!Peers[index]->print_name || strncmp (Peers[index]->print_name, text, len))) { - index ++; - } - if (index < peer_num) { - *R = strdup (Peers[index]->print_name); - return index; - } else { - return -1; - } -} - -int complete_string_list (char **list, int index, const char *text, int len, char **R) { - index ++; - while (list[index] && strncmp (list[index], text, len)) { - index ++; - } - if (list[index]) { - *R = strdup (list[index]); - return index; - } else { - *R = 0; - return -1; - } -} -char *command_generator (const char *text, int state) { - static int len, index, mode; - - if (in_chat_mode) { - char *R = 0; - index = complete_string_list (in_chat_commands, index, text, rl_point, &R); - return R; - } - - char c = 0; - if (!state) { - len = strlen (text); - index = -1; - - c = rl_line_buffer[rl_point]; - rl_line_buffer[rl_point] = 0; - mode = get_complete_mode (); - } else { - if (index == -1) { return 0; } - } - - if (mode == -1) { - if (c) { rl_line_buffer[rl_point] = c; } - return 0; - } - - char *R = 0; - switch (mode & 7) { - case 0: - index = complete_string_list (commands, index, text, len, &R); - if (c) { rl_line_buffer[rl_point] = c; } - return R; - case 1: - index = complete_user_list (index, text, len, &R); - if (c) { rl_line_buffer[rl_point] = c; } - return R; - case 2: - index = complete_user_chat_list (index, text, len, &R); - if (c) { rl_line_buffer[rl_point] = c; } - return R; - case 3: - R = rl_filename_completion_function(text,state); - if (c) { rl_line_buffer[rl_point] = c; } - return R; - case 4: - index = complete_chat_list (index, text, len, &R); - if (c) { rl_line_buffer[rl_point] = c; } - return R; - case 5: - index = complete_encr_chat_list (index, text, len, &R); - if (c) { rl_line_buffer[rl_point] = c; } - return R; - case 6: - index = complete_string_list (modifiers, index, text, len, &R); - if (c) { rl_line_buffer[rl_point] = c; } - return R; - default: - if (c) { rl_line_buffer[rl_point] = c; } - return 0; - } -} - -char **complete_text (char *text, int start UU, int end UU) { - return (char **) rl_completion_matches (text, command_generator); -} - -int offline_mode; -int count = 1; -void work_modifier (const char *s, int l) { - if (is_same_word (s, l, "[offline]")) { - offline_mode = 1; - } -#ifdef ALLOW_MULT - if (sscanf (s, "[x%d]", &count) >= 1) { - } -#endif -} - - - -void interpreter_chat_mode (char *line) { - if (line == NULL || /* EOF received */ - !strncmp (line, "/exit", 5) || !strncmp (line, "/quit", 5)) { - in_chat_mode = 0; - update_prompt (); - return; - } - if (!strncmp (line, "/history", 8)) { - int limit = 40; - sscanf (line, "/history %99d", &limit); - if (limit < 0 || limit > 1000) { limit = 40; } - do_get_history (chat_mode_id, limit); - return; - } - if (!strncmp (line, "/read", 5)) { - do_mark_read (chat_mode_id); - return; - } - if (strlen (line)>0) { - do_send_message (chat_mode_id, line, strlen (line)); - } -} - -void interpreter (char *line UU) { - assert (!in_readline); - in_readline = 1; - if (in_chat_mode) { - interpreter_chat_mode (line); - in_readline = 0; - return; - } - - line_ptr = line; - offline_mode = 0; - count = 1; - if (!line) { - in_readline = 0; - return; - } - if (line && *line) { - add_history (line); - } - - int l; - char *command; - while (1) { - command = next_token (&l); - if (!command) { in_readline = 0; return; } - if (*command == '[' && command[l - 1] == ']') { - work_modifier (command, l); - } else { - break; - } - } - - int _; - char *save = line_ptr; - int ll = l; - char *cs = command; - for (_ = 0; _ < count; _ ++) { - line_ptr = save; - l = ll; - command = cs; -#define IS_WORD(s) is_same_word (command, l, (s)) -#define RET in_readline = 0; return; - - peer_id_t id; -#define GET_PEER \ - id = next_token_peer (); \ - if (!cmp_peer_id (id, PEER_NOT_FOUND)) { \ - printf ("Bad user/chat id\n"); \ - RET; \ - } -#define GET_PEER_USER \ - id = next_token_user (); \ - if (!cmp_peer_id (id, PEER_NOT_FOUND)) { \ - printf ("Bad user id\n"); \ - RET; \ - } -#define GET_PEER_CHAT \ - id = next_token_chat (); \ - if (!cmp_peer_id (id, PEER_NOT_FOUND)) { \ - printf ("Bad chat id\n"); \ - RET; \ - } -#define GET_PEER_ENCR_CHAT \ - id = next_token_encr_chat (); \ - if (!cmp_peer_id (id, PEER_NOT_FOUND)) { \ - printf ("Bad encr_chat id\n"); \ - RET; \ - } - - if (IS_WORD ("contact_list")) { - do_update_contact_list (); - } else if (IS_WORD ("dialog_list")) { - do_get_dialog_list (); - } else if (IS_WORD ("stats")) { - static char stat_buf[1 << 15]; - print_stat (stat_buf, (1 << 15) - 1); - printf ("%s\n", stat_buf); - } else if (IS_WORD ("msg")) { - GET_PEER; - int t; - char *s = next_token (&t); - if (!s) { - printf ("Empty message\n"); - RET; - } - do_send_message (id, s, strlen (s)); - } else if (IS_WORD ("rename_chat")) { - GET_PEER_CHAT; - int t; - char *s = next_token (&t); - if (!s) { - printf ("Empty new name\n"); - RET; - } - do_rename_chat (id, s); - } else if (IS_WORD ("send_photo")) { - GET_PEER; - int t; - char *s = next_token (&t); - if (!s) { - printf ("Empty file name\n"); - RET; - } - do_send_photo (CODE_input_media_uploaded_photo, id, tstrndup (s, t)); - } else if (IS_WORD("send_video")) { - GET_PEER; - int t; - char *s = next_token (&t); - if (!s) { - printf ("Empty file name\n"); - RET; - } - do_send_photo (CODE_input_media_uploaded_video, id, tstrndup (s, t)); - } else if (IS_WORD ("send_text")) { - GET_PEER; - int t; - char *s = next_token (&t); - if (!s) { - printf ("Empty file name\n"); - RET; - } - do_send_text (id, tstrndup (s, t)); - } else if (IS_WORD ("fwd")) { - GET_PEER; - int num = next_token_int (); - if (num == NOT_FOUND || num <= 0) { - printf ("Bad msg id\n"); - RET; - } - do_forward_message (id, num); - } else if (IS_WORD ("load_photo")) { - long long num = next_token_int (); - if (num == NOT_FOUND) { - printf ("Bad msg id\n"); - RET; - } - struct message *M = message_get (num); - if (M && !M->service && M->media.type == CODE_message_media_photo) { - do_load_photo (&M->media.photo, 1); - } else if (M && !M->service && M->media.type == CODE_decrypted_message_media_photo) { - do_load_encr_video (&M->media.encr_video, 1); // this is not a bug. - } else { - printf ("Bad msg id\n"); - RET; - } - } else if (IS_WORD ("view_photo")) { - long long num = next_token_int (); - if (num == NOT_FOUND) { - printf ("Bad msg id\n"); - RET; - } - struct message *M = message_get (num); - if (M && !M->service && M->media.type == CODE_message_media_photo) { - do_load_photo (&M->media.photo, 2); - } else if (M && !M->service && M->media.type == CODE_decrypted_message_media_photo) { - do_load_encr_video (&M->media.encr_video, 2); // this is not a bug. - } else { - printf ("Bad msg id\n"); - RET; - } - } else if (IS_WORD ("load_video_thumb")) { - long long num = next_token_int (); - if (num == NOT_FOUND) { - printf ("Bad msg id\n"); - RET; - } - struct message *M = message_get (num); - if (M && !M->service && M->media.type == CODE_message_media_video) { - do_load_video_thumb (&M->media.video, 1); - } else { - printf ("Bad msg id\n"); - RET; - } - } else if (IS_WORD ("view_video_thumb")) { - long long num = next_token_int (); - if (num == NOT_FOUND) { - printf ("Bad msg id\n"); - RET; - } - struct message *M = message_get (num); - if (M && !M->service && M->media.type == CODE_message_media_video) { - do_load_video_thumb (&M->media.video, 2); - } else { - printf ("Bad msg id\n"); - RET; - } - } else if (IS_WORD ("load_video")) { - long long num = next_token_int (); - if (num == NOT_FOUND) { - printf ("Bad msg id\n"); - RET; - } - struct message *M = message_get (num); - if (M && !M->service && M->media.type == CODE_message_media_video) { - do_load_video (&M->media.video, 1); - } else if (M && !M->service && M->media.type == CODE_decrypted_message_media_video) { - do_load_encr_video (&M->media.encr_video, 1); - } else { - printf ("Bad msg id\n"); - RET; - } - } else if (IS_WORD ("view_video")) { - long long num = next_token_int (); - if (num == NOT_FOUND) { - printf ("Bad msg id\n"); - RET; - } - struct message *M = message_get (num); - if (M && !M->service && M->media.type == CODE_message_media_video) { - do_load_video (&M->media.video, 2); - } else if (M && !M->service && M->media.type == CODE_decrypted_message_media_video) { - do_load_encr_video (&M->media.encr_video, 2); - } else { - printf ("Bad msg id\n"); - RET; - } - } else if (IS_WORD ("chat_info")) { - GET_PEER_CHAT; - do_get_chat_info (id); - } else if (IS_WORD ("user_info")) { - GET_PEER_USER; - do_get_user_info (id); - } else if (IS_WORD ("history")) { - GET_PEER; - int limit = next_token_int (); - do_get_history (id, limit > 0 ? limit : 40); - } else if (IS_WORD ("chat_add_user")) { - GET_PEER_CHAT; - peer_id_t chat_id = id; - GET_PEER_USER; - do_add_user_to_chat (chat_id, id, 100); - } else if (IS_WORD ("chat_del_user")) { - GET_PEER_CHAT; - peer_id_t chat_id = id; - GET_PEER_USER; - do_del_user_from_chat (chat_id, id); - } else if (IS_WORD ("add_contact")) { - int phone_len, first_name_len, last_name_len; - char *phone, *first_name, *last_name; - phone = next_token (&phone_len); - if (!phone) { - printf ("No phone number found\n"); - RET; - } - first_name = next_token (&first_name_len); - if (!first_name_len) { - printf ("No first name found\n"); - RET; - } - last_name = next_token (&last_name_len); - if (!last_name_len) { - printf ("No last name found\n"); - RET; - } - do_add_contact (phone, phone_len, first_name, first_name_len, last_name, last_name_len, 0); - } else if (IS_WORD ("rename_contact")) { - GET_PEER_USER; - peer_t *U = user_chat_get (id); - if (!U) { - printf ("No such user\n"); - RET; - } - if (!U->user.phone || !strlen (U->user.phone)) { - printf ("User has no phone. Can not rename\n"); - RET; - } - int phone_len, first_name_len, last_name_len; - char *phone, *first_name, *last_name; - phone_len = strlen (U->user.phone); - phone = U->user.phone; - first_name = next_token (&first_name_len); - if (!first_name_len) { - printf ("No first name found\n"); - RET; - } - last_name = next_token (&last_name_len); - if (!last_name_len) { - printf ("No last name found\n"); - RET; - } - do_add_contact (phone, phone_len, first_name, first_name_len, last_name, last_name_len, 1); - } else if (IS_WORD ("help")) { - //print_start (); - push_color (COLOR_YELLOW); - printf ( - "help - prints this help\n" - "msg Text - sends message to this peer\n" - "contact_list - prints info about users in your contact list\n" - "stats - just for debugging \n" - "history [limit] - prints history (and marks it as read). Default limit = 40\n" - "dialog_list - prints info about your dialogs\n" - "send_photo - sends photo to peer\n" - "send_video - sends video to peer\n" - "send_text - sends text file as plain messages\n" - "chat_info - prints info about chat\n" - "user_info - prints info about user\n" - "fwd - forward message to user. You can see message numbers starting client with -N\n" - "rename_chat \n" - "load_photo/load_video/load_video_thumb - loads photo/video to download dir. You can see message numbers starting client with -N\n" - "view_photo/view_video/view_video_thumb - loads photo/video to download dir and starts system default viewer. You can see message numbers starting client with -N\n" - "show_license - prints contents of GPLv2\n" - "search pattern - searches pattern in messages with peer\n" - "global_search pattern - searches pattern in all messages\n" - "mark_read - mark read all received messages with peer\n" - "add_contact - tries to add contact to contact-list by phone\n" - "create_secret_chat - creates secret chat with this user\n" - "create_group_chat - creates group chat with this user, add more users with chat_add_user \n" - "rename_contact - tries to rename contact. If you have another device it will be a fight\n" - "suggested_contacts - print info about contacts, you have max common friends\n" - "visualize_key - prints visualization of encryption key. You should compare it to your partner's one\n" - "set . Possible values are:\n" - "\tdebug_verbosity - just as it sounds. Debug verbosity\n" - "\tlog_level - level of logging of new events. Lower is less verbose:\n" - "\t\tLevel 1: prints info about read messages\n" - "\t\tLevel 2: prints line, when somebody is typing in chat\n" - "\t\tLevel 3: prints line, when somebody changes online status\n" - "\tmsg_num - enables/disables numeration of messages\n" - "\talert - enables/disables alert sound notifications\n" - "chat_with_peer - starts chat with this peer. Every command after is message to this peer. Type /exit or /quit to end this mode\n" - ); - pop_color (); - } else if (IS_WORD ("show_license")) { - char *b = -#include "LICENSE.h" - ; - printf ("%s", b); - } else if (IS_WORD ("search")) { - GET_PEER; - int from = 0; - int to = 0; - int limit = 40; - int t; - char *s = next_token (&t); - if (!s) { - printf ("Empty message\n"); - RET; - } - do_msg_search (id, from, to, limit, s); - } else if (IS_WORD ("global_search")) { - int from = 0; - int to = 0; - int limit = 40; - int t; - char *s = next_token (&t); - if (!s) { - printf ("Empty message\n"); - RET; - } - do_msg_search (PEER_NOT_FOUND, from, to, limit, s); - } else if (IS_WORD ("mark_read")) { - GET_PEER; - do_mark_read (id); - } else if (IS_WORD ("visualize_key")) { - GET_PEER_ENCR_CHAT; - do_visualize_key (id); - } else if (IS_WORD ("create_secret_chat")) { - GET_PEER; - do_create_secret_chat (id); - } else if (IS_WORD ("create_group_chat")) { - GET_PEER; - int t; - char *s = next_token (&t); - if (!s) { - printf ("Empty chat topic\n"); - RET; - } - do_create_group_chat (id, s); - } else if (IS_WORD ("suggested_contacts")) { - do_get_suggested (); - } else if (IS_WORD ("status_online")) { - do_update_status (1); - } else if (IS_WORD ("status_offline")) { - do_update_status (0); - } else if (IS_WORD ("contacts_search")) { - int t; - char *s = next_token (&t); - if (!s) { - printf ("Empty search query\n"); - RET; - } - do_contacts_search (100, s); - } else if (IS_WORD("send_audio")) { - GET_PEER; - int t; - char *s = next_token (&t); - if (!s) { - printf ("Empty file name\n"); - RET; - } - do_send_photo (CODE_input_media_uploaded_audio, id, tstrndup (s, t)); - } else if (IS_WORD("send_document")) { - GET_PEER; - int t; - char *s = next_token (&t); - if (!s) { - printf ("Empty file name\n"); - RET; - } - do_send_photo (CODE_input_media_uploaded_document, id, tstrndup (s, t)); - } else if (IS_WORD ("load_audio")) { - long long num = next_token_int (); - if (num == NOT_FOUND) { - printf ("Bad msg id\n"); - RET; - } - struct message *M = message_get (num); - if (M && !M->service && M->media.type == CODE_message_media_audio) { - do_load_audio (&M->media.video, 1); - } else if (M && !M->service && M->media.type == CODE_decrypted_message_media_audio) { - do_load_encr_video (&M->media.encr_video, 1); - } else { - printf ("Bad msg id\n"); - RET; - } - } else if (IS_WORD ("view_audio")) { - long long num = next_token_int (); - if (num == NOT_FOUND) { - printf ("Bad msg id\n"); - RET; - } - struct message *M = message_get (num); - if (M && !M->service && M->media.type == CODE_message_media_audio) { - do_load_audio (&M->media.video, 2); - } else if (M && !M->service && M->media.type == CODE_decrypted_message_media_audio) { - do_load_encr_video (&M->media.encr_video, 2); - } else { - printf ("Bad msg id\n"); - RET; - } - } else if (IS_WORD ("load_document_thumb")) { - long long num = next_token_int (); - if (num == NOT_FOUND) { - printf ("Bad msg id\n"); - RET; - } - struct message *M = message_get (num); - if (M && !M->service && M->media.type == (int)CODE_message_media_document) { - do_load_document_thumb (&M->media.document, 1); - } else { - printf ("Bad msg id\n"); - RET; - } - } else if (IS_WORD ("view_document_thumb")) { - long long num = next_token_int (); - if (num == NOT_FOUND) { - printf ("Bad msg id\n"); - RET; - } - struct message *M = message_get (num); - if (M && !M->service && M->media.type == (int)CODE_message_media_document) { - do_load_document_thumb (&M->media.document, 2); - } else { - printf ("Bad msg id\n"); - RET; - } - } else if (IS_WORD ("load_document")) { - long long num = next_token_int (); - if (num == NOT_FOUND) { - printf ("Bad msg id\n"); - RET; - } - struct message *M = message_get (num); - if (M && !M->service && M->media.type == CODE_message_media_document) { - do_load_document (&M->media.document, 1); - } else if (M && !M->service && M->media.type == CODE_decrypted_message_media_document) { - do_load_encr_video (&M->media.encr_video, 1); - } else { - printf ("Bad msg id\n"); - RET; - } - } else if (IS_WORD ("view_document")) { - long long num = next_token_int (); - if (num == NOT_FOUND) { - printf ("Bad msg id\n"); - RET; - } - struct message *M = message_get (num); - if (M && !M->service && M->media.type == CODE_message_media_document) { - do_load_document (&M->media.document, 2); - } else if (M && !M->service && M->media.type == CODE_decrypted_message_media_document) { - do_load_encr_video (&M->media.encr_video, 2); - } else { - printf ("Bad msg id\n"); - RET; - } - } else if (IS_WORD ("set")) { - command = next_token (&l); - long long num = next_token_int (); - if (num == NOT_FOUND) { - printf ("Bad msg id\n"); - RET; - } - if (IS_WORD ("debug_verbosity")) { - verbosity = num; - } else if (IS_WORD ("log_level")) { - log_level = num; - } else if (IS_WORD ("msg_num")) { - msg_num_mode = num; - } else if (IS_WORD ("alert")) { - alert_sound = num; - } - } else if (IS_WORD ("chat_with_peer")) { - GET_PEER; - in_chat_mode = 1; - chat_mode_id = id; - } else if (IS_WORD ("delete_msg")) { - long long num = next_token_int (); - if (num == NOT_FOUND) { - printf ("Bad msg id\n"); - RET; - } - do_delete_msg (num); - } else if (IS_WORD ("restore_msg")) { - long long num = next_token_int (); - if (num == NOT_FOUND) { - printf ("Bad msg id\n"); - RET; - } - do_restore_msg (num); - } else if (IS_WORD ("delete_restore_msg")) { - long long num = next_token_int (); - if (num == NOT_FOUND) { - printf ("Bad msg id\n"); - RET; - } - do_delete_msg (num); - do_restore_msg (num); - } else if (IS_WORD ("quit")) { - exit (0); - } else if (IS_WORD ("safe_quit")) { - safe_quit = 1; - } - } -#undef IS_WORD -#undef RET - update_prompt (); - in_readline = 0; -} - -int readline_active; -void rprintf (const char *format, ...) { - print_start (); - va_list ap; - va_start (ap, format); - vfprintf (stdout, format, ap); - va_end (ap); - print_end(); -} - -int saved_point; -char *saved_line; -int prompt_was; -void print_start (void) { - if (in_readline) { return; } - assert (!prompt_was); - if (readline_active) { - saved_point = rl_point; -#ifdef READLINE_GNU - saved_line = talloc (rl_end + 1); - saved_line[rl_end] = 0; - memcpy (saved_line, rl_line_buffer, rl_end); - - rl_save_prompt(); - rl_replace_line("", 0); -#else - assert (rl_end >= 0); - saved_line = talloc (rl_end + 1); - memcpy (saved_line, rl_line_buffer, rl_end + 1); - rl_line_buffer[0] = 0; - set_prompt (""); -#endif - rl_redisplay(); - } - prompt_was = 1; -} - -void print_end (void) { - if (in_readline) { return; } - assert (prompt_was); - if (readline_active) { - set_prompt (get_default_prompt ()); -#if READLINE_GNU - rl_replace_line(saved_line, 0); -#else - memcpy (rl_line_buffer, saved_line, rl_end + 1); // not safe, but I hope this would work. -#endif - rl_point = saved_point; - rl_redisplay(); - tfree_str (saved_line); - } - prompt_was = 0; -} - - -/* -void logprintf (const char *format, ...) { - va_list ap; - va_start (ap, format); - log_message(format, ap); - va_end (ap); - //int x = 0; - //if (!prompt_was) { - // x = 1; - // print_start (); - //} - //printf (COLOR_GREY " *** "); - //printf (COLOR_NORMAL); - //if (x) { - // print_end (); - //} -} -*/ - -int color_stack_pos; -const char *color_stack[10]; - -void push_color (const char *color) { - assert (color_stack_pos < 10); - color_stack[color_stack_pos ++] = color; - printf ("%s", color); -} - -void pop_color (void) { - assert (color_stack_pos > 0); - color_stack_pos --; - if (color_stack_pos >= 1) { - printf ("%s", color_stack[color_stack_pos - 1]); - } else { - printf ("%s", COLOR_NORMAL); - } -} - -void print_media (struct message_media *M) { - assert (M); - switch (M->type) { - case CODE_message_media_empty: - case CODE_decrypted_message_media_empty: - return; - case CODE_message_media_photo: - if (M->photo.caption && strlen (M->photo.caption)) { - printf ("[photo %s]", M->photo.caption); - } else { - printf ("[photo]"); - } - return; - case CODE_message_media_video: - printf ("[video]"); - return; - case CODE_message_media_audio: - printf ("[audio]"); - return; - case CODE_message_media_document: - if (M->document.mime_type && M->document.caption) { - printf ("[document %s: type %s]", M->document.caption, M->document.mime_type); - } else { - printf ("[document]"); - } - return; - case CODE_decrypted_message_media_photo: - printf ("[photo]"); - return; - case CODE_decrypted_message_media_video: - printf ("[video]"); - return; - case CODE_decrypted_message_media_audio: - printf ("[audio]"); - return; - case CODE_decrypted_message_media_document: - printf ("[document]"); - return; - case CODE_message_media_geo: - printf ("[geo] https://maps.google.com/?q=%.6lf,%.6lf", M->geo.latitude, M->geo.longitude); - return; - case CODE_message_media_contact: - printf ("[contact] "); - push_color (COLOR_RED); - printf ("%s %s ", M->first_name, M->last_name); - pop_color (); - printf ("%s", M->phone); - return; - case CODE_message_media_unsupported: - printf ("[unsupported]"); - return; - default: - assert (0); - } -} - -int unknown_user_list_pos; -int unknown_user_list[1000]; - -void print_user_name (peer_id_t id, peer_t *U) { - assert (get_peer_type (id) == PEER_USER); - push_color (COLOR_RED); - if (!U) { - printf ("user#%d", get_peer_id (id)); - int i; - int ok = 1; - for (i = 0; i < unknown_user_list_pos; i++) { - if (unknown_user_list[i] == get_peer_id (id)) { - ok = 0; - break; - } - } - if (ok) { - assert (unknown_user_list_pos < 1000); - unknown_user_list[unknown_user_list_pos ++] = get_peer_id (id); - } - } else { - if (U->flags & (FLAG_USER_SELF | FLAG_USER_CONTACT)) { - push_color (COLOR_REDB); - } - if ((U->flags & FLAG_DELETED)) { - printf ("deleted user#%d", get_peer_id (id)); - } else if (!(U->flags & FLAG_CREATED)) { - printf ("empty user#%d", get_peer_id (id)); - } else if (!U->user.first_name || !strlen (U->user.first_name)) { - printf ("%s", U->user.last_name); - } else if (!U->user.last_name || !strlen (U->user.last_name)) { - printf ("%s", U->user.first_name); - } else { - printf ("%s %s", U->user.first_name, U->user.last_name); - } - if (U->flags & (FLAG_USER_SELF | FLAG_USER_CONTACT)) { - pop_color (); - } - } - pop_color (); -} - -void print_chat_name (peer_id_t id, peer_t *C) { - assert (get_peer_type (id) == PEER_CHAT); - push_color (COLOR_MAGENTA); - if (!C) { - printf ("chat#%d", get_peer_id (id)); - } else { - printf ("%s", C->chat.title); - } - pop_color (); -} - -void print_encr_chat_name (peer_id_t id, peer_t *C) { - assert (get_peer_type (id) == PEER_ENCR_CHAT); - push_color (COLOR_MAGENTA); - if (!C) { - printf ("encr_chat#%d", get_peer_id (id)); - } else { - printf ("%s", C->print_name); - } - pop_color (); -} - -void print_encr_chat_name_full (peer_id_t id, peer_t *C) { - assert (get_peer_type (id) == PEER_ENCR_CHAT); - push_color (COLOR_MAGENTA); - if (!C) { - printf ("encr_chat#%d", get_peer_id (id)); - } else { - printf ("%s", C->print_name); - } - pop_color (); -} - -static char *monthes[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; -void print_date (long t) { - struct tm *tm = localtime ((void *)&t); - if (time (0) - t < 12 * 60 * 60) { - printf ("[%02d:%02d] ", tm->tm_hour, tm->tm_min); - } else { - printf ("[%02d %s]", tm->tm_mday, monthes[tm->tm_mon]); - } -} - -void print_date_full (long t) { - struct tm *tm = localtime ((void *)&t); - printf ("[%04d/%02d/%02d %02d:%02d:%02d]", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); -} - -int our_id; - -void print_service_message (struct message *M) { - assert (M); - print_start (); - push_color (COLOR_GREY); - - push_color (COLOR_MAGENTA); - if (msg_num_mode) { - printf ("%lld ", M->id); - } - print_date (M->date); - pop_color (); - printf (" "); - if (get_peer_type (M->to_id) == PEER_CHAT) { - print_chat_name (M->to_id, user_chat_get (M->to_id)); - } else { - assert (get_peer_type (M->to_id) == PEER_ENCR_CHAT); - print_encr_chat_name (M->to_id, user_chat_get (M->to_id)); - } - printf (" "); - print_user_name (M->from_id, user_chat_get (M->from_id)); - - switch (M->action.type) { - case CODE_message_action_empty: - printf ("\n"); - break; - case CODE_message_action_geo_chat_create: - printf ("Created geo chat\n"); - break; - case CODE_message_action_geo_chat_checkin: - printf ("Checkin in geochat\n"); - break; - case CODE_message_action_chat_create: - printf (" created chat %s. %d users\n", M->action.title, M->action.user_num); - break; - case CODE_message_action_chat_edit_title: - printf (" changed title to %s\n", - M->action.new_title); - break; - case CODE_message_action_chat_edit_photo: - printf (" changed photo\n"); - break; - case CODE_message_action_chat_delete_photo: - printf (" deleted photo\n"); - break; - case CODE_message_action_chat_add_user: - printf (" added user "); - print_user_name (set_peer_id (PEER_USER, M->action.user), user_chat_get (set_peer_id (PEER_USER, M->action.user))); - printf ("\n"); - break; - case CODE_message_action_chat_delete_user: - printf (" deleted user "); - print_user_name (set_peer_id (PEER_USER, M->action.user), user_chat_get (set_peer_id (PEER_USER, M->action.user))); - printf ("\n"); - break; - case CODE_decrypted_message_action_set_message_t_t_l: - printf (" set ttl to %d seconds. Unsupported yet\n", M->action.ttl); - break; - default: - assert (0); - } - pop_color (); - print_end (); -} - -peer_id_t last_from_id; -peer_id_t last_to_id; - -void print_message (struct message *M) { - assert (M); - if (M->flags & (FLAG_MESSAGE_EMPTY | FLAG_DELETED)) { - return; - } - if (!(M->flags & FLAG_CREATED)) { return; } - if (M->service) { - print_service_message (M); - return; - } - if (!get_peer_type (M->to_id)) { - logprintf ("Bad msg\n"); - return; - } - - last_from_id = M->from_id; - last_to_id = M->to_id; - - print_start (); - if (get_peer_type (M->to_id) == PEER_USER) { - if (M->out) { - push_color (COLOR_GREEN); - if (msg_num_mode) { - logprintf ("%lld ", M->id); - } - print_date (M->date); - pop_color (); - logprintf (" "); - print_user_name (M->to_id, user_chat_get (M->to_id)); - push_color (COLOR_GREEN); - if (M->unread) { - logprintf (" <<< "); - } else { - logprintf (" ««« "); - } - } else { - push_color (COLOR_BLUE); - if (msg_num_mode) { - logprintf ("%lld ", M->id); - } - print_date (M->date); - pop_color (); - logprintf (" "); - print_user_name (M->from_id, user_chat_get (M->from_id)); - push_color (COLOR_BLUE); - if (M->unread) { - logprintf (" >>> "); - } else { - logprintf (" »»» "); - } - if (alert_sound) { - play_sound(); - } - } - } else if (get_peer_type (M->to_id) == PEER_ENCR_CHAT) { - peer_t *P = user_chat_get (M->to_id); - assert (P); - if (M->out) { - push_color (COLOR_GREEN); - if (msg_num_mode) { - logprintf ("%lld ", M->id); - } - print_date (M->date); - logprintf (" "); - push_color (COLOR_CYAN); - logprintf (" %s", P->print_name); - pop_color (); - if (M->unread) { - logprintf (" <<< "); - } else { - logprintf (" ««« "); - } - } else { - push_color (COLOR_BLUE); - if (msg_num_mode) { - logprintf ("%lld ", M->id); - } - print_date (M->date); - push_color (COLOR_CYAN); - logprintf (" %s", P->print_name); - pop_color (); - if (M->unread) { - logprintf (" >>> "); - } else { - logprintf (" »»» "); - } - if (alert_sound) { - play_sound(); - } - } - } else { - assert (get_peer_type (M->to_id) == PEER_CHAT); - push_color (COLOR_MAGENTA); - if (msg_num_mode) { - logprintf ("%lld ", M->id); - } - print_date (M->date); - pop_color (); - logprintf (" "); - print_chat_name (M->to_id, user_chat_get (M->to_id)); - logprintf (" "); - print_user_name (M->from_id, user_chat_get (M->from_id)); - if ((get_peer_type (M->from_id) == PEER_USER) && (get_peer_id (M->from_id) == our_id)) { - push_color (COLOR_GREEN); - } else { - push_color (COLOR_BLUE); - } - if (M->unread) { - logprintf (" >>> "); - } else { - logprintf (" »»» "); - } - } - if (get_peer_type (M->fwd_from_id) == PEER_USER) { - logprintf ("[fwd from "); - print_user_name (M->fwd_from_id, user_chat_get (M->fwd_from_id)); - logprintf ("] "); - } - if (M->message && strlen (M->message)) { - logprintf ("%s", M->message); - } - if (M->media.type != CODE_message_media_empty) { - print_media (&M->media); - } - pop_color (); - assert (!color_stack_pos); - logprintf ("\n"); - print_end(); -} - -void play_sound (void) { - printf ("\a"); -} - -void set_interface_callbacks (void) { - readline_active = 1; - rl_callback_handler_install (get_default_prompt (), interpreter); - rl_attempted_completion_function = (void *) complete_text; - rl_completion_entry_function = (void *)complete_none; -} diff --git a/interface.h b/interface.h deleted file mode 100644 index 99f0319..0000000 --- a/interface.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - This file is part of telegram-client. - - Telegram-client 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. - - Telegram-client 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 telegram-client. If not, see . - - Copyright Vitaly Valtman 2013 -*/ -#ifndef __INTERFACE_H__ -#define __INTERFACE_H__ -#include "structures.h" - -#define COLOR_RED "\033[0;31m" -#define COLOR_REDB "\033[1;31m" -#define COLOR_NORMAL "\033[0m" -#define COLOR_GREEN "\033[32;1m" -#define COLOR_GREY "\033[37;1m" -#define COLOR_YELLOW "\033[33;1m" -#define COLOR_BLUE "\033[34;1m" -#define COLOR_MAGENTA "\033[35;1m" -#define COLOR_CYAN "\033[36;1m" -#define COLOR_LCYAN "\033[0;36m" - -#define COLOR_INVERSE "\033[7m" - -char *get_default_prompt (void); -char *complete_none (const char *text, int state); -char **complete_text (char *text, int start, int end); -void interpreter (char *line); - -void rprintf (const char *format, ...) __attribute__ ((format (printf, 1, 2))); -void logprintf (const char *format, ...) __attribute__ ((format (printf, 1, 2))); -void hexdump (int *in_ptr, int *in_end); - -struct message; -union peer; -void print_message (struct message *M); -void print_chat_name (peer_id_t id, union peer *C); -void print_user_name (peer_id_t id, union peer *U); -void print_encr_chat_name_full (peer_id_t id, peer_t *C); -void print_encr_chat_name (peer_id_t id, peer_t *C); -//void print_media (struct message_media *M); -void pop_color (void); -void push_color (const char *color); -void print_start (void); -void print_end (void); -void print_date_full (long t); -void print_date (long t); - -void play_sound (void); -void update_prompt (void); -void set_interface_callbacks (void); -#endif diff --git a/loop.c b/loop.c index 9dfe044..c2a72bf 100644 --- a/loop.c +++ b/loop.c @@ -17,10 +17,6 @@ Copyright Vitaly Valtman 2013 */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #define _GNU_SOURCE #define READLINE_CALLBACKS @@ -28,13 +24,8 @@ #include #include #include -#ifdef READLINE_GNU #include #include -#else -#include -#include -#endif #include #include @@ -49,7 +40,6 @@ #include "telegram.h" #include "loop.h" #include "binlog.h" -#include "lua-tg.h" // @@ -70,65 +60,6 @@ extern int safe_quit; int unread_messages; void got_it (char *line, int len); -/* -void net_loop (int flags, int (*is_end)(void)) { - logprintf("starting net_loop()\n"); - while (!is_end ()) { - struct pollfd fds[101]; - int cc = 0; - if (flags & 3) { - fds[0].fd = 0; - fds[0].events = POLLIN; - cc ++; - } - - logprintf("writing_state_file()\n"); - write_state_file (); - // Ensure that all connections are active? - int x = connections_make_poll_array (fds + cc, 101 - cc) + cc; - double timer = next_timer_in (); - - // Wait until file descriptors are ready - if (timer > 1000) { timer = 1000; } - if (poll (fds, x, timer) < 0) { - logprintf("poll returned -1, wait a little bit.\n"); - work_timers (); - continue; - } - - // Execute all timers that are currently due - work_timers (); - - // ? - if ((flags & 3) && (fds[0].revents & POLLIN)) { - unread_messages = 0; - if (flags & 1) { - rl_callback_read_char (); - } else { - char *line = 0; - size_t len = 0; - assert (getline (&line, &len, stdin) >= 0); - got_it (line, strlen (line)); - } - } - - // - connections_poll_result (fds + cc, x - cc); - #ifdef USE_LUA - lua_do_all (); - #endif - if (safe_quit && !queries_num) { - logprintf ("All done. Exit\n"); - rl_callback_handler_remove (); - exit (0); - } - if (unknown_user_list_pos) { - do_get_user_list_info_silent (unknown_user_list_pos, unknown_user_list); - unknown_user_list_pos = 0; - } - } -} -*/ char **_s; size_t *_l; @@ -146,33 +77,8 @@ int is_got_it (void) { return got_it_ok; } -/* -int net_getline (char **s, size_t *l) { - fflush (stdout); -// rl_already_prompted = 1; - got_it_ok = 0; - _s = s; - _l = l; -// rl_callback_handler_install (0, got_it); - //net_loop (2, is_got_it); - return 0; -} -*/ - int ret1 (void) { return 0; } -/* -int main_loop (void) { - net_loop (1, ret1); - return 0; -} -*/ - - -//struct dc *DC_list[MAX_DC_ID + 1]; -//struct dc *DC_working; -//int dc_working_num; -//int auth_state; char *get_auth_key_filename (void); char *get_state_filename (void); int zero[512]; @@ -513,217 +419,3 @@ int readline_active; int new_dc_num; int wait_dialog_list; - -/** - * Discover the network and authorise with all data centers -void network_connect (struct telegram *instance) { - verbosity = 0; - on_start (); - // will return empty default values on empty files - instance->auth = read_auth_file ("/home/dev-jessie/.telegram/auth_file"); - instance->proto = read_state_file ("/home/dev-jessie/.telegram/auth_file"); - - struct dc *DC_list = (struct dc*)instance->auth.DC_list; - struct dc *DC_working = NULL; - - assert (DC_list[dc_working_num]); - if (!DC_working || !DC_working->auth_key_id) { -// if (auth_state == 0) { - logprintf("No working DC or not start_loopd.\n"); - DC_working = &DC_list[instance->auth.dc_working_num]; - assert (!DC_working->auth_key_id); - dc_authorize (DC_working); - assert (DC_working->auth_key_id); - auth_state = 100; - write_auth_file (instance->auth); - logprintf("Authorized DataCentre: auth_key_id: %lld \n", DC_working->auth_key_id); - } else { - } - - if (verbosity) { - logprintf ("Requesting info about DC...\n"); - } - do_help_get_config (); - logprintf("net_loop\n"); - net_loop (0, mcs); - logprintf("net_loop done...\n"); - if (verbosity) { - logprintf ("DC_info: %d new DC got\n", new_dc_num); - } - // read saved connection state - //read_state_file (); - read_secret_chat_file (); -} - */ - -/** - * Return if the given phone is registered - */ - /* -int network_phone_is_registered() { - int res = do_auth_check_phone (default_username); - assert(res >= 0); - return res; -} -*/ - - -/** - * Verify the phone number by providing the sms_code and the real name - * - * NOTE: This should be called when the phone number was previously - * unknown to the telegram network. - */ - /* -int network_verify_phone_registration(const char* code, const char *sms_hash, - const char *first ,const char *last) -{ - logprintf("Registering with code:%s, hash:%s, first:%s, last:%s\n", code, sms_hash, - first, last); - return 0; -} -*/ - -/** - * Export current authentication state to all known data centers. - */ -//void network_export_registration() -//{ -// int i; -// for (i = 0; i <= MAX_DC_NUM; i++) if (DC_list[i] && !DC_list[i]->has_auth) { -// do_export_auth (i); -// do_import_auth (i); -// bl_do_dc_signed (i); -// write_auth_file (); -// } -// write_auth_file (); -// fflush (stdout); -// fflush (stderr); -//} - -//int start_loop (char* code, char* auth_mode) { -// logprintf("Calling start_loop()\n"); -// logprintf("auth_state %i\n", auth_state); -// if (auth_state == 100 || !(DC_working->has_auth)) { -// logprintf("auth_state == 100 || !(DC_working->has_auth)"); -// int res = do_auth_check_phone (default_username); -// assert (res >= 0); -// logprintf ("%s\n", res > 0 ? "phone registered" : "phone not registered"); -// if (res > 0 && !register_mode) { -// // Register Mode 1 -// logprintf ("Register Mode 1\n"); -// if (code) { -// /* -// if (do_send_code_result (code) >= 0) { -// logprintf ("Authentication successfull, state = 300\n"); -// auth_state = 300; -// } -// */ -// } else { -// logprintf("No code given, attempting to register\n"); -// // Send Code -// logprintf ("auth mode %s\n", auth_mode); -// /* -// if (strcmp(TELEGRAM_AUTH_MODE_SMS"sms", auth_mode)) { -// */ -// do_send_code (default_username); -// logprintf ("Code from sms (if you did not receive an SMS and want to be called, type \"call\"): "); -// logprintf("storing current state in auth file...\n"); -// write_auth_file (); -// logprintf("exitting...\n"); -// return 0; -// /* -// } else { -// logprintf ("You typed \"call\", switching to phone system.\n"); -// do_phone_call (default_username); -// logprintf ("Calling you!"); -// } -// */ -// } -// } else { -// logprintf ("User is not registered. Do you want to register? [Y/n] "); -// logprintf ("ERROR THIS IS NOT POSSIBLE!\n"); -// return 1; -// // Register Mode 2 -// // TODO: Requires first and last name, decide how to handle this. -// // - We need some sort of switch between registration modes -// // - When this mode is selected First and Last name should be added to the form -// // Currently Requires Manuel Entry in Terminal. -// size_t size; -// char *first_name; -// logprintf ("First name: "); -// if (net_getline (&first_name, &size) == -1) { -// perror ("getline()"); -// exit (EXIT_FAILURE); -// } -// char *last_name; -// logprintf ("Last name: "); -// if (net_getline (&last_name, &size) == -1) { -// perror ("getline()"); -// exit (EXIT_FAILURE); -// } -// -// int dc_num = do_get_nearest_dc (); -// assert (dc_num >= 0 && dc_num <= MAX_DC_NUM && DC_list[dc_num]); -// dc_working_num = dc_num; -// DC_working = DC_list[dc_working_num]; -// -// if (*code) { -// if (do_send_code_result_auth (code, "-", first_name, last_name) >= 0) { -// auth_state = 300; -// } -// } else { -// if (strcmp(TELEGRAM_AUTH_MODE_SMS, auth_mode)) { -// do_send_code (default_username); -// logprintf ("Code from sms (if you did not receive an SMS and want to be called, type \"call\"): "); -// } else { -// logprintf ("You typed \"call\", switching to phone system.\n"); -// do_phone_call (default_username); -// logprintf ("Calling you! Code: "); -// } -// } -// } -// } -// logprintf("Authentication done\n"); -// -// int i; -// for (i = 0; i <= MAX_DC_NUM; i++) if (DC_list[i] && !DC_list[i]->has_auth) { -// do_export_auth (i); -// do_import_auth (i); -// bl_do_dc_signed (i); -// write_auth_file (); -// } -// write_auth_file (); -// -// fflush (stdout); -// fflush (stderr); -// -// // read saved connection state -// read_state_file (); -// read_secret_chat_file (); -// -// // callbacks for interface functions -// set_interface_callbacks (); -// -// do_get_difference (); -// net_loop (0, dgot); -// #ifdef USE_LUA -// lua_diff_end (); -// #endif -// send_all_unsent (); -// -// do_get_dialog_list (); -// if (wait_dialog_list) { -// dialog_list_got = 0; -// net_loop (0, dlgot); -// } -// -// return 0; //main_loop (); -//} - -/* -int loop (void) { - network_connect(); - return start_loop(NULL, NULL); -} -*/ diff --git a/lua-tg.c b/lua-tg.c deleted file mode 100644 index 6ff996b..0000000 --- a/lua-tg.c +++ /dev/null @@ -1,550 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef USE_LUA -/* -#include "lua-tg.h" - -#include "include.h" -#include -#include - - -#include -#include -#include -lua_State *luaState; - -#include "structures.h" -#include "constants.h" -#include "tools.h" -#include "queries.h" -#include "net.h" - -extern int verbosity; - -static int have_file; - -#define my_lua_checkstack(L,x) assert (lua_checkstack (L, x)) -void push_user (peer_t *P UU); -void push_peer (peer_id_t id, peer_t *P); - -void lua_add_string_field (const char *name, const char *value) { - assert (name && strlen (name)); - if (!value || !strlen (value)) { return; } - my_lua_checkstack (luaState, 3); - lua_pushstring (luaState, name); - lua_pushstring (luaState, value); - lua_settable (luaState, -3); -} - -void lua_add_num_field (const char *name, double value) { - assert (name && strlen (name)); - my_lua_checkstack (luaState, 3); - lua_pushstring (luaState, name); - lua_pushnumber (luaState, value); - lua_settable (luaState, -3); -} - -void push_peer_type (int x) { - switch (x) { - case PEER_USER: - lua_pushstring (luaState, "user"); - break; - case PEER_CHAT: - lua_pushstring (luaState, "chat"); - break; - case PEER_ENCR_CHAT: - lua_pushstring (luaState, "encr_chat"); - break; - default: - assert (0); - } -} - -void push_user (peer_t *P UU) { - my_lua_checkstack (luaState, 4); - lua_add_string_field ("first_name", P->user.first_name); - lua_add_string_field ("last_name", P->user.last_name); - lua_add_string_field ("real_first_name", P->user.real_first_name); - lua_add_string_field ("real_last_name", P->user.real_last_name); - lua_add_string_field ("phone", P->user.phone); -} - -void push_chat (peer_t *P) { - my_lua_checkstack (luaState, 4); - assert (P->chat.title); - lua_add_string_field ("title", P->chat.title); - lua_add_num_field ("members_num", P->chat.users_num); -} - -void push_encr_chat (peer_t *P) { - my_lua_checkstack (luaState, 4); - lua_pushstring (luaState, "user"); - push_peer (MK_USER (P->encr_chat.user_id), user_chat_get (MK_USER (P->encr_chat.user_id))); - lua_settable (luaState, -3); -} - -void push_peer (peer_id_t id, peer_t *P) { - lua_newtable (luaState); - - lua_add_num_field ("id", get_peer_id (id)); - lua_pushstring (luaState, "type"); - push_peer_type (get_peer_type (id)); - lua_settable (luaState, -3); - - - if (!P || !(P->flags & FLAG_CREATED)) { - lua_pushstring (luaState, "print_name"); - static char s[100]; - switch (get_peer_type (id)) { - case PEER_USER: - sprintf (s, "user#%d", get_peer_id (id)); - break; - case PEER_CHAT: - sprintf (s, "chat#%d", get_peer_id (id)); - break; - case PEER_ENCR_CHAT: - sprintf (s, "encr_chat#%d", get_peer_id (id)); - break; - default: - assert (0); - } - lua_pushstring (luaState, s); - lua_settable (luaState, -3); // flags - - return; - } - - lua_add_string_field ("print_name", P->print_name); - lua_add_num_field ("flags", P->flags); - - switch (get_peer_type (id)) { - case PEER_USER: - push_user (P); - break; - case PEER_CHAT: - push_chat (P); - break; - case PEER_ENCR_CHAT: - push_encr_chat (P); - break; - default: - assert (0); - } -} - -void push_media (struct message_media *M) { - my_lua_checkstack (luaState, 4); - - switch (M->type) { - case CODE_message_media_photo: - case CODE_decrypted_message_media_photo: - lua_pushstring (luaState, "photo"); - break; - case CODE_message_media_video: - case CODE_decrypted_message_media_video: - lua_pushstring (luaState, "video"); - break; - case CODE_message_media_audio: - case CODE_decrypted_message_media_audio: - lua_pushstring (luaState, "audio"); - break; - case CODE_message_media_document: - case CODE_decrypted_message_media_document: - lua_pushstring (luaState, "document"); - break; - case CODE_message_media_unsupported: - lua_pushstring (luaState, "unsupported"); - break; - case CODE_message_media_geo: - lua_newtable (luaState); - lua_add_num_field ("longitude", M->geo.longitude); - lua_add_num_field ("latitude", M->geo.latitude); - break; - case CODE_message_media_contact: - case CODE_decrypted_message_media_contact: - lua_newtable (luaState); - lua_add_string_field ("phone", M->phone); - lua_add_string_field ("first_name", M->first_name); - lua_add_string_field ("last_name", M->last_name); - lua_add_num_field ("user_id", M->user_id); - break; - default: - lua_pushstring (luaState, "???"); - } -} - -void push_message (struct message *M) { - assert (M); - my_lua_checkstack (luaState, 10); - lua_newtable (luaState); - - static char s[30]; - tsnprintf (s, 30, "%lld", M->id); - lua_add_string_field ("id", s); - lua_add_num_field ("flags", M->flags); - - if (get_peer_type (M->fwd_from_id)) { - lua_pushstring (luaState, "fwd_from"); - push_peer (M->fwd_from_id, user_chat_get (M->fwd_from_id)); - lua_settable (luaState, -3); // fwd_from - - lua_add_num_field ("fwd_date", M->fwd_date); - } - - lua_pushstring (luaState, "from"); - push_peer (M->from_id, user_chat_get (M->from_id)); - lua_settable (luaState, -3); - - lua_pushstring (luaState, "to"); - push_peer (M->to_id, user_chat_get (M->to_id)); - lua_settable (luaState, -3); - - lua_pushstring (luaState, "out"); - lua_pushboolean (luaState, M->out); - lua_settable (luaState, -3); - - lua_pushstring (luaState, "unread"); - lua_pushboolean (luaState, M->unread); - lua_settable (luaState, -3); - - lua_pushstring (luaState, "date"); - lua_pushnumber (luaState, M->date); - lua_settable (luaState, -3); - - lua_pushstring (luaState, "service"); - lua_pushboolean (luaState, M->service); - lua_settable (luaState, -3); - - if (!M->service) { - if (M->message_len && M->message) { - lua_pushstring (luaState, "text"); - lua_pushlstring (luaState, M->message, M->message_len); - lua_settable (luaState, -3); - } - if (M->media.type && M->media.type != CODE_message_media_empty && M->media.type != CODE_decrypted_message_media_empty) { - lua_pushstring (luaState, "media"); - push_media (&M->media); - lua_settable (luaState, -3); - } - } -} - -void lua_binlog_end (void) { - if (!have_file) { return; } - lua_settop (luaState, 0); - //lua_checkstack (luaState, 20); - my_lua_checkstack (luaState, 20); - lua_getglobal (luaState, "on_binlog_replay_end"); - assert (lua_gettop (luaState) == 1); - - int r = lua_pcall (luaState, 0, 0, 0); - if (r) { - logprintf ("lua: %s\n", lua_tostring (luaState, -1)); - } -} - -void lua_diff_end (void) { - if (!have_file) { return; } - lua_settop (luaState, 0); - //lua_checkstack (luaState, 20); - my_lua_checkstack (luaState, 20); - lua_getglobal (luaState, "on_get_difference_end"); - assert (lua_gettop (luaState) == 1); - - int r = lua_pcall (luaState, 0, 0, 0); - if (r) { - logprintf ("lua: %s\n", lua_tostring (luaState, -1)); - } -} - -void lua_our_id (int id) { - if (!have_file) { return; } - lua_settop (luaState, 0); - //lua_checkstack (luaState, 20); - my_lua_checkstack (luaState, 20); - lua_getglobal (luaState, "on_our_id"); - lua_pushnumber (luaState, id); - assert (lua_gettop (luaState) == 2); - - int r = lua_pcall (luaState, 1, 0, 0); - if (r) { - logprintf ("lua: %s\n", lua_tostring (luaState, -1)); - } -} - -void lua_new_msg (struct message *M UU) { - if (!have_file) { return; } - lua_settop (luaState, 0); - //lua_checkstack (luaState, 20); - my_lua_checkstack (luaState, 20); - lua_getglobal (luaState, "on_msg_receive"); - push_message (M); - assert (lua_gettop (luaState) == 2); - - int r = lua_pcall (luaState, 1, 0, 0); - if (r) { - logprintf ("lua: %s\n", lua_tostring (luaState, -1)); - } -} - -void lua_secret_chat_created (struct secret_chat *C) { - if (!have_file) { return; } - lua_settop (luaState, 0); - //lua_checkstack (luaState, 20); - my_lua_checkstack (luaState, 20); - lua_getglobal (luaState, "on_secret_chat_created"); - push_peer (C->id, (void *)C); - assert (lua_gettop (luaState) == 2); - - int r = lua_pcall (luaState, 1, 0, 0); - if (r) { - logprintf ("lua: %s\n", lua_tostring (luaState, -1)); - } -} - -void lua_user_update (struct user *U) { - if (!have_file) { return; } - lua_settop (luaState, 0); - //lua_checkstack (luaState, 20); - my_lua_checkstack (luaState, 20); - lua_getglobal (luaState, "on_user_update"); - push_peer (U->id, (void *)U); - assert (lua_gettop (luaState) == 2); - - int r = lua_pcall (luaState, 1, 0, 0); - if (r) { - logprintf ("lua: %s\n", lua_tostring (luaState, -1)); - } -} - -void lua_chat_update (struct chat *C) { - if (!have_file) { return; } - lua_settop (luaState, 0); - //lua_checkstack (luaState, 20); - my_lua_checkstack (luaState, 20); - lua_getglobal (luaState, "on_chat_update"); - push_peer (C->id, (void *)C); - assert (lua_gettop (luaState) == 2); - - int r = lua_pcall (luaState, 1, 0, 0); - if (r) { - logprintf ("lua: %s\n", lua_tostring (luaState, -1)); - } -} - -extern peer_t *Peers[]; -extern int peer_num; - -#define MAX_LUA_COMMANDS 1000 -void *lua_ptr[MAX_LUA_COMMANDS]; -static int pos; - -static peer_t *get_peer (const char *s) { - int index = 0; - while (index < peer_num && (!Peers[index]->print_name || strcmp (Peers[index]->print_name, s))) { - index ++; - } - return index == peer_num ? 0 : Peers[index]; -} - -void lua_do_all (void) { - int p = 0; - while (p < pos) { - int l = (long)lua_ptr[p ++]; - assert (p + l + 1 <= pos); - int f = (long)lua_ptr[p ++]; - switch (f) { - case 0: - do_send_message (((peer_t *)lua_ptr[p])->id, lua_ptr[p + 1], strlen (lua_ptr[p + 1])); - tfree_str (lua_ptr[p + 1]); - p += 2; - break; - case 1: - do_forward_message (((peer_t *)lua_ptr[p])->id, (long)lua_ptr[p + 1]); - p += 2; - break; - case 2: - #ifdef DEBUG - texists (lua_ptr[p], sizeof (peer_t)); - #endif - do_mark_read (((peer_t *)lua_ptr[p])->id); - p += 1; - break; - default: - assert (0); - } - } - pos = 0; -} - - -static int send_msg_from_lua (lua_State *L) { - if (MAX_LUA_COMMANDS - pos < 4) { - lua_pushboolean (L, 0); - return 1; - } - int n = lua_gettop (L); - if (n != 2) { - lua_pushboolean (L, 0); - return 1; - } - const char *s = lua_tostring (L, -2); - if (!s) { - lua_pushboolean (L, 0); - return 1; - } - const char *msg = lua_tostring (L, -1); - - peer_t *P = get_peer (s); - if (!P) { - lua_pushboolean (L, 0); - return 1; - } - - lua_ptr[pos ++] = (void *)2l; - lua_ptr[pos ++] = (void *)0l; - lua_ptr[pos ++] = P; - lua_ptr[pos ++] = tstrdup (msg); - logprintf ("msg = %s\n", msg); - - lua_pushboolean (L, 1); - return 1; -} - -static int fwd_msg_from_lua (lua_State *L) { - if (MAX_LUA_COMMANDS - pos < 4) { - lua_pushboolean (L, 0); - return 1; - } - int n = lua_gettop (L); - if (n != 2) { - lua_pushboolean (L, 0); - return 1; - } - const char *s = lua_tostring (L, -2); - long long num = atoll (lua_tostring (L, -1)); - if (!s) { - lua_pushboolean (L, 0); - return 1; - } - peer_t *P = get_peer (s); - if (!P) { - lua_pushboolean (L, 0); - return 1; - } - - lua_ptr[pos ++] = (void *)2l; - lua_ptr[pos ++] = (void *)1l; - lua_ptr[pos ++] = P; - lua_ptr[pos ++] = (void *)(long)num; - lua_pushboolean (L, 1); - return 1; -} - -static int mark_read_from_lua (lua_State *L) { - if (MAX_LUA_COMMANDS - pos < 4) { - lua_pushboolean (L, 0); - return 1; - } - int n = lua_gettop (L); - if (n != 1) { - lua_pushboolean (L, 0); - return 1; - } - const char *s = lua_tostring (L, -1); - if (!s) { - lua_pushboolean (L, 0); - return 1; - } - peer_t *P = get_peer (s); - if (!P) { - lua_pushboolean (L, 0); - return 1; - } - - lua_ptr[pos ++] = (void *)1l; - lua_ptr[pos ++] = (void *)2l; - lua_ptr[pos ++] = P; - lua_pushboolean (L, 1); - return 1; -} - -int lua_postpone_alarm (void *self) { - int *t = self; - - lua_settop (luaState, 0); - //lua_checkstack (luaState, 20); - my_lua_checkstack (luaState, 20); - - lua_rawgeti (luaState, LUA_REGISTRYINDEX, t[1]); - lua_rawgeti (luaState, LUA_REGISTRYINDEX, t[0]); - assert (lua_gettop (luaState) == 2); - - int r = lua_pcall (luaState, 1, 0, 0); - - luaL_unref (luaState, LUA_REGISTRYINDEX, t[0]); - luaL_unref (luaState, LUA_REGISTRYINDEX, t[1]); - - if (r) { - logprintf ("lua: %s\n", lua_tostring (luaState, -1)); - } - tfree (*(void **)(t + 2), sizeof (struct event_timer)); - tfree (t, 16); - return 0; -} - -static int postpone_from_lua (lua_State *L) { - int n = lua_gettop (L); - if (n != 3) { - lua_pushboolean (L, 0); - return 1; - } - - double timeout = lua_tonumber (L, -1); - if (timeout < 0) { - lua_pushboolean (L, 0); - return 1; - } - - lua_pop (L, 1); - int a1 = luaL_ref (L, LUA_REGISTRYINDEX); - int a2 = luaL_ref (L, LUA_REGISTRYINDEX); - - struct event_timer *ev = talloc (sizeof (*ev)); - int *t = talloc (16); - t[0] = a1; - t[1] = a2; - *(void **)(t + 2) = ev; - - ev->timeout = get_double_time () + timeout; - ev->alarm = (void *)lua_postpone_alarm; - ev->self = t; - insert_event_timer (ev); - - lua_pushboolean (L, 1); - return 1; -} - -void lua_init (const char *file) { - if (!file) { return; } - have_file = 1; - luaState = luaL_newstate (); - luaL_openlibs (luaState); - - lua_register (luaState, "send_msg", send_msg_from_lua); - lua_register (luaState, "fwd_msg", fwd_msg_from_lua); - lua_register (luaState, "mark_read", mark_read_from_lua); - lua_register (luaState, "postpone", postpone_from_lua); - - int ret = luaL_dofile (luaState, file); - if (ret) { - logprintf ("lua: %s\n", lua_tostring (luaState, -1)); - exit (1); - } -} -*/ - -#endif diff --git a/lua-tg.h b/lua-tg.h deleted file mode 100644 index 6ea8faa..0000000 --- a/lua-tg.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __LUA_TG_H__ -#define __LUA_TG_H__ - -#include -#include "structures.h" - -/* -void lua_init (const char *file); -void lua_new_msg (struct message *M); -void lua_our_id (int id); -void lua_secret_chat_created (struct secret_chat *U); -void lua_user_update (struct user *U); -void lua_chat_update (struct chat *C); -void lua_binlog_end (void); -void lua_diff_end (void); -void lua_do_all (void); -*/ -#endif diff --git a/main.c b/main.c deleted file mode 100644 index 0894f86..0000000 --- a/main.c +++ /dev/null @@ -1,493 +0,0 @@ -/* - This file is part of telegram-client. - - Telegram-client 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. - - Telegram-client 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 telegram-client. If not, see . - - Copyright Vitaly Valtman 2013 -*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#if (READLINE == GNU) -#include -#else -#include -#endif - -#include -#include -#include - -#ifdef HAVE_EXECINFO_H -#include -#endif -#include -#ifdef HAVE_LIBCONFIG -#include -#endif - -#include "telegram.h" -#include "loop.h" -#include "mtproto-client.h" -#include "tools.h" - -#ifdef USE_LUA -# include "lua-tg.h" -#endif - -// TODO: Delete this shit -#include -#define BREAK raise(SIGINT); - -#define PROGNAME "telegram-client" -#define VERSION "0.01" - -#define CONFIG_DIRECTORY "." PROG_NAME -#define CONFIG_FILE "config" -#define AUTH_KEY_FILE "auth" -#define STATE_FILE "state" -#define SECRET_CHAT_FILE "secret" -#define DOWNLOADS_DIRECTORY "downloads" -#define BINLOG_FILE "binlog" - -#define CONFIG_DIRECTORY_MODE 0700 - -#define DEFAULT_CONFIG_CONTENTS \ - "# This is an empty config file\n" \ - "# Feel free to put something here\n" - -char *default_username; -char *auth_token; -int msg_num_mode; -char *config_filename; -char *prefix; -int test_dc; -char *auth_file_name; -char *state_file_name; -char *secret_chat_file_name; -char *downloads_directory; -char *config_directory; -char *binlog_file_name; -extern int binlog_enabled; -extern int log_level; -int log_level = 1; -int sync_from_start; -int allow_weak_random; - -void set_default_username (const char *s) { - if (default_username) { - tfree_str (default_username); - } - default_username = tstrdup (s); -} - - -/* {{{ TERMINAL */ -static struct termios term_in, term_out; -static int term_set_in; -static int term_set_out; - -void get_terminal_attributes (void) { - if (tcgetattr (STDIN_FILENO, &term_in) < 0) { - } else { - term_set_in = 1; - } - if (tcgetattr (STDOUT_FILENO, &term_out) < 0) { - } else { - term_set_out = 1; - } -} - -void set_terminal_attributes (void) { - if (term_set_in) { - if (tcsetattr (STDIN_FILENO, 0, &term_in) < 0) { - perror ("tcsetattr()"); - } - } - if (term_set_out) { - if (tcsetattr (STDOUT_FILENO, 0, &term_out) < 0) { - perror ("tcsetattr()"); - } - } -} -/* }}} */ - -char *get_home_directory (void) { - static char *home_directory = NULL; - if (home_directory != NULL) { - return home_directory; - } - struct passwd *current_passwd; - uid_t user_id; - setpwent (); - user_id = getuid (); - while ((current_passwd = getpwent ())) { - if (current_passwd->pw_uid == user_id) { - home_directory = tstrdup (current_passwd->pw_dir); - break; - } - } - endpwent (); - if (home_directory == NULL) { - home_directory = tstrdup ("."); - } - return home_directory; -} - -char *get_config_directory (void) { - char *config_directory; - tasprintf (&config_directory, "%s/" CONFIG_DIRECTORY, get_home_directory ()); - return config_directory; -} - -char *get_config_filename (void) { - return config_filename; -} - -char *get_auth_key_filename (void) { - return auth_file_name; -} - -char *get_state_filename (void) { - return state_file_name; -} - -char *get_secret_chat_filename (void) { - return secret_chat_file_name; -} - -char *get_downloads_directory (void) { - return downloads_directory; -} - -char *get_binlog_file_name (void) { - return binlog_file_name; -} - -char *make_full_path (char *s) { - if (*s != '/') { - char *t = s; - tasprintf (&s, "%s/%s", get_home_directory (), s); - tfree_str (t); - } - return s; -} - -void check_type_sizes (void) { - if (sizeof (int) != 4u) { - logprintf ("sizeof (int) isn't equal 4.\n"); - exit (1); - } - if (sizeof (char) != 1u) { - logprintf ("sizeof (char) isn't equal 1.\n"); - exit (1); - } -} - -void running_for_first_time (void) { - check_type_sizes (); - if (config_filename) { - return; // Do not create custom config file - } - tasprintf (&config_filename, "%s/%s/%s", get_home_directory (), CONFIG_DIRECTORY, CONFIG_FILE); - config_filename = make_full_path (config_filename); - - int config_file_fd; - char *config_directory = get_config_directory (); - //char *downloads_directory = get_downloads_directory (); - - if (!mkdir (config_directory, CONFIG_DIRECTORY_MODE)) { - printf ("[%s] created\n", config_directory); - } - - tfree_str (config_directory); - config_directory = NULL; - // see if config file is there - if (access (config_filename, R_OK) != 0) { - // config file missing, so touch it - config_file_fd = open (config_filename, O_CREAT | O_RDWR, 0600); - if (config_file_fd == -1) { - perror ("open[config_file]"); - exit (EXIT_FAILURE); - } - if (write (config_file_fd, DEFAULT_CONFIG_CONTENTS, strlen (DEFAULT_CONFIG_CONTENTS)) <= 0) { - perror ("write[config_file]"); - exit (EXIT_FAILURE); - } - close (config_file_fd); - } -} - -#ifdef HAVE_LIBCONFIG -void parse_config_val (config_t *conf, char **s, char *param_name, const char *default_name, const char *path) { - static char buf[1000]; - int l = 0; - if (prefix) { - l = strlen (prefix); - memcpy (buf, prefix, l); - buf[l ++] = '.'; - } - *s = 0; - const char *r = 0; - strcpy (buf + l, param_name); - config_lookup_string (conf, buf, &r); - if (r) { - if (path) { - tasprintf (s, "%s/%s", path, r); - } else { - *s = tstrdup (r); - } - } else { - if (path) { - tasprintf (s, "%s/%s", path, default_name); - } else { - *s = tstrdup (default_name); - } - } -} - -void parse_config (void) { - config_filename = make_full_path (config_filename); - - config_t conf; - config_init (&conf); - if (config_read_file (&conf, config_filename) != CONFIG_TRUE) { - fprintf (stderr, "Can not read config '%s': error '%s' on the line %d\n", config_filename, config_error_text (&conf), config_error_line (&conf)); - exit (2); - } - - if (!prefix) { - config_lookup_string (&conf, "default_profile", (void *)&prefix); - } - - static char buf[1000]; - int l = 0; - if (prefix) { - l = strlen (prefix); - memcpy (buf, prefix, l); - buf[l ++] = '.'; - } - test_dc = 0; - strcpy (buf + l, "test"); - config_lookup_bool (&conf, buf, &test_dc); - - strcpy (buf + l, "log_lev el"); - long long t = log_level; - config_lookup_int (&conf, buf, (void *)&t); - log_level = t; - - if (!msg_num_mode) { - strcpy (buf + l, "msg_num"); - config_lookup_bool (&conf, buf, &msg_num_mode); - } - - parse_config_val (&conf, &config_directory, "config_directory", CONFIG_DIRECTORY, 0); - config_directory = make_full_path (config_directory); - - parse_config_val (&conf, &auth_file_name, "auth_file", AUTH_KEY_FILE, config_directory); - parse_config_val (&conf, &state_file_name, "state_file", STATE_FILE, config_directory); - parse_config_val (&conf, &secret_chat_file_name, "secret", SECRET_CHAT_FILE, config_directory); - parse_config_val (&conf, &downloads_directory, "downloads", DOWNLOADS_DIRECTORY, config_directory); - parse_config_val (&conf, &binlog_file_name, "binlog", BINLOG_FILE, config_directory); - - strcpy (buf + l, "binlog_enabled"); - config_lookup_bool (&conf, buf, &binlog_enabled); - - if (!mkdir (config_directory, CONFIG_DIRECTORY_MODE)) { - printf ("[%s] created\n", config_directory); - } - if (!mkdir (downloads_directory, CONFIG_DIRECTORY_MODE)) { - printf ("[%s] created\n", downloads_directory); - } -} -#else -void parse_config (void) { - printf ("libconfig not enabled\n"); - tasprintf (&auth_file_name, "%s/%s/%s", get_home_directory (), CONFIG_DIRECTORY, AUTH_KEY_FILE); - tasprintf (&state_file_name, "%s/%s/%s", get_home_directory (), CONFIG_DIRECTORY, STATE_FILE); - tasprintf (&secret_chat_file_name, "%s/%s/%s", get_home_directory (), CONFIG_DIRECTORY, SECRET_CHAT_FILE); - tasprintf (&downloads_directory, "%s/%s/%s", get_home_directory (), CONFIG_DIRECTORY, DOWNLOADS_DIRECTORY); - tasprintf (&binlog_file_name, "%s/%s/%s", get_home_directory (), CONFIG_DIRECTORY, BINLOG_FILE); -} -#endif - -void inner_main (void) { - loop (); -} - -void usage (void) { - printf ("%s Usage\n", PROGNAME); - - printf (" -h this help list\n"); - printf (" -u username specify username\n"); - printf (" -k public-key specify server public key\n"); - printf (" -v verbose\n"); - printf (" -l [1-3] log level\n"); - printf (" -L log-file log net file\n"); - printf (" -N message num mode\n"); - printf (" -c config-file specify config file\n"); - printf (" -p prefix specify prefix\n"); - printf (" -R register mode\n"); - printf (" -f sync from start\n"); - printf (" -B enable binlog\n"); - printf (" -E disable auto accept\n"); - printf (" -w allow weak random\n"); - printf (" -s specify lua script\n"); - printf (" -W wait dialog list\n"); - printf ("\n"); - - exit (1); -} - -extern char *rsa_public_key_name; -extern int verbosity; -extern int default_dc_num; - -char *log_net_file; -FILE *log_net_f; - -int register_mode; -int disable_auto_accept; -int wait_dialog_list; - -char *lua_file; - -void args_parse (int argc, char **argv) { - verbosity = 2; - int opt = 0; - while ((opt = getopt (argc, argv, "u:hk:vn:Nc:p:l:RfBL:Es:wW")) != -1) { - switch (opt) { - case 'u': - set_default_username (optarg); - break; - case 'k': - rsa_public_key_name = tstrdup (optarg); - break; - case 'v': - verbosity ++; - break; - case 'N': - msg_num_mode ++; - break; - case 'c': - config_filename = tstrdup (optarg); - break; - case 'p': - prefix = tstrdup (optarg); - assert (strlen (prefix) <= 100); - break; - case 'l': - log_level = atoi (optarg); - break; - case 'R': - register_mode = 1; - break; - case 'f': - sync_from_start = 1; - break; - case 'B': - binlog_enabled = 1; - break; - case 'L': - if (log_net_file) { - usage (); - } - log_net_file = tstrdup (optarg); - log_net_f = fopen (log_net_file, "a"); - assert (log_net_f); - break; - case 'E': - disable_auto_accept = 1; - break; - case 'w': - allow_weak_random = 1; - break; - case 's': - lua_file = tstrdup (optarg); - break; - case 'W': - wait_dialog_list = 1; - break; - case 'h': - default: - usage (); - break; - } - } -} - -#ifdef HAVE_EXECINFO_H -void print_backtrace (void) { - void *buffer[255]; - const int calls = backtrace (buffer, sizeof (buffer) / sizeof (void *)); - backtrace_symbols_fd (buffer, calls, 1); -} -#else -void print_backtrace (void) { - if (write (1, "No libexec. Backtrace disabled\n", 32) < 0) { - // Sad thing - } -} -#endif - -void sig_segv_handler (int signum __attribute__ ((unused))) { - set_terminal_attributes (); - if (write (1, "SIGSEGV received\n", 18) < 0) { - // Sad thing - } - print_backtrace (); - exit (EXIT_FAILURE); -} - -void sig_abrt_handler (int signum __attribute__ ((unused))) { - set_terminal_attributes (); - if (write (1, "SIGABRT received\n", 18) < 0) { - // Sad thing - } - print_backtrace (); - exit (EXIT_FAILURE); -} - -int tgmain (int argc, char **argv) { - signal (SIGSEGV, sig_segv_handler); - signal (SIGABRT, sig_abrt_handler); - - log_level = 10; - - args_parse (argc, argv); - running_for_first_time (); - parse_config (); - - get_terminal_attributes (); - - #ifdef USE_LUA - if (lua_file) { - lua_init (lua_file); - } - #endif - - inner_main (); - - return 0; -} diff --git a/mtproto-client.c b/mtproto-client.c index 3bc63c1..b7fcfee 100644 --- a/mtproto-client.c +++ b/mtproto-client.c @@ -18,10 +18,6 @@ Copyright Vitaly Valtman 2013 */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #define _FILE_OFFSET_BITS 64 #include @@ -73,20 +69,6 @@ int verbosity = 0; int allow_weak_random = 0; int disable_auto_accept = 0; -/* -enum dc_state c_state; -char nonce[256]; -char new_nonce[256]; -char server_nonce[256]; -extern int binlog_enabled; -extern int disable_auto_accept; -extern int allow_weak_random; - -int total_packets_sent; -long long total_data_sent; -*/ - - int rpc_execute (struct connection *c, int op, int len); int rpc_becomes_ready (struct connection *c); int rpc_close (struct connection *c); @@ -1467,23 +1449,6 @@ void work_new_session_created (struct connection *c, long long msg_id UU) { fetch_long (c->mtconnection); // unique_id GET_DC(c)->server_salt = fetch_long (c->mtconnection); logprintf ("new server_salt = %lld\n", GET_DC(c)->server_salt); - - - /* - // create a new empty session - assert (DC->working_sess + 1 < 3); - assert (!DC->sessions[++ DC->working_sess]); - struct session *s = DC->sessions[DC->working_sess] = alloc_session(); - - // DC->session_id = fetch_long (); - // long las_id = fetch_long (c->mtconnection); - long ses_id = fetch_long (c->mtconnection); - //s->session_id = ses_id; - logprintf ("new sess_id = %ld\n", ses_id); - - // fetch_long (c->mtconnection); // unique_id - DC->server_salt = fetch_long (c->mtconnection); - */ } void work_msgs_ack (struct connection *c UU, long long msg_id UU) { @@ -1833,26 +1798,6 @@ void on_start (struct mtproto_connection *self) { pk_fingerprint = compute_rsa_key_fingerprint (pubKey); } -/* -int auth_ok (void) { - return auth_success; -} -*/ - -/* -void dc_authorize (struct dc *DC) { - c_state = 0; - auth_success = 0; - if (!DC->sessions[0]) { - dc_create_session (DC); - } - if (verbosity) { - logprintf ( "Starting authorization for DC #%d: %s:%d\n", DC->id, DC->ip, DC->port); - } - net_loop (0, auth_ok); -} -*/ - struct connection_methods mtproto_methods = { .execute = rpc_execute, diff --git a/mtproto-client.h b/mtproto-client.h index b55e7d3..2130ec5 100644 --- a/mtproto-client.h +++ b/mtproto-client.h @@ -26,10 +26,6 @@ Copyright Nikolay Durov, Andrey Lopatin 2012-2013 */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include #include #include diff --git a/net.c b/net.c index c0c76c7..fad9eb5 100644 --- a/net.c +++ b/net.c @@ -17,10 +17,6 @@ Copyright Vitaly Valtman 2013 */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #define _GNU_SOURCE #include #include @@ -42,7 +38,6 @@ #include "include.h" #include "mtproto-client.h" #include "tree.h" -#include "interface.h" #ifndef POLLRDHUP #define POLLRDHUP 0 diff --git a/net.h b/net.h index eccac14..3152fe6 100644 --- a/net.h +++ b/net.h @@ -129,8 +129,6 @@ struct connection { void *extra; struct event_timer ev; double last_receive_time; - - // backreference to corrent telegram instance struct telegram *instance; struct mtproto_connection *mtconnection; }; diff --git a/queries.c b/queries.c index 4fc68af..1cd8bee 100644 --- a/queries.c +++ b/queries.c @@ -17,10 +17,6 @@ Copyright Vitaly Valtman 2013 */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #define _FILE_OFFSET_BITS 64 #include #include @@ -705,34 +701,6 @@ int get_contacts_on_answer (struct query *q UU) { n = fetch_int (mtp); for (i = 0; i < n; i++) { fetch_alloc_user (mtp); - /* - //print_start (); - //push_color (COLOR_YELLOW); - logprintf ("User #%d: ", get_peer_id (U->id)); - //print_user_name (U->id, (peer_t *)U); - //push_color (COLOR_GREEN); - logprintf (" ("); - logprintf ("%s", U->print_name); - if (U->phone) { - logprintf (" "); - logprintf ("%s", U->phone); - } - logprintf (") "); - //pop_color (); - if (U->status.online > 0) { - logprintf ("online\n"); - } else { - if (U->status.online < 0) { - logprintf ("offline. Was online "); - //print_date_full (U->status.when); - } else { - logprintf ("offline permanent"); - } - logprintf ("\n"); - } - //pop_color (); - //print_end (); - */ } contacts_got = 1; return 0; diff --git a/rpm/telegram-cli-Beta-2.fc20.x86_64.rpm b/rpm/telegram-cli-Beta-2.fc20.x86_64.rpm deleted file mode 100644 index 0deaace..0000000 Binary files a/rpm/telegram-cli-Beta-2.fc20.x86_64.rpm and /dev/null differ diff --git a/structures.c b/structures.c index a9dd465..cf7ad1c 100644 --- a/structures.c +++ b/structures.c @@ -17,10 +17,6 @@ Copyright Vitaly Valtman 2013 */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include #include #include "constants.h" diff --git a/telegram-cli.spec b/telegram-cli.spec deleted file mode 100644 index c187dc3..0000000 --- a/telegram-cli.spec +++ /dev/null @@ -1,46 +0,0 @@ -Name: telegram-cli -Version: Beta -Release: 2%{?dist} -Summary: Private fast and open platform for instant messaging - -Packager: Pablo Iranzo Gómez (Pablo.Iranzo@gmail.com) -Group: Internet/Messaging -License: GPL -URL: https://github.com/vysheng/tg -Source: master.zip - -BuildRequires: lua-devel, openssl-devel, libconfig-devel, readline-devel, wget -#Requires: wget - -%description -Telegram is an Open Source messaging platform for mobile, desktop focused on privacy. - - - - -%prep -[ -d %{name} ] && rm -Rfv %{name} -mkdir %{name} -cd %{name} -wget -O master.zip https://github.com/vysheng/tg/archive/master.zip -unzip master.zip -cd tg-master -./configure -make %{?_smp_mflags} - - -%install -cd %{name} -cd tg-master -%{__install} -D -m0755 telegram %{buildroot}/usr/bin/telegram -%{__install} -D -m0644 tg-server.pub %{buildroot}/etc/telegram/server.pub - -%files -/usr/bin/telegram -/etc/telegram/server.pub - -%changelog -* Tue Feb 4 2014 Pablo Iranzo Gómez (Pablo.Iranzo@gmail.com) -- Add server key to /etc/telegram/ -* Sat Feb 1 2014 Pablo Iranzo Gómez (Pablo.Iranzo@gmail.com) -- Initial SPEC file diff --git a/test.lua b/test.lua deleted file mode 100644 index 90a3de5..0000000 --- a/test.lua +++ /dev/null @@ -1,95 +0,0 @@ -started = 0 -our_id = 0 - -function vardump(value, depth, key) - local linePrefix = "" - local spaces = "" - - if key ~= nil then - linePrefix = "["..key.."] = " - end - - if depth == nil then - depth = 0 - else - depth = depth + 1 - for i=1, depth do spaces = spaces .. " " end - end - - if type(value) == 'table' then - mTable = getmetatable(value) - if mTable == nil then - print(spaces ..linePrefix.."(table) ") - else - print(spaces .."(metatable) ") - value = mTable - end - for tableKey, tableValue in pairs(value) do - vardump(tableValue, depth, tableKey) - end - elseif type(value) == 'function' or - type(value) == 'thread' or - type(value) == 'userdata' or - value == nil - then - print(spaces..tostring(value)) - else - print(spaces..linePrefix.."("..type(value)..") "..tostring(value)) - end -end - -print ("HI, this is lua script") - - - -function on_msg_receive (msg) - if started == 0 then - return - end - if msg.out then - return - end - if (msg.text == 'ping') then - if (msg.to.id == our_id) then - print ('sending pong to ' .. tostring (msg.from.print_name)) - send_msg (msg.from.print_name, 'pong') - else - print ('sending pong to ' .. tostring (msg.to.print_name)) - send_msg (msg.to.print_name, 'pong') - end - return - end - if (msg.text == 'PING') then - if (msg.to.id == our_id) then - fwd_msg (msg.from.print_name, msg.id) - else - fwd_msg (msg.to.print_name, msg.id) - end - return - end - --vardump (msg) - --print ( "Message # " .. msg.id .. " (flags " .. msg.flags .. ")") -end - -function on_our_id (id) - our_id = id -end - -function on_secret_chat_created (peer) - --vardump (peer) -end - -function on_user_update (user) - --vardump (user) -end - -function on_chat_update (user) - --vardump (user) -end - -function on_get_difference_end () -end - -function on_binlog_replay_end () - started = 1 -end diff --git a/tools.c b/tools.c index 888e8c4..5291d4f 100644 --- a/tools.c +++ b/tools.c @@ -17,10 +17,6 @@ Copyright Vitaly Valtman 2013 */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #define _GNU_SOURCE #include @@ -30,8 +26,8 @@ #include #include -#include "interface.h" #include "tools.h" +#include "msglog.h" #ifdef DEBUG #define RES_PRE 8 @@ -105,32 +101,6 @@ void tfree (void *ptr, int size __attribute__ ((unused))) { #endif } -/** - * Add a variable amount of strings together - */ -//char *stradd(const char *strs, ...) -//{ -// va_list args; -// size_t size = 0; -// char *result; -// -// // count strlen -// va_start(args, strs); -// for (int i = 0; strs[i] != '\0'; i++) { -// size += strlen(va_arg(args, char*)); -// } -// va_end(args); -// -// // create the new string -// result = talloc0(size + 1); -// va_start(args, strs); -// for (int i = 0; strs[i] != '\0'; i++) { -// strcat(result, va_arg(args, char*)); -// } -// va_end(args); -// return result; -//} - void tfree_str (void *ptr) { if (!ptr) { return; } tfree (ptr, strlen (ptr) + 1);