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

Function ng_decodeidname

freebsd/netgraph/ng_base.c:944–962  ·  view source on GitHub ↗

* Decode an ID name, eg. "[f03034de]". Returns 0 if the * string is not valid, otherwise returns the value. */

Source from the content-addressed store, hash-verified

942 * string is not valid, otherwise returns the value.
943 */
944static ng_ID_t
945ng_decodeidname(const char *name)
946{
947 const int len = strlen(name);
948 char *eptr;
949 u_long val;
950
951 /* Check for proper length, brackets, no leading junk */
952 if ((len < 3) || (name[0] != '[') || (name[len - 1] != ']') ||
953 (!isxdigit(name[1])))
954 return ((ng_ID_t)0);
955
956 /* Decode number */
957 val = strtoul(name + 1, &eptr, 16);
958 if ((eptr - name != len - 1) || (val == ULONG_MAX) || (val == 0))
959 return ((ng_ID_t)0);
960
961 return ((ng_ID_t)val);
962}
963
964/*
965 * Remove a name from a node. This should only be called

Callers 2

ng_name_nodeFunction · 0.70
ng_name2noderefFunction · 0.70

Calls 2

isxdigitFunction · 0.85
strtoulFunction · 0.85

Tested by

no test coverage detected