Adding preliminary python files based on lua bindings.

This commit is contained in:
Vincent Castellano 2015-05-02 03:43:53 -07:00
parent 01f5d9a3b6
commit 31524068b6
4 changed files with 1642 additions and 0 deletions

98
ax_python.m4 Normal file
View File

@ -0,0 +1,98 @@
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_python.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_PYTHON
#
# DESCRIPTION
#
# This macro does a complete Python development environment check.
#
# It recurses through several python versions (from 2.1 to 2.6 in this
# version), looking for an executable. When it finds an executable, it
# looks to find the header files and library.
#
# It sets PYTHON_BIN to the name of the python executable,
# PYTHON_INCLUDE_DIR to the directory holding the header files, and
# PYTHON_LIB to the name of the Python library.
#
# This macro calls AC_SUBST on PYTHON_BIN (via AC_CHECK_PROG),
# PYTHON_INCLUDE_DIR and PYTHON_LIB.
#
# LICENSE
#
# Copyright (c) 2008 Michael Tindal
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <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 14
AC_DEFUN([AX_PYTHON],
[AC_MSG_CHECKING(for python build information)
AC_MSG_RESULT([])
for python in python3.3 python3.2 python3.1 python3.0 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python; do
AC_CHECK_PROGS(PYTHON_BIN, [$python])
ax_python_bin=$PYTHON_BIN
if test x$ax_python_bin != x; then
AC_CHECK_LIB($ax_python_bin, main, ax_python_lib=$ax_python_bin, ax_python_lib=no)
if test x$ax_python_lib == xno; then
AC_CHECK_LIB(${ax_python_bin}m, main, ax_python_lib=${ax_python_bin}m, ax_python_lib=no)
fi
if test x$ax_python_lib != xno; then
ax_python_header=`$ax_python_bin -c "from distutils.sysconfig import *; print(get_config_var('CONFINCLUDEPY'))"`
if test x$ax_python_header != x; then
break;
fi
fi
fi
done
if test x$ax_python_bin = x; then
ax_python_bin=no
fi
if test x$ax_python_header = x; then
ax_python_header=no
fi
if test x$ax_python_lib = x; then
ax_python_lib=no
fi
AC_MSG_RESULT([ results of the Python check:])
AC_MSG_RESULT([ Binary: $ax_python_bin])
AC_MSG_RESULT([ Library: $ax_python_lib])
AC_MSG_RESULT([ Include Dir: $ax_python_header])
if test x$ax_python_header != xno; then
PYTHON_INCLUDE_DIR=$ax_python_header
AC_SUBST(PYTHON_INCLUDE_DIR)
fi
if test x$ax_python_lib != xno; then
PYTHON_LIB=$ax_python_lib
AC_SUBST(PYTHON_LIB)
fi
])dnl

View File

@ -4,6 +4,7 @@ AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADERS([config.h])
m4_include([ax_lua.m4])
m4_include([ax_python.m4])
m4_include([m4_ax_check_openssl.m4])
m4_include([m4_ax_check_zlib.m4])
m4_include([m4-ax_gcc_builtin.m4])
@ -94,6 +95,17 @@ AC_ARG_ENABLE(liblua,[--enable-liblua/--disable-liblua],
])
])
AC_ARG_ENABLE(python,[--enable-python/--disable-python],
[
dnl python checks (you can change the required python version bellow)
AM_PATH_PYTHON(2.7.0)
PY_PREFIX=`$PYTHON -c 'import sys ; print sys.prefix'`
PYTHON_LIBS="-lpython$PYTHON_VERSION"
PYTHON_CFLAGS="-I$PY_PREFIX/include/python$PYTHON_VERSION"
AC_SUBST([PYTHON_LIBS])
AC_SUBST([PYTHON_CFLAGS])
])
#check for custom prog name
AC_ARG_WITH(progname,[--with-progname=<name>],
[

1497
python-tg.c Normal file

File diff suppressed because it is too large Load Diff

35
python-tg.h Normal file
View File

@ -0,0 +1,35 @@
/*
This file is part of telegram-cli.
Telegram-cli 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-cli 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-cli. If not, see <http://www.gnu.org/licenses/>.
Copyright Vitaly Valtman 2013-2015
Copyright Vincent Castellano 2015
*/
#ifndef __PYTHON_TG_H__
#define __PYTHON_TG_H__
#include <string.h>
#include <tgl/tgl.h>
void py_init (const char *file);
void py_new_msg (struct tgl_message *M);
void py_our_id (int id);
void py_secret_chat_update (struct tgl_secret_chat *U, unsigned flags);
void py_user_update (struct tgl_user *U, unsigned flags);
void py_chat_update (struct tgl_chat *C, unsigned flags);
void py_binlog_end (void);
void py_diff_end (void);
void py_do_all (void);
#endif