Eneboo - Documentación para desarrolladores
src/libmysql_std/include/my_net.h
Ir a la documentación de este archivo.
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; version 2 of the License.
00006 
00007    This program is distributed in the hope that it will be useful,
00008    but WITHOUT ANY WARRANTY; without even the implied warranty of
00009    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010    GNU General Public License for more details.
00011 
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software
00014    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
00015 
00016 /*
00017   thread safe version of some common functions:
00018   my_inet_ntoa
00019 
00020   This file is also used to make handling of sockets and ioctl()
00021   portable accross systems.
00022 
00023 */
00024 
00025 #ifndef _my_net_h
00026 #define _my_net_h
00027 C_MODE_START
00028 
00029 #include <errno.h>
00030 #ifdef HAVE_SYS_SOCKET_H
00031 #include <sys/socket.h>
00032 #endif
00033 #ifdef HAVE_NETINET_IN_H
00034 #include <netinet/in.h>
00035 #endif
00036 #ifdef HAVE_ARPA_INET_H
00037 #include <arpa/inet.h>
00038 #endif
00039 #ifdef HAVE_POLL
00040 #include <sys/poll.h>
00041 #endif
00042 #ifdef HAVE_SYS_IOCTL_H
00043 #include <sys/ioctl.h>
00044 #endif
00045 
00046 #if !defined(MSDOS) && !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__BEOS__) && !defined(__NETWARE__)
00047 #include <netinet/in_systm.h>
00048 #include <netinet/in.h>
00049 #include <netinet/ip.h>
00050 #if !defined(alpha_linux_port)
00051 #include <netinet/tcp.h>
00052 #endif
00053 #endif
00054 
00055 #if defined(__EMX__)
00056 #include <sys/ioctl.h>
00057 #define ioctlsocket(A,B,C) ioctl((A),(B),(void *)(C),sizeof(*(C)))
00058 #undef HAVE_FCNTL
00059 #endif  /* defined(__EMX__) */
00060 
00061 #if defined(MSDOS) || defined(__WIN__)
00062 #define O_NONBLOCK 1    /* For emulation of fcntl() */
00063 
00064 /*
00065   SHUT_RDWR is called SD_BOTH in windows and
00066   is defined to 2 in winsock2.h
00067   #define SD_BOTH 0x02
00068 */
00069 #define SHUT_RDWR 0x02
00070 
00071 #endif
00072 
00073 /*
00074   On OSes which don't have the in_addr_t, we guess that using uint32 is the best
00075   possible choice. We guess this from the fact that on HP-UX64bit & FreeBSD64bit
00076   & Solaris64bit, in_addr_t is equivalent to uint32. And on Linux32bit too.
00077 */
00078 #ifndef HAVE_IN_ADDR_T
00079 #define in_addr_t uint32
00080 #endif
00081 
00082 /* On some operating systems (e.g. Solaris) INADDR_NONE is not defined */
00083 #ifndef INADDR_NONE
00084 #define INADDR_NONE -1                          /* Error value from inet_addr */
00085 #endif
00086 
00087 /* Thread safe or portable version of some functions */
00088 
00089 void my_inet_ntoa(struct in_addr in, char *buf);
00090 
00091 /*
00092   Handling of gethostbyname_r()
00093 */
00094 
00095 #if !defined(HPUX10)
00096 struct hostent;
00097 #endif /* HPUX */
00098 #if !defined(HAVE_GETHOSTBYNAME_R)
00099 struct hostent *my_gethostbyname_r(const char *name,
00100                                    struct hostent *result, char *buffer,
00101                                    int buflen, int *h_errnop);
00102 void my_gethostbyname_r_free();
00103 #elif defined(HAVE_PTHREAD_ATTR_CREATE) || defined(_AIX) || defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)
00104 struct hostent *my_gethostbyname_r(const char *name,
00105                                    struct hostent *result, char *buffer,
00106                                    int buflen, int *h_errnop);
00107 #define my_gethostbyname_r_free()
00108 #if !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) && !defined(HPUX10)
00109 #define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data)
00110 #endif /* !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) */
00111 
00112 #elif defined(HAVE_GETHOSTBYNAME_R_RETURN_INT)
00113 #define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data)
00114 struct hostent *my_gethostbyname_r(const char *name,
00115                                    struct hostent *result, char *buffer,
00116                                    int buflen, int *h_errnop);
00117 #define my_gethostbyname_r_free()
00118 #else
00119 #define my_gethostbyname_r(A,B,C,D,E) gethostbyname_r((A),(B),(C),(D),(E))
00120 #define my_gethostbyname_r_free()
00121 #endif /* !defined(HAVE_GETHOSTBYNAME_R) */
00122 
00123 #ifndef GETHOSTBYNAME_BUFF_SIZE
00124 #define GETHOSTBYNAME_BUFF_SIZE 2048
00125 #endif
00126 
00127 /* On SCO you get a link error when refering to h_errno */
00128 #ifdef SCO
00129 #undef h_errno
00130 #define h_errno errno
00131 #endif
00132 
00133 C_MODE_END
00134 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'