[Freeswitch-svn] [commit] r2598 - in freeswitch/branches/docelmo/trunk: . src/mod/languages/mod_php src/mod/languages/mod_python

Freeswitch SVN docelmo at freeswitch.org
Sat Sep 9 07:25:23 EDT 2006


Author: docelmo
Date: Sat Sep  9 07:25:23 2006
New Revision: 2598

Modified:
   freeswitch/branches/docelmo/trunk/modules.conf.in
   freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/php_freeswitch.h
   freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/switch_swig.c
   freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/switch_swig_wrap.c
   freeswitch/branches/docelmo/trunk/src/mod/languages/mod_python/Makefile
   freeswitch/branches/docelmo/trunk/src/mod/languages/mod_python/mod_python.c
   freeswitch/branches/docelmo/trunk/src/mod/languages/mod_python/switch_swig.c
   freeswitch/branches/docelmo/trunk/src/mod/languages/mod_python/switch_swig_wrap.c

Log:
Python is ready for testing

Modified: freeswitch/branches/docelmo/trunk/modules.conf.in
==============================================================================
--- freeswitch/branches/docelmo/trunk/modules.conf.in	(original)
+++ freeswitch/branches/docelmo/trunk/modules.conf.in	Sat Sep  9 07:25:23 2006
@@ -34,5 +34,6 @@
 formats/mod_sndfile
 #languages/mod_perl
 #languages/mod_spidermonkey
+#languages/mod_php
 timers/mod_softtimer
 #xml_int/mod_xml_rpc

Modified: freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/php_freeswitch.h
==============================================================================
--- freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/php_freeswitch.h	(original)
+++ freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/php_freeswitch.h	Sat Sep  9 07:25:23 2006
@@ -56,8 +56,8 @@
 ZEND_NAMED_FUNCTION(_wrap_fs_loadable_module_init);
 ZEND_NAMED_FUNCTION(_wrap_fs_loadable_module_shutdown);
 ZEND_NAMED_FUNCTION(_wrap_fs_console_loop);
-ZEND_NAMED_FUNCTION(_wrap_fs_console_clean);
-ZEND_NAMED_FUNCTION(_wrap_fs_console_log);
+ZEND_NAMED_FUNCTION(_wrap_fs_consol_log);
+ZEND_NAMED_FUNCTION(_wrap_fs_consol_clean);
 ZEND_NAMED_FUNCTION(_wrap_fs_core_session_locate);
 ZEND_NAMED_FUNCTION(_wrap_fs_channel_answer);
 ZEND_NAMED_FUNCTION(_wrap_fs_channel_pre_answer);

Modified: freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/switch_swig.c
==============================================================================
--- freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/switch_swig.c	(original)
+++ freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/switch_swig.c	Sat Sep  9 07:25:23 2006
@@ -86,7 +86,7 @@
 	return 0;
 }
 
-void fs_console_log(char *level_str, char *msg)
+void fs_consol_log(char *level_str, char *msg)
 {
         switch_log_level_t level = SWITCH_LOG_DEBUG;
         if (level_str) {
@@ -96,21 +96,11 @@
         switch_log_printf(SWITCH_CHANNEL_LOG, level, msg);
 }
 	
-void fs_console_clean(char *msg)
+void fs_consol_clean(char *msg)
 {
         switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, msg);
 }
 
-void fs_console_log(char *msg)
-{
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, msg);
-}
-
-void fs_console_clean(char *msg)
-{
-	switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, msg);
-}
-
 switch_core_session_t *fs_core_session_locate(char *uuid)
 {
 	switch_core_session_t *session;
@@ -274,8 +264,8 @@
         if ((var = switch_channel_get_variable(caller_channel, "call_timeout"))) {
                 timelimit = atoi(var);
         }
-        switch_ivr_originate(session, &peer_session, data, timelimit, NULL, NULL, NULL, NULL)
-        if (switch_ivr_originate(session, &peer_session, data, timelimit, NULL, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
+        
+        if (switch_ivr_originate(session, &peer_session, bridgeto, timelimit, NULL, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n");
                 switch_channel_hangup(caller_channel, SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL);
                 return;

Modified: freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/switch_swig_wrap.c
==============================================================================
--- freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/switch_swig_wrap.c	(original)
+++ freeswitch/branches/docelmo/trunk/src/mod/languages/mod_php/switch_swig_wrap.c	Sat Sep  9 07:25:23 2006
@@ -967,8 +967,8 @@
   ZEND_NAMED_FE(fs_loadable_module_init,_wrap_fs_loadable_module_init, NULL)
   ZEND_NAMED_FE(fs_loadable_module_shutdown,_wrap_fs_loadable_module_shutdown, NULL)
   ZEND_NAMED_FE(fs_console_loop,_wrap_fs_console_loop, NULL)
-  ZEND_NAMED_FE(fs_console_clean,_wrap_fs_console_clean, NULL)
-  ZEND_NAMED_FE(fs_console_log,_wrap_fs_console_log, NULL)
+  ZEND_NAMED_FE(fs_consol_log,_wrap_fs_consol_log, NULL)
+  ZEND_NAMED_FE(fs_consol_clean,_wrap_fs_consol_clean, NULL)
   ZEND_NAMED_FE(fs_core_session_locate,_wrap_fs_core_session_locate, NULL)
   ZEND_NAMED_FE(fs_channel_answer,_wrap_fs_channel_answer, NULL)
   ZEND_NAMED_FE(fs_channel_pre_answer,_wrap_fs_channel_pre_answer, NULL)
@@ -1179,7 +1179,7 @@
 }
 
 
-ZEND_NAMED_FUNCTION(_wrap_fs_console_log__SWIG_0) {
+ZEND_NAMED_FUNCTION(_wrap_fs_consol_log) {
   char *arg1 = (char *) 0 ;
   char *arg2 = (char *) 0 ;
   zval **args[2];
@@ -1201,7 +1201,7 @@
     arg2 = (char *) Z_STRVAL_PP(args[1]);
     /*@SWIG@*/;
   }
-  fs_console_log(arg1,arg2);
+  fs_consol_log(arg1,arg2);
   
   return;
 fail:
@@ -1209,7 +1209,7 @@
 }
 
 
-ZEND_NAMED_FUNCTION(_wrap_fs_console_clean) {
+ZEND_NAMED_FUNCTION(_wrap_fs_consol_clean) {
   char *arg1 = (char *) 0 ;
   zval **args[1];
   
@@ -1224,70 +1224,10 @@
     arg1 = (char *) Z_STRVAL_PP(args[0]);
     /*@SWIG@*/;
   }
-  fs_console_clean(arg1);
+  fs_consol_clean(arg1);
   
   return;
 fail:
-  zend_error(ErrorCode(),ErrorMsg());
-}
-
-
-ZEND_NAMED_FUNCTION(_wrap_fs_console_log__SWIG_1) {
-  char *arg1 = (char *) 0 ;
-  zval **args[1];
-  
-  SWIG_ResetError();
-  if(((ZEND_NUM_ARGS() )!= 1) || (zend_get_parameters_array_ex(1, args)!= SUCCESS)) {
-    WRONG_PARAM_COUNT;
-  }
-  
-  {
-    /*@SWIG:CONVERT_STRING_IN@*/
-    convert_to_string_ex(args[0]);
-    arg1 = (char *) Z_STRVAL_PP(args[0]);
-    /*@SWIG@*/;
-  }
-  fs_console_log(arg1);
-  
-  return;
-fail:
-  zend_error(ErrorCode(),ErrorMsg());
-}
-
-
-ZEND_NAMED_FUNCTION(_wrap_fs_console_log) {
-  int argc;
-  zval **argv[2];
-  int ii;
-  
-  argc = ZEND_NUM_ARGS();
-  zend_get_parameters_array_ex(argc,argv);
-  if (argc == 1) {
-    int _v;
-    _v = (Z_TYPE_PP(argv[0]) == IS_LONG ||
-      Z_TYPE_PP(argv[0]) == IS_DOUBLE ||
-      Z_TYPE_PP(argv[0]) == IS_STRING) ? 1 : 0; 
-    if (_v) {
-      return _wrap_fs_console_log__SWIG_1(INTERNAL_FUNCTION_PARAM_PASSTHRU);
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    _v = (Z_TYPE_PP(argv[0]) == IS_LONG ||
-      Z_TYPE_PP(argv[0]) == IS_DOUBLE ||
-      Z_TYPE_PP(argv[0]) == IS_STRING) ? 1 : 0; 
-    if (_v) {
-      _v = (Z_TYPE_PP(argv[1]) == IS_LONG ||
-        Z_TYPE_PP(argv[1]) == IS_DOUBLE ||
-        Z_TYPE_PP(argv[1]) == IS_STRING) ? 1 : 0; 
-      if (_v) {
-        return _wrap_fs_console_log__SWIG_0(INTERNAL_FUNCTION_PARAM_PASSTHRU);
-      }
-    }
-  }
-  
-  ErrorCode() = E_ERROR;
-  ErrorMsg() = "No matching function for overloaded 'fs_console_log'";
   zend_error(ErrorCode(),ErrorMsg());
 }
 

Modified: freeswitch/branches/docelmo/trunk/src/mod/languages/mod_python/Makefile
==============================================================================
--- freeswitch/branches/docelmo/trunk/src/mod/languages/mod_python/Makefile	(original)
+++ freeswitch/branches/docelmo/trunk/src/mod/languages/mod_python/Makefile	Sat Sep  9 07:25:23 2006
@@ -1,5 +1,5 @@
 LCFLAGS=-fPIC -DZTS -DPTHREADS -Xlinker -export-dynamic
-CFLAGS += `-fPIC`
+CFLAGS += -fPIC -I/usr/local/include/python2.4/
 PYMOD=freeswitch
 
 

Modified: freeswitch/branches/docelmo/trunk/src/mod/languages/mod_python/mod_python.c
==============================================================================
--- freeswitch/branches/docelmo/trunk/src/mod/languages/mod_python/mod_python.c	(original)
+++ freeswitch/branches/docelmo/trunk/src/mod/languages/mod_python/mod_python.c	Sat Sep  9 07:25:23 2006
@@ -42,8 +42,20 @@
 #include <switch.h>
 
 const char modname[] = "mod_python";
+static int numargs=0;
 
+static PyObject* emb_numargs(PyObject *self, PyObject *args)
+{
+    if(!PyArg_ParseTuple(args, ":numargs"))
+        return NULL;
+    return Py_BuildValue("i", numargs);
+}
 
+static PyMethodDef EmbMethods[] = {
+    {"numargs", emb_numargs, METH_VARARGS,
+     "Return the number of arguments received by the process."},
+    {NULL, NULL, 0, NULL}
+};
 
 static void python_function(switch_core_session_t *session, char *data)
 {
@@ -51,12 +63,12 @@
 	uint32_t ulen = strlen(uuid);
 	uint32_t len = strlen((char *) data) + ulen + 2;
 	char *mydata = switch_core_session_alloc(session, len);
-	int argc;
+	int argc, i;
 	char *argv[5];
 	char python_code[1024]; 
-	void*** tsrm_ls = NULL;
+//	void*** tsrm_ls = NULL;
 
-	PyObject *pName, *pModule, *pDict, *pFunc;
+	PyObject *pName, *pModule, *pFunc;
     	PyObject *pArgs, *pValue;
 
 
@@ -73,6 +85,7 @@
 
 	
     Py_Initialize();
+    numargs = argc;
     Py_InitModule("emb", EmbMethods);
     pName = PyString_FromString(data);
     /* Error checking of pName left out */
@@ -92,7 +105,7 @@
                     Py_DECREF(pArgs);
                     Py_DECREF(pModule);
                     switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot convert argument\n");
-                    return 1;
+                    
                 }
                 /* pValue reference stolen here: */
                 PyTuple_SetItem(pArgs, i, pValue);
@@ -108,7 +121,7 @@
                 Py_DECREF(pModule);
                 PyErr_Print();
                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Call failed\n");
-                return 1;
+                
             }
         }
         else {
@@ -122,10 +135,10 @@
     else {
         PyErr_Print();
         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to load \"%s\"\n", argv[1]);
-        return 1;
+        
     }
     Py_Finalize();
-    return 0;
+    
 
 }
 
@@ -176,16 +189,3 @@
 
 
 /* Return the number of arguments of the application command line */
-static PyObject*
-emb_numargs(PyObject *self, PyObject *args)
-{
-    if(!PyArg_ParseTuple(args, ":numargs"))
-        return NULL;
-    return Py_BuildValue("i", numargs);
-}
-
-static PyMethodDef EmbMethods[] = {
-    {"numargs", emb_numargs, METH_VARARGS,
-     "Return the number of arguments received by the process."},
-    {NULL, NULL, 0, NULL}
-};

Modified: freeswitch/branches/docelmo/trunk/src/mod/languages/mod_python/switch_swig.c
==============================================================================
--- freeswitch/branches/docelmo/trunk/src/mod/languages/mod_python/switch_swig.c	(original)
+++ freeswitch/branches/docelmo/trunk/src/mod/languages/mod_python/switch_swig.c	Sat Sep  9 07:25:23 2006
@@ -86,7 +86,7 @@
 	return 0;
 }
 
-void fs_console_log(char *level_str, char *msg)
+void fs_consol_log(char *level_str, char *msg)
 {
         switch_log_level_t level = SWITCH_LOG_DEBUG;
         if (level_str) {
@@ -96,21 +96,11 @@
         switch_log_printf(SWITCH_CHANNEL_LOG, level, msg);
 }
 	
-void fs_console_clean(char *msg)
+void fs_consol_clean(char *msg)
 {
         switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, msg);
 }
 
-void fs_console_log(char *msg)
-{
-	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, msg);
-}
-
-void fs_console_clean(char *msg)
-{
-	switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG, msg);
-}
-
 switch_core_session_t *fs_core_session_locate(char *uuid)
 {
 	switch_core_session_t *session;
@@ -274,8 +264,8 @@
         if ((var = switch_channel_get_variable(caller_channel, "call_timeout"))) {
                 timelimit = atoi(var);
         }
-        switch_ivr_originate(session, &peer_session, data, timelimit, NULL, NULL, NULL, NULL)
-        if (switch_ivr_originate(session, &peer_session, data, timelimit, NULL, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
+        
+        if (switch_ivr_originate(session, &peer_session, bridgeto, timelimit, NULL, NULL, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create Outgoing Channel!\n");
                 switch_channel_hangup(caller_channel, SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL);
                 return;

Modified: freeswitch/branches/docelmo/trunk/src/mod/languages/mod_python/switch_swig_wrap.c
==============================================================================
--- freeswitch/branches/docelmo/trunk/src/mod/languages/mod_python/switch_swig_wrap.c	(original)
+++ freeswitch/branches/docelmo/trunk/src/mod/languages/mod_python/switch_swig_wrap.c	Sat Sep  9 07:25:23 2006
@@ -2824,7 +2824,7 @@
 }
 
 
-SWIGINTERN PyObject *_wrap_fs_console_log__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_fs_consol_log(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   char *arg1 = (char *) 0 ;
   char *arg2 = (char *) 0 ;
@@ -2837,18 +2837,18 @@
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:fs_console_log",&obj0,&obj1)) SWIG_fail;
+  if (!PyArg_ParseTuple(args,(char *)"OO:fs_consol_log",&obj0,&obj1)) SWIG_fail;
   res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_console_log" "', argument " "1"" of type '" "char *""'");
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_consol_log" "', argument " "1"" of type '" "char *""'");
   }
   arg1 = buf1;
   res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fs_console_log" "', argument " "2"" of type '" "char *""'");
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "fs_consol_log" "', argument " "2"" of type '" "char *""'");
   }
   arg2 = buf2;
-  fs_console_log(arg1,arg2);
+  fs_consol_log(arg1,arg2);
   resultobj = SWIG_Py_Void();
   if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
   if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
@@ -2860,7 +2860,7 @@
 }
 
 
-SWIGINTERN PyObject *_wrap_fs_console_clean(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_fs_consol_clean(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   char *arg1 = (char *) 0 ;
   int res1 ;
@@ -2868,13 +2868,13 @@
   int alloc1 = 0 ;
   PyObject * obj0 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:fs_console_clean",&obj0)) SWIG_fail;
+  if (!PyArg_ParseTuple(args,(char *)"O:fs_consol_clean",&obj0)) SWIG_fail;
   res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_console_clean" "', argument " "1"" of type '" "char *""'");
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_consol_clean" "', argument " "1"" of type '" "char *""'");
   }
   arg1 = buf1;
-  fs_console_clean(arg1);
+  fs_consol_clean(arg1);
   resultobj = SWIG_Py_Void();
   if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
   return resultobj;
@@ -2884,67 +2884,6 @@
 }
 
 
-SWIGINTERN PyObject *_wrap_fs_console_log__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  char *arg1 = (char *) 0 ;
-  int res1 ;
-  char *buf1 = 0 ;
-  int alloc1 = 0 ;
-  PyObject * obj0 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:fs_console_log",&obj0)) SWIG_fail;
-  res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "fs_console_log" "', argument " "1"" of type '" "char *""'");
-  }
-  arg1 = buf1;
-  fs_console_log(arg1);
-  resultobj = SWIG_Py_Void();
-  if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
-  return resultobj;
-fail:
-  if (alloc1 == SWIG_NEWOBJ) free((char*)buf1);
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_fs_console_log(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[3];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = PyObject_Length(args);
-  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 1) {
-    int _v;
-    int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      return _wrap_fs_console_log__SWIG_1(self, args);
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    int res = SWIG_AsCharPtrAndSize(argv[0], 0, NULL, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsCharPtrAndSize(argv[1], 0, NULL, 0);
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        return _wrap_fs_console_log__SWIG_0(self, args);
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"No matching function for overloaded 'fs_console_log'");
-  return NULL;
-}
-
-
 SWIGINTERN PyObject *_wrap_fs_core_session_locate(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   char *arg1 = (char *) 0 ;
@@ -3835,8 +3774,8 @@
 	 { (char *)"fs_loadable_module_init", _wrap_fs_loadable_module_init, METH_VARARGS, NULL},
 	 { (char *)"fs_loadable_module_shutdown", _wrap_fs_loadable_module_shutdown, METH_VARARGS, NULL},
 	 { (char *)"fs_console_loop", _wrap_fs_console_loop, METH_VARARGS, NULL},
-	 { (char *)"fs_console_clean", _wrap_fs_console_clean, METH_VARARGS, NULL},
-	 { (char *)"fs_console_log", _wrap_fs_console_log, METH_VARARGS, NULL},
+	 { (char *)"fs_consol_log", _wrap_fs_consol_log, METH_VARARGS, NULL},
+	 { (char *)"fs_consol_clean", _wrap_fs_consol_clean, METH_VARARGS, NULL},
 	 { (char *)"fs_core_session_locate", _wrap_fs_core_session_locate, METH_VARARGS, NULL},
 	 { (char *)"fs_channel_answer", _wrap_fs_channel_answer, METH_VARARGS, NULL},
 	 { (char *)"fs_channel_pre_answer", _wrap_fs_channel_pre_answer, METH_VARARGS, NULL},



More information about the Freeswitch-svn mailing list