MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / libssh_connect

Function libssh_connect

libavformat/libssh.c:190–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188}
189
190static av_cold int libssh_connect(URLContext *h, const char *url, char *path, size_t path_size)
191{
192 LIBSSHContext *libssh = h->priv_data;
193 char proto[10], hostname[1024], credentials[1024];
194 int port = 22, ret;
195 const char *user = NULL, *pass = NULL;
196 char *end = NULL;
197
198 av_url_split(proto, sizeof(proto),
199 credentials, sizeof(credentials),
200 hostname, sizeof(hostname),
201 &port,
202 path, path_size,
203 url);
204
205 if (!(*path))
206 av_strlcpy(path, "/", path_size);
207
208 // a port of 0 will use a port from ~/.ssh/config or the default value 22
209 if (port < 0 || port > 65535)
210 port = 0;
211
212 if ((ret = libssh_create_ssh_session(libssh, hostname, port)) < 0)
213 return ret;
214
215 user = av_strtok(credentials, ":", &end);
216 pass = av_strtok(end, ":", &end);
217
218 if ((ret = libssh_authentication(libssh, user, pass)) < 0)
219 return ret;
220
221 if ((ret = libssh_create_sftp_session(libssh)) < 0)
222 return ret;
223
224 return 0;
225}
226
227static av_cold int libssh_open(URLContext *h, const char *url, int flags)
228{

Callers 4

libssh_openFunction · 0.85
libssh_open_dirFunction · 0.85
libssh_deleteFunction · 0.85
libssh_moveFunction · 0.85

Calls 6

av_url_splitFunction · 0.85
av_strlcpyFunction · 0.85
av_strtokFunction · 0.85
libssh_authenticationFunction · 0.85

Tested by

no test coverage detected