Commit | Line | Data |
---|---|---|
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 | */ | |
9 | enum 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 | */ | |
27 | struct 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 */ |
b1ec1da6 JA |
32 | }; |
33 | ||
c06c78c0 | 34 | #define OPT_LEN_MAX 4096 |
b1ec1da6 JA |
35 | #define PARSE_MAX_VP 16 |
36 | ||
e1f36503 JA |
37 | /* |
38 | * Option define | |
39 | */ | |
40 | struct fio_option { | |
ee738499 | 41 | const char *name; /* option name */ |
03b74b3e | 42 | const char *alias; /* possible old allowed name */ |
ee738499 JA |
43 | enum fio_opt_type type; /* option type */ |
44 | unsigned int off1; /* potential parameters */ | |
e1f36503 | 45 | unsigned int off2; |
f90eff5a JA |
46 | unsigned int off3; |
47 | unsigned int off4; | |
02c6aad5 | 48 | void *roff1, *roff2, *roff3, *roff4; |
ee738499 | 49 | unsigned int maxval; /* max and min value */ |
63f29372 | 50 | int minval; |
83349190 YH |
51 | double maxfp; /* max and min floating value */ |
52 | double minfp; | |
53 | unsigned int maxlen; /* max length */ | |
76a43db4 | 54 | int neg; /* negate value stored */ |
3b8b7135 | 55 | int prio; |
ee738499 JA |
56 | void *cb; /* callback */ |
57 | const char *help; /* help text for option */ | |
58 | const char *def; /* default setting */ | |
f5b6bb85 | 59 | struct value_pair posval[PARSE_MAX_VP];/* possible values */ |
afdf9352 | 60 | const char *parent; /* parent option */ |
70a4c0c8 | 61 | int (*verify)(struct fio_option *, void *); |
07b3232d | 62 | const char *prof_name; /* only valid for specific profile */ |
e1f36503 JA |
63 | }; |
64 | ||
65 | typedef int (str_cb_fn)(void *, char *); | |
66 | ||
07b3232d | 67 | extern int parse_option(const char *, struct fio_option *, void *); |
3b8b7135 | 68 | extern void sort_options(char **, struct fio_option *, int); |
07b3232d JA |
69 | extern int parse_cmd_option(const char *t, const char *l, struct fio_option *, void *); |
70 | extern int show_cmd_help(struct fio_option *, const char *); | |
ee738499 | 71 | extern void fill_default_options(void *, struct fio_option *); |
9f988e2e | 72 | extern void option_init(struct fio_option *); |
13335ddb | 73 | extern void options_init(struct fio_option *); |
e1f36503 JA |
74 | |
75 | extern void strip_blank_front(char **); | |
76 | extern void strip_blank_end(char *); | |
d6978a32 | 77 | extern int str_to_decimal(const char *, long long *, int, void *); |
e1f36503 JA |
78 | |
79 | /* | |
80 | * Handlers for the options | |
81 | */ | |
b4692828 | 82 | typedef int (fio_opt_str_fn)(void *, const char *); |
63f29372 JA |
83 | typedef int (fio_opt_str_val_fn)(void *, long long *); |
84 | typedef int (fio_opt_int_fn)(void *, int *); | |
e1f36503 JA |
85 | typedef int (fio_opt_str_set_fn)(void *); |
86 | ||
87 | #define td_var(start, offset) ((void *) start + (offset)) | |
88 | ||
0e9f7fac JA |
89 | #ifndef min |
90 | #define min(a, b) ((a) < (b) ? (a) : (b)) | |
91 | #endif | |
92 | #ifndef max | |
93 | #define max(a, b) ((a) > (b) ? (a) : (b)) | |
94 | #endif | |
95 | ||
7bb59102 JA |
96 | static inline int parse_is_percent(unsigned long long val) |
97 | { | |
98 | return val <= -1ULL && val >= (-1ULL - 100ULL); | |
99 | } | |
100 | ||
e1f36503 | 101 | #endif |