MCPcopy Create free account
hub / github.com/F-Stack/f-stack / name2protox

Function name2protox

tools/netstat/main.c:961–986  ·  view source on GitHub ↗

* Find the protox corresponding to name. */

Source from the content-addressed store, hash-verified

959 * Find the protox corresponding to name.
960 */
961static struct protox *
962name2protox(const char *name)
963{
964 struct protox *tp;
965 char **alias; /* alias from p->aliases */
966 struct protoent *p;
967
968 /*
969 * Try to find the name in the list of "well-known" names. If that
970 * fails, check if name is an alias for an Internet protocol.
971 */
972 if ((tp = knownname(name)) != NULL)
973 return (tp);
974
975 setprotoent(1); /* make protocol lookup cheaper */
976 while ((p = getprotoent()) != NULL) {
977 /* assert: name not same as p->name */
978 for (alias = p->p_aliases; *alias; alias++)
979 if (strcmp(name, *alias) == 0) {
980 endprotoent();
981 return (knownname(p->p_name));
982 }
983 }
984 endprotoent();
985 return (NULL);
986}
987
988static void
989usage(void)

Callers 1

main.cFile · 0.85

Calls 2

knownnameFunction · 0.85
strcmpFunction · 0.85

Tested by

no test coverage detected