Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
6a32e98c
提交
6a32e98c
authored
5月 15, 2012
作者:
Mathieu Rene
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add mod_megaco skeleton with basic profile support and a lot of todos for Kapil
上级
67c43a07
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
352 行增加
和
12 行删除
+352
-12
install-sh
libs/ldns/install-sh
+18
-11
switch_apr.h
src/include/switch_apr.h
+2
-1
Makefile
src/mod/endpoints/mod_megaco/Makefile
+3
-0
megaco.c
src/mod/endpoints/mod_megaco/megaco.c
+132
-0
mod_megaco.c
src/mod/endpoints/mod_megaco/mod_megaco.c
+141
-0
mod_megaco.h
src/mod/endpoints/mod_megaco/mod_megaco.h
+56
-0
没有找到文件。
libs/ldns/install-sh
浏览文件 @
6a32e98c
#!/bin/sh
# install - install a program, script, or datafile
scriptversion
=
20
09-04-28
.21
;
# UTC
scriptversion
=
20
11-01-19
.21
;
# UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
...
...
@@ -156,6 +156,10 @@ while test $# -ne 0; do
-s
)
stripcmd
=
$stripprog
;;
-t
)
dst_arg
=
$2
# Protect names problematic for `test' and other utilities.
case
$dst_arg
in
-
*
|
[=
\(\)
!]
)
dst_arg
=
./
$dst_arg
;;
esac
shift
;;
-T
)
no_target_directory
=
true
;;
...
...
@@ -186,6 +190,10 @@ if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
fi
shift
# arg
dst_arg
=
$arg
# Protect names problematic for `test' and other utilities.
case
$dst_arg
in
-
*
|
[=
\(\)
!]
)
dst_arg
=
./
$dst_arg
;;
esac
done
fi
...
...
@@ -200,7 +208,11 @@ if test $# -eq 0; then
fi
if
test
-z
"
$dir_arg
"
;
then
trap
'(exit $?); exit'
1 2 13 15
do_exit
=
'(exit $ret); exit $ret'
trap
"ret=129;
$do_exit
"
1
trap
"ret=130;
$do_exit
"
2
trap
"ret=141;
$do_exit
"
13
trap
"ret=143;
$do_exit
"
15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
...
...
@@ -228,9 +240,9 @@ fi
for
src
do
# Protect names
starting with `-'
.
# Protect names
problematic for `test' and other utilities
.
case
$src
in
-
*
)
src
=
./
$src
;;
-
*
|
[=
\(\)
!]
)
src
=
./
$src
;;
esac
if
test
-n
"
$dir_arg
"
;
then
...
...
@@ -252,12 +264,7 @@ do
echo
"
$0
: no destination specified."
>
&2
exit
1
fi
dst
=
$dst_arg
# Protect names starting with `-'.
case
$dst
in
-
*
)
dst
=
./
$dst
;;
esac
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
...
...
@@ -385,7 +392,7 @@ do
case
$dstdir
in
/
*
)
prefix
=
'/'
;;
-
*
)
prefix
=
'./'
;;
[
-
=
\(\)
!]
*
)
prefix
=
'./'
;;
*
)
prefix
=
''
;;
esac
...
...
@@ -403,7 +410,7 @@ do
for
d
do
test
-z
"
$d
"
&&
continue
test
X
"
$d
"
=
X
&&
continue
prefix
=
$prefix$d
if
test
-d
"
$prefix
"
;
then
...
...
src/include/switch_apr.h
浏览文件 @
6a32e98c
...
...
@@ -773,7 +773,8 @@ typedef gid_t switch_gid_t;
typedef
ino_t
switch_ino_t
;
typedef
dev_t
switch_dev_t
;
#endif
typedef
off64_t
switch_off_t
;
typedef
off_t
switch_off_t
;
/**
* Structure for referencing file information
...
...
src/mod/endpoints/mod_megaco/Makefile
0 → 100644
浏览文件 @
6a32e98c
BASE
=
../../../..
LOCAL_OBJS
=
megaco.o
include
$(BASE)/build/modmake.rules
src/mod/endpoints/mod_megaco/megaco.c
0 → 100644
浏览文件 @
6a32e98c
/*
* Copyright (c) 2012, Sangoma Technologies
* Mathieu Rene <mrene@avgs.ca>
* All rights reserved.
*
* <Insert license here>
*/
#include "mod_megaco.h"
megaco_profile_t
*
megaco_profile_locate
(
const
char
*
name
)
{
megaco_profile_t
*
profile
=
switch_core_hash_find_rdlock
(
megaco_globals
.
profile_hash
,
name
,
megaco_globals
.
profile_rwlock
);
if
(
profile
)
{
if
(
switch_thread_rwlock_tryrdlock
(
profile
->
rwlock
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Profile %s is locked
\n
"
,
name
);
profile
=
NULL
;
}
}
return
profile
;
}
void
megaco_profile_release
(
megaco_profile_t
*
profile
)
{
switch_thread_rwlock_unlock
(
profile
->
rwlock
);
}
static
switch_status_t
config_profile
(
megaco_profile_t
*
profile
,
switch_bool_t
reload
)
{
switch_xml_t
cfg
,
xml
,
x_profiles
,
x_profile
,
x_settings
;
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
switch_event_t
*
event
=
NULL
;
int
count
;
const
char
*
file
=
"megaco.conf"
;
if
(
!
(
xml
=
switch_xml_open_cfg
(
file
,
&
cfg
,
NULL
)))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Could not open %s
\n
"
,
file
);
goto
done
;
}
if
(
!
(
x_profiles
=
switch_xml_child
(
cfg
,
"profiles"
)))
{
goto
done
;
}
for
(
x_profile
=
switch_xml_child
(
x_profiles
,
"profile"
);
x_profile
;
x_profile
=
x_profile
->
next
)
{
const
char
*
name
=
switch_xml_attr_soft
(
x_profile
,
"name"
);
if
(
strcmp
(
name
,
profile
->
name
))
{
continue
;
}
if
(
!
(
x_settings
=
switch_xml_child
(
x_profile
,
"settings"
)))
{
goto
done
;
}
count
=
switch_event_import_xml
(
switch_xml_child
(
x_settings
,
"param"
),
"name"
,
"value"
,
&
event
);
// status = switch_xml_config_parse_event(event, count, reload, instructions);
/* TODO: Initialize stack configuration */
}
done:
if
(
xml
)
{
switch_xml_free
(
xml
);
}
if
(
event
)
{
switch_event_destroy
(
&
event
);
}
return
status
;
}
switch_status_t
megaco_profile_start
(
const
char
*
profilename
)
{
switch_memory_pool_t
*
pool
;
megaco_profile_t
*
profile
;
switch_assert
(
profilename
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"Starting profile: %s
\n
"
,
profilename
);
switch_core_new_memory_pool
(
&
pool
);
profile
=
switch_core_alloc
(
pool
,
sizeof
(
*
profile
));
profile
->
pool
=
pool
;
profile
->
name
=
switch_core_strdup
(
pool
,
profilename
);
switch_thread_rwlock_create
(
&
profile
->
rwlock
,
pool
);
/* TODO: Kapil: Insert stack per-interface startup code here */
switch_core_hash_insert_wrlock
(
megaco_globals
.
profile_hash
,
profile
->
name
,
profile
,
megaco_globals
.
profile_rwlock
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"Started profile: %s
\n
"
,
profile
->
name
);
return
SWITCH_STATUS_SUCCESS
;
fail:
switch_core_destroy_memory_pool
(
&
pool
);
return
SWITCH_STATUS_FALSE
;
}
switch_status_t
megaco_profile_destroy
(
megaco_profile_t
**
profile
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"Stopping profile: %s
\n
"
,
(
*
profile
)
->
name
);
switch_thread_rwlock_wrlock
((
*
profile
)
->
rwlock
);
/* TODO: Kapil: Insert stack per-interface shutdown code here */
switch_thread_rwlock_unlock
((
*
profile
)
->
rwlock
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"Stopped profile: %s
\n
"
,
(
*
profile
)
->
name
);
switch_core_hash_delete_wrlock
(
megaco_globals
.
profile_hash
,
(
*
profile
)
->
name
,
megaco_globals
.
profile_rwlock
);
switch_core_destroy_memory_pool
(
&
(
*
profile
)
->
pool
);
return
SWITCH_STATUS_SUCCESS
;
}
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
*/
src/mod/endpoints/mod_megaco/mod_megaco.c
0 → 100644
浏览文件 @
6a32e98c
/*
* Copyright (c) 2012, Sangoma Technologies
* Mathieu Rene <mrene@avgs.ca>
* All rights reserved.
*
* <Insert license here>
*/
#include "mod_megaco.h"
struct
megaco_globals
megaco_globals
;
SWITCH_MODULE_LOAD_FUNCTION
(
mod_megaco_load
);
SWITCH_MODULE_SHUTDOWN_FUNCTION
(
mod_megaco_shutdown
);
SWITCH_MODULE_DEFINITION
(
mod_megaco
,
mod_megaco_load
,
mod_megaco_shutdown
,
NULL
);
#define MEGACO_FUNCTION_SYNTAX "profile [name] [start | stop]"
SWITCH_STANDARD_API
(
megaco_function
)
{
int
argc
;
char
*
argv
[
10
];
char
*
dup
=
NULL
;
if
(
zstr
(
cmd
))
{
goto
usage
;
}
dup
=
strdup
(
cmd
);
argc
=
switch_split
(
dup
,
' '
,
argv
);
if
(
argc
<
1
||
zstr
(
argv
[
0
]))
{
goto
usage
;
}
if
(
!
strcmp
(
argv
[
0
],
"profile"
))
{
if
(
zstr
(
argv
[
1
])
||
zstr
(
argv
[
2
]))
{
goto
usage
;
}
if
(
!
strcmp
(
argv
[
2
],
"start"
))
{
megaco_profile_t
*
profile
=
megaco_profile_locate
(
argv
[
1
]);
if
(
profile
)
{
megaco_profile_release
(
profile
);
stream
->
write_function
(
stream
,
"-ERR Profile %s is already started
\n
"
,
argv
[
2
]);
}
else
{
megaco_profile_start
(
argv
[
1
]);
stream
->
write_function
(
stream
,
"+OK
\n
"
);
}
}
else
if
(
!
strcmp
(
argv
[
2
],
"stop"
))
{
megaco_profile_t
*
profile
=
megaco_profile_locate
(
argv
[
1
]);
if
(
profile
)
{
megaco_profile_release
(
profile
);
megaco_profile_destroy
(
&
profile
);
stream
->
write_function
(
stream
,
"+OK
\n
"
);
}
else
{
stream
->
write_function
(
stream
,
"-ERR No such profile
\n
"
);
}
}
}
goto
done
;
usage
:
stream
->
write_function
(
stream
,
"-ERR Usage: "
MEGACO_FUNCTION_SYNTAX
"
\n
"
);
done
:
switch_safe_free
(
dup
);
return
SWITCH_STATUS_SUCCESS
;
}
static
switch_status_t
console_complete_hashtable
(
switch_hash_t
*
hash
,
const
char
*
line
,
const
char
*
cursor
,
switch_console_callback_match_t
**
matches
)
{
switch_hash_index_t
*
hi
;
void
*
val
;
const
void
*
vvar
;
switch_console_callback_match_t
*
my_matches
=
NULL
;
switch_status_t
status
=
SWITCH_STATUS_FALSE
;
for
(
hi
=
switch_hash_first
(
NULL
,
hash
);
hi
;
hi
=
switch_hash_next
(
hi
))
{
switch_hash_this
(
hi
,
&
vvar
,
NULL
,
&
val
);
switch_console_push_match
(
&
my_matches
,
(
const
char
*
)
vvar
);
}
if
(
my_matches
)
{
*
matches
=
my_matches
;
status
=
SWITCH_STATUS_SUCCESS
;
}
return
status
;
}
static
switch_status_t
list_profiles
(
const
char
*
line
,
const
char
*
cursor
,
switch_console_callback_match_t
**
matches
)
{
switch_status_t
status
;
switch_thread_rwlock_rdlock
(
megaco_globals
.
profile_rwlock
);
status
=
console_complete_hashtable
(
megaco_globals
.
profile_hash
,
line
,
cursor
,
matches
);
switch_thread_rwlock_unlock
(
megaco_globals
.
profile_rwlock
);
return
status
;
}
SWITCH_MODULE_LOAD_FUNCTION
(
mod_megaco_load
)
{
switch_api_interface_t
*
api_interface
;
memset
(
&
megaco_globals
,
0
,
sizeof
(
megaco_globals
));
megaco_globals
.
pool
=
pool
;
*
module_interface
=
switch_loadable_module_create_module_interface
(
pool
,
modname
);
switch_core_hash_init
(
&
megaco_globals
.
profile_hash
,
pool
);
switch_thread_rwlock_create
(
&
megaco_globals
.
profile_rwlock
,
pool
);
SWITCH_ADD_API
(
api_interface
,
"megaco"
,
"megaco"
,
megaco_function
,
MEGACO_FUNCTION_SYNTAX
);
switch_console_set_complete
(
"add megaco profile ::megaco::list_profiles start"
);
switch_console_set_complete
(
"add megaco profile ::megaco::list_profiles stop"
);
switch_console_add_complete_func
(
"::megaco::list_profiles"
,
list_profiles
);
/* TODO: Kapil: Insert stack global startup code here */
return
SWITCH_STATUS_SUCCESS
;
}
SWITCH_MODULE_SHUTDOWN_FUNCTION
(
mod_megaco_shutdown
)
{
/* TODO: Kapil: Insert stack global shutdown code here */
return
SWITCH_STATUS_SUCCESS
;
}
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
*/
src/mod/endpoints/mod_megaco/mod_megaco.h
0 → 100644
浏览文件 @
6a32e98c
/*
* Copyright (c) 2012, Sangoma Technologies
* Mathieu Rene <mrene@avgs.ca>
* All rights reserved.
*
* <Insert license here>
*/
#ifndef MOD_MEGACO_H
#define MOD_MEGACO_H
#include <switch.h>
struct
megaco_globals
{
switch_memory_pool_t
*
pool
;
switch_hash_t
*
profile_hash
;
switch_thread_rwlock_t
*
profile_rwlock
;
/* TODO: Kapil: add global variables here */
};
extern
struct
megaco_globals
megaco_globals
;
/* < defined in mod_megaco.c */
typedef
enum
{
PF_RUNNING
=
(
1
<<
0
)
}
megaco_profile_flags_t
;
typedef
struct
megaco_profile_s
{
char
*
name
;
switch_memory_pool_t
*
pool
;
switch_thread_rwlock_t
*
rwlock
;
/* < Reference counting rwlock */
megaco_profile_flags_t
flags
;
/* TODO: Kapil: Insert interface-specific stack elements here */
}
megaco_profile_t
;
megaco_profile_t
*
megaco_profile_locate
(
const
char
*
name
);
void
megaco_profile_release
(
megaco_profile_t
*
profile
);
switch_status_t
megaco_profile_start
(
const
char
*
profilename
);
switch_status_t
megaco_profile_destroy
(
megaco_profile_t
**
profile
);
#endif
/* MOD_MEGACO_H */
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4:
*/
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论