Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
92b0269c
提交
92b0269c
authored
10月 12, 2007
作者:
Anthony Minessale
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
doh
git-svn-id:
http://svn.freeswitch.org/svn/freeswitch/trunk@5848
d0543943-73ff-0310-b7d9-9358b9ac24b2
上级
5a3c08c2
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
136 行增加
和
0 行删除
+136
-0
mod_spidermonkey_etpan.c
...languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c
+136
-0
没有找到文件。
src/mod/languages/mod_spidermonkey_etpan/mod_spidermonkey_etpan.c
浏览文件 @
92b0269c
...
@@ -37,7 +37,20 @@
...
@@ -37,7 +37,20 @@
static
const
char
modname
[]
=
"etpan"
;
static
const
char
modname
[]
=
"etpan"
;
#define B64BUFFLEN 1024
static
const
char
c64
[
65
]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
static
int
write_buf
(
int
fd
,
char
*
buf
)
{
int
len
=
(
int
)
strlen
(
buf
);
if
(
fd
&&
write
(
fd
,
buf
,
len
)
!=
len
)
{
close
(
fd
);
return
0
;
}
return
1
;
}
/* etpan Object */
/* etpan Object */
/*********************************************************************************/
/*********************************************************************************/
...
@@ -61,7 +74,130 @@ enum etpan_tinyid {
...
@@ -61,7 +74,130 @@ enum etpan_tinyid {
etpan_NAME
etpan_NAME
};
};
static
JSBool
js_email
(
JSContext
*
cx
,
JSObject
*
obj
,
uintN
argc
,
jsval
*
argv
,
jsval
*
rval
)
{
char
*
to
=
NULL
,
*
from
=
NULL
,
*
headers
,
*
body
=
NULL
,
*
file
=
NULL
;
char
*
bound
=
"XXXX_boundary_XXXX"
;
char
filename
[
80
],
buf
[
B64BUFFLEN
];
int
fd
=
0
,
ifd
=
0
;
int
x
=
0
,
y
=
0
,
bytes
=
0
,
ilen
=
0
;
unsigned
int
b
=
0
,
l
=
0
;
unsigned
char
in
[
B64BUFFLEN
];
unsigned
char
out
[
B64BUFFLEN
+
512
];
char
*
path
=
NULL
;
if
(
argc
>
3
&&
(
from
=
JS_GetStringBytes
(
JS_ValueToString
(
cx
,
argv
[
0
])))
&&
(
to
=
JS_GetStringBytes
(
JS_ValueToString
(
cx
,
argv
[
1
])))
&&
(
headers
=
JS_GetStringBytes
(
JS_ValueToString
(
cx
,
argv
[
2
])))
&&
(
body
=
JS_GetStringBytes
(
JS_ValueToString
(
cx
,
argv
[
3
])))
)
{
if
(
argc
>
4
)
{
file
=
JS_GetStringBytes
(
JS_ValueToString
(
cx
,
argv
[
4
]));
}
snprintf
(
filename
,
80
,
"%smail.%ld%04x"
,
SWITCH_GLOBAL_dirs
.
temp_dir
,
time
(
NULL
),
rand
()
&
0xffff
);
if
((
fd
=
open
(
filename
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
0644
)))
{
if
(
file
)
{
path
=
file
;
if
((
ifd
=
open
(
path
,
O_RDONLY
))
<
1
)
{
return
JS_FALSE
;
}
snprintf
(
buf
,
B64BUFFLEN
,
"MIME-Version: 1.0
\n
Content-Type: multipart/mixed; boundary=
\"
%s
\"\n
"
,
bound
);
if
(
!
write_buf
(
fd
,
buf
))
{
return
JS_FALSE
;
}
}
if
(
!
write_buf
(
fd
,
headers
))
return
JS_FALSE
;
if
(
!
write_buf
(
fd
,
"
\n\n
"
))
return
JS_FALSE
;
if
(
file
)
{
snprintf
(
buf
,
B64BUFFLEN
,
"--%s
\n
Content-Type: text/plain
\n\n
"
,
bound
);
if
(
!
write_buf
(
fd
,
buf
))
return
JS_FALSE
;
}
if
(
!
write_buf
(
fd
,
body
))
return
JS_FALSE
;
if
(
file
)
{
snprintf
(
buf
,
B64BUFFLEN
,
"
\n\n
--%s
\n
Content-Type: application/octet-stream
\n
"
"Content-Transfer-Encoding: base64
\n
"
"Content-Description: Sound attachment.
\n
"
"Content-Disposition: attachment; filename=
\"
%s
\"\n\n
"
,
bound
,
(
argc
>
5
)
?
JS_GetStringBytes
(
JS_ValueToString
(
cx
,
argv
[
5
]))
:
switch_cut_path
(
file
));
if
(
!
write_buf
(
fd
,
buf
))
return
JS_FALSE
;
while
((
ilen
=
read
(
ifd
,
in
,
B64BUFFLEN
)))
{
for
(
x
=
0
;
x
<
ilen
;
x
++
)
{
b
=
(
b
<<
8
)
+
in
[
x
];
l
+=
8
;
while
(
l
>=
6
)
{
out
[
bytes
++
]
=
c64
[(
b
>>
(
l
-=
6
))
%
64
];
if
(
++
y
!=
72
)
continue
;
out
[
bytes
++
]
=
'\n'
;
y
=
0
;
}
}
if
(
write
(
fd
,
&
out
,
bytes
)
!=
bytes
)
{
return
-
1
;
}
else
bytes
=
0
;
}
if
(
l
>
0
)
{
out
[
bytes
++
]
=
c64
[((
b
%
16
)
<<
(
6
-
l
))
%
64
];
}
if
(
l
!=
0
)
while
(
l
<
6
)
{
out
[
bytes
++
]
=
'='
,
l
+=
2
;
}
if
(
write
(
fd
,
&
out
,
bytes
)
!=
bytes
)
{
return
-
1
;
}
}
if
(
file
)
{
snprintf
(
buf
,
B64BUFFLEN
,
"
\n\n
--%s--
\n
.
\n
"
,
bound
);
if
(
!
write_buf
(
fd
,
buf
))
return
JS_FALSE
;
}
}
if
(
fd
)
{
close
(
fd
);
}
if
(
ifd
)
{
close
(
ifd
);
}
snprintf
(
buf
,
B64BUFFLEN
,
"/bin/cat %s | /usr/sbin/sendmail -tf
\"
%s
\"
%s"
,
filename
,
from
,
to
);
if
(
!
system
(
buf
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Unable to execute command: %s
\n
"
,
buf
);
}
unlink
(
filename
);
if
(
file
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"Emailed file [%s] to [%s]
\n
"
,
filename
,
to
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_INFO
,
"Emailed data to [%s]
\n
"
,
to
);
}
return
JS_TRUE
;
}
return
JS_FALSE
;
}
static
JSFunctionSpec
etpan_methods
[]
=
{
static
JSFunctionSpec
etpan_methods
[]
=
{
// {"myMethod", odbc_my_method, 1},
// {"myMethod", odbc_my_method, 1},
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论