00001 /* Copyright (C) 2000 MySQL AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 /* 00018 thread safe version of some common functions: 00019 my_inet_ntoa 00020 00021 This file is also used to make handling of sockets and ioctl() 00022 portable accross systems. 00023 00024 */ 00025 00026 #ifndef _my_net_h 00027 #define _my_net_h 00028 C_MODE_START 00029 00030 #include <errno.h> 00031 #ifdef HAVE_SYS_SOCKET_H 00032 #include <sys/socket.h> 00033 #endif 00034 #ifdef HAVE_NETINET_IN_H 00035 #include <netinet/in.h> 00036 #endif 00037 #ifdef HAVE_ARPA_INET_H 00038 #include <arpa/inet.h> 00039 #endif 00040 #ifdef HAVE_POLL 00041 #include <sys/poll.h> 00042 #endif 00043 #ifdef HAVE_SYS_IOCTL_H 00044 #include <sys/ioctl.h> 00045 #endif 00046 00047 #if !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__BEOS__) && !defined(__NETWARE__) 00048 #include <netinet/in_systm.h> 00049 #include <netinet/in.h> 00050 #include <netinet/ip.h> 00051 #if !defined(alpha_linux_port) 00052 #include <netinet/tcp.h> 00053 #endif 00054 #endif 00055 00056 #if defined(__WIN__) 00057 #define O_NONBLOCK 1 /* For emulation of fcntl() */ 00058 #endif 00059 00060 /* 00061 On OSes which don't have the in_addr_t, we guess that using uint32 is the best 00062 possible choice. We guess this from the fact that on HP-UX64bit & FreeBSD64bit 00063 & Solaris64bit, in_addr_t is equivalent to uint32. And on Linux32bit too. 00064 */ 00065 #ifndef HAVE_IN_ADDR_T 00066 #define in_addr_t uint32 00067 #endif 00068 00069 /* On some operating systems (e.g. Solaris) INADDR_NONE is not defined */ 00070 #ifndef INADDR_NONE 00071 #define INADDR_NONE -1 /* Error value from inet_addr */ 00072 #endif 00073 00074 /* Thread safe or portable version of some functions */ 00075 00076 void my_inet_ntoa(struct in_addr in, char *buf); 00077 00078 /* 00079 Handling of gethostbyname_r() 00080 */ 00081 00082 #if !defined(HPUX10) 00083 struct hostent; 00084 #endif /* HPUX */ 00085 #if !defined(HAVE_GETHOSTBYNAME_R) 00086 struct hostent *my_gethostbyname_r(const char *name, 00087 struct hostent *result, char *buffer, 00088 int buflen, int *h_errnop); 00089 void my_gethostbyname_r_free(); 00090 #elif defined(HAVE_PTHREAD_ATTR_CREATE) || defined(_AIX) || defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) 00091 struct hostent *my_gethostbyname_r(const char *name, 00092 struct hostent *result, char *buffer, 00093 int buflen, int *h_errnop); 00094 #define my_gethostbyname_r_free() 00095 #if !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) && !defined(HPUX10) 00096 #define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data) 00097 #endif /* !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) */ 00098 00099 #elif defined(HAVE_GETHOSTBYNAME_R_RETURN_INT) 00100 #define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data) 00101 struct hostent *my_gethostbyname_r(const char *name, 00102 struct hostent *result, char *buffer, 00103 int buflen, int *h_errnop); 00104 #define my_gethostbyname_r_free() 00105 #else 00106 #define my_gethostbyname_r(A,B,C,D,E) gethostbyname_r((A),(B),(C),(D),(E)) 00107 #define my_gethostbyname_r_free() 00108 #endif /* !defined(HAVE_GETHOSTBYNAME_R) */ 00109 00110 #ifndef GETHOSTBYNAME_BUFF_SIZE 00111 #define GETHOSTBYNAME_BUFF_SIZE 2048 00112 #endif 00113 00114 /* On SCO you get a link error when refering to h_errno */ 00115 #ifdef SCO 00116 #undef h_errno 00117 #define h_errno errno 00118 #endif 00119 00120 C_MODE_END 00121 #endif
1.4.7

