blob: 12fc3482f5fc7ae1135d2a7f9a10358d88a9bcf9 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * linux/include/linux/parser.h
4 *
5 * Header for lib/parser.c
6 * Intended use of these functions is parsing filesystem argument lists,
7 * but could potentially be used anywhere else that simple option=arg
8 * parsing is required.
9 */
10
11
12/* associates an integer enumerator with a pattern string. */
13struct match_token {
14 int token;
David Howellsef4533f2007-05-03 03:10:39 -070015 const char *pattern;
Linus Torvalds1da177e2005-04-16 15:20:36 -070016};
17
Linus Torvalds1a3f7d92008-08-04 16:50:38 -070018typedef struct match_token match_table_t[];
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
20/* Maximum number of arguments that match_token will find in a pattern */
21enum {MAX_OPT_ARGS = 3};
22
23/* Describe the location within a string of a substring */
24typedef struct {
25 char *from;
26 char *to;
27} substring_t;
28
Steven Whitehousea447c092008-10-13 10:46:57 +010029int match_token(char *, const match_table_t table, substring_t args[]);
Linus Torvalds1da177e2005-04-16 15:20:36 -070030int match_int(substring_t *, int *result);
James Smarta3171782016-10-21 23:51:54 +030031int match_u64(substring_t *, u64 *result);
Linus Torvalds1da177e2005-04-16 15:20:36 -070032int match_octal(substring_t *, int *result);
33int match_hex(substring_t *, int *result);
Du, Changbinaace0502014-01-23 15:54:12 -080034bool match_wildcard(const char *pattern, const char *str);
Markus Armbrusterb32a09d2008-02-26 09:57:11 -060035size_t match_strlcpy(char *, const substring_t *, size_t);
David Howellsef4533f2007-05-03 03:10:39 -070036char *match_strdup(const substring_t *);