Main Page | Class List | Directories | File List | Class Members | File Members

utils.h

Go to the documentation of this file.
00001 /* <@LICENSE>
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to you under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at:
00008  * 
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  * 
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  * </@LICENSE>
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;    /* default timeout in seconds */
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;                /* fake type to avoid conditional compilation */
00035 typedef int SSL_CTX;
00036 typedef int SSL_METHOD;
00037 #endif
00038 
00039 #ifdef _WIN32
00040 #include <winsock.h>
00041 /*
00042  * BSD-compatible socket error codes for Win32
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 /* #define ENAMETOOLONG            WSAENAMETOOLONG */
00074 #define EHOSTDOWN               WSAEHOSTDOWN
00075 #define EHOSTUNREACH            WSAEHOSTUNREACH
00076 /* #define ENOTEMPTY               WSAENOTEMPTY */
00077 #define EPROCLIM                WSAEPROCLIM
00078 #define EUSERS                  WSAEUSERS
00079 #define EDQUOT                  WSAEDQUOT
00080 #define ESTALE                  WSAESTALE
00081 #define EREMOTE                 WSAEREMOTE
00082 
00083 /* NOTE: these are not errno constants in UNIX! */
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 /* uses size_t instead of socket_t because socket_t not defined on some platforms */
00095 int timeout_connect (int sockfd, const struct sockaddr *serv_addr, size_t addrlen);
00096 
00097 /* these are fd-only, no SSL support */
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

© sourcejam.com 2005-2008