MCPcopy Index your code
hub / github.com/F-Stack/f-stack / ng_ksocket_parse

Function ng_ksocket_parse

freebsd/netgraph/ng_ksocket.c:1252–1271  ·  view source on GitHub ↗

* Parse out either an integer value or an alias. */

Source from the content-addressed store, hash-verified

1250 * Parse out either an integer value or an alias.
1251 */
1252static int
1253ng_ksocket_parse(const struct ng_ksocket_alias *aliases,
1254 const char *s, int family)
1255{
1256 int k, val;
1257 char *eptr;
1258
1259 /* Try aliases */
1260 for (k = 0; aliases[k].name != NULL; k++) {
1261 if (strcmp(s, aliases[k].name) == 0
1262 && aliases[k].family == family)
1263 return aliases[k].value;
1264 }
1265
1266 /* Try parsing as a number */
1267 val = (int)strtoul(s, &eptr, 10);
1268 if (val < 0 || *eptr != '\0')
1269 return (-1);
1270 return (val);
1271}

Callers 2

ng_ksocket_newhookFunction · 0.85

Calls 2

strcmpFunction · 0.85
strtoulFunction · 0.85

Tested by

no test coverage detected