1
1

Changed the threads cbks from struct to publ func

Этот коммит содержится в:
Aris Adamantiadis 2010-09-30 11:10:08 +02:00
родитель bedc65313f
Коммит 5b1c985a0e
4 изменённых файлов: 26 добавлений и 5 удалений

Просмотреть файл

@ -279,8 +279,21 @@ struct ssh_threads_callbacks_struct {
LIBSSH_API int ssh_threads_set_callbacks(struct ssh_threads_callbacks_struct LIBSSH_API int ssh_threads_set_callbacks(struct ssh_threads_callbacks_struct
*cb); *cb);
extern struct ssh_threads_callbacks_struct ssh_threads_pthread; /**
extern struct ssh_threads_callbacks_struct ssh_threads_noop; * @brief returns a pointer on the pthread threads callbacks, to be used with
* ssh_threads_set_callbacks.
* @warning you have to link with the library ssh_threads.
* @see ssh_threads_set_callbacks
*/
LIBSSH_API struct ssh_threads_callbacks_struct *ssh_threads_get_pthread(void);
/**
* @brief returns a pointer on the noop threads callbacks, to be used with
* ssh_threads_set_callbacks. These callbacks do nothing and are being used by
* default.
* @see ssh_threads_set_callbacks
*/
LIBSSH_API struct ssh_threads_callbacks_struct *ssh_threads_get_noop(void);
/** @} */ /** @} */
#ifdef __cplusplus #ifdef __cplusplus

Просмотреть файл

@ -39,7 +39,7 @@ static unsigned long threads_id_noop (void){
return 1; return 1;
} }
struct ssh_threads_callbacks_struct ssh_threads_noop = static struct ssh_threads_callbacks_struct ssh_threads_noop =
{ {
"threads_noop", "threads_noop",
threads_noop, threads_noop,
@ -49,6 +49,10 @@ struct ssh_threads_callbacks_struct ssh_threads_noop =
threads_id_noop threads_id_noop
}; };
struct ssh_threads_callbacks_struct *ssh_threads_get_noop(){
return &ssh_threads_noop;
}
static struct ssh_threads_callbacks_struct *user_callbacks =&ssh_threads_noop; static struct ssh_threads_callbacks_struct *user_callbacks =&ssh_threads_noop;
#ifdef HAVE_LIBGCRYPT #ifdef HAVE_LIBGCRYPT

Просмотреть файл

@ -78,7 +78,7 @@ static unsigned long ssh_pthread_thread_id (void){
return (unsigned long) pthread_self(); return (unsigned long) pthread_self();
} }
struct ssh_threads_callbacks_struct ssh_threads_pthread = static struct ssh_threads_callbacks_struct ssh_threads_pthread =
{ {
.type="threads_pthread", .type="threads_pthread",
.mutex_init=ssh_pthread_mutex_init, .mutex_init=ssh_pthread_mutex_init,
@ -88,4 +88,8 @@ struct ssh_threads_callbacks_struct ssh_threads_pthread =
.thread_id=ssh_pthread_thread_id .thread_id=ssh_pthread_thread_id
}; };
struct ssh_threads_callbacks_struct *ssh_threads_get_pthread(){
return &ssh_threads_pthread;
}
#endif /* HAVE_PTHREAD */ #endif /* HAVE_PTHREAD */

Просмотреть файл

@ -15,7 +15,7 @@
static void setup(){ static void setup(){
printf("setup\n"); printf("setup\n");
ssh_threads_set_callbacks(&ssh_threads_pthread); ssh_threads_set_callbacks(ssh_threads_get_pthread());
ssh_init(); ssh_init();
} }