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