The SSH threading functions.

Overview

Threading with libssh. Moreā€¦

// global variables

static void** libcrypto_mutexes;
static struct ssh_threads_callbacks_struct ssh_threads_noop = {     "threads_noop",     threads_noop,     threads_noop,     threads_noop,     threads_noop,     threads_id_noop };
static struct ssh_threads_callbacks_struct* user_callbacks =&ssh_threads_noop;

// global functions

LIBSSH_API int
ssh_threads_set_callbacks(struct ssh_threads_callbacks_struct* cb);

LIBSSH_API struct ssh_threads_callbacks_struct*
ssh_threads_get_noop(void);

static
void
libcrypto_lock_callback(
    int mode,
    int i,
    const char* file,
    int line
);

static
void
libcrypto_thread_finalize(void);

static
int
libcrypto_thread_init(void);

void
ssh_threads_finalize(void);

const char*
ssh_threads_get_type(void);

int
ssh_threads_init(void);

static
unsigned long
threads_id_noop(void);

static
int
threads_noop(void** lock);

Detailed Documentation

Threading with libssh.

Global Functions

LIBSSH_API int
ssh_threads_set_callbacks(struct ssh_threads_callbacks_struct* cb)

Set the thread callbacks structure.

This is necessary if your program is using libssh in a multithreaded fashion. This function must be called first, outside of any threading context (in your main() function for instance), before you call ssh_init().

Bug libgcrypt 1.6 and bigger backend does not support custom callback. Using anything else than pthreads here will fail.

Parameters:

cb

A pointer to a ssh_threads_callbacks_struct structure, which contains the different callbacks to be set.

Returns:

Always returns SSH_OK.

See also:

ssh_threads_callbacks_struct

SSH_THREADS_PTHREAD

LIBSSH_API struct ssh_threads_callbacks_struct*
ssh_threads_get_noop(void)

Get the noop threads callbacks structure.

This can be used with ssh_threads_set_callbacks. These callbacks do nothing and are being used by default.

Returns:

Always returns a valid pointer to the noop callbacks structure.

See also:

ssh_threads_set_callbacks