gettime: remove unneeded 'ret' in {utime,mtime}_since()
[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,
75e6bcba 23 FIO_OPT_UNSUPPORTED,
e1f36503
JA
24};
25
b1ec1da6
JA
26/*
27 * Match a possible value string with the integer option.
28 */
29struct 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 */
43struct 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
83typedef int (str_cb_fn)(void *, char *);
84
c2292325 85extern int parse_option(char *, const char *, struct fio_option *, struct fio_option **, void *, struct flist_head *);
3b8b7135 86extern void sort_options(char **, struct fio_option *, int);
d8b4f395 87extern int parse_cmd_option(const char *t, const char *l, struct fio_option *, void *, struct flist_head *);
07b3232d 88extern int show_cmd_help(struct fio_option *, const char *);
ee738499 89extern void fill_default_options(void *, struct fio_option *);
9f988e2e 90extern void option_init(struct fio_option *);
13335ddb 91extern void options_init(struct fio_option *);
7e356b2d 92extern void options_free(struct fio_option *, void *);
e1f36503
JA
93
94extern void strip_blank_front(char **);
95extern void strip_blank_end(char *);
88038bc7 96extern int str_to_decimal(const char *, long long *, int, void *, int, int);
9af4a244 97extern int check_str_bytes(const char *p, long long *val, void *data);
0de5b26f 98extern int check_str_time(const char *p, long long *val, int);
88038bc7 99extern int str_to_float(const char *str, double *val, int is_time);
e1f36503 100
a893c261 101extern int string_distance(const char *s1, const char *s2);
3701636d 102extern int string_distance_ok(const char *s1, int dist);
a893c261 103
e1f36503
JA
104/*
105 * Handlers for the options
106 */
b4692828 107typedef int (fio_opt_str_fn)(void *, const char *);
63f29372
JA
108typedef int (fio_opt_str_val_fn)(void *, long long *);
109typedef int (fio_opt_int_fn)(void *, int *);
e1f36503
JA
110typedef int (fio_opt_str_set_fn)(void *);
111
3b5dac63 112#define __td_var(start, offset) ((char *) start + (offset))
f0fdbcaf
JA
113
114struct thread_options;
115static inline void *td_var(struct thread_options *to, struct fio_option *o,
116 unsigned int offset)
117{
118 if (o->prof_opts)
119 return __td_var(o->prof_opts, offset);
120
121 return __td_var(to, offset);
122}
e1f36503 123
7bb59102
JA
124static inline int parse_is_percent(unsigned long long val)
125{
126 return val <= -1ULL && val >= (-1ULL - 100ULL);
127}
128
c2292325
JA
129struct print_option {
130 struct flist_head list;
131 char *name;
132 char *value;
133};
134
e1f36503 135#endif