libkdenetwork Library API Documentation

ath.h

00001 /* ath.h - Interfaces for thread-safeness library.
00002    Copyright (C) 2002, 2003 g10 Code GmbH
00003 
00004    This file is part of GPGME.
00005  
00006    GPGME is free software; you can redistribute it and/or modify it
00007    under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010  
00011    GPGME is distributed in the hope that it will be useful, but
00012    WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    General Public License for more details.
00015  
00016    You should have received a copy of the GNU General Public License
00017    along with GPGME; if not, write to the Free Software Foundation,
00018    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
00019 
00020 #ifndef ATH_H
00021 #define ATH_H
00022 
00023 #ifdef HAVE_SYS_SELECT_H
00024 # include <sys/select.h>
00025 #else
00026 # include <sys/time.h>
00027 #endif
00028 #include <sys/types.h>
00029 #include <sys/socket.h>
00030 
00031 
00032 /* Define _ATH_EXT_SYM_PREFIX if you want to give all external symbols
00033    a prefix.  */
00034 #define _ATH_EXT_SYM_PREFIX _gpgme_
00035 
00036 #ifdef _ATH_EXT_SYM_PREFIX
00037 #define _ATH_PREFIX1(x,y) x ## y
00038 #define _ATH_PREFIX2(x,y) _ATH_PREFIX1(x,y)
00039 #define _ATH_PREFIX(x) _ATH_PREFIX2(_ATH_EXT_SYM_PREFIX,x)
00040 #define ath_mutex_init _ATH_PREFIX(ath_mutex_init)
00041 #define ath_mutex_destroy _ATH_PREFIX(ath_mutex_destroy)
00042 #define ath_mutex_lock _ATH_PREFIX(ath_mutex_lock)
00043 #define ath_mutex_unlock _ATH_PREFIX(ath_mutex_unlock)
00044 #define ath_read _ATH_PREFIX(ath_read)
00045 #define ath_write _ATH_PREFIX(ath_write)
00046 #define ath_select _ATH_PREFIX(ath_select)
00047 #define ath_waitpid _ATH_PREFIX(ath_waitpid)
00048 #define ath_connect _ATH_PREFIX(ath_connect)
00049 #define ath_accept _ATH_PREFIX(ath_accept)
00050 #define ath_sendmsg _ATH_PREFIX(ath_sendmsg)
00051 #define ath_recvmsg _ATH_PREFIX(ath_recvmsg)
00052 #endif
00053 
00054 
00055 typedef void *ath_mutex_t;
00056 #define ATH_MUTEX_INITIALIZER 0;
00057 
00058 /* Functions for mutual exclusion.  */
00059 int ath_mutex_init (ath_mutex_t *mutex);
00060 int ath_mutex_destroy (ath_mutex_t *mutex);
00061 int ath_mutex_lock (ath_mutex_t *mutex);
00062 int ath_mutex_unlock (ath_mutex_t *mutex);
00063 
00064 /* Replacement for the POSIX functions, which can be used to allow
00065    other (user-level) threads to run.  */
00066 ssize_t ath_read (int fd, void *buf, size_t nbytes);
00067 ssize_t ath_write (int fd, const void *buf, size_t nbytes);
00068 ssize_t ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
00069             struct timeval *timeout);
00070 ssize_t ath_waitpid (pid_t pid, int *status, int options);
00071 int ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr);
00072 int ath_connect (int s, const struct sockaddr *addr, socklen_t length);
00073 int ath_sendmsg (int s, const struct msghdr *msg, int flags);
00074 int ath_recvmsg (int s, struct msghdr *msg, int flags);
00075 
00076 #define _ATH_COMPAT
00077 #ifdef _ATH_COMPAT
00078 struct ath_ops
00079 {
00080   int (*mutex_init) (void **priv, int just_check);
00081   int (*mutex_destroy) (void *priv);
00082   int (*mutex_lock) (void *priv);
00083   int (*mutex_unlock) (void *priv);
00084   ssize_t (*read) (int fd, void *buf, size_t nbytes);
00085   ssize_t (*write) (int fd, const void *buf, size_t nbytes);
00086   ssize_t (*select) (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
00087              struct timeval *timeout);
00088   ssize_t (*waitpid) (pid_t pid, int *status, int options);
00089   int (*accept) (int s, struct sockaddr *addr, socklen_t *length_ptr);
00090   int (*connect) (int s, const struct sockaddr *addr, socklen_t length);
00091   int (*sendmsg) (int s, const struct msghdr *msg, int flags);
00092   int (*recvmsg) (int s, struct msghdr *msg, int flags);
00093 };
00094 
00095 /* Initialize the any-thread package.  */
00096 #define ath_init _ATH_PREFIX(ath_init)
00097 void ath_init (void);
00098 
00099 /* Used by ath_pkg_init.  */
00100 #define ath_pthread_available _ATH_PREFIX(ath_pthread_available)
00101 struct ath_ops *ath_pthread_available (void);
00102 #define ath_pth_available _ATH_PREFIX(ath_pth_available)
00103 struct ath_ops *ath_pth_available (void);
00104 #endif
00105 
00106 #endif  /* ATH_H */
KDE Logo
This file is part of the documentation for libkdenetwork Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Aug 2 09:52:01 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003