libssh  0.7.3
Functions
The SSH string functions

String manipulations used in libssh. More...

Collaboration diagram for The SSH string functions:

Functions

void ssh_string_burn (struct ssh_string_struct *s)
 Destroy the data in a string so it couldn't appear in a core dump. More...
 
struct ssh_string_struct * ssh_string_copy (struct ssh_string_struct *s)
 Copy a string, return a newly allocated string. More...
 
void * ssh_string_data (struct ssh_string_struct *s)
 Get the payload of the string. More...
 
int ssh_string_fill (struct ssh_string_struct *s, const void *data, size_t len)
 Fill a string with given data. More...
 
void ssh_string_free (struct ssh_string_struct *s)
 Deallocate a SSH string object. More...
 
void ssh_string_free_char (char *s)
 Deallocate a char string object. More...
 
struct ssh_string_struct * ssh_string_from_char (const char *what)
 Create a ssh string using a C string. More...
 
const char * ssh_string_get_char (struct ssh_string_struct *s)
 Get the the string as a C nul-terminated string. More...
 
size_t ssh_string_len (struct ssh_string_struct *s)
 Return the size of a SSH string. More...
 
struct ssh_string_struct * ssh_string_new (size_t size)
 Create a new SSH String object. More...
 
char * ssh_string_to_char (struct ssh_string_struct *s)
 Convert a SSH string to a C nul-terminated string. More...
 

Detailed Description

String manipulations used in libssh.

Function Documentation

void ssh_string_burn ( struct ssh_string_struct *  s)

Destroy the data in a string so it couldn't appear in a core dump.

Parameters
[in]sThe string to burn.

References ssh_string_len().

Referenced by ssh_pki_export_privkey_file().

struct ssh_string_struct* ssh_string_copy ( struct ssh_string_struct *  s)

Copy a string, return a newly allocated string.

The caller has to free the string.

Parameters
[in]sString to copy.
Returns
Newly allocated copy of the string, NULL on error.

References ssh_string_len(), and ssh_string_new().

void* ssh_string_data ( struct ssh_string_struct *  s)

Get the payload of the string.

Parameters
sThe string to get the data from.
Returns
Return the data of the string or NULL on error.

Referenced by sftp_async_read(), sftp_read(), ssh_buffer_get_len(), ssh_channel_new(), ssh_get_pubkey_hash(), ssh_get_publickey_hash(), ssh_gssapi_get_creds(), ssh_message_free(), ssh_pki_export_privkey_file(), ssh_pki_export_pubkey_base64(), and ssh_pki_import_pubkey_base64().

int ssh_string_fill ( struct ssh_string_struct *  s,
const void *  data,
size_t  len 
)

Fill a string with given data.

The string should be big enough.

Parameters
sAn allocated string to fill with data.
dataThe data to fill the string with.
lenSize of data.
Returns
0 on success, < 0 on error.

References ssh_string_len().

Referenced by ssh_pki_export_pubkey_base64().

void ssh_string_free ( struct ssh_string_struct *  s)
void ssh_string_free_char ( char *  s)

Deallocate a char string object.

Parameters
[in]sThe string to delete.

Referenced by ssh_userauth_agent().

struct ssh_string_struct* ssh_string_from_char ( const char *  what)

Create a ssh string using a C string.

Parameters
[in]whatThe source 0-terminated C string.
Returns
The newly allocated string, NULL on error with errno set.
Note
The nul byte is not copied nor counted in the ouput string.

References ssh_string_new().

Referenced by sftp_canonicalize_path(), sftp_fstatvfs(), sftp_mkdir(), sftp_open(), sftp_opendir(), sftp_readlink(), sftp_setstat(), sftp_statvfs(), ssh_message_auth_pubkey(), and ssh_pki_export_pubkey_base64().

const char* ssh_string_get_char ( struct ssh_string_struct *  s)

Get the the string as a C nul-terminated string.

This is only available as long as the SSH string exists.

Parameters
[in]sThe SSH string to get the C string from.
Returns
The char pointer, NULL on error.

References ssh_string_len().

Referenced by ssh_pki_export_privkey_file(), ssh_pki_export_pubkey_base64(), and ssh_pki_import_pubkey_base64().

size_t ssh_string_len ( struct ssh_string_struct *  s)
struct ssh_string_struct* ssh_string_new ( size_t  size)

Create a new SSH String object.

Parameters
[in]sizeThe size of the string.
Returns
The newly allocated string, NULL on error.

Referenced by ssh_buffer_get_len(), ssh_gssapi_get_creds(), ssh_pki_export_pubkey_base64(), ssh_string_copy(), and ssh_string_from_char().

char* ssh_string_to_char ( struct ssh_string_struct *  s)

Convert a SSH string to a C nul-terminated string.

Parameters
[in]sThe SSH input string.
Returns
An allocated string pointer, NULL on error with errno set.
Note
If the input SSH string contains zeroes, some parts of the output string may not be readable with regular libc functions.

References ssh_string_len().

Referenced by sftp_canonicalize_path(), sftp_opendir(), sftp_readlink(), ssh_get_issue_banner(), and ssh_message_free().