Add initial support for profile specific options
[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 {
10 FIO_OPT_STR = 0,
11 FIO_OPT_STR_VAL,
12 FIO_OPT_STR_VAL_TIME,
13 FIO_OPT_STR_STORE,
14 FIO_OPT_RANGE,
15 FIO_OPT_INT,
13335ddb 16 FIO_OPT_BOOL,
e1f36503 17 FIO_OPT_STR_SET,
15ca150e 18 FIO_OPT_DEPRECATED,
e1f36503
JA
19};
20
b1ec1da6
JA
21/*
22 * Match a possible value string with the integer option.
23 */
24struct value_pair {
25 const char *ival; /* string option */
26 unsigned int oval; /* output value */
7837213b 27 const char *help; /* help text for sub option */
b1ec1da6
JA
28};
29
c06c78c0 30#define OPT_LEN_MAX 4096
b1ec1da6
JA
31#define PARSE_MAX_VP 16
32
e1f36503
JA
33/*
34 * Option define
35 */
36struct fio_option {
ee738499 37 const char *name; /* option name */
03b74b3e 38 const char *alias; /* possible old allowed name */
ee738499
JA
39 enum fio_opt_type type; /* option type */
40 unsigned int off1; /* potential parameters */
e1f36503 41 unsigned int off2;
f90eff5a
JA
42 unsigned int off3;
43 unsigned int off4;
02c6aad5 44 void *roff1, *roff2, *roff3, *roff4;
ee738499 45 unsigned int maxval; /* max and min value */
63f29372 46 int minval;
76a43db4 47 int neg; /* negate value stored */
3b8b7135 48 int prio;
ee738499
JA
49 void *cb; /* callback */
50 const char *help; /* help text for option */
51 const char *def; /* default setting */
b1ec1da6 52 const struct value_pair posval[PARSE_MAX_VP];/* possible values */
afdf9352 53 const char *parent; /* parent option */
70a4c0c8 54 int (*verify)(struct fio_option *, void *);
e1f36503
JA
55};
56
57typedef int (str_cb_fn)(void *, char *);
58
9f988e2e 59extern int parse_option(const char *, struct fio_option *, struct flist_head *, void *);
3b8b7135 60extern void sort_options(char **, struct fio_option *, int);
9f988e2e 61extern int parse_cmd_option(const char *t, const char *l, struct fio_option *, struct flist_head *, void *);
e2de69da 62extern int show_cmd_help(struct fio_option *, struct flist_head *, const char *);
ee738499 63extern void fill_default_options(void *, struct fio_option *);
9f988e2e 64extern void option_init(struct fio_option *);
13335ddb 65extern void options_init(struct fio_option *);
e1f36503
JA
66
67extern void strip_blank_front(char **);
68extern void strip_blank_end(char *);
d6978a32 69extern int str_to_decimal(const char *, long long *, int, void *);
e1f36503
JA
70
71/*
72 * Handlers for the options
73 */
b4692828 74typedef int (fio_opt_str_fn)(void *, const char *);
63f29372
JA
75typedef int (fio_opt_str_val_fn)(void *, long long *);
76typedef int (fio_opt_int_fn)(void *, int *);
e1f36503
JA
77typedef int (fio_opt_str_set_fn)(void *);
78
79#define td_var(start, offset) ((void *) start + (offset))
80
0e9f7fac
JA
81#ifndef min
82#define min(a, b) ((a) < (b) ? (a) : (b))
83#endif
84#ifndef max
85#define max(a, b) ((a) > (b) ? (a) : (b))
86#endif
87
e1f36503 88#endif