libssh
0.7
|
Different helper functions used in the SSH Library. More...
Functions | |
char * | ssh_basename (const char *path) |
basename - parse filename component. More... | |
char * | ssh_dirname (const char *path) |
Parse directory component. More... | |
int | ssh_getpass (const char *prompt, char *buf, size_t len, int echo, int verify) |
Get a password from the console. More... | |
int | ssh_mkdir (const char *pathname, mode_t mode) |
Attempts to create a directory with the given pathname. More... | |
char * | ssh_path_expand_tilde (const char *d) |
Expand a directory starting with a tilde '~'. More... | |
int | ssh_timeout_update (struct ssh_timestamp *ts, int timeout) |
updates a timeout value so it reflects the remaining time More... | |
const char * | ssh_version (int req_version) |
Check if libssh is the required version or get the version string. More... | |
Different helper functions used in the SSH Library.
char* ssh_basename | ( | const char * | path | ) |
basename - parse filename component.
basename breaks a null-terminated pathname string into a filename component. ssh_basename() returns the component following the final '/'. Trailing '/' characters are not counted as part of the pathname.
[in] | path | The path to parse. |
Referenced by ssh_scp_push_directory(), and ssh_scp_push_file64().
char* ssh_dirname | ( | const char * | path | ) |
Parse directory component.
dirname breaks a null-terminated pathname string into a directory component. In the usual case, ssh_dirname() returns the string up to, but not including, the final '/'. Trailing '/' characters are not counted as part of the pathname. The caller must free the memory.
[in] | path | The path to parse. |
Referenced by ssh_write_knownhost().
int ssh_getpass | ( | const char * | prompt, |
char * | buf, | ||
size_t | len, | ||
int | echo, | ||
int | verify | ||
) |
Get a password from the console.
You should make sure that the buffer is an empty string!
You can also use this function to ask for a username. Then you can fill the buffer with the username and it is shows to the users. If the users just presses enter the buffer will be untouched.
The prompt will look like this:
Username: [john]
If you press enter then john is used as the username, or you can type it in to change it.
[in] | prompt | The prompt to show to ask for the password. |
[out] | buf | The buffer the password should be stored. It NEEDS to be empty or filled out. |
[in] | len | The length of the buffer. |
[in] | echo | Should we echo what you type. |
[in] | verify | Should we ask for the password twice. |
int ssh_mkdir | ( | const char * | pathname, |
mode_t | mode | ||
) |
Attempts to create a directory with the given pathname.
This is the portable version of mkdir, mode is ignored on Windows systems.
[in] | pathname | The path name to create the directory. |
[in] | mode | The permissions to use. |
Referenced by ssh_write_knownhost().
char* ssh_path_expand_tilde | ( | const char * | d | ) |
Expand a directory starting with a tilde '~'.
[in] | d | The directory to expand. |
Referenced by ssh_options_set().
int ssh_timeout_update | ( | struct ssh_timestamp * | ts, |
int | timeout | ||
) |
updates a timeout value so it reflects the remaining time
[in] | ts | pointer to an existing timestamp |
[in] | timeout | timeout in milliseconds. Negative values mean infinite timeout |
Referenced by ssh_channel_select(), ssh_poll_ctx_dopoll(), and ssh_select().
const char* ssh_version | ( | int | req_version | ) |
Check if libssh is the required version or get the version string.
[in] | req_version | The version required. |
Example: