gfio: sync range spin buttons in edit view
[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_INVALID = 0,
11 FIO_OPT_STR,
12 FIO_OPT_STR_MULTI,
13 FIO_OPT_STR_VAL,
14 FIO_OPT_STR_VAL_TIME,
15 FIO_OPT_STR_STORE,
16 FIO_OPT_RANGE,
17 FIO_OPT_INT,
18 FIO_OPT_BOOL,
19 FIO_OPT_FLOAT_LIST,
20 FIO_OPT_STR_SET,
21 FIO_OPT_DEPRECATED,
22};
23
24/*
25 * Match a possible value string with the integer option.
26 */
27struct value_pair {
28 const char *ival; /* string option */
29 unsigned int oval; /* output value */
30 const char *help; /* help text for sub option */
31 int or; /* OR value */
32 void *cb; /* sub-option callback */
33};
34
35#define OPT_LEN_MAX 4096
36#define PARSE_MAX_VP 16
37
38/*
39 * Option define
40 */
41struct fio_option {
42 const char *name; /* option name */
43 const char *alias; /* possible old allowed name */
44 enum fio_opt_type type; /* option type */
45 unsigned int off1; /* potential parameters */
46 unsigned int off2;
47 unsigned int off3;
48 unsigned int off4;
49 void *roff1, *roff2, *roff3, *roff4;
50 unsigned int maxval; /* max and min value */
51 int minval;
52 double maxfp; /* max and min floating value */
53 double minfp;
54 unsigned int maxlen; /* max length */
55 int neg; /* negate value stored */
56 int prio;
57 void *cb; /* callback */
58 const char *help; /* help text for option */
59 const char *def; /* default setting */
60 struct value_pair posval[PARSE_MAX_VP];/* possible values */
61 const char *parent; /* parent option */
62 int (*verify)(struct fio_option *, void *);
63 const char *prof_name; /* only valid for specific profile */
64 unsigned int category; /* for type grouping */
65};
66
67typedef int (str_cb_fn)(void *, char *);
68
69extern int parse_option(char *, const char *, struct fio_option *, struct fio_option **, void *);
70extern void sort_options(char **, struct fio_option *, int);
71extern int parse_cmd_option(const char *t, const char *l, struct fio_option *, void *);
72extern int show_cmd_help(struct fio_option *, const char *);
73extern void fill_default_options(void *, struct fio_option *);
74extern void option_init(struct fio_option *);
75extern void options_init(struct fio_option *);
76extern void options_free(struct fio_option *, void *);
77
78extern void strip_blank_front(char **);
79extern void strip_blank_end(char *);
80extern int str_to_decimal(const char *, long long *, int, void *);
81extern int check_str_bytes(const char *p, long long *val, void *data);
82
83/*
84 * Handlers for the options
85 */
86typedef int (fio_opt_str_fn)(void *, const char *);
87typedef int (fio_opt_str_val_fn)(void *, long long *);
88typedef int (fio_opt_int_fn)(void *, int *);
89typedef int (fio_opt_str_set_fn)(void *);
90
91#define td_var(start, offset) ((void *) start + (offset))
92
93#ifndef min
94#define min(a, b) ((a) < (b) ? (a) : (b))
95#endif
96#ifndef max
97#define max(a, b) ((a) > (b) ? (a) : (b))
98#endif
99
100static inline int parse_is_percent(unsigned long long val)
101{
102 return val <= -1ULL && val >= (-1ULL - 100ULL);
103}
104
105#endif