EXPORT_SYMBOL(cfs_str2mask);
/**
- * Extracts tokens from strings.
- *
- * Looks for \a delim in string \a next, sets \a res to point to
- * substring before the delimiter, sets \a next right after the found
- * delimiter.
- *
- * \retval 1 if \a res points to a string of non-whitespace characters
- * \retval 0 otherwise
- */
-int
-cfs_gettok(struct cfs_lstr *next, char delim, struct cfs_lstr *res)
-{
- char *end;
-
- if (next->ls_str == NULL)
- return 0;
-
- /* skip leading white spaces */
- while (next->ls_len) {
- if (!isspace(*next->ls_str))
- break;
- next->ls_str++;
- next->ls_len--;
- }
-
- if (next->ls_len == 0) /* whitespaces only */
- return 0;
-
- if (*next->ls_str == delim) {
- /* first non-writespace is the delimiter */
- return 0;
- }
-
- res->ls_str = next->ls_str;
- end = memchr(next->ls_str, delim, next->ls_len);
- if (end == NULL) {
- /* there is no the delimeter in the string */
- end = next->ls_str + next->ls_len;
- next->ls_str = NULL;
- next->ls_len = 0;
- } else {
- next->ls_str = end + 1;
- next->ls_len -= (end - res->ls_str + 1);
- }
-
- /* skip ending whitespaces */
- while (--end != res->ls_str) {
- if (!isspace(*end))
- break;
- }
-
- res->ls_len = end - res->ls_str + 1;
- return 1;
-}
-EXPORT_SYMBOL(cfs_gettok);
-
-/**
- * Converts string to integer.
- *
- * Accepts decimal and hexadecimal number recordings.
- *
- * \retval 1 if first \a nob chars of \a str convert to decimal or
- * hexadecimal integer in the range [\a min, \a max]
- * \retval 0 otherwise
- */
-int
-cfs_str2num_check(char *str, int nob, unsigned *num,
- unsigned min, unsigned max)
-{
- bool all_numbers = true;
- char *endp, cache;
- int len;
- int rc;
-
- endp = strim(str);
- /**
- * kstrouint can only handle strings composed
- * of only numbers. We need to scan the string
- * passed in for the first non-digit character
- * and end the string at that location. If we
- * don't find any non-digit character we still
- * need to place a '\0' at position len since
- * we are not interested in the rest of the
- * string which is longer than len in size.
- * After we are done the character at the
- * position we placed '\0' must be restored.
- */
- len = min((int)strlen(endp), nob);
- for (; endp < str + len; endp++) {
- if (!isxdigit(*endp) && *endp != '-' &&
- *endp != '+') {
- all_numbers = false;
- break;
- }
- }
-
- /* Eat trailing space */
- if (!all_numbers && isspace(*endp)) {
- all_numbers = true;
- endp--;
- }
-
- cache = *endp;
- *endp = '\0';
-
- rc = kstrtouint(str, 0, num);
- *endp = cache;
- if (rc || !all_numbers)
- return 0;
-
- return (*num >= min && *num <= max);
-}
-EXPORT_SYMBOL(cfs_str2num_check);
-
-/**
* Parses \<range_expr\> token of the syntax. If \a bracketed is false,
* \a src should only have a single token which can be \<number\> or \*
*