* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
static char sccsid
[] = "@(#)getservent.c 5.1 (Berkeley) %G%";
static char SERVDB
[] = "/etc/services";
static FILE *servf
= NULL
;
static char line
[BUFSIZ
+1];
static struct servent serv
;
static char *serv_aliases
[MAXALIASES
];
servf
= fopen(SERVDB
, "r" );
if (servf
&& !stayopen
) {
if (servf
== NULL
&& (servf
= fopen(SERVDB
, "r" )) == NULL
)
if ((p
= fgets(line
, BUFSIZ
, servf
)) == NULL
)
while (*p
== ' ' || *p
== '\t')
serv
.s_port
= htons((u_short
)atoi(p
));
q
= serv
.s_aliases
= serv_aliases
;
if (*cp
== ' ' || *cp
== '\t') {
if (q
< &serv_aliases
[MAXALIASES
- 1])
for (mp
= match
; *mp
; mp
++)