* Decode an ID name, eg. "[f03034de]". Returns 0 if the * string is not valid, otherwise returns the value. */
| 942 | * string is not valid, otherwise returns the value. |
| 943 | */ |
| 944 | static ng_ID_t |
| 945 | ng_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 |
no test coverage detected