libssh  0.11.0
The SSH library
Loading...
Searching...
No Matches
The SSH string functions

String manipulations used in libssh. More...

Collaboration diagram for The SSH string functions:

Functions

struct ssh_string_struct * ssh_string_new (size_t size)
 Create a new SSH String object.
 
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.
 
struct ssh_string_struct * ssh_string_from_char (const char *what)
 Create a ssh string using a C string.
 
size_t ssh_string_len (struct ssh_string_struct *s)
 Return the size of a SSH string.
 
const char * ssh_string_get_char (struct ssh_string_struct *s)
 Get the string as a C null-terminated string.
 
char * ssh_string_to_char (struct ssh_string_struct *s)
 Convert a SSH string to a C null-terminated string.
 
void ssh_string_free_char (char *s)
 Deallocate a char string object.
 
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.
 
void ssh_string_burn (struct ssh_string_struct *s)
 Destroy the data in a string so it couldn't appear in a core dump.
 
void * ssh_string_data (struct ssh_string_struct *s)
 Get the payload of the string.
 
void ssh_string_free (struct ssh_string_struct *s)
 Deallocate a SSH string object.
 

Detailed Description

String manipulations used in libssh.

Function Documentation

◆ ssh_string_burn()

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.

◆ ssh_string_copy()

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.

◆ ssh_string_data()

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.

◆ ssh_string_fill()

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.

◆ ssh_string_free()

void ssh_string_free ( struct ssh_string_struct * s)

Deallocate a SSH string object.

Parameters
[in]sThe SSH string to delete.

◆ ssh_string_free_char()

void ssh_string_free_char ( char * s)

Deallocate a char string object.

Parameters
[in]sThe string to delete.

◆ ssh_string_from_char()

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 null byte is not copied nor counted in the output string.

◆ ssh_string_get_char()

const char * ssh_string_get_char ( struct ssh_string_struct * s)

Get the string as a C null-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.

◆ ssh_string_len()

size_t ssh_string_len ( struct ssh_string_struct * s)

Return the size of a SSH string.

Parameters
[in]sThe input SSH string.
Returns
The size of the content of the string, 0 on error.

◆ ssh_string_new()

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.

◆ ssh_string_to_char()

char * ssh_string_to_char ( struct ssh_string_struct * s)

Convert a SSH string to a C null-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.