Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2013-12-14 16:44:27 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5b29d0ec429d50fc474fee2185de9792ec696201
5b29d0ec
1 parent
3dd7156f
refine the config
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
29 行增加
和
21 行删除
trunk/src/core/srs_core_config.cpp
trunk/src/core/srs_core_config.cpp
查看文件 @
5b29d0e
...
...
@@ -61,14 +61,13 @@ bool is_common_space(char ch)
class
SrsFileBuffer
{
private
:
int
fd
;
// last available position.
char
*
last
;
// end of buffer.
char
*
end
;
public
:
// start of buffer.
char
*
start
;
public
:
// current consumed position.
char
*
pos
;
// current parsed line.
...
...
@@ -82,7 +81,6 @@ public:
SrsFileBuffer
::
SrsFileBuffer
()
{
fd
=
-
1
;
line
=
0
;
pos
=
last
=
start
=
NULL
;
...
...
@@ -91,39 +89,48 @@ SrsFileBuffer::SrsFileBuffer()
SrsFileBuffer
::~
SrsFileBuffer
()
{
if
(
fd
>
0
)
{
close
(
fd
);
}
srs_freepa
(
start
);
}
int
SrsFileBuffer
::
fullfill
(
const
char
*
filename
)
{
assert
(
fd
==
-
1
);
int
ret
=
ERROR_SUCCESS
;
int
fd
=
-
1
;
int
nread
=
0
;
int
filesize
=
0
;
if
((
fd
=
::
open
(
filename
,
O_RDONLY
,
0
))
<
0
)
{
srs_error
(
"open conf file error. errno=%d(%s)"
,
errno
,
strerror
(
errno
));
return
ERROR_SYSTEM_CONFIG_INVALID
;
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"open conf file error. ret=%d"
,
ret
);
goto
finish
;
}
line
=
1
;
int
size
=
FILE_SIZE
(
fd
)
-
FILE_OFFSET
(
fd
);
if
(
size
<=
0
)
{
return
ERROR_SYSTEM_CONFIG_EOF
;
if
((
filesize
=
FILE_SIZE
(
fd
)
-
FILE_OFFSET
(
fd
))
<=
0
)
{
ret
=
ERROR_SYSTEM_CONFIG_EOF
;
srs_error
(
"read conf file error. ret=%d"
,
ret
);
goto
finish
;
}
srs_freepa
(
start
);
pos
=
last
=
start
=
new
char
[
size
];
end
=
start
+
size
;
pos
=
last
=
start
=
new
char
[
filesize
];
end
=
start
+
filesize
;
int
n
=
read
(
fd
,
start
,
size
);
if
(
n
!=
size
)
{
srs_error
(
"read file read error. expect %d, actual %d bytes."
,
size
,
n
);
return
ERROR_SYSTEM_CONFIG_INVALID
;
if
((
nread
=
read
(
fd
,
start
,
filesize
))
!=
filesize
)
{
ret
=
ERROR_SYSTEM_CONFIG_INVALID
;
srs_error
(
"read file read error. expect %d, actual %d bytes, ret=%d"
,
filesize
,
nread
,
ret
);
goto
finish
;
}
return
ERROR_SUCCESS
;
line
=
1
;
finish
:
if
(
fd
>
0
)
{
::
close
(
fd
);
}
return
ret
;
}
bool
SrsFileBuffer
::
empty
()
...
...
@@ -1245,6 +1252,7 @@ int SrsConfig::parse_file(const char* filename)
"directive
\"
listen
\"
is empty, ret=%d"
,
(
conf
?
conf
->
conf_line
:
0
),
ret
);
return
ret
;
}
// TODO: check the hls.
// TODO: check other config.
// TODO: check hls.
...
...
请
注册
或
登录
后发表评论