libtar-1.2.11 tarball sources, taken from Debian's orig tar
[libtar.git] / compat / getservbyname_r.c
blobe386bc9f6f76b3ac6f2b5d1071576a1d018ce7ce
1 /*
2 ** Copyright 2002 University of Illinois Board of Trustees
3 ** Copyright 2002 Mark D. Roth
4 ** All rights reserved.
5 **
6 ** getservbyname_r.c - getservbyname_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
13 #include <config.h>
15 #include <stdio.h>
16 #include <sys/types.h>
17 #include <netdb.h>
20 int
21 compat_getservbyname_r(const char *name, const char *proto,
22 struct servent *sp, char *buf, size_t buflen,
23 struct servent **spp)
25 #if GETSERVBYNAME_R_NUM_ARGS == 5
26 *spp = getservbyname_r(name, proto, sp, buf, buflen);
28 if (*spp == NULL)
29 return -1;
30 return 0;
31 #elif GETSERVBYNAME_R_NUM_ARGS == 4
32 struct servent_data sdata;
34 if (getservbyname_r(name, proto, sp, &sdata) == -1)
35 return -1;
36 *spp = sp;
37 return 0;
38 #endif /* GETSERVBYNAME_R_NUM_ARGS == 5 */