00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef UTILS_H
00020 #define UTILS_H
00021
00022 #define UNUSED_VARIABLE(v) ((void)(v))
00023
00024 #include <stddef.h>
00025
00026 extern int libspamc_timeout;
00027
00028 #ifdef SPAMC_SSL
00029 #include <openssl/crypto.h>
00030 #include <openssl/pem.h>
00031 #include <openssl/ssl.h>
00032 #include <openssl/err.h>
00033 #else
00034 typedef int SSL;
00035 typedef int SSL_CTX;
00036 typedef int SSL_METHOD;
00037 #endif
00038
00039 #ifdef _WIN32
00040 #include <winsock.h>
00041
00042
00043
00044
00045 #define EWOULDBLOCK WSAEWOULDBLOCK
00046 #define EINPROGRESS WSAEINPROGRESS
00047 #define EALREADY WSAEALREADY
00048 #define ENOTSOCK WSAENOTSOCK
00049 #define EDESTADDRREQ WSAEDESTADDRREQ
00050 #define EMSGSIZE WSAEMSGSIZE
00051 #define EPROTOTYPE WSAEPROTOTYPE
00052 #define ENOPROTOOPT WSAENOPROTOOPT
00053 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
00054 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
00055 #define EOPNOTSUPP WSAEOPNOTSUPP
00056 #define EPFNOSUPPORT WSAEPFNOSUPPORT
00057 #define EAFNOSUPPORT WSAEAFNOSUPPORT
00058 #define EADDRINUSE WSAEADDRINUSE
00059 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
00060 #define ENETDOWN WSAENETDOWN
00061 #define ENETUNREACH WSAENETUNREACH
00062 #define ENETRESET WSAENETRESET
00063 #define ECONNABORTED WSAECONNABORTED
00064 #define ECONNRESET WSAECONNRESET
00065 #define ENOBUFS WSAENOBUFS
00066 #define EISCONN WSAEISCONN
00067 #define ENOTCONN WSAENOTCONN
00068 #define ESHUTDOWN WSAESHUTDOWN
00069 #define ETOOMANYREFS WSAETOOMANYREFS
00070 #define ETIMEDOUT WSAETIMEDOUT
00071 #define ECONNREFUSED WSAECONNREFUSED
00072 #define ELOOP WSAELOOP
00073
00074 #define EHOSTDOWN WSAEHOSTDOWN
00075 #define EHOSTUNREACH WSAEHOSTUNREACH
00076
00077 #define EPROCLIM WSAEPROCLIM
00078 #define EUSERS WSAEUSERS
00079 #define EDQUOT WSAEDQUOT
00080 #define ESTALE WSAESTALE
00081 #define EREMOTE WSAEREMOTE
00082
00083
00084 #define HOST_NOT_FOUND WSAHOST_NOT_FOUND
00085 #define TRY_AGAIN WSATRY_AGAIN
00086 #define NO_RECOVERY WSANO_RECOVERY
00087 #define NO_DATA WSANO_DATA
00088
00089 #endif
00090
00091 int fd_timeout_read(int fd, char fdflag, void *, size_t);
00092 int ssl_timeout_read(SSL * ssl, void *, int);
00093
00094
00095 int timeout_connect (int sockfd, const struct sockaddr *serv_addr, size_t addrlen);
00096
00097
00098 int full_read(int fd, char fdflag, void *buf, int min, int len);
00099 int full_read_ssl(SSL * ssl, unsigned char *buf, int min, int len);
00100 int full_write(int fd, char fdflag, const void *buf, int len);
00101
00102 #endif