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