Add support for registrering external options
[fio.git] / parse.h
... / ...
CommitLineData
1#ifndef FIO_PARSE_H
2#define FIO_PARSE_H
3
4#include "flist.h"
5
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,
16 FIO_OPT_BOOL,
17 FIO_OPT_STR_SET,
18 FIO_OPT_DEPRECATED,
19};
20
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 */
27 const char *help; /* help text for sub option */
28};
29
30#define OPT_LEN_MAX 4096
31#define PARSE_MAX_VP 16
32
33/*
34 * Option define
35 */
36struct fio_option {
37 const char *name; /* option name */
38 const char *alias; /* possible old allowed name */
39 enum fio_opt_type type; /* option type */
40 unsigned int off1; /* potential parameters */
41 unsigned int off2;
42 unsigned int off3;
43 unsigned int off4;
44 unsigned int maxval; /* max and min value */
45 int minval;
46 int neg; /* negate value stored */
47 int prio;
48 void *cb; /* callback */
49 const char *help; /* help text for option */
50 const char *def; /* default setting */
51 const struct value_pair posval[PARSE_MAX_VP];/* possible values */
52 const char *parent; /* parent option */
53 int (*verify)(struct fio_option *, void *);
54};
55
56typedef int (str_cb_fn)(void *, char *);
57
58extern int parse_option(const char *, struct fio_option *, struct flist_head *, void *);
59extern void sort_options(char **, struct fio_option *, int);
60extern int parse_cmd_option(const char *t, const char *l, struct fio_option *, struct flist_head *, void *);
61extern int show_cmd_help(struct fio_option *, const char *);
62extern void fill_default_options(void *, struct fio_option *);
63extern void option_init(struct fio_option *);
64extern void options_init(struct fio_option *);
65
66extern void strip_blank_front(char **);
67extern void strip_blank_end(char *);
68extern int str_to_decimal(const char *, long long *, int, void *);
69
70/*
71 * Handlers for the options
72 */
73typedef int (fio_opt_str_fn)(void *, const char *);
74typedef int (fio_opt_str_val_fn)(void *, long long *);
75typedef int (fio_opt_int_fn)(void *, int *);
76typedef int (fio_opt_str_set_fn)(void *);
77
78#define td_var(start, offset) ((void *) start + (offset))
79
80#ifndef min
81#define min(a, b) ((a) < (b) ? (a) : (b))
82#endif
83#ifndef max
84#define max(a, b) ((a) > (b) ? (a) : (b))
85#endif
86
87#endif