blob: 7374c258ab95a339cff8853707a567df2ad68422 [file] [log] [blame]
Jens Axboee1f36502006-10-27 10:54:08 +02001#ifndef FIO_PARSE_H
2#define FIO_PARSE_H
3
4/*
5 * Option types
6 */
7enum fio_opt_type {
8 FIO_OPT_STR = 0,
9 FIO_OPT_STR_VAL,
Jens Axboe75e6f362006-11-03 08:17:09 +010010 FIO_OPT_STR_VAL_INT,
Jens Axboee1f36502006-10-27 10:54:08 +020011 FIO_OPT_STR_VAL_TIME,
12 FIO_OPT_STR_STORE,
13 FIO_OPT_RANGE,
14 FIO_OPT_INT,
Jens Axboe13335dd2007-01-10 13:14:02 +010015 FIO_OPT_BOOL,
Jens Axboee1f36502006-10-27 10:54:08 +020016 FIO_OPT_STR_SET,
17};
18
19/*
20 * Option define
21 */
22struct fio_option {
Jens Axboeee738492007-01-10 11:23:16 +010023 const char *name; /* option name */
Jens Axboe03b74b32007-01-11 11:04:31 +010024 const char *alias; /* possible old allowed name */
Jens Axboeee738492007-01-10 11:23:16 +010025 enum fio_opt_type type; /* option type */
26 unsigned int off1; /* potential parameters */
Jens Axboee1f36502006-10-27 10:54:08 +020027 unsigned int off2;
Jens Axboef90eff52006-11-06 11:08:21 +010028 unsigned int off3;
29 unsigned int off4;
Jens Axboeee738492007-01-10 11:23:16 +010030 unsigned int maxval; /* max and min value */
Jens Axboe63f29372007-01-10 13:20:09 +010031 int minval;
Jens Axboe76a43db2007-01-11 13:24:44 +010032 int neg; /* negate value stored */
Jens Axboeee738492007-01-10 11:23:16 +010033 void *cb; /* callback */
34 const char *help; /* help text for option */
35 const char *def; /* default setting */
Jens Axboe15f79182007-01-10 12:26:18 +010036 const char *posval[16]; /* possible values */
Jens Axboee1f36502006-10-27 10:54:08 +020037};
38
39typedef int (str_cb_fn)(void *, char *);
40
41extern int parse_option(const char *, struct fio_option *, void *);
Jens Axboeb4692822006-10-27 13:43:22 +020042extern int parse_cmd_option(const char *t, const char *l, struct fio_option *, void *);
Jens Axboefd28ca42007-01-09 21:20:13 +010043extern int show_cmd_help(struct fio_option *, const char *);
Jens Axboeee738492007-01-10 11:23:16 +010044extern void fill_default_options(void *, struct fio_option *);
Jens Axboe13335dd2007-01-10 13:14:02 +010045extern void options_init(struct fio_option *);
Jens Axboee1f36502006-10-27 10:54:08 +020046
47extern void strip_blank_front(char **);
48extern void strip_blank_end(char *);
49
50/*
51 * Handlers for the options
52 */
Jens Axboeb4692822006-10-27 13:43:22 +020053typedef int (fio_opt_str_fn)(void *, const char *);
Jens Axboe63f29372007-01-10 13:20:09 +010054typedef int (fio_opt_str_val_fn)(void *, long long *);
55typedef int (fio_opt_int_fn)(void *, int *);
Jens Axboee1f36502006-10-27 10:54:08 +020056typedef int (fio_opt_str_set_fn)(void *);
57
58#define td_var(start, offset) ((void *) start + (offset))
59
60#endif