[asterisk-commits] russell: branch russell/bindings r103274 - in /team/russell/bindings: ./ bind...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Feb 9 16:19:04 CST 2008
Author: russell
Date: Sat Feb 9 16:19:04 2008
New Revision: 103274
URL: http://svn.digium.com/view/asterisk?view=rev&rev=103274
Log:
- pull the definition of ast_cdr out of cdr.h automagically
- other bits of integration into the build system ...
Added:
team/russell/bindings/bindings/get_swig (with props)
Modified:
team/russell/bindings/Makefile
team/russell/bindings/bindings/Makefile
team/russell/bindings/bindings/cdr.i
team/russell/bindings/bindings/cdr_wrap.c
team/russell/bindings/bindings/examples/cdr_test_vars.py
team/russell/bindings/bindings/strings-cstrlength-fix.diff1.txt
team/russell/bindings/build_tools/menuselect-deps.in
team/russell/bindings/cdr/cdr_python.c
team/russell/bindings/configure.ac
team/russell/bindings/include/asterisk/cdr.h
team/russell/bindings/makeopts.in
Modified: team/russell/bindings/Makefile
URL: http://svn.digium.com/view/asterisk/team/russell/bindings/Makefile?view=diff&rev=103274&r1=103273&r2=103274
==============================================================================
--- team/russell/bindings/Makefile (original)
+++ team/russell/bindings/Makefile Sat Feb 9 16:19:04 2008
@@ -65,6 +65,7 @@
export ASTBINDIR
export ASTSBINDIR
export AGI_DIR
+export PYTHON_DIR
export ASTCONFPATH
export OSARCH # Operating system
@@ -92,6 +93,7 @@
export AWK
export GREP
export ID
+export SWIG
# even though we could use '-include makeopts' here, use a wildcard
# lookup anyway, so that make won't try to build makeopts if it doesn't
@@ -163,6 +165,7 @@
ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
MODULES_DIR=$(ASTLIBDIR)/modules
AGI_DIR=$(ASTDATADIR)/agi-bin
+PYTHON_DIR=$(ASTDATADIR)/python
# If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
HTTP_DOCSDIR=/var/www/html
@@ -281,7 +284,7 @@
ASTCFLAGS+=$(MALLOC_DEBUG)$(OPTIONS)
MOD_SUBDIRS:=channels pbx apps codecs formats cdr funcs tests main res $(LOCAL_MOD_SUBDIRS)
-OTHER_SUBDIRS:=utils agi
+OTHER_SUBDIRS:=utils agi bindings
SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
@@ -470,6 +473,7 @@
$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
done
mkdir -p $(DESTDIR)$(AGI_DIR)
+ mkdir -p $(DESTDIR)$(PYTHON_DIR)
$(MAKE) -C sounds install
update:
Modified: team/russell/bindings/bindings/Makefile
URL: http://svn.digium.com/view/asterisk/team/russell/bindings/bindings/Makefile?view=diff&rev=103274&r1=103273&r2=103274
==============================================================================
--- team/russell/bindings/bindings/Makefile (original)
+++ team/russell/bindings/bindings/Makefile Sat Feb 9 16:19:04 2008
@@ -1,13 +1,35 @@
-PYTHON_BINDINGS:=_cdr.so
+#
+# Asterisk -- A telephony toolkit for Linux.
+#
+# Makefile for AGI-related stuff
+#
+# Copyright (C) 2008, Digium, Inc.
+#
+# Russell Bryant <russell at digium.com>
+#
+# This program is free software, distributed under the terms of
+# the GNU General Public License
+#
-all: $(PYTHON_BINDINGS)
+PYTHON_MODS:=cdr.py
-_cdr.so: cdr_wrap.c cdr_setup.py
- python cdr_setup.py build_ext --inplace
+all: cdr_wrap.c
+
+cdr.i: ../include/asterisk/cdr.h
+ $(AWK) -f get_swig $< >> $@
cdr_wrap.c: cdr.i
- swig -I../include -python cdr.i
- swig -I../include -python -external-runtime
+ifneq ($(SWIG),:)
+ $(SWIG) -I$(ASTTOPDIR)/include -python cdr.i
+ $(SWIG) -I$(ASTTOPDIR)/include -python -external-runtime
+endif
+
+install: all
+ mkdir -p $(DESTDIR)$(PYTHON_DIR)
+ for x in $(PYTHON_MODS) ; do $(INSTALL) -m 755 $$x $(DESTDIR)$(PYTHON_DIR) ; done
+
+uninstall:
+ for x in $(PYTHON_MODS); do rm -f $(DESTDIR)$(PYTHON_DIR)/$$x $(DESTDIR)$(PYTHON_DIR)/$${x}c ; done
clean:
rm -f _cdr.so cdr_wrap.c cdr.py cdr.pyc swigpyrun.h
Modified: team/russell/bindings/bindings/cdr.i
URL: http://svn.digium.com/view/asterisk/team/russell/bindings/bindings/cdr.i?view=diff&rev=103274&r1=103273&r2=103274
==============================================================================
--- team/russell/bindings/bindings/cdr.i (original)
+++ team/russell/bindings/bindings/cdr.i Sat Feb 9 16:19:04 2008
@@ -9,36 +9,6 @@
struct timeval {
long tv_sec;
long tv_usec;
-};
-
-struct ast_cdr {
- char clid[AST_MAX_EXTENSION];
- char src[AST_MAX_EXTENSION];
- char dst[AST_MAX_EXTENSION];
- char dcontext[AST_MAX_EXTENSION];
-
- char channel[AST_MAX_EXTENSION];
- char dstchannel[AST_MAX_EXTENSION];
- char lastapp[AST_MAX_EXTENSION];
- char lastdata[AST_MAX_EXTENSION];
-
- struct timeval start;
-
- struct timeval answer;
-
- struct timeval end;
- long int duration;
- long int billsec;
- long int disposition;
- long int amaflags;
- char accountcode[AST_MAX_ACCOUNT_CODE];
- unsigned int flags;
- char uniqueid[32];
- char userfield[AST_MAX_USER_FIELD];
-
- struct varshead varshead;
-
- struct ast_cdr *next;
};
%extend ast_cdr {
@@ -91,3 +61,50 @@
return NULL;
}
};
+
+/*! \brief Responsible for call detail data */
+struct ast_cdr {
+ /*! Caller*ID with text */
+ char clid[AST_MAX_EXTENSION];
+ /*! Caller*ID number */
+ char src[AST_MAX_EXTENSION];
+ /*! Destination extension */
+ char dst[AST_MAX_EXTENSION];
+ /*! Destination context */
+ char dcontext[AST_MAX_EXTENSION];
+
+ char channel[AST_MAX_EXTENSION];
+ /*! Destination channel if appropriate */
+ char dstchannel[AST_MAX_EXTENSION];
+ /*! Last application if appropriate */
+ char lastapp[AST_MAX_EXTENSION];
+ /*! Last application data */
+ char lastdata[AST_MAX_EXTENSION];
+
+ struct timeval start;
+
+ struct timeval answer;
+
+ struct timeval end;
+ /*! Total time in system, in seconds */
+ long int duration;
+ /*! Total time call is up, in seconds */
+ long int billsec;
+ /*! What happened to the call */
+ long int disposition;
+ /*! What flags to use */
+ long int amaflags;
+ /*! What account number to use */
+ char accountcode[AST_MAX_ACCOUNT_CODE];
+ /*! flags */
+ unsigned int flags;
+ /*! Unique Channel Identifier */
+ char uniqueid[32];
+ /*! User field */
+ char userfield[AST_MAX_USER_FIELD];
+
+ /*! A linked list for variables */
+ struct varshead varshead;
+
+ struct ast_cdr *next;
+};
Modified: team/russell/bindings/bindings/cdr_wrap.c
URL: http://svn.digium.com/view/asterisk/team/russell/bindings/bindings/cdr_wrap.c?view=diff&rev=103274&r1=103273&r2=103274
==============================================================================
--- team/russell/bindings/bindings/cdr_wrap.c (original)
+++ team/russell/bindings/bindings/cdr_wrap.c Sat Feb 9 16:19:04 2008
@@ -2478,6 +2478,7 @@
------------------------------------------------*/
#define SWIG_init init_cdr
+void SWIG_init(void);
#define SWIG_name "_cdr"
#define SWIGVERSION 0x010333
@@ -5000,8 +5001,6 @@
* Partial Init method
* -----------------------------------------------------------------------------*/
-void SWIG_init(void);
-
#ifdef __cplusplus
extern "C"
#endif
Modified: team/russell/bindings/bindings/examples/cdr_test_vars.py
URL: http://svn.digium.com/view/asterisk/team/russell/bindings/bindings/examples/cdr_test_vars.py?view=diff&rev=103274&r1=103273&r2=103274
==============================================================================
--- team/russell/bindings/bindings/examples/cdr_test_vars.py (original)
+++ team/russell/bindings/bindings/examples/cdr_test_vars.py Sat Feb 9 16:19:04 2008
@@ -2,8 +2,10 @@
Copyright (C) 2008, Digium, Inc.
Russell Bryant <russell at digium.com>
-This python module re-implements the functionality of cdr_csv or cdr_custom
-in python using the cdr_python module.
+This module demonstrates how to access custom CDR variables. You can:
+ - get the number of custom variables
+ - access the name or value of the variable by index
+ - get the value of a variable by name
'''
import cdr
Added: team/russell/bindings/bindings/get_swig
URL: http://svn.digium.com/view/asterisk/team/russell/bindings/bindings/get_swig?view=auto&rev=103274
==============================================================================
--- team/russell/bindings/bindings/get_swig (added)
+++ team/russell/bindings/bindings/get_swig Sat Feb 9 16:19:04 2008
@@ -1,0 +1,3 @@
+/\/\*\*\* SWIG_BEGIN \*\*\*\// {printit=1; next}
+/\/\*\*\* SWIG_END \*\*\*\// {if (printit) printit=0;}
+// {if (printit) print}
Propchange: team/russell/bindings/bindings/get_swig
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/russell/bindings/bindings/get_swig
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/russell/bindings/bindings/get_swig
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: team/russell/bindings/bindings/strings-cstrlength-fix.diff1.txt
URL: http://svn.digium.com/view/asterisk/team/russell/bindings/bindings/strings-cstrlength-fix.diff1.txt?view=diff&rev=103274&r1=103273&r2=103274
==============================================================================
--- team/russell/bindings/bindings/strings-cstrlength-fix.diff1.txt (original)
+++ team/russell/bindings/bindings/strings-cstrlength-fix.diff1.txt Sat Feb 9 16:19:04 2008
@@ -1,3 +1,17 @@
+This patch was made against swig 1.3.33. This file generated some bogus C code
+for calculating the length of strings. It made the assumption that the entire
+unused portion of the buffer was zeroed out. This gives Asterisk grief, because
+our string functions are optimized to only write a single '\0' terminating byte
+as opposed to zeroing out the entire buffer like strncpy() does.
+
+The patch could be simplified with strlen(), but was written this way to maintain
+the existing behavior that the code was safe against buffers that contained no
+'\0' terminating byte at all.
+
+Apply this patch to swig before compiling and installing, or else you may see
+some weird string behavior when using the bindings in Asterisk.
+
+
--- strings.swg.orig 2007-10-25 19:05:32.000000000 -0400
+++ strings.swg 2008-02-06 18:33:48.000000000 -0500
@@ -280,9 +280,11 @@
Modified: team/russell/bindings/build_tools/menuselect-deps.in
URL: http://svn.digium.com/view/asterisk/team/russell/bindings/build_tools/menuselect-deps.in?view=diff&rev=103274&r1=103273&r2=103274
==============================================================================
--- team/russell/bindings/build_tools/menuselect-deps.in (original)
+++ team/russell/bindings/build_tools/menuselect-deps.in Sat Feb 9 16:19:04 2008
@@ -37,6 +37,7 @@
SS7=@PBX_SS7@
SSL=@PBX_OPENSSL@
SUPPSERV=@PBX_SUPPSERV@
+SWIG=@PBX_SWIG@
TONEZONE=@PBX_TONEZONE@
UNIXODBC=@PBX_UNIXODBC@
USB=@PBX_USB@
Modified: team/russell/bindings/cdr/cdr_python.c
URL: http://svn.digium.com/view/asterisk/team/russell/bindings/cdr/cdr_python.c?view=diff&rev=103274&r1=103273&r2=103274
==============================================================================
--- team/russell/bindings/cdr/cdr_python.c (original)
+++ team/russell/bindings/cdr/cdr_python.c Sat Feb 9 16:19:04 2008
@@ -29,6 +29,7 @@
/*** MODULEINFO
<depend>python</depend>
+ <depend>swig</depend>
***/
#include "asterisk.h"
@@ -64,7 +65,7 @@
#define PY_CDR_MODS_BUCKETS 1
struct ao2_container *py_cdr_mods;
-/*! Comes from cdr_wrap.c */
+/*! Comes from python_cdr_wrap.c */
void init_cdr(void);
static struct py_cdr_mod *unref_py_cdr_mod(struct py_cdr_mod *py_cdr_mod)
Modified: team/russell/bindings/configure.ac
URL: http://svn.digium.com/view/asterisk/team/russell/bindings/configure.ac?view=diff&rev=103274&r1=103273&r2=103274
==============================================================================
--- team/russell/bindings/configure.ac (original)
+++ team/russell/bindings/configure.ac Sat Feb 9 16:19:04 2008
@@ -151,18 +151,20 @@
AC_SUBST(GNU_LD)
AC_PATH_PROG([AWK], [awk], :)
+AC_PATH_PROG([BASENAME], [basename], :)
+AC_PATH_PROG([COMPRESS], [compress], :)
+AC_PATH_PROG([DIRNAME], [dirname], :)
+AC_PATH_PROG([DOT], [dot], :)
+AC_PATH_PROG([FIND], [find], :)
AC_PATH_PROG([GREP], [grep], :)
-AC_PATH_PROG([FIND], [find], :)
-AC_PATH_PROG([COMPRESS], [compress], :)
-AC_PATH_PROG([BASENAME], [basename], :)
AC_PATH_PROG([ID], [id], :)
-AC_PATH_PROG([DIRNAME], [dirname], :)
+AC_PATH_PROG([KPATHSEA], [kpsewhich], :)
+AC_PATH_PROG([LN], [ln], :)
+AC_PATH_PROG([RUBBER], [rubber], :)
AC_PATH_PROG([SHELL], [sh], :)
-AC_PATH_PROG([LN], [ln], :)
-AC_PATH_PROG([DOT], [dot], :)
+AC_PATH_PROG([SWIG], [swig], :)
AC_PATH_PROG([WGET], [wget], :)
-AC_PATH_PROG([RUBBER], [rubber], :)
-AC_PATH_PROG([KPATHSEA], [kpsewhich], :)
+
if test "${WGET}" != ":" ; then
DOWNLOAD=${WGET}
else
@@ -170,6 +172,13 @@
DOWNLOAD=${FETCH}
fi
AC_SUBST(DOWNLOAD)
+
+if test "${SWIG}" != ":" ; then
+ PBX_SWIG=1
+else
+ PBX_SWIG=0
+fi
+AC_SUBST(PBX_SWIG)
AC_CHECK_TOOL([SOXMIX], [soxmix], [:])
if test "${SOXMIX}" != ":" ; then
Modified: team/russell/bindings/include/asterisk/cdr.h
URL: http://svn.digium.com/view/asterisk/team/russell/bindings/include/asterisk/cdr.h?view=diff&rev=103274&r1=103273&r2=103274
==============================================================================
--- team/russell/bindings/include/asterisk/cdr.h (original)
+++ team/russell/bindings/include/asterisk/cdr.h Sat Feb 9 16:19:04 2008
@@ -1,7 +1,7 @@
/*
* Asterisk -- An open source telephony toolkit.
*
- * Copyright (C) 1999 - 2005, Digium, Inc.
+ * Copyright (C) 1999 - 2008, Digium, Inc.
*
* Mark Spencer <markster at digium.com>
*
@@ -53,6 +53,7 @@
#include "asterisk/channel.h"
#include "asterisk/utils.h"
+/*** SWIG_BEGIN ***/
/*! \brief Responsible for call detail data */
struct ast_cdr {
/*! Caller*ID with text */
@@ -99,6 +100,7 @@
struct ast_cdr *next;
};
+/*** SWIG_END ***/
void ast_cdr_getvar(struct ast_cdr *cdr, const char *name, char **ret, char *workspace, int workspacelen, int recur, int raw);
int ast_cdr_setvar(struct ast_cdr *cdr, const char *name, const char *value, int recur);
Modified: team/russell/bindings/makeopts.in
URL: http://svn.digium.com/view/asterisk/team/russell/bindings/makeopts.in?view=diff&rev=103274&r1=103273&r2=103274
==============================================================================
--- team/russell/bindings/makeopts.in (original)
+++ team/russell/bindings/makeopts.in Sat Feb 9 16:19:04 2008
@@ -24,6 +24,7 @@
DOWNLOAD=@DOWNLOAD@
RUBBER=@RUBBER@
KPATHSEA=@KPATHSEA@
+SWIG=@SWIG@
BUILD_PLATFORM=@BUILD_PLATFORM@
BUILD_CPU=@BUILD_CPU@
More information about the asterisk-commits
mailing list