Blame parse.h

Packit 8930e1
#ifndef FIO_PARSE_H
Packit 8930e1
#define FIO_PARSE_H
Packit 8930e1
Packit 8930e1
#include <inttypes.h>
Packit 8930e1
#include "flist.h"
Packit 8930e1
Packit 8930e1
/*
Packit 8930e1
 * Option types
Packit 8930e1
 */
Packit 8930e1
enum fio_opt_type {
Packit 8930e1
	FIO_OPT_INVALID = 0,
Packit 8930e1
	FIO_OPT_STR,
Packit 8930e1
	FIO_OPT_STR_ULL,
Packit 8930e1
	FIO_OPT_STR_MULTI,
Packit 8930e1
	FIO_OPT_STR_VAL,
Packit 8930e1
	FIO_OPT_STR_VAL_TIME,
Packit 8930e1
	FIO_OPT_STR_STORE,
Packit 8930e1
	FIO_OPT_RANGE,
Packit 8930e1
	FIO_OPT_INT,
Packit 8930e1
	FIO_OPT_ULL,
Packit 8930e1
	FIO_OPT_BOOL,
Packit 8930e1
	FIO_OPT_FLOAT_LIST,
Packit 8930e1
	FIO_OPT_STR_SET,
Packit 8930e1
	FIO_OPT_DEPRECATED,
Packit 8930e1
	FIO_OPT_SOFT_DEPRECATED,
Packit 8930e1
	FIO_OPT_UNSUPPORTED,	/* keep this last */
Packit 8930e1
};
Packit 8930e1
Packit 8930e1
/*
Packit 8930e1
 * Match a possible value string with the integer option.
Packit 8930e1
 */
Packit 8930e1
struct value_pair {
Packit 8930e1
	const char *ival;		/* string option */
Packit 8930e1
	unsigned long long oval;/* output value */
Packit 8930e1
	const char *help;		/* help text for sub option */
Packit 8930e1
	int orval;			/* OR value */
Packit 8930e1
	void *cb;			/* sub-option callback */
Packit 8930e1
};
Packit 8930e1
Packit 8930e1
#define OPT_LEN_MAX 	8192
Packit 8930e1
#define PARSE_MAX_VP	32
Packit 8930e1
Packit 8930e1
/*
Packit 8930e1
 * Option define
Packit 8930e1
 */
Packit 8930e1
struct fio_option {
Packit 8930e1
	const char *name;		/* option name */
Packit 8930e1
	const char *lname;		/* long option name */
Packit 8930e1
	const char *alias;		/* possible old allowed name */
Packit 8930e1
	enum fio_opt_type type;		/* option type */
Packit 8930e1
	unsigned int off1;		/* potential parameters */
Packit 8930e1
	unsigned int off2;
Packit 8930e1
	unsigned int off3;
Packit 8930e1
	unsigned int off4;
Packit 8930e1
	unsigned int off5;
Packit 8930e1
	unsigned int off6;
Packit 8930e1
	unsigned long long maxval;		/* max and min value */
Packit 8930e1
	int minval;
Packit 8930e1
	double maxfp;			/* max and min floating value */
Packit 8930e1
	double minfp;
Packit 8930e1
	unsigned int interval;		/* client hint for suitable interval */
Packit 8930e1
	unsigned int maxlen;		/* max length */
Packit 8930e1
	int neg;			/* negate value stored */
Packit 8930e1
	int prio;
Packit 8930e1
	void *cb;			/* callback */
Packit 8930e1
	const char *help;		/* help text for option */
Packit 8930e1
	const char *def;		/* default setting */
Packit 8930e1
	struct value_pair posval[PARSE_MAX_VP];/* possible values */
Packit 8930e1
	const char *parent;		/* parent option */
Packit 8930e1
	int hide;			/* hide if parent isn't set */
Packit 8930e1
	int hide_on_set;		/* hide on set, not on unset */
Packit 8930e1
	const char *inverse;		/* if set, apply opposite action to this option */
Packit 8930e1
	struct fio_option *inv_opt;	/* cached lookup */
Packit 8930e1
	int (*verify)(const struct fio_option *, void *);
Packit 8930e1
	const char *prof_name;		/* only valid for specific profile */
Packit 8930e1
	void *prof_opts;
Packit 8930e1
	uint64_t category;		/* what type of option */
Packit 8930e1
	uint64_t group;			/* who to group with */
Packit 8930e1
	void *gui_data;
Packit 8930e1
	int is_seconds;			/* time value with seconds base */
Packit 8930e1
	int is_time;			/* time based value */
Packit 8930e1
	int no_warn_def;
Packit 8930e1
	int pow2;			/* must be a power-of-2 */
Packit 8930e1
	int no_free;
Packit 8930e1
};
Packit 8930e1
Packit 8930e1
extern int parse_option(char *, const char *, const struct fio_option *,
Packit 8930e1
			const struct fio_option **, void *,
Packit 8930e1
			struct flist_head *);
Packit 8930e1
extern void sort_options(char **, const struct fio_option *, int);
Packit 8930e1
extern int parse_cmd_option(const char *t, const char *l,
Packit 8930e1
			    const struct fio_option *, void *,
Packit 8930e1
			    struct flist_head *);
Packit 8930e1
extern int show_cmd_help(const struct fio_option *, const char *);
Packit 8930e1
extern void fill_default_options(void *, const struct fio_option *);
Packit 8930e1
extern void options_init(struct fio_option *);
Packit 8930e1
extern void options_mem_dupe(const struct fio_option *, void *);
Packit 8930e1
extern void options_free(const struct fio_option *, void *);
Packit 8930e1
Packit 8930e1
extern void strip_blank_front(char **);
Packit 8930e1
extern void strip_blank_end(char *);
Packit 8930e1
extern int str_to_decimal(const char *, long long *, int, void *, int, int);
Packit 8930e1
extern int check_str_bytes(const char *p, long long *val, void *data);
Packit 8930e1
extern int check_str_time(const char *p, long long *val, int);
Packit 8930e1
extern int str_to_float(const char *str, double *val, int is_time);
Packit 8930e1
Packit 8930e1
extern int string_distance(const char *s1, const char *s2);
Packit 8930e1
extern int string_distance_ok(const char *s1, int dist);
Packit 8930e1
Packit 8930e1
/*
Packit 8930e1
 * Handlers for the options
Packit 8930e1
 */
Packit 8930e1
typedef int (fio_opt_str_fn)(void *, const char *);
Packit 8930e1
typedef int (fio_opt_str_val_fn)(void *, long long *);
Packit 8930e1
typedef int (fio_opt_int_fn)(void *, int *);
Packit 8930e1
Packit 8930e1
struct thread_options;
Packit 8930e1
static inline void *td_var(void *to, const struct fio_option *o,
Packit 8930e1
			   unsigned int offset)
Packit 8930e1
{
Packit 8930e1
	void *ret;
Packit 8930e1
Packit 8930e1
	if (o->prof_opts)
Packit 8930e1
		ret = o->prof_opts;
Packit 8930e1
	else
Packit 8930e1
		ret = to;
Packit 8930e1
Packit 8930e1
	return ret + offset;
Packit 8930e1
}
Packit 8930e1
Packit 8930e1
static inline int parse_is_percent(unsigned long long val)
Packit 8930e1
{
Packit 8930e1
	return val <= -1ULL && val >= (-1ULL - 100ULL);
Packit 8930e1
}
Packit 8930e1
Packit 8930e1
struct print_option {
Packit 8930e1
	struct flist_head list;
Packit 8930e1
	char *name;
Packit 8930e1
	char *value;
Packit 8930e1
};
Packit 8930e1
Packit 8930e1
#endif