Suppress gcc 8 compiler warnings
[fio.git] / parse.h
... / ...
CommitLineData
1#ifndef FIO_PARSE_H
2#define FIO_PARSE_H
3
4#include <inttypes.h>
5#include "flist.h"
6
7/*
8 * Option types
9 */
10enum fio_opt_type {
11 FIO_OPT_INVALID = 0,
12 FIO_OPT_STR,
13 FIO_OPT_STR_MULTI,
14 FIO_OPT_STR_VAL,
15 FIO_OPT_STR_VAL_TIME,
16 FIO_OPT_STR_STORE,
17 FIO_OPT_RANGE,
18 FIO_OPT_INT,
19 FIO_OPT_BOOL,
20 FIO_OPT_FLOAT_LIST,
21 FIO_OPT_STR_SET,
22 FIO_OPT_DEPRECATED,
23 FIO_OPT_SOFT_DEPRECATED,
24 FIO_OPT_UNSUPPORTED, /* keep this last */
25};
26
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 */
33 const char *help; /* help text for sub option */
34 int orval; /* OR value */
35 void *cb; /* sub-option callback */
36};
37
38#define OPT_LEN_MAX 4096
39#define PARSE_MAX_VP 24
40
41/*
42 * Option define
43 */
44struct fio_option {
45 const char *name; /* option name */
46 const char *lname; /* long option name */
47 const char *alias; /* possible old allowed name */
48 enum fio_opt_type type; /* option type */
49 unsigned int off1; /* potential parameters */
50 unsigned int off2;
51 unsigned int off3;
52 unsigned int off4;
53 unsigned int off5;
54 unsigned int off6;
55 unsigned int maxval; /* max and min value */
56 int minval;
57 double maxfp; /* max and min floating value */
58 double minfp;
59 unsigned int interval; /* client hint for suitable interval */
60 unsigned int maxlen; /* max length */
61 int neg; /* negate value stored */
62 int prio;
63 void *cb; /* callback */
64 const char *help; /* help text for option */
65 const char *def; /* default setting */
66 struct value_pair posval[PARSE_MAX_VP];/* possible values */
67 const char *parent; /* parent option */
68 int hide; /* hide if parent isn't set */
69 int hide_on_set; /* hide on set, not on unset */
70 const char *inverse; /* if set, apply opposite action to this option */
71 struct fio_option *inv_opt; /* cached lookup */
72 int (*verify)(const struct fio_option *, void *);
73 const char *prof_name; /* only valid for specific profile */
74 void *prof_opts;
75 uint64_t category; /* what type of option */
76 uint64_t group; /* who to group with */
77 void *gui_data;
78 int is_seconds; /* time value with seconds base */
79 int is_time; /* time based value */
80 int no_warn_def;
81 int pow2; /* must be a power-of-2 */
82 int no_free;
83};
84
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 *);
94extern void options_init(struct fio_option *);
95extern void options_mem_dupe(const struct fio_option *, void *);
96extern void options_free(const struct fio_option *, void *);
97
98extern void strip_blank_front(char **);
99extern void strip_blank_end(char *);
100extern int str_to_decimal(const char *, long long *, int, void *, int, int);
101extern int check_str_bytes(const char *p, long long *val, void *data);
102extern int check_str_time(const char *p, long long *val, int);
103extern int str_to_float(const char *str, double *val, int is_time);
104
105extern int string_distance(const char *s1, const char *s2);
106extern int string_distance_ok(const char *s1, int dist);
107
108/*
109 * Handlers for the options
110 */
111typedef int (fio_opt_str_fn)(void *, const char *);
112typedef int (fio_opt_str_val_fn)(void *, long long *);
113typedef int (fio_opt_int_fn)(void *, int *);
114
115struct thread_options;
116static inline void *td_var(void *to, const struct fio_option *o,
117 unsigned int offset)
118{
119 void *ret;
120
121 if (o->prof_opts)
122 ret = o->prof_opts;
123 else
124 ret = to;
125
126 return ret + offset;
127}
128
129static inline int parse_is_percent(unsigned long long val)
130{
131 return val <= -1ULL && val >= (-1ULL - 100ULL);
132}
133
134struct print_option {
135 struct flist_head list;
136 char *name;
137 char *value;
138};
139
140#endif