예제 #1
0
struct protoent *
getprotobyname_r(const char *name, struct protoent *pr,
    struct protoent_data *pd)
{
	struct protoent *p;
	char **cp;

	_DIAGASSERT(name != NULL);

	setprotoent_r(pd->stayopen, pd);
	while ((p = getprotoent_r(pr, pd)) != NULL) {
		if (strcmp(p->p_name, name) == 0)
			break;
		for (cp = p->p_aliases; *cp != NULL; cp++)
			if (strcmp(*cp, name) == 0)
				goto found;
	}
found:
	if (!pd->stayopen)
		if (pd->fp != NULL) {
			(void)fclose(pd->fp);
			pd->fp = NULL;
		}
	return p;
}
예제 #2
0
int
getprotobynumber_r(int num, struct protoent *pe, struct protoent_data *pd)
{
	int error;

	setprotoent_r(pd->stayopen, pd);
	while ((error = getprotoent_r(pe, pd)) == 0)
		if (pe->p_proto == num)
			break;
	if (!pd->stayopen && pd->fp != NULL) {
		(void)fclose(pd->fp);
		pd->fp = NULL;
	}
	return (error);
}
예제 #3
0
void
setprotoent(int f)
{
	setprotoent_r(f, &_protoent_data);
}