struct protoent * bt_getprotobynumber(int num) { struct protoent *p; bt_setprotoent(proto_stayopen); while ((p = bt_getprotoent()) != NULL) if (p->p_proto == num) break; bt_endprotoent(); return (p); }
struct protoent * bt_getprotobyname(char const *name) { struct protoent *p; char **cp; bt_setprotoent(proto_stayopen); while ((p = bt_getprotoent()) != NULL) { if (strcmp(p->p_name, name) == 0) break; for (cp = p->p_aliases; *cp != 0; cp++) if (strcmp(*cp, name) == 0) goto found; } found: bt_endprotoent(); return (p); }