Remove unused code and build files
This commit is contained in:
parent
832cf949f0
commit
5a425be62f
36 changed files with 73 additions and 6396 deletions
|
@ -1,177 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>App configuration</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="apple-itunes-app" content="app-id=686449807">
|
||||
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
|
||||
|
||||
<link rel="shortcut icon" href="/favicon.ico?3" type="image/x-icon" />
|
||||
|
||||
<link href="/css/telegram.css?22" rel="stylesheet" media="screen">
|
||||
<style>
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="fb-root"></div>
|
||||
<div class="tl_page_wrap">
|
||||
<div class="tl_page_head navbar navbar-static-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<ul class="nav pull-right"><li class="hidden-phone"><a href="/dl/android" target="_blank" data-track="AppDownload/Android">Android</a></li><li class="hidden-phone"><a href="/dl/ios" target="_blank" data-track="AppDownload/iOS">iPhone</a></li><li><a href="https://twitter.com/telegram" target="_blank" data-track="Follow/Twitter"><i class="icon icon-twitter"></i> Twitter</a></li></ul>
|
||||
<ul class="nav">
|
||||
<li><a href="//telegram.org/">Home</a></li>
|
||||
<li><a href="//telegram.org/faq">FAQ</a></li>
|
||||
<li><a href="//telegram.org/apps">Apps</a></li>
|
||||
<li class="hidden-phone"><a href="//core.telegram.org/api">API</a></li>
|
||||
<li class="hidden-phone"><a href="//core.telegram.org/mtproto">Protocol</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container tl_page_container">
|
||||
<div class="tl_page">
|
||||
<div class="app_edit_page">
|
||||
<form class="form-horizontal" id="app_edit_form">
|
||||
<h2>App configuration</h2>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="app_id">App api_id:</label>
|
||||
<div class="controls">
|
||||
<span class="input-xlarge uneditable-input" onclick="this.select();"><strong>16154</strong></span>
|
||||
<div class="app_lock_tt"><i class="icon icon-lock"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="app_hash">App api_hash:</label>
|
||||
<div class="controls">
|
||||
<span class="input-xlarge uneditable-input" onclick="this.select();">99428c722d0ed59b9cd844e4577cb4bb</span>
|
||||
<div class="app_lock_tt"><i class="icon icon-lock"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="app_title">App title:</label>
|
||||
<div class="controls">
|
||||
<input id="app_title" name="app_title" type="text" class="input-xlarge" value="Telegram Libpurple" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="app_shortname">Short name:</label>
|
||||
<div class="controls">
|
||||
<input id="app_shortname" name="app_shortname" type="text" class="input-xlarge" value="telerampurple" />
|
||||
<p class="help-block"><span class="muted">alphanumeric, 5-32 characters</span></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: none;">
|
||||
<h3>PUSH-notifications settings</h3>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="app_gcm_api_key">GCM API key:</label>
|
||||
<div class="controls">
|
||||
<input id="app_gcm_api_key" name="app_gcm_api_key" type="text" class="input-xlarge" value="" />
|
||||
<p class="help-block"><a href="http://developer.android.com/google/gcm/gs.html#access-key" target="_blank">How do I get this?</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="display: none;">
|
||||
<h3>
|
||||
APNS certificates
|
||||
<small>
|
||||
<a href="/apps/apns_cert">Update</a>
|
||||
<a href="/apps/apns_cert_delete" onclick="return confirm('Are you sure to delete certificates?');" style="display: none;">Delete</a>
|
||||
</small>
|
||||
</h3>
|
||||
|
||||
<div class="control-group" style="display: none;">
|
||||
<label class="control-label" for="app_apns_production_pem">APNS production certificate:</label>
|
||||
<div class="controls">
|
||||
<span class="input-xlarge uneditable-input"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group" style="display: none;">
|
||||
<label class="control-label" for="app_apns_dev_pem">APNS development certificate:</label>
|
||||
<div class="controls">
|
||||
<span class="input-xlarge uneditable-input"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3>Available MTProto servers</h3>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">Test configuration:</label>
|
||||
<div class="controls">
|
||||
<span class="input-xlarge uneditable-input"><strong>173.240.5.253:443</strong></span>
|
||||
<p class="help-block">First DC</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label">Production configuration</label>
|
||||
<div class="controls">
|
||||
<span class="input-xlarge uneditable-input"><strong>173.240.5.1:443</strong></span>
|
||||
<p class="help-block">First DC</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label">Public keys:</label>
|
||||
<div class="controls">
|
||||
<pre><code>-----BEGIN RSA PUBLIC KEY-----
|
||||
MIIBCgKCAQEAwVACPi9w23mF3tBkdZz+zwrzKOaaQdr01vAbU4E1pvkfj4sqDsm6
|
||||
lyDONS789sVoD/xCS9Y0hkkC3gtL1tSfTlgCMOOul9lcixlEKzwKENj1Yz/s7daS
|
||||
an9tqw3bfUV/nqgbhGX81v/+7RFAEd+RwFnK7a+XYl9sluzHRyVVaTTveB2GazTw
|
||||
Efzk2DWgkBluml8OREmvfraX3bkHZJTKX4EQSjBbbdJ2ZXIsRrYOXfaA+xayEGB+
|
||||
8hdlLmAjbCVfaigxX0CDqWeR1yFL9kwd9P0NsZRPsmoqVwMbMu7mStFai6aIhc3n
|
||||
Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB
|
||||
-----END RSA PUBLIC KEY-----</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="button" class="btn btn-primary" data-loading-text="Saving..." id="app_save_btn" onclick="saveApp(); return false;">Save changes</button>
|
||||
<a href="/" class="btn">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="/js/jquery.min.js"></script>
|
||||
<script src="/js/bootstrap.min.js"></script>
|
||||
<script src="/js/main.js?4"></script>
|
||||
|
||||
<script>$('#app_save_btn').button();
|
||||
$('.app_lock_tt').tooltip({html: true, title: '<div class="app_lock_text">It is forbidden to pass this value to third parties.</div>'});
|
||||
|
||||
function saveApp() {
|
||||
$('#app_save_btn').button('loading');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/apps/save',
|
||||
data: $('#app_edit_form').serialize(),
|
||||
success: function (error) {
|
||||
$('#app_save_btn').button('reset');
|
||||
if (error) {
|
||||
alert(error);
|
||||
}
|
||||
},
|
||||
error: function (error) {
|
||||
$('#app_save_btn').button('reset');
|
||||
if (error) {
|
||||
alert(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -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@
|
||||
|
|
614
ax_lua.m4
614
ax_lua.m4
|
@ -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 <tprk77@gmail.com>
|
||||
# Copyright (c) 2013 Reuben Thomas <rrt@sc3d.org>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# 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 <lua.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
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])
|
||||
])
|
6
binlog.c
6
binlog.c
|
@ -17,10 +17,6 @@
|
|||
Copyright Vitaly Valtman 2013
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -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;
|
||||
|
|
177
config.h.in
177
config.h.in
|
@ -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 <arpa/inet.h> 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 <execinfo.h> header file. */
|
||||
#undef HAVE_EXECINFO_H
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the <lauxlib.h> 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 <luaconf.h> header file. */
|
||||
#undef HAVE_LUACONF_H
|
||||
|
||||
/* Define to 1 if you have the <lualib.h> header file. */
|
||||
#undef HAVE_LUALIB_H
|
||||
|
||||
/* Define to 1 if you have the <lua.h> header file. */
|
||||
#undef HAVE_LUA_H
|
||||
|
||||
/* Define to 1 if you have the <mach/mach.h> 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 <malloc.h> 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 <memory.h> 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 <netdb.h> header file. */
|
||||
#undef HAVE_NETDB_H
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> 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 <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> 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 <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> 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 <sys/file.h> header file. */
|
||||
#undef HAVE_SYS_FILE_H
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#undef HAVE_SYS_SOCKET_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <termios.h> 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 <unistd.h> 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 <sys/types.h> 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 <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
#undef uid_t
|
|
@ -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;
|
||||
};
|
||||
|
54
configure.ac
54
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=<name>],
|
||||
[
|
||||
|
|
5
debian/changelog
vendored
5
debian/changelog
vendored
|
@ -1,5 +0,0 @@
|
|||
telegram-cli (0.1-1) unstable; urgency=low
|
||||
|
||||
* Initial release (Closes #737563)
|
||||
|
||||
-- Cleto Martín <cleto@debian.org> Mon, 03 Feb 2014 20:00:03 +0000
|
1
debian/clean
vendored
1
debian/clean
vendored
|
@ -1 +0,0 @@
|
|||
Makefile
|
1
debian/compat
vendored
1
debian/compat
vendored
|
@ -1 +0,0 @@
|
|||
9
|
36
debian/control
vendored
36
debian/control
vendored
|
@ -1,36 +0,0 @@
|
|||
Source: telegram-cli
|
||||
Section: net
|
||||
Priority: optional
|
||||
Maintainer: Cleto Martín <cleto@debian.org>
|
||||
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.
|
28
debian/copyright
vendored
28
debian/copyright
vendored
|
@ -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 <cleto@debian.org>
|
||||
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 <http://www.gnu.org/licenses/>
|
||||
.
|
||||
On Debian systems, the complete text of the GNU General
|
||||
Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
|
1
debian/docs
vendored
1
debian/docs
vendored
|
@ -1 +0,0 @@
|
|||
README.md
|
1
debian/install
vendored
1
debian/install
vendored
|
@ -1 +0,0 @@
|
|||
telegram usr/bin
|
17
debian/rules
vendored
17
debian/rules
vendored
|
@ -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
|
1
debian/source/format
vendored
1
debian/source/format
vendored
|
@ -1 +0,0 @@
|
|||
3.0 (quilt)
|
4
debian/watch
vendored
4
debian/watch
vendored
|
@ -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
|
|
@ -1 +0,0 @@
|
|||
EBUILD telegram-cli-9999.ebuild 641 SHA256 4597e2f84c36b1ee02ecc415c399408bb8536b456e94370e996d57477db621be SHA512 287da263c9a4ba2058bf2f5844599432619053abc9249fd5725ed7b5e920c5c02e2493ad7b07f89177933b2c15394d939e7dc7dbf05d5873c32e55c9ec614d4c WHIRLPOOL 73dee37f91f1d4b747afc35c0a0cb2efb141d37702c71a7a9d188d2e1d727375c0ee3e7a1192e6c4c34f17ba1303f3a0be47b24272b5378ff255bce1a4a281be
|
|
@ -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
|
||||
}
|
1577
interface.c
1577
interface.c
File diff suppressed because it is too large
Load diff
63
interface.h
63
interface.h
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
308
loop.c
308
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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef READLINE_GNU
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
#else
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <poll.h>
|
||||
|
@ -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);
|
||||
}
|
||||
*/
|
||||
|
|
550
lua-tg.c
550
lua-tg.c
|
@ -1,550 +0,0 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_LUA
|
||||
/*
|
||||
#include "lua-tg.h"
|
||||
|
||||
#include "include.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#include <lua.h>
|
||||
#include <lualib.h>
|
||||
#include <lauxlib.h>
|
||||
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
|
18
lua-tg.h
18
lua-tg.h
|
@ -1,18 +0,0 @@
|
|||
#ifndef __LUA_TG_H__
|
||||
#define __LUA_TG_H__
|
||||
|
||||
#include <string.h>
|
||||
#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
|
493
main.c
493
main.c
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Copyright Vitaly Valtman 2013
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <pwd.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#if (READLINE == GNU)
|
||||
#include <readline/readline.h>
|
||||
#else
|
||||
#include <editline/readline.h>
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <time.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef HAVE_EXECINFO_H
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
#include <signal.h>
|
||||
#ifdef HAVE_LIBCONFIG
|
||||
#include <libconfig.h>
|
||||
#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 <signal.h>
|
||||
#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;
|
||||
}
|
|
@ -18,10 +18,6 @@
|
|||
Copyright Vitaly Valtman 2013
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -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,
|
||||
|
|
|
@ -26,10 +26,6 @@ Copyright Nikolay Durov, Andrey Lopatin 2012-2013
|
|||
*/
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
|
5
net.c
5
net.c
|
@ -17,10 +17,6 @@
|
|||
Copyright Vitaly Valtman 2013
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -42,7 +38,6 @@
|
|||
#include "include.h"
|
||||
#include "mtproto-client.h"
|
||||
#include "tree.h"
|
||||
#include "interface.h"
|
||||
|
||||
#ifndef POLLRDHUP
|
||||
#define POLLRDHUP 0
|
||||
|
|
2
net.h
2
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;
|
||||
};
|
||||
|
|
32
queries.c
32
queries.c
|
@ -17,10 +17,6 @@
|
|||
Copyright Vitaly Valtman 2013
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
#include <string.h>
|
||||
#include <memory.h>
|
||||
|
@ -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;
|
||||
|
|
Binary file not shown.
|
@ -17,10 +17,6 @@
|
|||
Copyright Vitaly Valtman 2013
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "constants.h"
|
||||
|
|
|
@ -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
|
95
test.lua
95
test.lua
|
@ -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
|
32
tools.c
32
tools.c
|
@ -17,10 +17,6 @@
|
|||
Copyright Vitaly Valtman 2013
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -30,8 +26,8 @@
|
|||
#include <openssl/err.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#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);
|
||||
|
|
Loading…
Add table
Reference in a new issue