Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
2bce38af
提交
2bce38af
authored
1月 26, 2017
作者:
colm
提交者:
Mike Jerris
3月 22, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-9952: Add base64 code (from verto)
上级
59b1ab82
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
186 行增加
和
2 行删除
+186
-2
Makefile.am
libs/libks/Makefile.am
+2
-2
ks_base64.h
libs/libks/src/include/ks_base64.h
+54
-0
ks_base64.c
libs/libks/src/ks_base64.c
+130
-0
没有找到文件。
libs/libks/Makefile.am
浏览文件 @
2bce38af
...
@@ -10,7 +10,7 @@ lib_LTLIBRARIES = libks.la
...
@@ -10,7 +10,7 @@ lib_LTLIBRARIES = libks.la
libks_la_SOURCES
=
src/ks.c src/ks_string.c src/ks_json.c src/cJSON.c src/cJSON_Utils.c src/ks_thread.c src/ks_thread_pool.c src/ks_mutex.c src/ks_config.c
libks_la_SOURCES
=
src/ks.c src/ks_string.c src/ks_json.c src/cJSON.c src/cJSON_Utils.c src/ks_thread.c src/ks_thread_pool.c src/ks_mutex.c src/ks_config.c
libks_la_SOURCES
+=
src/ks_log.c src/ks_socket.c src/ks_buffer.c src/ks_pool.c src/simclist.c
libks_la_SOURCES
+=
src/ks_log.c src/ks_socket.c src/ks_buffer.c src/ks_pool.c src/simclist.c
libks_la_SOURCES
+=
src/ks_time.c src/ks_printf.c src/ks_hash.c src/ks_q.c src/ks_dso.c
# src/ks_dht.c
libks_la_SOURCES
+=
src/ks_time.c src/ks_printf.c src/ks_hash.c src/ks_q.c src/ks_dso.c
# src/ks_dht.c
libks_la_SOURCES
+=
src/ks_ssl.c src/kws.c src/ks_rng.c src/ks_rpcmessage.c
libks_la_SOURCES
+=
src/ks_ssl.c src/kws.c src/ks_rng.c src/ks_rpcmessage.c
src/ks_base64.c
libks_la_SOURCES
+=
src/utp/utp_api.cpp src/utp/utp_callbacks.cpp src/utp/utp_hash.cpp src/utp/utp_internal.cpp
libks_la_SOURCES
+=
src/utp/utp_api.cpp src/utp/utp_callbacks.cpp src/utp/utp_hash.cpp src/utp/utp_internal.cpp
libks_la_SOURCES
+=
src/utp/utp_packedsockaddr.cpp src/utp/utp_utils.cpp src/ks_bencode.c
libks_la_SOURCES
+=
src/utp/utp_packedsockaddr.cpp src/utp/utp_utils.cpp src/ks_bencode.c
libks_la_SOURCES
+=
src/dht/ks_dht.c src/dht/ks_dht_datagram.c src/dht/ks_dht_endpoint.c src/dht/ks_dht_message.c src/dht/ks_dht_transaction.c
libks_la_SOURCES
+=
src/dht/ks_dht.c src/dht/ks_dht_datagram.c src/dht/ks_dht_endpoint.c src/dht/ks_dht_message.c src/dht/ks_dht_transaction.c
...
@@ -30,7 +30,7 @@ library_include_HEADERS += src/include/ks_thread_pool.h src/include/ks_cJSON.h s
...
@@ -30,7 +30,7 @@ library_include_HEADERS += src/include/ks_thread_pool.h src/include/ks_cJSON.h s
library_include_HEADERS
+=
src/include/ks_pool.h src/include/simclist.h src/include/ks_time.h src/include/ks_q.h src/include/ks_socket.h
library_include_HEADERS
+=
src/include/ks_pool.h src/include/simclist.h src/include/ks_time.h src/include/ks_q.h src/include/ks_socket.h
library_include_HEADERS
+=
src/include/ks_dso.h src/include/ks_platform.h src/include/ks_types.h
# src/include/ks_rng.h src/include/ks_dht.h
library_include_HEADERS
+=
src/include/ks_dso.h src/include/ks_platform.h src/include/ks_types.h
# src/include/ks_rng.h src/include/ks_dht.h
library_include_HEADERS
+=
src/include/ks_printf.h src/include/ks_hash.h src/include/ks_ssl.h src/include/kws.h
library_include_HEADERS
+=
src/include/ks_printf.h src/include/ks_hash.h src/include/ks_ssl.h src/include/kws.h
library_include_HEADERS
+=
src/include/ks_rpcmessage.h
library_include_HEADERS
+=
src/include/ks_rpcmessage.h
src/include/ks_base64.h
library_include_HEADERS
+=
src/utp/utp_internal.h src/utp/utp.h src/utp/utp_types.h src/utp/utp_callbacks.h src/utp/utp_templates.h
library_include_HEADERS
+=
src/utp/utp_internal.h src/utp/utp.h src/utp/utp_types.h src/utp/utp_callbacks.h src/utp/utp_templates.h
library_include_HEADERS
+=
src/utp/utp_hash.h src/utp/utp_packedsockaddr.h src/utp/utp_utils.h src/include/ks_utp.h src/include/ks_acl.h
library_include_HEADERS
+=
src/utp/utp_hash.h src/utp/utp_packedsockaddr.h src/utp/utp_utils.h src/include/ks_utp.h src/include/ks_acl.h
...
...
libs/libks/src/include/ks_base64.h
0 → 100644
浏览文件 @
2bce38af
/*
* Copyright (c) 2017 FreeSWITCH Solutions LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _KS_BASE64_H__
#define _KS_BASE64_H__
#include <ks.h>
KS_DECLARE
(
ks_status_t
)
ks_b64_encode
(
unsigned
char
*
in
,
ks_size_t
ilen
,
unsigned
char
*
out
,
ks_size_t
olen
);
KS_DECLARE
(
ks_size_t
)
ks_b64_decode
(
char
*
in
,
char
*
out
,
ks_size_t
olen
);
#endif
/* 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 noet:
*/
libs/libks/src/ks_base64.c
0 → 100644
浏览文件 @
2bce38af
/*
* Copyright (c) 2017 FreeSWITCH Solutions LLC
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of the original author; nor the names of any contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <ks_base64.h>
static
const
char
ks_b64_table
[
65
]
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
;
KS_DECLARE
(
ks_status_t
)
ks_b64_encode
(
unsigned
char
*
in
,
ks_size_t
ilen
,
unsigned
char
*
out
,
ks_size_t
olen
)
{
int
y
=
0
,
bytes
=
0
;
size_t
x
=
0
;
unsigned
int
b
=
0
,
l
=
0
;
for
(
x
=
0
;
x
<
ilen
;
x
++
)
{
b
=
(
b
<<
8
)
+
in
[
x
];
l
+=
8
;
while
(
l
>=
6
)
{
out
[
bytes
++
]
=
ks_b64_table
[(
b
>>
(
l
-=
6
))
%
64
];
if
(
bytes
>=
(
int
)
olen
-
1
)
{
goto
end
;
}
if
(
++
y
!=
72
)
{
continue
;
}
/* out[bytes++] = '\n'; */
y
=
0
;
}
}
if
(
l
>
0
)
{
out
[
bytes
++
]
=
ks_b64_table
[((
b
%
16
)
<<
(
6
-
l
))
%
64
];
}
if
(
l
!=
0
)
{
while
(
l
<
6
&&
bytes
<
(
int
)
olen
-
1
)
{
out
[
bytes
++
]
=
'='
,
l
+=
2
;
}
}
end
:
out
[
bytes
]
=
'\0'
;
return
KS_STATUS_SUCCESS
;
}
KS_DECLARE
(
ks_size_t
)
ks_b64_decode
(
char
*
in
,
char
*
out
,
ks_size_t
olen
)
{
char
l64
[
256
];
int
b
=
0
,
c
,
l
=
0
,
i
;
char
*
ip
,
*
op
=
out
;
size_t
ol
=
0
;
for
(
i
=
0
;
i
<
256
;
i
++
)
{
l64
[
i
]
=
-
1
;
}
for
(
i
=
0
;
i
<
64
;
i
++
)
{
l64
[(
int
)
ks_b64_table
[
i
]]
=
(
char
)
i
;
}
for
(
ip
=
in
;
ip
&&
*
ip
;
ip
++
)
{
c
=
l64
[(
int
)
*
ip
];
if
(
c
==
-
1
)
{
continue
;
}
b
=
(
b
<<
6
)
+
c
;
l
+=
6
;
while
(
l
>=
8
)
{
op
[
ol
++
]
=
(
char
)
((
b
>>
(
l
-=
8
))
%
256
);
if
(
ol
>=
olen
-
2
)
{
goto
end
;
}
}
}
end
:
op
[
ol
++
]
=
'\0'
;
return
ol
;
}
/* 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 noet:
*/
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论