DocumentationGenerated on Thu Aug 31 00:02:30 2006 |
||
tls.cppGo to the documentation of this file.00001 00002 // $Id: tls.cpp,v 1.2 2005/02/14 21:48:27 klas Exp $ 00003 // 00004 // Shamelessly ripped code from gcrypt.h, modified for c++. 00005 // Included when we have new gcrypt and need to tell it how to do 00006 // thread locking for us. 00007 // 00008 // A part of babyftpd, licensed under the GNU GPL, see the file 00009 // LICENSE for complete information. 00010 // 00012 00013 #define TLS_CPP 00014 #ifndef OLD_GCRYPT 00015 00016 static int gcry_pthread_mutex_init (void **priv) 00017 { 00018 int err = 0; 00019 pthread_mutex_t *lock = new pthread_mutex_t; 00020 if (!lock) 00021 err = ENOMEM; 00022 if (!err) 00023 { 00024 err = pthread_mutex_init (lock, NULL); 00025 if (err) 00026 delete lock; 00027 else 00028 *priv = lock; 00029 } 00030 return err; 00031 } 00032 00033 static int gcry_pthread_mutex_destroy (void **lock) 00034 { 00035 pthread_mutex_t *temp_lock = (static_cast<pthread_mutex_t*>(*lock)); 00036 int err = pthread_mutex_destroy(temp_lock); 00037 delete temp_lock; 00038 return err; 00039 } 00040 00041 static int gcry_pthread_mutex_lock (void **lock) 00042 { 00043 pthread_mutex_t *temp_lock = (static_cast<pthread_mutex_t*>(*lock)); 00044 return pthread_mutex_lock(temp_lock); 00045 } 00046 00047 static int gcry_pthread_mutex_unlock (void **lock) 00048 { 00049 pthread_mutex_t *temp_lock = (static_cast<pthread_mutex_t*>(*lock)); 00050 return pthread_mutex_unlock(temp_lock); 00051 } 00052 00053 static struct gcry_thread_cbs gcry_threads_pthread = 00054 { 00055 GCRY_THREAD_OPTION_PTHREAD, NULL, 00056 gcry_pthread_mutex_init, gcry_pthread_mutex_destroy, 00057 gcry_pthread_mutex_lock, gcry_pthread_mutex_unlock 00058 }; 00059 00060 #endif // OLD_GCRYPT |
- Copyright © 2005, BabyFTPd
- Powered by: