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