Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
8d3f14e1
Commit
8d3f14e1
authored
Jan 20, 2014
by
Lukasz Marek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lavf/libssh: factorize open_file function
Signed-off-by:
Lukasz Marek
<
lukasz.m.luki@gmail.com
>
parent
7e8f3048
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
18 deletions
+26
-18
libssh.c
libavformat/libssh.c
+26
-18
No files found.
libavformat/libssh.c
View file @
8d3f14e1
...
...
@@ -84,6 +84,30 @@ static av_cold int libssh_authentication(LIBSSHContext *libssh, const char *user
return
0
;
}
static
av_cold
int
libssh_open_file
(
LIBSSHContext
*
libssh
,
int
flags
,
const
char
*
file
)
{
int
access
;
if
((
flags
&
AVIO_FLAG_WRITE
)
&&
(
flags
&
AVIO_FLAG_READ
))
{
access
=
O_CREAT
|
O_RDWR
;
if
(
libssh
->
trunc
)
access
|=
O_TRUNC
;
}
else
if
(
flags
&
AVIO_FLAG_WRITE
)
{
access
=
O_CREAT
|
O_WRONLY
;
if
(
libssh
->
trunc
)
access
|=
O_TRUNC
;
}
else
access
=
O_RDONLY
;
/* 0666 = -rw-rw-rw- = read+write for everyone, minus umask */
if
(
!
(
libssh
->
file
=
sftp_open
(
libssh
->
sftp
,
file
,
access
,
0666
)))
{
av_log
(
libssh
,
AV_LOG_ERROR
,
"Error opening sftp file: %s
\n
"
,
ssh_get_error
(
libssh
->
session
));
return
AVERROR
(
EIO
);
}
return
0
;
}
static
int
libssh_close
(
URLContext
*
h
)
{
LIBSSHContext
*
s
=
h
->
priv_data
;
...
...
@@ -103,7 +127,7 @@ static int libssh_open(URLContext *h, const char *url, int flags)
static
const
int
verbosity
=
SSH_LOG_NOLOG
;
LIBSSHContext
*
s
=
h
->
priv_data
;
char
proto
[
10
],
path
[
MAX_URL_SIZE
],
hostname
[
1024
],
credencials
[
1024
];
int
port
=
22
,
access
,
ret
;
int
port
=
22
,
ret
;
long
timeout
=
s
->
rw_timeout
*
1000
;
const
char
*
user
=
NULL
,
*
pass
=
NULL
;
char
*
end
=
NULL
;
...
...
@@ -152,24 +176,8 @@ static int libssh_open(URLContext *h, const char *url, int flags)
goto
fail
;
}
if
((
flags
&
AVIO_FLAG_WRITE
)
&&
(
flags
&
AVIO_FLAG_READ
))
{
access
=
O_CREAT
|
O_RDWR
;
if
(
s
->
trunc
)
access
|=
O_TRUNC
;
}
else
if
(
flags
&
AVIO_FLAG_WRITE
)
{
access
=
O_CREAT
|
O_WRONLY
;
if
(
s
->
trunc
)
access
|=
O_TRUNC
;
}
else
{
access
=
O_RDONLY
;
}
/* 0666 = -rw-rw-rw- = read+write for everyone, minus umask */
if
(
!
(
s
->
file
=
sftp_open
(
s
->
sftp
,
path
,
access
,
0666
)))
{
av_log
(
h
,
AV_LOG_ERROR
,
"Error opening sftp file: %s
\n
"
,
ssh_get_error
(
s
->
session
));
ret
=
AVERROR
(
EIO
);
if
((
ret
=
libssh_open_file
(
s
,
flags
,
path
))
<
0
)
goto
fail
;
}
if
(
!
(
stat
=
sftp_fstat
(
s
->
file
)))
{
av_log
(
h
,
AV_LOG_WARNING
,
"Cannot stat remote file %s.
\n
"
,
path
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment