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