OS_NS_netdb.inl

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // $Id: OS_NS_netdb.inl 75251 2006-11-07 15:53:57Z mcorino $
00004 
00005 #include "ace/OS_NS_macros.h"
00006 #include "ace/OS_NS_string.h"
00007 #include "ace/OS_NS_errno.h"
00008 
00009 #if defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00010 # if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00011 #   define ACE_NETDBCALL_RETURN(OP,TYPE,FAILVALUE,TARGET,SIZE) \
00012   do \
00013   { \
00014     if (ACE_OS::netdb_acquire ())  \
00015       return FAILVALUE; \
00016     else \
00017       { \
00018         TYPE ace_result_; \
00019         ACE_OSCALL (OP, TYPE, FAILVALUE, ace_result_); \
00020         if (ace_result_ != FAILVALUE) \
00021           ACE_OS::memcpy (TARGET, \
00022                     ace_result_, \
00023                     SIZE < sizeof (TYPE) ? SIZE : sizeof (TYPE)); \
00024         ACE_OS::netdb_release (); \
00025         return ace_result_; \
00026       } \
00027   } while(0)
00028 # else /* ! (ACE_MT_SAFE && ACE_MT_SAFE != 0) */
00029 #   define ACE_NETDBCALL_RETURN(OP,TYPE,FAILVALUE,TARGET,SIZE) \
00030   do \
00031   { \
00032         TYPE ace_result_; \
00033         ACE_OSCALL(OP,TYPE,FAILVALUE,ace_result_); \
00034         if (ace_result_ != FAILVALUE) \
00035           ACE_OS::memcpy (TARGET, \
00036                     ace_result_, \
00037                     SIZE < sizeof (TYPE) ? SIZE : sizeof (TYPE)); \
00038         return ace_result_; \
00039   } while(0)
00040 # endif /* ACE_MT_SAFE && ACE_MT_SAFE != 0 */
00041 #endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00042 
00043 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00044 
00045 #if !(defined (ACE_VXWORKS) && defined (ACE_LACKS_GETHOSTBYADDR))
00046 
00047 ACE_INLINE struct hostent *
00048 ACE_OS::gethostbyaddr (const char *addr, int length, int type)
00049 {
00050   ACE_OS_TRACE ("ACE_OS::gethostbyaddr");
00051 # if defined (ACE_LACKS_GETHOSTBYADDR)
00052   ACE_UNUSED_ARG (addr);
00053   ACE_UNUSED_ARG (length);
00054   ACE_UNUSED_ARG (type);
00055   ACE_NOTSUP_RETURN (0);
00056 # else
00057 
00058   if (0 == addr || '\0' == addr[0])
00059       return 0;
00060 
00061 #   if defined (ACE_VXWORKS)
00062   // VxWorks 6.x has a gethostbyaddr() that is threadsafe and
00063   // returns an heap-allocated hostentry structure.
00064   // just call ACE_OS::gethostbyaddr_r () which knows how to handle this.
00065   struct hostent hentry;
00066   ACE_HOSTENT_DATA buf;
00067   int h_error;  // Not the same as errno!
00068   return ACE_OS::gethostbyaddr_r (addr, length, type, &hentry, buf, &h_error);
00069 #   elif defined (ACE_HAS_NONCONST_GETBY)
00070   ACE_SOCKCALL_RETURN (::gethostbyaddr (const_cast<char *> (addr),
00071                                         (ACE_SOCKET_LEN) length,
00072                                         type),
00073                        struct hostent *,
00074                        0);
00075 #   else
00076   ACE_SOCKCALL_RETURN (::gethostbyaddr (addr,
00077                                         (ACE_SOCKET_LEN) length,
00078                                         type),
00079                        struct hostent *,
00080                        0);
00081 #   endif /* ACE_HAS_NONCONST_GETBY */
00082 # endif /* !ACE_LACKS_GETHOSTBYADDR */
00083 }
00084 
00085 #endif
00086 
00087 #if !(defined (ACE_VXWORKS) && defined (ACE_LACKS_GETHOSTBYADDR))
00088 
00089 ACE_INLINE struct hostent *
00090 ACE_OS::gethostbyaddr_r (const char *addr,
00091                          int length,
00092                          int type,
00093                          struct hostent *result,
00094                          ACE_HOSTENT_DATA buffer,
00095                          int *h_errnop)
00096 {
00097   ACE_OS_TRACE ("ACE_OS::gethostbyaddr_r");
00098 # if defined (ACE_LACKS_GETHOSTBYADDR_R)
00099   ACE_UNUSED_ARG (addr);
00100   ACE_UNUSED_ARG (length);
00101   ACE_UNUSED_ARG (type);
00102   ACE_UNUSED_ARG (result);
00103   ACE_UNUSED_ARG (buffer);
00104   ACE_UNUSED_ARG (h_errnop);
00105   ACE_NOTSUP_RETURN (0);
00106 # elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
00107 
00108   if (0 == addr || '\0' == addr[0])
00109       return 0;
00110 
00111 #   if defined (AIX) || defined (DIGITAL_UNIX)
00112   ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
00113 
00114   if (::gethostbyaddr_r ((char *) addr, length, type, result,
00115                          (struct hostent_data *) buffer)== 0)
00116     return result;
00117   else
00118     {
00119       *h_errnop = h_errno;
00120       return (struct hostent *) 0;
00121     }
00122 #   elif defined (__GLIBC__)
00123   // GNU C library has a different signature
00124   ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
00125 
00126   if (::gethostbyaddr_r ((char *) addr,
00127                          length,
00128                          type,
00129                          result,
00130                          buffer,
00131                          sizeof (ACE_HOSTENT_DATA),
00132                          &result,
00133                          h_errnop) == 0)
00134     return result;
00135   else
00136     return (struct hostent *) 0;
00137 #   elif defined (ACE_VXWORKS)
00138   // VxWorks 6.x has a threadsafe gethostbyaddr() which returns a heap-allocated
00139   // data structure which needs to be freed with hostentFree()
00140   struct hostent* hp = ::gethostbyaddr (addr, length, type);
00141   if (hp)
00142   {
00143     result->h_addrtype = hp->h_addrtype;
00144     result->h_length = hp->h_length;
00145 
00146     // buffer layout:
00147     // buffer[0-3]: h_addr_list[0], pointer to the addr.
00148     // buffer[4-7]: h_addr_list[1], null terminator for the h_addr_list.
00149     // buffer[8..(8+h_length)]: the first (and only) addr.
00150     // buffer[(8+h_length)...]: hostname
00151 
00152     // Store the address list in buffer.
00153     result->h_addr_list = (char **) buffer;
00154     // Store the actual address _after_ the address list.
00155     result->h_addr_list[0] = (char *) &result->h_addr_list[2];
00156     ACE_OS::memcpy (result->h_addr_list[0], hp->h_addr_list[0], hp->h_length);
00157     // Null-terminate the list of addresses.
00158     result->h_addr_list[1] = 0;
00159     // And no aliases, so null-terminate h_aliases.
00160     result->h_aliases = &result->h_addr_list[1];
00161 
00162     if (((2*sizeof(char*))+hp->h_length+ACE_OS::strlen (hp->h_name)+1) > sizeof (ACE_HOSTENT_DATA))
00163     {
00164       result->h_name = (char *) result->h_addr_list[0] + hp->h_length;
00165       ACE_OS::strcpy (result->h_name, hp->h_name);
00166     }
00167     else
00168     {
00169       result->h_name = (char *)0;
00170     }
00171 
00172     // free hostent memory
00173     ::hostentFree (hp);
00174 
00175     return result;
00176   }
00177   else
00178   {
00179     return (struct hostent *) 0;
00180   }
00181 #   else
00182 #     if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00183   ACE_UNUSED_ARG (result);
00184   ACE_UNUSED_ARG (h_errnop);
00185   ACE_NETDBCALL_RETURN (::gethostbyaddr (addr, (ACE_SOCKET_LEN) length, type),
00186                         struct hostent *, 0,
00187                         buffer, sizeof (ACE_HOSTENT_DATA));
00188 #     else
00189   ACE_SOCKCALL_RETURN (::gethostbyaddr_r (addr, length, type, result,
00190                                           buffer, sizeof (ACE_HOSTENT_DATA),
00191                                           h_errnop),
00192                        struct hostent *, 0);
00193 #     endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00194 #   endif /* defined (AIX) || defined (DIGITAL_UNIX) */
00195 # elif defined (ACE_HAS_NONCONST_GETBY)
00196   ACE_UNUSED_ARG (result);
00197   ACE_UNUSED_ARG (buffer);
00198   ACE_UNUSED_ARG (h_errnop);
00199   ACE_SOCKCALL_RETURN (::gethostbyaddr (const_cast<char *> (addr),
00200                                         (ACE_SOCKET_LEN) length,
00201                                         type),
00202                        struct hostent *,
00203                        0);
00204 # else
00205   ACE_UNUSED_ARG (h_errnop);
00206   ACE_UNUSED_ARG (buffer);
00207   ACE_UNUSED_ARG (result);
00208 
00209   ACE_SOCKCALL_RETURN (::gethostbyaddr (addr,
00210                                         (ACE_SOCKET_LEN) length,
00211                                         type),
00212                        struct hostent *,
00213                        0);
00214 # endif /* ACE_LACKS_GETHOSTBYADDR_R */
00215 }
00216 
00217 #endif
00218 
00219 #if !(defined (ACE_VXWORKS) && defined (ACE_LACKS_GETHOSTBYNAME))
00220 
00221 ACE_INLINE struct hostent *
00222 ACE_OS::gethostbyname (const char *name)
00223 {
00224   ACE_OS_TRACE ("ACE_OS::gethostbyname");
00225 # if defined (ACE_LACKS_GETHOSTBYNAME)
00226   ACE_UNUSED_ARG (name);
00227   ACE_NOTSUP_RETURN (0);
00228 # else
00229 
00230   if (0 == name || '\0' == name[0])
00231       return 0;
00232 
00233 #   if defined (ACE_VXWORKS)
00234   // VxWorks 6.x has a gethostbyname() that is threadsafe and
00235   // returns an heap-allocated hostentry structure.
00236   // just call ACE_OS::gethostbyname_r () which knows how to handle this.
00237   struct hostent hentry;
00238   ACE_HOSTENT_DATA buf;
00239   int h_error;  // Not the same as errno!
00240   return ACE_OS::gethostbyname_r (name, &hentry, buf, &h_error);
00241 #   elif defined (ACE_HAS_NONCONST_GETBY)
00242   ACE_SOCKCALL_RETURN (::gethostbyname (const_cast<char *> (name)),
00243                        struct hostent *,
00244                        0);
00245 #   else
00246   ACE_SOCKCALL_RETURN (::gethostbyname (name),
00247                        struct hostent *,
00248                        0);
00249 #   endif /* ACE_HAS_NONCONST_GETBY */
00250 # endif /* !ACE_LACKS_GETHOSTBYNAME */
00251 }
00252 
00253 #endif
00254 
00255 #if !(defined (ACE_VXWORKS) && defined (ACE_LACKS_GETHOSTBYNAME))
00256 
00257 ACE_INLINE struct hostent *
00258 ACE_OS::gethostbyname_r (const char *name,
00259                          struct hostent *result,
00260                          ACE_HOSTENT_DATA buffer,
00261                          int *h_errnop)
00262 {
00263   ACE_OS_TRACE ("ACE_OS::gethostbyname_r");
00264 #if defined (ACE_LACKS_GETHOSTBYNAME)
00265   ACE_UNUSED_ARG (name);
00266   ACE_UNUSED_ARG (result);
00267   ACE_UNUSED_ARG (buffer);
00268   ACE_UNUSED_ARG (h_errnop);
00269   ACE_NOTSUP_RETURN (0);
00270 # elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
00271 
00272   if (0 == name || '\0' == name[0])
00273       return (struct hostent *)0;
00274 
00275 #   if defined (DIGITAL_UNIX) || \
00276        (defined (ACE_AIX_MINOR_VERS) && (ACE_AIX_MINOR_VERS > 2))
00277   ACE_UNUSED_ARG (result);
00278   ACE_UNUSED_ARG (buffer);
00279   ACE_UNUSED_ARG (h_errnop);
00280 
00281   // gethostbyname returns thread-specific storage on Digital Unix and
00282   // AIX 4.3
00283   ACE_SOCKCALL_RETURN (::gethostbyname (name), struct hostent *, 0);
00284 #   elif defined (AIX)
00285   ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
00286 
00287   if (::gethostbyname_r (name, result, (struct hostent_data *) buffer) == 0)
00288     return result;
00289   else
00290     {
00291       *h_errnop = h_errno;
00292       return (struct hostent *) 0;
00293     }
00294 #   elif defined (__GLIBC__)
00295   // GNU C library has a different signature
00296   ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
00297 
00298   if (::gethostbyname_r (name,
00299                          result,
00300                          buffer,
00301                          sizeof (ACE_HOSTENT_DATA),
00302                          &result,
00303                          h_errnop) == 0)
00304     return result;
00305   else
00306     return (struct hostent *) 0;
00307 #   elif defined (ACE_VXWORKS)
00308   // VxWorks 6.x has a threadsafe gethostbyname() which returns a heap-allocated
00309   // data structure which needs to be freed with hostentFree()
00310   struct hostent* hp = ::gethostbyname (name);
00311   if (hp)
00312   {
00313     result->h_addrtype = hp->h_addrtype;
00314     result->h_length = hp->h_length;
00315 
00316     // buffer layout:
00317     // buffer[0-3]: h_addr_list[0], pointer to the addr.
00318     // buffer[4-7]: h_addr_list[1], null terminator for the h_addr_list.
00319     // buffer[8...]: the first (and only) addr.
00320 
00321     // Store the address list in buffer.
00322     result->h_addr_list = (char **) buffer;
00323     // Store the actual address _after_ the address list.
00324     result->h_addr_list[0] = (char *) &result->h_addr_list[2];
00325     ACE_OS::memcpy (result->h_addr_list[0], hp->h_addr_list[0], hp->h_length);
00326     // Null-terminate the list of addresses.
00327     result->h_addr_list[1] = 0;
00328     // And no aliases, so null-terminate h_aliases.
00329     result->h_aliases = &result->h_addr_list[1];
00330 
00331     if (((2*sizeof(char*))+hp->h_length+ACE_OS::strlen (hp->h_name)+1) > sizeof (ACE_HOSTENT_DATA))
00332     {
00333       result->h_name = (char *) result->h_addr_list[0] + hp->h_length;
00334       ACE_OS::strcpy (result->h_name, hp->h_name);
00335     }
00336     else
00337     {
00338       result->h_name = (char *)0;
00339     }
00340 
00341     // free hostent memory
00342     ::hostentFree (hp);
00343 
00344     return result;
00345   }
00346   else
00347   {
00348     return (struct hostent *) 0;
00349   }
00350 #   else
00351 #     if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00352   ACE_UNUSED_ARG (result);
00353   ACE_UNUSED_ARG (h_errnop);
00354   ACE_NETDBCALL_RETURN (::gethostbyname (name),
00355                         struct hostent *, 0,
00356                         buffer, sizeof (ACE_HOSTENT_DATA));
00357 #     else
00358   ACE_SOCKCALL_RETURN (::gethostbyname_r (name, result, buffer,
00359                                           sizeof (ACE_HOSTENT_DATA),
00360                                           h_errnop),
00361                        struct hostent *,
00362                        0);
00363 #     endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00364 #   endif /* defined (AIX) || defined (DIGITAL_UNIX) */
00365 # elif defined (ACE_HAS_NONCONST_GETBY)
00366   ACE_UNUSED_ARG (result);
00367   ACE_UNUSED_ARG (buffer);
00368   ACE_UNUSED_ARG (h_errnop);
00369   ACE_SOCKCALL_RETURN (::gethostbyname (const_cast<char *> (name)),
00370                        struct hostent *,
00371                        0);
00372 # else
00373   ACE_UNUSED_ARG (result);
00374   ACE_UNUSED_ARG (buffer);
00375   ACE_UNUSED_ARG (h_errnop);
00376 
00377   ACE_SOCKCALL_RETURN (::gethostbyname (name),
00378                        struct hostent *,
00379                        0);
00380 # endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
00381 }
00382 
00383 #endif
00384 
00385 ACE_INLINE struct hostent *
00386 ACE_OS::getipnodebyaddr (const void *src, size_t len, int family)
00387 {
00388 #if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32)
00389 #  if defined (ACE_LACKS_GETIPNODEBYADDR)
00390   ACE_UNUSED_ARG (src);
00391   ACE_UNUSED_ARG (len);
00392   ACE_UNUSED_ARG (family);
00393   ACE_NOTSUP_RETURN (0);
00394 #  else
00395   struct hostent *hptr = 0;
00396   int errnum;
00397   if ((hptr = ::getipnodebyaddr (src, len, family, &errnum)) == 0)
00398     {
00399       errno = errnum;
00400     }
00401   return hptr;
00402 #  endif /* ACE_LACKS_GETIPNODEBYADDR */
00403 #else
00404   // IPv4-only implementation
00405   if (family == AF_INET)
00406     return ACE_OS::gethostbyaddr (static_cast<const char *> (src),
00407                                   static_cast<int> (len),
00408                                   family);
00409 
00410   ACE_NOTSUP_RETURN (0);
00411 # endif /* defined (ACE_HAS_IPV6) && !defined (ACE_WIN32) */
00412 }
00413 
00414 ACE_INLINE struct hostent *
00415 ACE_OS::getipnodebyname (const char *name, int family, int flags)
00416 {
00417   ACE_OS_TRACE ("ACE_OS::getipnodebyname");
00418 # if defined (ACE_HAS_IPV6) && !defined (ACE_LACKS_GETIPNODEBYNAME_IPV6)
00419 #   if defined (ACE_LACKS_GETIPNODEBYNAME)
00420   ACE_UNUSED_ARG (flags);
00421 #     if defined (ACE_HAS_NONCONST_GETBY)
00422   ACE_SOCKCALL_RETURN (::gethostbyname2 (const_cast<char *> (name),
00423                                          family),
00424                        struct hostent *, 0);
00425 #     else
00426   ACE_SOCKCALL_RETURN (::gethostbyname2 (name, family),
00427                        struct hostent *, 0);
00428 #     endif /* ACE_HAS_NONCONST_GETBY */
00429 #   else
00430   struct hostent *hptr = 0;
00431   int errnum;
00432   if ((hptr = ::getipnodebyname (name, family, flags, &errnum)) == 0)
00433     {
00434       errno = errnum;
00435     }
00436   return hptr;
00437 #   endif /* ACE_LACKS_GETIPNODEBYNAME */
00438 # else
00439   // IPv4-only implementation
00440   ACE_UNUSED_ARG (flags);
00441   if (family == AF_INET)
00442     return ACE_OS::gethostbyname (name);
00443 
00444   ACE_NOTSUP_RETURN (0);
00445 # endif /* defined (ACE_HAS_IPV6) && !ACE_LACKS_GETIPNODEBYNAME_IPV6 */
00446 }
00447 
00448 ACE_INLINE struct protoent *
00449 ACE_OS::getprotobyname (const char *name)
00450 {
00451 #if defined (ACE_LACKS_GETPROTOBYNAME)
00452   ACE_UNUSED_ARG (name);
00453   ACE_NOTSUP_RETURN (0);
00454 #elif defined (ACE_HAS_NONCONST_GETBY)
00455   ACE_SOCKCALL_RETURN (::getprotobyname (const_cast<char *> (name)),
00456                        struct protoent *,
00457                        0);
00458 #else
00459   ACE_SOCKCALL_RETURN (::getprotobyname (name),
00460                        struct protoent *,
00461                        0);
00462 #endif /* ACE_LACKS_GETPROTOBYNAME */
00463 }
00464 
00465 ACE_INLINE struct protoent *
00466 ACE_OS::getprotobyname_r (const char *name,
00467                           struct protoent *result,
00468                           ACE_PROTOENT_DATA buffer)
00469 {
00470 #if defined (ACE_LACKS_GETPROTOBYNAME)
00471   ACE_UNUSED_ARG (name);
00472   ACE_UNUSED_ARG (result);
00473   ACE_UNUSED_ARG (buffer);
00474   ACE_NOTSUP_RETURN (0);
00475 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
00476 # if defined (AIX) || defined (DIGITAL_UNIX)
00477   if (::getprotobyname_r (name, result, (struct protoent_data *) buffer) == 0)
00478     return result;
00479   else
00480     return 0;
00481 # elif defined (__GLIBC__)
00482   // GNU C library has a different signature
00483   if (::getprotobyname_r (name,
00484                           result,
00485                           buffer,
00486                           sizeof (ACE_PROTOENT_DATA),
00487                           &result) == 0)
00488     return result;
00489   else
00490     return 0;
00491 # else
00492 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00493   ACE_UNUSED_ARG (result);
00494   ACE_NETDBCALL_RETURN (::getprotobyname (name),
00495                         struct protoent *, 0,
00496                         buffer, sizeof (ACE_PROTOENT_DATA));
00497 #   else
00498     ACE_SOCKCALL_RETURN (::getprotobyname_r (name,
00499                                              result,
00500                                              buffer,
00501                                              sizeof (ACE_PROTOENT_DATA)),
00502                        struct protoent *, 0);
00503 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00504 # endif /* defined (AIX) || defined (DIGITAL_UNIX) */
00505 #elif defined (ACE_HAS_NONCONST_GETBY)
00506   ACE_UNUSED_ARG (result);
00507   ACE_UNUSED_ARG (buffer);
00508   ACE_SOCKCALL_RETURN (::getprotobyname (const_cast<char *> (name)),
00509                        struct protoent *, 0);
00510 #else
00511   ACE_UNUSED_ARG (buffer);
00512   ACE_UNUSED_ARG (result);
00513 
00514   ACE_SOCKCALL_RETURN (::getprotobyname (name),
00515                        struct protoent *,
00516                        0);
00517 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) !defined (UNIXWARE) */
00518 }
00519 
00520 ACE_INLINE struct protoent *
00521 ACE_OS::getprotobynumber (int proto)
00522 {
00523 #if defined (ACE_LACKS_GETPROTOBYNUMBER)
00524   ACE_UNUSED_ARG (proto);
00525   ACE_NOTSUP_RETURN (0);
00526 #else
00527   ACE_SOCKCALL_RETURN (::getprotobynumber (proto),
00528                        struct protoent *, 0);
00529 #endif /* ACE_LACKS_GETPROTOBYNUMBER */
00530 }
00531 
00532 ACE_INLINE struct protoent *
00533 ACE_OS::getprotobynumber_r (int proto,
00534                             struct protoent *result,
00535                             ACE_PROTOENT_DATA buffer)
00536 {
00537 #if defined (ACE_LACKS_GETPROTOBYNUMBER)
00538   ACE_UNUSED_ARG (proto);
00539   ACE_UNUSED_ARG (result);
00540   ACE_UNUSED_ARG (buffer);
00541   ACE_NOTSUP_RETURN (0);
00542 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
00543 # if defined (AIX) || defined (DIGITAL_UNIX)
00544   if (::getprotobynumber_r (proto, result, (struct protoent_data *) buffer) == 0)
00545     return result;
00546   else
00547     return 0;
00548 # elif defined (__GLIBC__)
00549   // GNU C library has a different signature
00550   if (::getprotobynumber_r (proto,
00551                             result,
00552                             buffer,
00553                             sizeof (ACE_PROTOENT_DATA),
00554                             &result) == 0)
00555     return result;
00556   else
00557     return 0;
00558 # else
00559 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00560   ACE_UNUSED_ARG (result);
00561   ACE_NETDBCALL_RETURN (::getprotobynumber (proto),
00562                         struct protoent *, 0,
00563                         buffer, sizeof (ACE_PROTOENT_DATA));
00564 #   else
00565   ACE_SOCKCALL_RETURN (::getprotobynumber_r (proto, result, buffer, sizeof (ACE_PROTOENT_DATA)),
00566                        struct protoent *, 0);
00567 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00568 # endif /* defined (AIX) || defined (DIGITAL_UNIX) */
00569 #else
00570   ACE_UNUSED_ARG (buffer);
00571   ACE_UNUSED_ARG (result);
00572 
00573   ACE_SOCKCALL_RETURN (::getprotobynumber (proto),
00574                        struct protoent *, 0);
00575 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
00576 }
00577 
00578 ACE_INLINE struct servent *
00579 ACE_OS::getservbyname (const char *svc, const char *proto)
00580 {
00581   ACE_OS_TRACE ("ACE_OS::getservbyname");
00582 #if defined (ACE_LACKS_GETSERVBYNAME)
00583   ACE_UNUSED_ARG (svc);
00584   ACE_UNUSED_ARG (proto);
00585   ACE_NOTSUP_RETURN (0);
00586 #elif defined (ACE_HAS_NONCONST_GETBY)
00587   ACE_SOCKCALL_RETURN (::getservbyname (const_cast<char *> (svc),
00588                                         const_cast<char *> (proto)),
00589                        struct servent *,
00590                        0);
00591 #else
00592   ACE_SOCKCALL_RETURN (::getservbyname (svc,
00593                                         proto),
00594                        struct servent *,
00595                        0);
00596 #endif /* ACE_HAS_NONCONST_GETBY */
00597 }
00598 
00599 ACE_INLINE struct servent *
00600 ACE_OS::getservbyname_r (const char *svc,
00601                          const char *proto,
00602                          struct servent *result,
00603                          ACE_SERVENT_DATA buf)
00604 {
00605   ACE_OS_TRACE ("ACE_OS::getservbyname_r");
00606 #if defined (ACE_LACKS_GETSERVBYNAME)
00607   ACE_UNUSED_ARG (svc);
00608   ACE_UNUSED_ARG (proto);
00609   ACE_UNUSED_ARG (result);
00610   ACE_UNUSED_ARG (buf);
00611   ACE_NOTSUP_RETURN (0);
00612 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
00613 # if defined (AIX) || defined (DIGITAL_UNIX)
00614   ACE_OS::memset (buf, 0, sizeof (ACE_SERVENT_DATA));
00615 
00616   if (::getservbyname_r (svc, proto, result, (struct servent_data *) buf) == 0)
00617     return result;
00618   else
00619     return (struct servent *) 0;
00620 # elif defined (__GLIBC__)
00621   // GNU C library has a different signature
00622   ACE_OS::memset (buf, 0, sizeof (ACE_SERVENT_DATA));
00623 
00624   if (::getservbyname_r (svc,
00625                          proto,
00626                          result,
00627                          buf,
00628                          sizeof (ACE_SERVENT_DATA),
00629                          &result) == 0)
00630     return result;
00631   else
00632     return (struct servent *) 0;
00633 # else
00634 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
00635   ACE_UNUSED_ARG (result);
00636   ACE_NETDBCALL_RETURN (::getservbyname (svc, proto),
00637                         struct servent *, 0,
00638                         buf, sizeof (ACE_SERVENT_DATA));
00639 #   else
00640   ACE_SOCKCALL_RETURN (::getservbyname_r (svc, proto, result, buf,
00641                                           sizeof (ACE_SERVENT_DATA)),
00642                        struct servent *, 0);
00643 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
00644 # endif /* defined (AIX) || defined (DIGITAL_UNIX) */
00645 #elif defined (ACE_HAS_NONCONST_GETBY)
00646   ACE_UNUSED_ARG (buf);
00647   ACE_UNUSED_ARG (result);
00648   ACE_SOCKCALL_RETURN (::getservbyname (const_cast<char *> (svc),
00649                                         const_cast<char *> (proto)),
00650                        struct servent *,
00651                        0);
00652 #else
00653   ACE_UNUSED_ARG (buf);
00654   ACE_UNUSED_ARG (result);
00655 
00656   ACE_SOCKCALL_RETURN (::getservbyname (svc,
00657                                         proto),
00658                        struct servent *,
00659                        0);
00660 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
00661 }
00662 
00663 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Sun Jan 27 12:05:33 2008 for ACE by doxygen 1.3.6