Commit | Line | Data |
---|---|---|
e1f36503 JA |
1 | #ifndef FIO_PARSE_H |
2 | #define FIO_PARSE_H | |
3 | ||
b5f4ef37 | 4 | #include <inttypes.h> |
9f988e2e JA |
5 | #include "flist.h" |
6 | ||
e1f36503 JA |
7 | /* |
8 | * Option types | |
9 | */ | |
10 | enum fio_opt_type { | |
07b3232d JA |
11 | FIO_OPT_INVALID = 0, |
12 | FIO_OPT_STR, | |
5f6ddf1e | 13 | FIO_OPT_STR_MULTI, |
e1f36503 JA |
14 | FIO_OPT_STR_VAL, |
15 | FIO_OPT_STR_VAL_TIME, | |
16 | FIO_OPT_STR_STORE, | |
17 | FIO_OPT_RANGE, | |
18 | FIO_OPT_INT, | |
13335ddb | 19 | FIO_OPT_BOOL, |
83349190 | 20 | FIO_OPT_FLOAT_LIST, |
e1f36503 | 21 | FIO_OPT_STR_SET, |
15ca150e | 22 | FIO_OPT_DEPRECATED, |
e1f36503 JA |
23 | }; |
24 | ||
b1ec1da6 JA |
25 | /* |
26 | * Match a possible value string with the integer option. | |
27 | */ | |
28 | struct value_pair { | |
29 | const char *ival; /* string option */ | |
30 | unsigned int oval; /* output value */ | |
7837213b | 31 | const char *help; /* help text for sub option */ |
ebadc0ce | 32 | int orval; /* OR value */ |
c44b1ff5 | 33 | void *cb; /* sub-option callback */ |
b1ec1da6 JA |
34 | }; |
35 | ||
c06c78c0 | 36 | #define OPT_LEN_MAX 4096 |
3ae4f4af | 37 | #define PARSE_MAX_VP 24 |
b1ec1da6 | 38 | |
e1f36503 JA |
39 | /* |
40 | * Option define | |
41 | */ | |
42 | struct fio_option { | |
ee738499 | 43 | const char *name; /* option name */ |
e8b0e958 | 44 | const char *lname; /* long option name */ |
03b74b3e | 45 | const char *alias; /* possible old allowed name */ |
ee738499 JA |
46 | enum fio_opt_type type; /* option type */ |
47 | unsigned int off1; /* potential parameters */ | |
e1f36503 | 48 | unsigned int off2; |
f90eff5a JA |
49 | unsigned int off3; |
50 | unsigned int off4; | |
6eaf09d6 SL |
51 | unsigned int off5; |
52 | unsigned int off6; | |
ee738499 | 53 | unsigned int maxval; /* max and min value */ |
63f29372 | 54 | int minval; |
83349190 YH |
55 | double maxfp; /* max and min floating value */ |
56 | double minfp; | |
20eb06bd | 57 | unsigned int interval; /* client hint for suitable interval */ |
83349190 | 58 | unsigned int maxlen; /* max length */ |
76a43db4 | 59 | int neg; /* negate value stored */ |
3b8b7135 | 60 | int prio; |
ee738499 JA |
61 | void *cb; /* callback */ |
62 | const char *help; /* help text for option */ | |
63 | const char *def; /* default setting */ | |
f5b6bb85 | 64 | struct value_pair posval[PARSE_MAX_VP];/* possible values */ |
afdf9352 | 65 | const char *parent; /* parent option */ |
d71c154c | 66 | int hide; /* hide if parent isn't set */ |
a4ed77fe | 67 | int hide_on_set; /* hide on set, not on unset */ |
90265353 JA |
68 | const char *inverse; /* if set, apply opposite action to this option */ |
69 | struct fio_option *inv_opt; /* cached lookup */ | |
70a4c0c8 | 70 | int (*verify)(struct fio_option *, void *); |
07b3232d | 71 | const char *prof_name; /* only valid for specific profile */ |
7b504edd | 72 | void *prof_opts; |
b5f4ef37 JA |
73 | uint64_t category; /* what type of option */ |
74 | uint64_t group; /* who to group with */ | |
90265353 | 75 | void *gui_data; |
0de5b26f | 76 | int is_seconds; /* time value with seconds base */ |
88038bc7 | 77 | int is_time; /* time based value */ |
c8931876 | 78 | int no_warn_def; |
0f38bbef | 79 | int pow2; /* must be a power-of-2 */ |
e1f36503 JA |
80 | }; |
81 | ||
82 | typedef int (str_cb_fn)(void *, char *); | |
83 | ||
c2292325 | 84 | extern int parse_option(char *, const char *, struct fio_option *, struct fio_option **, void *, struct flist_head *); |
3b8b7135 | 85 | extern void sort_options(char **, struct fio_option *, int); |
d8b4f395 | 86 | extern int parse_cmd_option(const char *t, const char *l, struct fio_option *, void *, struct flist_head *); |
07b3232d | 87 | extern int show_cmd_help(struct fio_option *, const char *); |
ee738499 | 88 | extern void fill_default_options(void *, struct fio_option *); |
9f988e2e | 89 | extern void option_init(struct fio_option *); |
13335ddb | 90 | extern void options_init(struct fio_option *); |
7e356b2d | 91 | extern void options_free(struct fio_option *, void *); |
e1f36503 JA |
92 | |
93 | extern void strip_blank_front(char **); | |
94 | extern void strip_blank_end(char *); | |
88038bc7 | 95 | extern int str_to_decimal(const char *, long long *, int, void *, int, int); |
9af4a244 | 96 | extern int check_str_bytes(const char *p, long long *val, void *data); |
0de5b26f | 97 | extern int check_str_time(const char *p, long long *val, int); |
88038bc7 | 98 | extern int str_to_float(const char *str, double *val, int is_time); |
e1f36503 | 99 | |
a893c261 | 100 | extern int string_distance(const char *s1, const char *s2); |
3701636d | 101 | extern int string_distance_ok(const char *s1, int dist); |
a893c261 | 102 | |
e1f36503 JA |
103 | /* |
104 | * Handlers for the options | |
105 | */ | |
b4692828 | 106 | typedef int (fio_opt_str_fn)(void *, const char *); |
63f29372 JA |
107 | typedef int (fio_opt_str_val_fn)(void *, long long *); |
108 | typedef int (fio_opt_int_fn)(void *, int *); | |
e1f36503 JA |
109 | typedef int (fio_opt_str_set_fn)(void *); |
110 | ||
3b5dac63 | 111 | #define __td_var(start, offset) ((char *) start + (offset)) |
f0fdbcaf JA |
112 | |
113 | struct thread_options; | |
114 | static inline void *td_var(struct thread_options *to, struct fio_option *o, | |
115 | unsigned int offset) | |
116 | { | |
117 | if (o->prof_opts) | |
118 | return __td_var(o->prof_opts, offset); | |
119 | ||
120 | return __td_var(to, offset); | |
121 | } | |
e1f36503 | 122 | |
7bb59102 JA |
123 | static inline int parse_is_percent(unsigned long long val) |
124 | { | |
125 | return val <= -1ULL && val >= (-1ULL - 100ULL); | |
126 | } | |
127 | ||
c2292325 JA |
128 | struct print_option { |
129 | struct flist_head list; | |
130 | char *name; | |
131 | char *value; | |
132 | }; | |
133 | ||
e1f36503 | 134 | #endif |