1 /* ath.h - Interfaces for thread-safeness library.
2    Copyright (C) 2002, 2003, 2004 g10 Code GmbH
3 
4    This file is part of GPGME.
5 
6    GPGME is free software; you can redistribute it and/or modify it
7    under the terms of the GNU Lesser General Public License as
8    published by the Free Software Foundation; either version 2.1 of
9    the License, or (at your option) any later version.
10 
11    GPGME is distributed in the hope that it will be useful, but
12    WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14    Lesser General Public License for more details.
15 
16    You should have received a copy of the GNU Lesser General Public
17    License along with this program; if not, write to the Free Software
18    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19    02111-1307, USA.  */
20 
21 #ifndef ATH_H
22 #define ATH_H
23 
24 #ifdef HAVE_STDINT_H
25 #include <stdint.h>
26 #endif
27 #ifdef HAVE_W32_SYSTEM
28   /* fixme: Check how we did it in libgcrypt.  */
29   struct msghdr { int dummy; };
30   typedef int socklen_t;
31 # include <windows.h>
32 # include <io.h>
33 
34 #else /*!HAVE_W32_SYSTEM*/
35 
36 # ifdef HAVE_SYS_SELECT_H
37 #  include <sys/select.h>
38 # else
39 #  ifdef HAVE_SYS_TIME_H
40 #   include <sys/time.h>
41 #  endif
42 # endif
43 # ifdef HAVE_SYS_TYPES_H
44 #  include <sys/types.h>
45 # endif
46 # include <sys/socket.h>
47 
48 #endif  /*!HAVE_W32_SYSTEM*/
49 
50 
51 
52 /* Define _ATH_EXT_SYM_PREFIX if you want to give all external symbols
53    a prefix.  */
54 #define _ATH_EXT_SYM_PREFIX _gpgme_
55 
56 #ifdef _ATH_EXT_SYM_PREFIX
57 #define _ATH_PREFIX1(x,y) x ## y
58 #define _ATH_PREFIX2(x,y) _ATH_PREFIX1(x,y)
59 #define _ATH_PREFIX(x) _ATH_PREFIX2(_ATH_EXT_SYM_PREFIX,x)
60 #define ath_read _ATH_PREFIX(ath_read)
61 #define ath_write _ATH_PREFIX(ath_write)
62 #define ath_select _ATH_PREFIX(ath_select)
63 #define ath_waitpid _ATH_PREFIX(ath_waitpid)
64 #define ath_connect _ATH_PREFIX(ath_connect)
65 #define ath_accept _ATH_PREFIX(ath_accept)
66 #define ath_sendmsg _ATH_PREFIX(ath_sendmsg)
67 #define ath_recvmsg _ATH_PREFIX(ath_recvmsg)
68 #endif
69 
70 
71 uintptr_t ath_self (void);
72 
73 /* Replacement for the POSIX functions, which can be used to allow
74    other (user-level) threads to run.  */
75 gpgme_ssize_t ath_read (int fd, void *buf, size_t nbytes);
76 gpgme_ssize_t ath_write (int fd, const void *buf, size_t nbytes);
77 gpgme_ssize_t ath_select (int nfd, fd_set *rset, fd_set *wset, fd_set *eset,
78                            struct timeval *timeout);
79 gpgme_ssize_t ath_waitpid (pid_t pid, int *status, int options);
80 int ath_accept (int s, struct sockaddr *addr, socklen_t *length_ptr);
81 int ath_connect (int s, const struct sockaddr *addr, socklen_t length);
82 int ath_sendmsg (int s, const struct msghdr *msg, int flags);
83 int ath_recvmsg (int s, struct msghdr *msg, int flags);
84 
85 #endif	/* ATH_H */
86