Restore build on FreeBSD.
[getmangos.git] / dep / ACE_wrappers / ace / OS_NS_netdb.inl
blob58ebc0c1f3574ea3779f1efaab7327cf5cee7e7c
1 // -*- C++ -*-
2 //
3 // $Id: OS_NS_netdb.inl 80826 2008-03-04 14:51:23Z wotte $
5 #include "ace/OS_NS_macros.h"
6 #include "ace/OS_NS_string.h"
7 #include "ace/OS_NS_errno.h"
9 #if defined (ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
10 # if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
11 #   define ACE_NETDBCALL_RETURN(OP,TYPE,FAILVALUE,TARGET,SIZE) \
12   do \
13   { \
14     if (ACE_OS::netdb_acquire ())  \
15       return FAILVALUE; \
16     else \
17       { \
18         TYPE ace_result_; \
19         ACE_OSCALL (OP, TYPE, FAILVALUE, ace_result_); \
20         if (ace_result_ != FAILVALUE) \
21           ACE_OS::memcpy (TARGET, \
22                     ace_result_, \
23                     SIZE < sizeof (TYPE) ? SIZE : sizeof (TYPE)); \
24         ACE_OS::netdb_release (); \
25         return ace_result_; \
26       } \
27   } while(0)
28 # else /* ! (ACE_MT_SAFE && ACE_MT_SAFE != 0) */
29 #   define ACE_NETDBCALL_RETURN(OP,TYPE,FAILVALUE,TARGET,SIZE) \
30   do \
31   { \
32         TYPE ace_result_; \
33         ACE_OSCALL(OP,TYPE,FAILVALUE,ace_result_); \
34         if (ace_result_ != FAILVALUE) \
35           ACE_OS::memcpy (TARGET, \
36                     ace_result_, \
37                     SIZE < sizeof (TYPE) ? SIZE : sizeof (TYPE)); \
38         return ace_result_; \
39   } while(0)
40 # endif /* ACE_MT_SAFE && ACE_MT_SAFE != 0 */
41 #endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
43 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
45 #if !(defined (ACE_VXWORKS) && defined (ACE_LACKS_GETHOSTBYADDR))
47 ACE_INLINE struct hostent *
48 ACE_OS::gethostbyaddr (const char *addr, int length, int type)
50   ACE_OS_TRACE ("ACE_OS::gethostbyaddr");
51 # if defined (ACE_LACKS_GETHOSTBYADDR)
52   ACE_UNUSED_ARG (addr);
53   ACE_UNUSED_ARG (length);
54   ACE_UNUSED_ARG (type);
55   ACE_NOTSUP_RETURN (0);
56 # else
58   if (0 == addr || '\0' == addr[0])
59       return 0;
61 #   if defined (ACE_VXWORKS)
62   // VxWorks 6.x has a gethostbyaddr() that is threadsafe and
63   // returns an heap-allocated hostentry structure.
64   // just call ACE_OS::gethostbyaddr_r () which knows how to handle this.
65   struct hostent hentry;
66   ACE_HOSTENT_DATA buf;
67   int h_error;  // Not the same as errno!
68   return ACE_OS::gethostbyaddr_r (addr, length, type, &hentry, buf, &h_error);
69 #   elif defined (ACE_HAS_NONCONST_GETBY)
70   //FUZZ: disable check_for_lack_ACE_OS
71   ACE_SOCKCALL_RETURN (::gethostbyaddr (const_cast<char *> (addr),
72                                         (ACE_SOCKET_LEN) length,
73                                         type),
74                        struct hostent *,
75                        0);
76   //FUZZ: enable check_for_lack_ACE_OS
77 #   else
78   //FUZZ: disable check_for_lack_ACE_OS
79   ACE_SOCKCALL_RETURN (::gethostbyaddr (addr,
80                                         (ACE_SOCKET_LEN) length,
81                                         type),
82                        struct hostent *,
83                        0);
84   //FUZZ: enable check_for_lack_ACE_OS
85 #   endif /* ACE_HAS_NONCONST_GETBY */
86 # endif /* !ACE_LACKS_GETHOSTBYADDR */
89 #endif
91 #if !(defined (ACE_VXWORKS) && defined (ACE_LACKS_GETHOSTBYADDR))
93 ACE_INLINE struct hostent *
94 ACE_OS::gethostbyaddr_r (const char *addr,
95                          int length,
96                          int type,
97                          struct hostent *result,
98                          ACE_HOSTENT_DATA buffer,
99                          int *h_errnop)
101   ACE_OS_TRACE ("ACE_OS::gethostbyaddr_r");
102 # if defined (ACE_LACKS_GETHOSTBYADDR_R)
103   ACE_UNUSED_ARG (addr);
104   ACE_UNUSED_ARG (length);
105   ACE_UNUSED_ARG (type);
106   ACE_UNUSED_ARG (result);
107   ACE_UNUSED_ARG (buffer);
108   ACE_UNUSED_ARG (h_errnop);
109   ACE_NOTSUP_RETURN (0);
110 # elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
112   if (0 == addr || '\0' == addr[0])
113       return 0;
115 #   if defined (AIX) || defined (DIGITAL_UNIX)
116   ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
118   //FUZZ: disable check_for_lack_ACE_OS
119   if (::gethostbyaddr_r ((char *) addr, length, type, result,
120                          (struct hostent_data *) buffer)== 0)
121     return result;
122   //FUZZ: enable check_for_lack_ACE_OS
123   else
124     {
125       *h_errnop = h_errno;
126       return (struct hostent *) 0;
127     }
128 #   elif defined (__GLIBC__) || defined (__FreeBSD__)
129   // GNU C library has a different signature
130   ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
132   //FUZZ: disable check_for_lack_ACE_OS
133   if (::gethostbyaddr_r ((char *) addr,
134                          length,
135                          type,
136                          result,
137                          buffer,
138                          sizeof (ACE_HOSTENT_DATA),
139                          &result,
140                          h_errnop) == 0)
141     return result;
142   //FUZZ: enable check_for_lack_ACE_OS
143   else
144     return (struct hostent *) 0;
145 #   elif defined (ACE_VXWORKS)
146   // VxWorks 6.x has a threadsafe gethostbyaddr() which returns a heap-allocated
147   // data structure which needs to be freed with hostentFree()
148   //FUZZ: disable check_for_lack_ACE_OS
149   struct hostent* hp = ::gethostbyaddr (addr, length, type);
150   //FUZZ: enable check_for_lack_ACE_OS
152   if (hp)
153   {
154     result->h_addrtype = hp->h_addrtype;
155     result->h_length = hp->h_length;
157     // buffer layout:
158     // buffer[0-3]: h_addr_list[0], pointer to the addr.
159     // buffer[4-7]: h_addr_list[1], null terminator for the h_addr_list.
160     // buffer[8..(8+h_length)]: the first (and only) addr.
161     // buffer[(8+h_length)...]: hostname
163     // Store the address list in buffer.
164     result->h_addr_list = (char **) buffer;
165     // Store the actual address _after_ the address list.
166     result->h_addr_list[0] = (char *) &result->h_addr_list[2];
167     ACE_OS::memcpy (result->h_addr_list[0], hp->h_addr_list[0], hp->h_length);
168     // Null-terminate the list of addresses.
169     result->h_addr_list[1] = 0;
170     // And no aliases, so null-terminate h_aliases.
171     result->h_aliases = &result->h_addr_list[1];
173     if (((2*sizeof(char*))+hp->h_length+ACE_OS::strlen (hp->h_name)+1) <= sizeof (ACE_HOSTENT_DATA))
174     {
175       result->h_name = (char *) result->h_addr_list[0] + hp->h_length;
176       ACE_OS::strcpy (result->h_name, hp->h_name);
177     }
178     else
179     {
180       result->h_name = (char *)0;
181     }
183     // free hostent memory
184     ::hostentFree (hp);
186     return result;
187   }
188   else
189   {
190     return (struct hostent *) 0;
191   }
192 #   else
193 #     if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
194   ACE_UNUSED_ARG (result);
195   ACE_UNUSED_ARG (h_errnop);
196   //FUZZ: disable check_for_lack_ACE_OS
197   ACE_NETDBCALL_RETURN (::gethostbyaddr (addr, (ACE_SOCKET_LEN) length, type),
198                         struct hostent *, 0,
199                         buffer, sizeof (ACE_HOSTENT_DATA));
200   //FUZZ: enable check_for_lack_ACE_OS
201 #     else
202   //FUZZ: disable check_for_lack_ACE_OS
203   ACE_SOCKCALL_RETURN (::gethostbyaddr_r (addr, length, type, result,
204                                           buffer, sizeof (ACE_HOSTENT_DATA),
205                                           h_errnop),
206                        struct hostent *, 0);
207   //FUZZ: enable check_for_lack_ACE_OS
208 #     endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
209 #   endif /* defined (AIX) || defined (DIGITAL_UNIX) */
210 # elif defined (ACE_HAS_NONCONST_GETBY)
211   ACE_UNUSED_ARG (result);
212   ACE_UNUSED_ARG (buffer);
213   ACE_UNUSED_ARG (h_errnop);
214   //FUZZ: disable check_for_lack_ACE_OS
215   ACE_SOCKCALL_RETURN (::gethostbyaddr (const_cast<char *> (addr),
216                                         (ACE_SOCKET_LEN) length,
217                                         type),
218                        struct hostent *,
219                        0);
220   //FUZZ: enable check_for_lack_ACE_OS
221 # else
222   ACE_UNUSED_ARG (h_errnop);
223   ACE_UNUSED_ARG (buffer);
224   ACE_UNUSED_ARG (result);
226   //FUZZ: disable check_for_lack_ACE_OS
227   ACE_SOCKCALL_RETURN (::gethostbyaddr (addr,
228                                         (ACE_SOCKET_LEN) length,
229                                         type),
230                        struct hostent *,
231                        0);
232   //FUZZ: enable check_for_lack_ACE_OS
233 # endif /* ACE_LACKS_GETHOSTBYADDR_R */
236 #endif
238 #if !(defined (ACE_VXWORKS) && defined (ACE_LACKS_GETHOSTBYNAME))
240 ACE_INLINE struct hostent *
241 ACE_OS::gethostbyname (const char *name)
243   ACE_OS_TRACE ("ACE_OS::gethostbyname");
244 # if defined (ACE_LACKS_GETHOSTBYNAME)
245   ACE_UNUSED_ARG (name);
246   ACE_NOTSUP_RETURN (0);
247 # else
249   if (0 == name || '\0' == name[0])
250       return 0;
252 #   if defined (ACE_VXWORKS)
253   // VxWorks 6.x has a gethostbyname() that is threadsafe and
254   // returns an heap-allocated hostentry structure.
255   // just call ACE_OS::gethostbyname_r () which knows how to handle this.
256   struct hostent hentry;
257   ACE_HOSTENT_DATA buf;
258   int h_error;  // Not the same as errno!
259   return ACE_OS::gethostbyname_r (name, &hentry, buf, &h_error);
260 #   elif defined (ACE_HAS_NONCONST_GETBY)
261   //FUZZ: disable check_for_lack_ACE_OS
262   ACE_SOCKCALL_RETURN (::gethostbyname (const_cast<char *> (name)),
263                        struct hostent *,
264                        0);
265   //FUZZ: enable check_for_lack_ACE_OS
266 #   else
267   //FUZZ: disable check_for_lack_ACE_OS
268   ACE_SOCKCALL_RETURN (::gethostbyname (name),
269                        struct hostent *,
270                        0);
271   //FUZZ: enable check_for_lack_ACE_OS
272 #   endif /* ACE_HAS_NONCONST_GETBY */
273 # endif /* !ACE_LACKS_GETHOSTBYNAME */
276 #endif
278 #if !(defined (ACE_VXWORKS) && defined (ACE_LACKS_GETHOSTBYNAME))
280 ACE_INLINE struct hostent *
281 ACE_OS::gethostbyname_r (const char *name,
282                          struct hostent *result,
283                          ACE_HOSTENT_DATA buffer,
284                          int *h_errnop)
286   ACE_OS_TRACE ("ACE_OS::gethostbyname_r");
287 #if defined (ACE_LACKS_GETHOSTBYNAME)
288   ACE_UNUSED_ARG (name);
289   ACE_UNUSED_ARG (result);
290   ACE_UNUSED_ARG (buffer);
291   ACE_UNUSED_ARG (h_errnop);
292   ACE_NOTSUP_RETURN (0);
293 # elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
295   if (0 == name || '\0' == name[0])
296       return (struct hostent *)0;
298 #   if defined (DIGITAL_UNIX) || \
299        (defined (ACE_AIX_MINOR_VERS) && (ACE_AIX_MINOR_VERS > 2))
300   ACE_UNUSED_ARG (result);
301   ACE_UNUSED_ARG (buffer);
302   ACE_UNUSED_ARG (h_errnop);
304   // gethostbyname returns thread-specific storage on Digital Unix and
305   // AIX 4.3
306   //FUZZ: disable check_for_lack_ACE_OS
307   ACE_SOCKCALL_RETURN (::gethostbyname (name), struct hostent *, 0);
308   //FUZZ: enable check_for_lack_ACE_OS
309 #   elif defined (AIX)
310   ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
312   //FUZZ: disable check_for_lack_ACE_OS
313   if (::gethostbyname_r (name, result, (struct hostent_data *) buffer) == 0)
314     return result;
315   //FUZZ: enable check_for_lack_ACE_OS
316   else
317     {
318       *h_errnop = h_errno;
319       return (struct hostent *) 0;
320     }
321 #   elif defined (__GLIBC__) || defined (__FreeBSD__)
322   // GNU C library has a different signature
323   ACE_OS::memset (buffer, 0, sizeof (ACE_HOSTENT_DATA));
325   //FUZZ: disable check_for_lack_ACE_OS
326   if (::gethostbyname_r (name,
327                          result,
328                          buffer,
329                          sizeof (ACE_HOSTENT_DATA),
330                          &result,
331                          h_errnop) == 0)
332     return result;
333   //FUZZ: enable check_for_lack_ACE_OS
334   else
335     return (struct hostent *) 0;
336 #   elif defined (ACE_VXWORKS)
337   // VxWorks 6.x has a threadsafe gethostbyname() which returns a heap-allocated
338   // data structure which needs to be freed with hostentFree()
339   //FUZZ: disable check_for_lack_ACE_OS
340   struct hostent* hp = ::gethostbyname (name);
341   //FUZZ: enable check_for_lack_ACE_OS
343   if (hp)
344   {
345     result->h_addrtype = hp->h_addrtype;
346     result->h_length = hp->h_length;
348     // buffer layout:
349     // buffer[0-3]: h_addr_list[0], pointer to the addr.
350     // buffer[4-7]: h_addr_list[1], null terminator for the h_addr_list.
351     // buffer[8...]: the first (and only) addr.
353     // Store the address list in buffer.
354     result->h_addr_list = (char **) buffer;
355     // Store the actual address _after_ the address list.
356     result->h_addr_list[0] = (char *) &result->h_addr_list[2];
357     ACE_OS::memcpy (result->h_addr_list[0], hp->h_addr_list[0], hp->h_length);
358     // Null-terminate the list of addresses.
359     result->h_addr_list[1] = 0;
360     // And no aliases, so null-terminate h_aliases.
361     result->h_aliases = &result->h_addr_list[1];
363     if (((2*sizeof(char*))+hp->h_length+ACE_OS::strlen (hp->h_name)+1) <= sizeof (ACE_HOSTENT_DATA))
364     {
365       result->h_name = (char *) result->h_addr_list[0] + hp->h_length;
366       ACE_OS::strcpy (result->h_name, hp->h_name);
367     }
368     else
369     {
370       result->h_name = (char *)0;
371     }
373     // free hostent memory
374     ::hostentFree (hp);
376     return result;
377   }
378   else
379   {
380     return (struct hostent *) 0;
381   }
382 #   else
383 #     if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
384   ACE_UNUSED_ARG (result);
385   ACE_UNUSED_ARG (h_errnop);
386   //FUZZ: disable check_for_lack_ACE_OS
387   ACE_NETDBCALL_RETURN (::gethostbyname (name),
388                         struct hostent *, 0,
389                         buffer, sizeof (ACE_HOSTENT_DATA));
390   //FUZZ: enable check_for_lack_ACE_OS
391 #     else
392   //FUZZ: disable check_for_lack_ACE_OS
393   ACE_SOCKCALL_RETURN (::gethostbyname_r (name, result, buffer,
394                                           sizeof (ACE_HOSTENT_DATA),
395                                           h_errnop),
396                        struct hostent *,
397                        0);
398   //FUZZ: enable check_for_lack_ACE_OS
399 #     endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
400 #   endif /* defined (AIX) || defined (DIGITAL_UNIX) */
401 # elif defined (ACE_HAS_NONCONST_GETBY)
402   ACE_UNUSED_ARG (result);
403   ACE_UNUSED_ARG (buffer);
404   ACE_UNUSED_ARG (h_errnop);
405   //FUZZ: disable check_for_lack_ACE_OS
406   ACE_SOCKCALL_RETURN (::gethostbyname (const_cast<char *> (name)),
407                        struct hostent *,
408                        0);
409   //FUZZ: enable check_for_lack_ACE_OS
410 # else
411   ACE_UNUSED_ARG (result);
412   ACE_UNUSED_ARG (buffer);
413   ACE_UNUSED_ARG (h_errnop);
415   //FUZZ: disable check_for_lack_ACE_OS
416   ACE_SOCKCALL_RETURN (::gethostbyname (name),
417                        struct hostent *,
418                        0);
419   //FUZZ: enable check_for_lack_ACE_OS
420 # endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
423 #endif
425 ACE_INLINE struct hostent *
426 ACE_OS::getipnodebyaddr (const void *src, size_t len, int family)
428 #if defined (ACE_HAS_IPV6) && !defined (ACE_WIN32)
429 #  if defined (ACE_LACKS_GETIPNODEBYADDR)
430   ACE_UNUSED_ARG (src);
431   ACE_UNUSED_ARG (len);
432   ACE_UNUSED_ARG (family);
433   ACE_NOTSUP_RETURN (0);
434 #  else
435   struct hostent *hptr = 0;
436   int errnum;
437   //FUZZ: disable check_for_lack_ACE_OS
438   if ((hptr = ::getipnodebyaddr (src, len, family, &errnum)) == 0)
439     {
440       errno = errnum;
441     }
442   //FUZZ: enable check_for_lack_ACE_OS
443   return hptr;
444 #  endif /* ACE_LACKS_GETIPNODEBYADDR */
445 #else
446   // IPv4-only implementation
447   if (family == AF_INET)
448     return ACE_OS::gethostbyaddr (static_cast<const char *> (src),
449                                   static_cast<int> (len),
450                                   family);
452   ACE_NOTSUP_RETURN (0);
453 # endif /* defined (ACE_HAS_IPV6) && !defined (ACE_WIN32) */
456 ACE_INLINE struct hostent *
457 ACE_OS::getipnodebyname (const char *name, int family, int flags)
459   ACE_OS_TRACE ("ACE_OS::getipnodebyname");
460 # if defined (ACE_HAS_IPV6) && !defined (ACE_LACKS_GETIPNODEBYNAME_IPV6)
461 #   if defined (ACE_LACKS_GETIPNODEBYNAME)
462   ACE_UNUSED_ARG (flags);
463 #     if defined (ACE_HAS_NONCONST_GETBY)
464   ACE_SOCKCALL_RETURN (::gethostbyname2 (const_cast<char *> (name),
465                                          family),
466                        struct hostent *, 0);
467 #     else
468   ACE_SOCKCALL_RETURN (::gethostbyname2 (name, family),
469                        struct hostent *, 0);
470 #     endif /* ACE_HAS_NONCONST_GETBY */
471 #   else
472   struct hostent *hptr = 0;
473   int errnum;
474   //FUZZ: disable check_for_lack_ACE_OS
475   if ((hptr = ::getipnodebyname (name, family, flags, &errnum)) == 0)
476     {
477       errno = errnum;
478     }
479   //FUZZ: enable check_for_lack_ACE_OS
480   return hptr;
481 #   endif /* ACE_LACKS_GETIPNODEBYNAME */
482 # else
483   // IPv4-only implementation
484   ACE_UNUSED_ARG (flags);
485   if (family == AF_INET)
486     return ACE_OS::gethostbyname (name);
488   ACE_NOTSUP_RETURN (0);
489 # endif /* defined (ACE_HAS_IPV6) && !ACE_LACKS_GETIPNODEBYNAME_IPV6 */
492 ACE_INLINE struct protoent *
493 ACE_OS::getprotobyname (const char *name)
495 #if defined (ACE_LACKS_GETPROTOBYNAME)
496   ACE_UNUSED_ARG (name);
497   ACE_NOTSUP_RETURN (0);
498 #elif defined (ACE_HAS_NONCONST_GETBY)
499   //FUZZ: disable check_for_lack_ACE_OS
500   ACE_SOCKCALL_RETURN (::getprotobyname (const_cast<char *> (name)),
501                        struct protoent *,
502                        0);
503   //FUZZ: enable check_for_lack_ACE_OS
504 #else
505   //FUZZ: disable check_for_lack_ACE_OS
506   ACE_SOCKCALL_RETURN (::getprotobyname (name),
507                        struct protoent *,
508                        0);
509   //FUZZ: enable check_for_lack_ACE_OS
510 #endif /* ACE_LACKS_GETPROTOBYNAME */
513 ACE_INLINE struct protoent *
514 ACE_OS::getprotobyname_r (const char *name,
515                           struct protoent *result,
516                           ACE_PROTOENT_DATA buffer)
518 #if defined (ACE_LACKS_GETPROTOBYNAME)
519   ACE_UNUSED_ARG (name);
520   ACE_UNUSED_ARG (result);
521   ACE_UNUSED_ARG (buffer);
522   ACE_NOTSUP_RETURN (0);
523 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
524 # if defined (AIX) || defined (DIGITAL_UNIX)
525   //FUZZ: disable check_for_lack_ACE_OS
526   if (::getprotobyname_r (name, result, (struct protoent_data *) buffer) == 0)
527     return result;
528   else
529     return 0;
530   //FUZZ: enable check_for_lack_ACE_OS
531 # elif defined (__GLIBC__) || defined (__FreeBSD__)
532   // GNU C library has a different signature
533   //FUZZ: disable check_for_lack_ACE_OS
534   if (::getprotobyname_r (name,
535                           result,
536                           buffer,
537                           sizeof (ACE_PROTOENT_DATA),
538                           &result) == 0)
539   //FUZZ: enable check_for_lack_ACE_OS
540     return result;
541   else
542     return 0;
543 # else
544 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
545   ACE_UNUSED_ARG (result);
546   //FUZZ: disable check_for_lack_ACE_OS
547   ACE_NETDBCALL_RETURN (::getprotobyname (name),
548                         struct protoent *, 0,
549                         buffer, sizeof (ACE_PROTOENT_DATA));
550   //FUZZ: enable check_for_lack_ACE_OS
551 #   else
552     //FUZZ: disable check_for_lack_ACE_OS
553     ACE_SOCKCALL_RETURN (::getprotobyname_r (name,
554                                              result,
555                                              buffer,
556                                              sizeof (ACE_PROTOENT_DATA)),
557                        struct protoent *, 0);
558     //FUZZ: enable check_for_lack_ACE_OS
559 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
560 # endif /* defined (AIX) || defined (DIGITAL_UNIX) */
561 #elif defined (ACE_HAS_NONCONST_GETBY)
562   ACE_UNUSED_ARG (result);
563   ACE_UNUSED_ARG (buffer);
564   //FUZZ: disable check_for_lack_ACE_OS
565   ACE_SOCKCALL_RETURN (::getprotobyname (const_cast<char *> (name)),
566                        struct protoent *, 0);
567   //FUZZ: enable check_for_lack_ACE_OS
568 #else
569   ACE_UNUSED_ARG (buffer);
570   ACE_UNUSED_ARG (result);
572   //FUZZ: disable check_for_lack_ACE_OS
573   ACE_SOCKCALL_RETURN (::getprotobyname (name),
574                        struct protoent *,
575                        0);
576   //FUZZ: enable check_for_lack_ACE_OS
577 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) !defined (UNIXWARE) */
580 ACE_INLINE struct protoent *
581 ACE_OS::getprotobynumber (int proto)
583 #if defined (ACE_LACKS_GETPROTOBYNUMBER)
584   ACE_UNUSED_ARG (proto);
585   ACE_NOTSUP_RETURN (0);
586 #else
587   //FUZZ: disable check_for_lack_ACE_OS
588   ACE_SOCKCALL_RETURN (::getprotobynumber (proto),
589                        struct protoent *, 0);
590   //FUZZ: enable check_for_lack_ACE_OS
591 #endif /* ACE_LACKS_GETPROTOBYNUMBER */
594 ACE_INLINE struct protoent *
595 ACE_OS::getprotobynumber_r (int proto,
596                             struct protoent *result,
597                             ACE_PROTOENT_DATA buffer)
599 #if defined (ACE_LACKS_GETPROTOBYNUMBER)
600   ACE_UNUSED_ARG (proto);
601   ACE_UNUSED_ARG (result);
602   ACE_UNUSED_ARG (buffer);
603   ACE_NOTSUP_RETURN (0);
604 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
605 # if defined (AIX) || defined (DIGITAL_UNIX)
606   //FUZZ: disable check_for_lack_ACE_OS
607   if (::getprotobynumber_r (proto, result, (struct protoent_data *) buffer) == 0)
608     return result;
609   //FUZZ: enable check_for_lack_ACE_OS
610   else
611     return 0;
612 # elif defined (__GLIBC__) || defined (__FreeBSD__)
613   // GNU C library has a different signature
614   //FUZZ: disable check_for_lack_ACE_OS
615   if (::getprotobynumber_r (proto,
616                             result,
617                             buffer,
618                             sizeof (ACE_PROTOENT_DATA),
619                             &result) == 0)
620   //FUZZ: enable check_for_lack_ACE_OS
621     return result;
622   else
623     return 0;
624 # else
625 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
626   ACE_UNUSED_ARG (result);
627   //FUZZ: disable check_for_lack_ACE_OS
628   ACE_NETDBCALL_RETURN (::getprotobynumber (proto),
629                         struct protoent *, 0,
630                         buffer, sizeof (ACE_PROTOENT_DATA));
631   //FUZZ: enable check_for_lack_ACE_OS
632 #   else
633   //FUZZ: disable check_for_lack_ACE_OS
634   ACE_SOCKCALL_RETURN (::getprotobynumber_r (proto, result, buffer, sizeof (ACE_PROTOENT_DATA)),
635                        struct protoent *, 0);
636   //FUZZ: enable check_for_lack_ACE_OS
637 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
638 # endif /* defined (AIX) || defined (DIGITAL_UNIX) */
639 #else
640   ACE_UNUSED_ARG (buffer);
641   ACE_UNUSED_ARG (result);
643   //FUZZ: disable check_for_lack_ACE_OS
644   ACE_SOCKCALL_RETURN (::getprotobynumber (proto),
645                        struct protoent *, 0);
646   //FUZZ: enable check_for_lack_ACE_OS
647 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
650 ACE_INLINE struct servent *
651 ACE_OS::getservbyname (const char *svc, const char *proto)
653   ACE_OS_TRACE ("ACE_OS::getservbyname");
654 #if defined (ACE_LACKS_GETSERVBYNAME)
655   ACE_UNUSED_ARG (svc);
656   ACE_UNUSED_ARG (proto);
657   ACE_NOTSUP_RETURN (0);
658 #elif defined (ACE_HAS_NONCONST_GETBY)
659   //FUZZ: disable check_for_lack_ACE_OS
660   ACE_SOCKCALL_RETURN (::getservbyname (const_cast<char *> (svc),
661                                         const_cast<char *> (proto)),
662                        struct servent *,
663                        0);
664   //FUZZ: enable check_for_lack_ACE_OS
665 #else
666   //FUZZ: disable check_for_lack_ACE_OS
667   ACE_SOCKCALL_RETURN (::getservbyname (svc,
668                                         proto),
669                        struct servent *,
670                        0);
671   //FUZZ: enable check_for_lack_ACE_OS
672 #endif /* ACE_HAS_NONCONST_GETBY */
675 ACE_INLINE struct servent *
676 ACE_OS::getservbyname_r (const char *svc,
677                          const char *proto,
678                          struct servent *result,
679                          ACE_SERVENT_DATA buf)
681   ACE_OS_TRACE ("ACE_OS::getservbyname_r");
682 #if defined (ACE_LACKS_GETSERVBYNAME)
683   ACE_UNUSED_ARG (svc);
684   ACE_UNUSED_ARG (proto);
685   ACE_UNUSED_ARG (result);
686   ACE_UNUSED_ARG (buf);
687   ACE_NOTSUP_RETURN (0);
688 #elif defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE)
689 # if defined (AIX) || defined (DIGITAL_UNIX)
690   ACE_OS::memset (buf, 0, sizeof (ACE_SERVENT_DATA));
692   //FUZZ: disable check_for_lack_ACE_OS
693   if (::getservbyname_r (svc, proto, result, (struct servent_data *) buf) == 0)
694     return result;
695   //FUZZ: enable check_for_lack_ACE_OS
696   else
697     return (struct servent *) 0;
698 # elif defined (__GLIBC__) || defined (__FreeBSD__)
699   // GNU C library has a different signature
700   ACE_OS::memset (buf, 0, sizeof (ACE_SERVENT_DATA));
702   //FUZZ: disable check_for_lack_ACE_OS
703   if (::getservbyname_r (svc,
704                          proto,
705                          result,
706                          buf,
707                          sizeof (ACE_SERVENT_DATA),
708                          &result) == 0)
709     return result;
710   //FUZZ: enable check_for_lack_ACE_OS
711   else
712     return (struct servent *) 0;
713 # else
714 #   if defined(ACE_LACKS_NETDB_REENTRANT_FUNCTIONS)
715   ACE_UNUSED_ARG (result);
716   //FUZZ: disable check_for_lack_ACE_OS
717   ACE_NETDBCALL_RETURN (::getservbyname (svc, proto),
718                         struct servent *, 0,
719                         buf, sizeof (ACE_SERVENT_DATA));
720   //FUZZ: enable check_for_lack_ACE_OS
721 #   else
722   //FUZZ: disable check_for_lack_ACE_OS
723   ACE_SOCKCALL_RETURN (::getservbyname_r (svc, proto, result, buf,
724                                           sizeof (ACE_SERVENT_DATA)),
725                        struct servent *, 0);
726   //FUZZ: enable check_for_lack_ACE_OS
727 #   endif /* ACE_LACKS_NETDB_REENTRANT_FUNCTIONS */
728 # endif /* defined (AIX) || defined (DIGITAL_UNIX) */
729 #elif defined (ACE_HAS_NONCONST_GETBY)
730   ACE_UNUSED_ARG (buf);
731   ACE_UNUSED_ARG (result);
732   //FUZZ: disable check_for_lack_ACE_OS
733   ACE_SOCKCALL_RETURN (::getservbyname (const_cast<char *> (svc),
734                                         const_cast<char *> (proto)),
735                        struct servent *,
736                        0);
737   //FUZZ: enable check_for_lack_ACE_OS
738 #else
739   ACE_UNUSED_ARG (buf);
740   ACE_UNUSED_ARG (result);
741   //FUZZ: disable check_for_lack_ACE_OS
742   ACE_SOCKCALL_RETURN (::getservbyname (svc,
743                                         proto),
744                        struct servent *,
745                        0);
746   //FUZZ: enable check_for_lack_ACE_OS
747 #endif /* defined (ACE_HAS_REENTRANT_FUNCTIONS) && !defined (UNIXWARE) */
750 ACE_END_VERSIONED_NAMESPACE_DECL