[PATCH] Abstract option handling
[fio.git] / parse.h
1 #ifndef FIO_PARSE_H
2 #define FIO_PARSE_H
3
4 /*
5  * Option types
6  */
7 enum fio_opt_type {
8         FIO_OPT_STR = 0,
9         FIO_OPT_STR_VAL,
10         FIO_OPT_STR_VAL_TIME,
11         FIO_OPT_STR_STORE,
12         FIO_OPT_RANGE,
13         FIO_OPT_INT,
14         FIO_OPT_STR_SET,
15 };
16
17 /*
18  * Option define
19  */
20 struct fio_option {
21         char *name;
22         enum fio_opt_type type;
23         unsigned int off1;
24         unsigned int off2;
25         unsigned int max_val;
26         void *cb;
27 };
28
29 typedef int (str_cb_fn)(void *, char *);
30
31 extern int parse_option(const char *, struct fio_option *, void *);
32
33 extern void strip_blank_front(char **);
34 extern void strip_blank_end(char *);
35
36 /*
37  * Handlers for the options
38  */
39 typedef int (fio_opt_str_fn)(void *, char *);
40 typedef int (fio_opt_str_val_fn)(void *, unsigned long long *);
41 typedef int (fio_opt_int_fn)(void *, unsigned int *);
42 typedef int (fio_opt_str_set_fn)(void *);
43
44 #define td_var(start, offset)   ((void *) start + (offset))
45
46 #endif