Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/include/linux/kstrtox.h
| Show First 20 Lines • Show All 243 Lines • ▼ Show 20 Lines | |||||
| kstrtoull(const char *cp, unsigned int base, unsigned long long *res) | kstrtoull(const char *cp, unsigned int base, unsigned long long *res) | ||||
| { | { | ||||
| return (kstrtou64(cp, base, (uint64_t *)res)); | return (kstrtou64(cp, base, (uint64_t *)res)); | ||||
| } | } | ||||
| static inline int | static inline int | ||||
| kstrtobool(const char *s, bool *res) | kstrtobool(const char *s, bool *res) | ||||
| { | { | ||||
| size_t len; | if (s == NULL || *s == '\0') | ||||
| if (s == NULL || (len = strlen(s)) == 0 || res == NULL) | |||||
| return (-EINVAL); | return (-EINVAL); | ||||
| /* skip newline character, if any */ | if (strchr("eEtTyY1", s[0]) != NULL) | ||||
| if (s[len - 1] == '\n') | |||||
| len--; | |||||
| if (len == 1 && strchr("yY1", s[0]) != NULL) | |||||
| *res = true; | *res = true; | ||||
| else if (len == 1 && strchr("nN0", s[0]) != NULL) | else if (strchr("dDfFnN0", s[0]) != NULL) | ||||
| *res = false; | *res = false; | ||||
| else if (strncasecmp("on", s, len) == 0) | else if (strncasecmp("on", s, 2) == 0) | ||||
| *res = true; | *res = true; | ||||
| else if (strncasecmp("off", s, len) == 0) | else if (strncasecmp("of", s, 2) == 0) | ||||
| *res = false; | *res = false; | ||||
| else | else | ||||
| return (-EINVAL); | return (-EINVAL); | ||||
| return (0); | return (0); | ||||
| } | } | ||||
| static inline int | static inline int | ||||
| ▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines | |||||