home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 March (DVD) / PCWorld_2008-03_DVD.iso / komunikace / mysql / mysql-essential-5.0.45-win32.msi / product.cab / fili180 < prev    next >
Encoding:
Text File  |  2007-07-06  |  3.8 KB  |  135 lines

  1. /* Copyright (C) 2000 MySQL AB
  2.  
  3.    This program is free software; you can redistribute it and/or modify
  4.    it under the terms of the GNU General Public License as published by
  5.    the Free Software Foundation; version 2 of the License.
  6.  
  7.    This program is distributed in the hope that it will be useful,
  8.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.    GNU General Public License for more details.
  11.  
  12.    You should have received a copy of the GNU General Public License
  13.    along with this program; if not, write to the Free Software
  14.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  15.  
  16. /*
  17.   thread safe version of some common functions:
  18.   my_inet_ntoa
  19.  
  20.   This file is also used to make handling of sockets and ioctl()
  21.   portable accross systems.
  22.  
  23. */
  24.  
  25. #ifndef _my_net_h
  26. #define _my_net_h
  27. C_MODE_START
  28.  
  29. #include <errno.h>
  30. #ifdef HAVE_SYS_SOCKET_H
  31. #include <sys/socket.h>
  32. #endif
  33. #ifdef HAVE_NETINET_IN_H
  34. #include <netinet/in.h>
  35. #endif
  36. #ifdef HAVE_ARPA_INET_H
  37. #include <arpa/inet.h>
  38. #endif
  39. #ifdef HAVE_POLL
  40. #include <sys/poll.h>
  41. #endif
  42. #ifdef HAVE_SYS_IOCTL_H
  43. #include <sys/ioctl.h>
  44. #endif
  45.  
  46. #if !defined(MSDOS) && !defined(__WIN__) && !defined(HAVE_BROKEN_NETINET_INCLUDES) && !defined(__BEOS__) && !defined(__NETWARE__)
  47. #include <netinet/in_systm.h>
  48. #include <netinet/in.h>
  49. #include <netinet/ip.h>
  50. #if !defined(alpha_linux_port)
  51. #include <netinet/tcp.h>
  52. #endif
  53. #endif
  54.  
  55. #if defined(__EMX__)
  56. #include <sys/ioctl.h>
  57. #define ioctlsocket(A,B,C) ioctl((A),(B),(void *)(C),sizeof(*(C)))
  58. #undef HAVE_FCNTL
  59. #endif    /* defined(__EMX__) */
  60.  
  61. #if defined(MSDOS) || defined(__WIN__)
  62. #define O_NONBLOCK 1    /* For emulation of fcntl() */
  63.  
  64. /*
  65.   SHUT_RDWR is called SD_BOTH in windows and
  66.   is defined to 2 in winsock2.h
  67.   #define SD_BOTH 0x02
  68. */
  69. #define SHUT_RDWR 0x02
  70.  
  71. #endif
  72.  
  73. /*
  74.   On OSes which don't have the in_addr_t, we guess that using uint32 is the best
  75.   possible choice. We guess this from the fact that on HP-UX64bit & FreeBSD64bit
  76.   & Solaris64bit, in_addr_t is equivalent to uint32. And on Linux32bit too.
  77. */
  78. #ifndef HAVE_IN_ADDR_T
  79. #define in_addr_t uint32
  80. #endif
  81.  
  82. /* On some operating systems (e.g. Solaris) INADDR_NONE is not defined */
  83. #ifndef INADDR_NONE
  84. #define INADDR_NONE -1                          /* Error value from inet_addr */
  85. #endif
  86.  
  87. /* Thread safe or portable version of some functions */
  88.  
  89. void my_inet_ntoa(struct in_addr in, char *buf);
  90.  
  91. /*
  92.   Handling of gethostbyname_r()
  93. */
  94.  
  95. #if !defined(HPUX10)
  96. struct hostent;
  97. #endif /* HPUX */
  98. #if !defined(HAVE_GETHOSTBYNAME_R)
  99. struct hostent *my_gethostbyname_r(const char *name,
  100.                    struct hostent *result, char *buffer,
  101.                    int buflen, int *h_errnop);
  102. void my_gethostbyname_r_free();
  103. #elif defined(HAVE_PTHREAD_ATTR_CREATE) || defined(_AIX) || defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)
  104. struct hostent *my_gethostbyname_r(const char *name,
  105.                    struct hostent *result, char *buffer,
  106.                    int buflen, int *h_errnop);
  107. #define my_gethostbyname_r_free()
  108. #if !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) && !defined(HPUX10)
  109. #define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data)
  110. #endif /* !defined(HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE) */
  111.  
  112. #elif defined(HAVE_GETHOSTBYNAME_R_RETURN_INT)
  113. #define GETHOSTBYNAME_BUFF_SIZE sizeof(struct hostent_data)
  114. struct hostent *my_gethostbyname_r(const char *name,
  115.                    struct hostent *result, char *buffer,
  116.                    int buflen, int *h_errnop);
  117. #define my_gethostbyname_r_free()
  118. #else
  119. #define my_gethostbyname_r(A,B,C,D,E) gethostbyname_r((A),(B),(C),(D),(E))
  120. #define my_gethostbyname_r_free()
  121. #endif /* !defined(HAVE_GETHOSTBYNAME_R) */
  122.  
  123. #ifndef GETHOSTBYNAME_BUFF_SIZE
  124. #define GETHOSTBYNAME_BUFF_SIZE 2048
  125. #endif
  126.  
  127. /* On SCO you get a link error when refering to h_errno */
  128. #ifdef SCO
  129. #undef h_errno
  130. #define h_errno errno
  131. #endif
  132.  
  133. C_MODE_END
  134. #endif
  135.