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