Files
Arquivotheca.Solaris-2.5/lib/libsocket/inet/getservent.c
seta75D 7c4988eac0 Init
2021-10-11 19:38:01 -03:00

69 lines
1.3 KiB
C
Executable File

/*
* Copyright (c) 1986-1994 by Sun Microsystems Inc.
*
* Ye olde non-reentrant interface (MT-unsafe, caveat utor)
*
* lib/libsocket/inet/getservent.c
*/
#ident "@(#)getservent.c 1.14 94/03/24 SMI"
#include <netdb.h>
#include <nss_dbdefs.h>
#ifdef NSS_INCLUDE_UNSAFE
/*
* Don't free this, even on an endservent(), because bitter experience shows
* that there's production code that does getXXXbyYYY(), then endXXXent(),
* and then continues to use the pointer it got back.
*/
static nss_XbyY_buf_t *buffer;
#define GETBUF() \
NSS_XbyY_ALLOC(&buffer, sizeof (struct servent), NSS_BUFLEN_SERVICES)
/* === ?? set ENOMEM on failure? */
struct servent *
getservbyname(nam, proto)
const char *nam;
const char *proto;
{
nss_XbyY_buf_t *b;
struct servent *res = 0;
if ((b = GETBUF()) != 0) {
res = getservbyname_r(nam, proto,
b->result, b->buffer, b->buflen);
}
return (res);
}
struct servent *
getservbyport(port, proto)
int port;
const char *proto;
{
nss_XbyY_buf_t *b;
struct servent *res = 0;
if ((b = GETBUF()) != 0) {
res = getservbyport_r(port, proto,
b->result, b->buffer, b->buflen);
}
return (res);
}
struct servent *
getservent()
{
nss_XbyY_buf_t *b;
struct servent *res = 0;
if ((b = GETBUF()) != 0) {
res = getservent_r(b->result, b->buffer, b->buflen);
}
return (res);
}
#endif NSS_INCLUDE_UNSAFE