Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * linux/include/linux/parser.h
0004  *
0005  * Header for lib/parser.c
0006  * Intended use of these functions is parsing filesystem argument lists,
0007  * but could potentially be used anywhere else that simple option=arg
0008  * parsing is required.
0009  */
0010 #ifndef _LINUX_PARSER_H
0011 #define _LINUX_PARSER_H
0012 
0013 /* associates an integer enumerator with a pattern string. */
0014 struct match_token {
0015     int token;
0016     const char *pattern;
0017 };
0018 
0019 typedef struct match_token match_table_t[];
0020 
0021 /* Maximum number of arguments that match_token will find in a pattern */
0022 enum {MAX_OPT_ARGS = 3};
0023 
0024 /* Describe the location within a string of a substring */
0025 typedef struct {
0026     char *from;
0027     char *to;
0028 } substring_t;
0029 
0030 int match_token(char *, const match_table_t table, substring_t args[]);
0031 int match_int(substring_t *, int *result);
0032 int match_uint(substring_t *s, unsigned int *result);
0033 int match_u64(substring_t *, u64 *result);
0034 int match_octal(substring_t *, int *result);
0035 int match_hex(substring_t *, int *result);
0036 bool match_wildcard(const char *pattern, const char *str);
0037 size_t match_strlcpy(char *, const substring_t *, size_t);
0038 char *match_strdup(const substring_t *);
0039 
0040 #endif /* _LINUX_PARSER_H */