Eneboo - Documentación para desarrolladores
src/libmysql_macosx/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; 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(MSDOS) && !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(__EMX__)
00057 #include <sys/ioctl.h>
00058 #define ioctlsocket(A,B,C) ioctl((A),(B),(void *)(C),sizeof(*(C)))
00059 #undef HAVE_FCNTL
00060 #endif  /* defined(__EMX__) */
00061 
00062 #if defined(MSDOS) || defined(__WIN__)
00063 #define O_NONBLOCK 1    /* For emulation of fcntl() */
00064 #endif
00065 
00066 /*
00067   On OSes which don't have the in_addr_t, we guess that using uint32 is the best
00068   possible choice. We guess this from the fact that on HP-UX64bit & FreeBSD64bit
00069   & Solaris64bit, in_addr_t is equivalent to uint32. And on Linux32bit too.
00070 */
00071 #ifndef HAVE_IN_ADDR_T
00072 #define in_addr_t uint32
00073 #endif
00074 
00075 /* Thread safe or portable version of some functions */
00076 
00077 void my_inet_ntoa(struct in_addr in, char *buf);
00078 
00079 /*
00080   Handling of gethostbyname_r()
00081 */
00082 
00083 #if !defined(HPUX10)
00084 struct hostent;
00085 #endif /* HPUX */
00086 #if !defined(HAVE_GETHOSTBYNAME_R)
00087 struct hostent *my_gethostbyname_r(const char *name,
00088                                    struct hostent *result, char *buffer,
00089                                    int buflen, int *h_errnop);
00090 void my_gethostbyname_r_free();
00091 #elif defined(HAVE_PTHREAD_ATTR_CREATE) || defined(_AIX) || defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)
00092 struct hostent *my_gethostbyname_r(const char *name,
00093                                    struct hostent *result, char *buffer,
00094                                    int buflen, int *h_errnop);
00095 #define my_gethostbyname_r_free()
00096 #if !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) && !defined(HPUX10)
00097 #define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data)
00098 #endif /* !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) */
00099 
00100 #elif defined(HAVE_GETHOSTBYNAME_R_RETURN_INT)
00101 #define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data)
00102 struct hostent *my_gethostbyname_r(const char *name,
00103                                    struct hostent *result, char *buffer,
00104                                    int buflen, int *h_errnop);
00105 #define my_gethostbyname_r_free()
00106 #else
00107 #define my_gethostbyname_r(A,B,C,D,E) gethostbyname_r((A),(B),(C),(D),(E))
00108 #define my_gethostbyname_r_free()
00109 #endif /* !defined(HAVE_GETHOSTBYNAME_R) */
00110 
00111 #ifndef GETHOSTBYNAME_BUFF_SIZE
00112 #define GETHOSTBYNAME_BUFF_SIZE 2048
00113 #endif
00114 
00115 /* On SCO you get a link error when refering to h_errno */
00116 #ifdef SCO
00117 #undef h_errno
00118 #define h_errno errno
00119 #endif
00120 
00121 C_MODE_END
00122 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'