提交 3e6f072b authored 作者: Anthony Minessale's avatar Anthony Minessale

initial checkin of mod_php (don't get too excited)

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2558 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 086676f6
CFLAGS += -I/usr/local/include/php/TSRM -I/usr/local/include/php/main/ -I/usr/local/include/php/Zend/ -I/usr/local/include/php/
PHPMOD=freeswitch
all: depends $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(PHPMOD).$(DYNAMIC_LIB_EXTEN)
depends:
%.o: %.c
$(CC) -fPIC $(CFLAGS) -c $< -o $@
reswig:
rm -f switch_swig_wrap.c config.m4 CREDITS *$(PHPMOD)*
swig -lswitch_swig.i -ignoremissing -DMULTIPLICITY -php -module $(PHPMOD) switch_swig.c
patch -p0 -i fix.diff
switch_swig_wrap.o: switch_swig_wrap.c
$(CC) -w $(CFLAGS) -c $< -o $@
$(PHPMOD).$(DYNAMIC_LIB_EXTEN): $(MODNAME).$(DYNAMIC_LIB_EXTEN) switch_swig_wrap.o switch_swig.o
$(CC) $(SOLINK) -o php_$(PHPMOD).$(DYNAMIC_LIB_EXTEN) switch_swig_wrap.o switch_swig.o $(LDFLAGS)
$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c $(MODNAME).o $(OBJS)
$(CC) -fPIC $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(MODNAME).o $(OBJS) $(LDFLAGS)
clean:
rm -fr *.$(DYNAMIC_LIB_EXTEN) *.o *~
install:
cp -f $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(PREFIX)/mod
--- switch_swig_wrap.c 2006-09-07 14:16:42.000000000 -0400
+++ fix.c 2006-09-07 14:16:29.000000000 -0400
@@ -284,6 +284,7 @@
#include <string.h>
+#include "switch.h"
#ifdef __cplusplus
extern "C" {
<?php
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.29
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
* changes to this file unless you know what you are doing--modify the SWIG
* interface file instead.
* ----------------------------------------------------------------------------- */
global $FREESWITCH_LOADED__;
if ($FREESWITCH_LOADED__) return;
$FREESWITCH_LOADED__ = true;
/* if our extension has not been loaded, do what we can */
if (!extension_loaded("php_freeswitch")) {
if (!dl("php_freeswitch.so")) return;
}
?>
差异被折叠。
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.29
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
* changes to this file unless you know what you are doing--modify the SWIG
* interface file instead.
* ----------------------------------------------------------------------------- */
/*
+----------------------------------------------------------------------+
| PHP version 4.0 |
+----------------------------------------------------------------------+
| Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available at through the world-wide-web at |
| http://www.php.net/license/2_02.txt. |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: |
| |
+----------------------------------------------------------------------+
*/
#ifndef PHP_FREESWITCH_H
#define PHP_FREESWITCH_H
extern zend_module_entry freeswitch_module_entry;
#define phpext_freeswitch_ptr &freeswitch_module_entry
#ifdef PHP_WIN32
# define PHP_FREESWITCH_API __declspec(dllexport)
#else
# define PHP_FREESWITCH_API
#endif
#ifdef ZTS
#include "TSRM.h"
#endif
PHP_MINIT_FUNCTION(freeswitch);
PHP_MSHUTDOWN_FUNCTION(freeswitch);
PHP_RINIT_FUNCTION(freeswitch);
PHP_RSHUTDOWN_FUNCTION(freeswitch);
PHP_MINFO_FUNCTION(freeswitch);
ZEND_NAMED_FUNCTION(_wrap_fs_core_set_globals);
ZEND_NAMED_FUNCTION(_wrap_fs_core_init);
ZEND_NAMED_FUNCTION(_wrap_fs_core_destroy);
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_log);
ZEND_NAMED_FUNCTION(_wrap_fs_console_clean);
ZEND_NAMED_FUNCTION(_wrap_fs_core_session_locate);
ZEND_NAMED_FUNCTION(_wrap_fs_channel_answer);
ZEND_NAMED_FUNCTION(_wrap_fs_channel_pre_answer);
ZEND_NAMED_FUNCTION(_wrap_fs_channel_hangup);
ZEND_NAMED_FUNCTION(_wrap_fs_channel_set_variable);
ZEND_NAMED_FUNCTION(_wrap_fs_channel_get_variable);
ZEND_NAMED_FUNCTION(_wrap_fs_channel_set_state);
ZEND_NAMED_FUNCTION(_wrap_fs_ivr_play_file);
#endif /* PHP_FREESWITCH_H */
#include <switch.h>
#ifdef __ICC
#pragma warning (disable:1418)
#endif
#ifdef _MSC_VER
#include <php.h>
#pragma comment(lib, PHP_LIB)
#endif
void fs_core_set_globals(void)
{
switch_core_set_globals();
}
int fs_core_init(char *path)
{
switch_status_t status;
const char *err = NULL;
if (switch_strlen_zero(path)) {
path = NULL;
}
status = switch_core_init(path, &err);
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
int fs_core_destroy(void)
{
switch_status_t status;
status = switch_core_destroy();
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
int fs_loadable_module_init(void)
{
return switch_loadable_module_init() == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
int fs_loadable_module_shutdown(void)
{
switch_loadable_module_shutdown();
return 1;
}
int fs_console_loop(void)
{
switch_console_loop();
return 0;
}
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)
{
return switch_core_session_locate(uuid);
}
void fs_channel_answer(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_channel_answer(channel);
}
void fs_channel_pre_answer(switch_core_session_t *session)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_channel_pre_answer(channel);
}
void fs_channel_hangup(switch_core_session_t *session, char *cause)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_channel_hangup(channel, switch_channel_str2cause(cause));
}
void fs_channel_set_variable(switch_core_session_t *session, char *var, char *val)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_channel_set_variable(channel, var, val);
}
void fs_channel_get_variable(switch_core_session_t *session, char *var)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_channel_get_variable(channel, var);
}
void fs_channel_set_state(switch_core_session_t *session, char *state)
{
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_channel_state_t fs_state = switch_channel_get_state(channel);
if ((fs_state = switch_channel_name_state(state)) < CS_HANGUP) {
switch_channel_set_state(channel, fs_state);
}
}
int fs_ivr_play_file(switch_core_session_t *session,
char *file,
char *timer_name,
switch_input_callback_function_t dtmf_callback,
void *buf,
unsigned int buflen)
{
switch_status_t status;
if (switch_strlen_zero(timer_name)) {
timer_name = NULL;
}
status = switch_ivr_play_file(session, NULL, file, timer_name, NULL, NULL, 0);
return status == SWITCH_STATUS_SUCCESS ? 1 : 0;
}
%module fs_elmoscript
%{
#include "switch.h"
%}
%include "/usr/local/freeswitch/include/switch.h"
差异被折叠。
<?
include("freeswitch.php");
fs_core_set_globals();
fs_core_init("");
fs_loadable_module_init();
fs_console_loop();
fs_core_destroy();
?>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论