SSH Misc

Misc functions. More...

Functions

char * ssh_basename (const char *path)
 basename - parse filename component.
char * ssh_dirname (const char *path)
 Parse directory component.
int ssh_mkdir (const char *pathname, mode_t mode)
 Attempts to create a directory with the given pathname.
const char * ssh_version (int req_version)
 Check if libssh is the required version or get the version string.

Detailed Description

Misc functions.


Function Documentation

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.

Parameters:
path The path to parse.
Returns:
The filename of path or NULL if we can't allocate memory. If path is a the string "/", basename returns the string "/". If path is NULL or an empty string, "." is returned.

Referenced by ssh_scp_push_directory(), and ssh_scp_push_file().

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.

Parameters:
path The path to parse.
Returns:
The dirname of path or NULL if we can't allocate memory. If path does not contain a slash, c_dirname() returns the string ".". If path is the string "/", it returns the string "/". If path is NULL or an empty string, "." is returned.

Referenced by ssh_write_knownhost().

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.

Parameters:
pathname The path name to create the directory.
mode The permissions to use.
Returns:
0 on success, < 0 on error with errno set.

Referenced by ssh_write_knownhost().

const char* ssh_version ( int  req_version  ) 

Check if libssh is the required version or get the version string.

Parameters:
req_version The version required.
Returns:
If the version of libssh is newer than the version required it will return a version string. NULL if the version is older.

Example:

  if (ssh_version(SSH_VERSION_INT(0,2,1)) == NULL) {
    fprintf(stderr, "libssh version is too old!\n");
    exit(1);
  }

  if (debug) {
    printf("libssh %s\n", ssh_version(0));
  }
Generated on Mon Jul 5 22:12:40 2010 for libssh by  doxygen 1.6.3