bigbiff bigbiff | 9c75405 | 2013-01-09 09:09:08 -0500 | [diff] [blame] | 1 | /* |
| 2 | ** Copyright 2002 University of Illinois Board of Trustees |
| 3 | ** Copyright 2002 Mark D. Roth |
| 4 | ** All rights reserved. |
| 5 | ** |
| 6 | ** gethostbyname_r.c - gethostbyname_r() function for compatibility library |
| 7 | ** |
| 8 | ** Mark D. Roth <roth@uiuc.edu> |
| 9 | ** Campus Information Technologies and Educational Services |
| 10 | ** University of Illinois at Urbana-Champaign |
| 11 | */ |
| 12 | |
| 13 | #include <config.h> |
| 14 | |
| 15 | #include <stdio.h> |
| 16 | #include <sys/types.h> |
| 17 | #include <netdb.h> |
| 18 | |
| 19 | |
| 20 | int |
| 21 | compat_gethostbyname_r(const char *name, struct hostent *hp, |
| 22 | char *buf, size_t buflen, |
| 23 | struct hostent **hpp, int *herr) |
| 24 | { |
| 25 | #if GETHOSTBYNAME_R_NUM_ARGS == 5 |
| 26 | *hpp = gethostbyname_r(name, hp, buf, buflen, herr); |
| 27 | |
| 28 | if (*hpp == NULL) |
| 29 | return -1; |
| 30 | return 0; |
| 31 | #elif GETHOSTBYNAME_R_NUM_ARGS == 3 |
| 32 | struct hostent_data hdata; |
| 33 | |
| 34 | if (gethostbyname_r(name, hp, &hdata) == -1) |
| 35 | return -1; |
| 36 | *hpp = hp; |
| 37 | return 0; |
| 38 | #endif /* GETHOSTBYNAME_R_NUM_ARGS == 5 */ |
| 39 | } |
| 40 | |
| 41 | |