gfio: add View -> Results menu item
[fio.git] / parse.h
CommitLineData
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 */
9enum 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 */
27struct value_pair {
28 const char *ival; /* string option */
29 unsigned int oval; /* output value */
7837213b 30 const char *help; /* help text for sub option */
5f6ddf1e 31 int or; /* OR value */
c44b1ff5 32 void *cb; /* sub-option callback */
b1ec1da6
JA
33};
34
c06c78c0 35#define OPT_LEN_MAX 4096
b1ec1da6
JA
36#define PARSE_MAX_VP 16
37
c9c63318
JA
38enum opt_category {
39 FIO_OPT_G_DESC = 1UL << 0,
40 FIO_OPT_G_FILE = 1UL << 1,
41 FIO_OPT_G_MISC = 1UL << 2,
42 FIO_OPT_G_IO = 1UL << 3,
43 FIO_OPT_G_IO_DDIR = 1UL << 4,
44 FIO_OPT_G_IO_BUF = 1UL << 5,
45 FIO_OPT_G_RAND = 1UL << 6,
46 FIO_OPT_G_OS = 1UL << 7,
47 FIO_OPT_G_MEM = 1UL << 8,
48 FIO_OPT_G_VERIFY = 1UL << 9,
49 FIO_OPT_G_CPU = 1UL << 10,
50 FIO_OPT_G_LOG = 1UL << 11,
51 FIO_OPT_G_ZONE = 1UL << 12,
52 FIO_OPT_G_CACHE = 1UL << 13,
53 FIO_OPT_G_STAT = 1UL << 14,
54 FIO_OPT_G_ERR = 1UL << 15,
55 FIO_OPT_G_JOB = 1UL << 16,
56};
57
e1f36503
JA
58/*
59 * Option define
60 */
61struct fio_option {
ee738499 62 const char *name; /* option name */
03b74b3e 63 const char *alias; /* possible old allowed name */
ee738499
JA
64 enum fio_opt_type type; /* option type */
65 unsigned int off1; /* potential parameters */
e1f36503 66 unsigned int off2;
f90eff5a
JA
67 unsigned int off3;
68 unsigned int off4;
02c6aad5 69 void *roff1, *roff2, *roff3, *roff4;
ee738499 70 unsigned int maxval; /* max and min value */
63f29372 71 int minval;
83349190
YH
72 double maxfp; /* max and min floating value */
73 double minfp;
74 unsigned int maxlen; /* max length */
76a43db4 75 int neg; /* negate value stored */
3b8b7135 76 int prio;
ee738499
JA
77 void *cb; /* callback */
78 const char *help; /* help text for option */
79 const char *def; /* default setting */
f5b6bb85 80 struct value_pair posval[PARSE_MAX_VP];/* possible values */
afdf9352 81 const char *parent; /* parent option */
70a4c0c8 82 int (*verify)(struct fio_option *, void *);
07b3232d 83 const char *prof_name; /* only valid for specific profile */
c9c63318 84 unsigned int category; /* for type grouping */
e1f36503
JA
85};
86
87typedef int (str_cb_fn)(void *, char *);
88
de890a1e 89extern int parse_option(char *, const char *, struct fio_option *, struct fio_option **, void *);
3b8b7135 90extern void sort_options(char **, struct fio_option *, int);
07b3232d
JA
91extern int parse_cmd_option(const char *t, const char *l, struct fio_option *, void *);
92extern int show_cmd_help(struct fio_option *, const char *);
ee738499 93extern void fill_default_options(void *, struct fio_option *);
9f988e2e 94extern void option_init(struct fio_option *);
13335ddb 95extern void options_init(struct fio_option *);
7e356b2d 96extern void options_free(struct fio_option *, void *);
e1f36503
JA
97
98extern void strip_blank_front(char **);
99extern void strip_blank_end(char *);
6925dd35 100extern int str_to_decimal(const char *, long long *, int, void *);
e1f36503
JA
101
102/*
103 * Handlers for the options
104 */
b4692828 105typedef int (fio_opt_str_fn)(void *, const char *);
63f29372
JA
106typedef int (fio_opt_str_val_fn)(void *, long long *);
107typedef int (fio_opt_int_fn)(void *, int *);
e1f36503
JA
108typedef int (fio_opt_str_set_fn)(void *);
109
110#define td_var(start, offset) ((void *) start + (offset))
111
0e9f7fac
JA
112#ifndef min
113#define min(a, b) ((a) < (b) ? (a) : (b))
114#endif
115#ifndef max
116#define max(a, b) ((a) > (b) ? (a) : (b))
117#endif
118
7bb59102
JA
119static inline int parse_is_percent(unsigned long long val)
120{
121 return val <= -1ULL && val >= (-1ULL - 100ULL);
122}
123
e1f36503 124#endif