fio: fix aio trim completion latencies
[fio.git] / lib / pattern.h
1 #ifndef FIO_PARSE_PATTERN_H
2 #define FIO_PARSE_PATTERN_H
3
4 /**
5  * Pattern format description. The input for 'parse_pattern'.
6  * Describes format with its name and callback, which should
7  * be called to paste something inside the buffer.
8  */
9 struct pattern_fmt_desc {
10         const char  *fmt;
11         unsigned int len;
12         int (*paste)(char *buf, unsigned int len, void *priv);
13 };
14
15 /**
16  * Pattern format. The output of 'parse_pattern'.
17  * Describes the exact position inside the xbuffer.
18  */
19 struct pattern_fmt {
20         unsigned int off;
21         const struct pattern_fmt_desc *desc;
22 };
23
24 int parse_and_fill_pattern(const char *in, unsigned int in_len,
25                            char *out, unsigned int out_len,
26                            const struct pattern_fmt_desc *fmt_desc,
27                            unsigned int fmt_desc_sz,
28                            struct pattern_fmt *fmt,
29                            unsigned int *fmt_sz_out);
30
31 int paste_format_inplace(char *pattern, unsigned int pattern_len,
32                          struct pattern_fmt *fmt, unsigned int fmt_sz,
33                          void *priv);
34
35 int paste_format(const char *pattern, unsigned int pattern_len,
36                  struct pattern_fmt *fmt, unsigned int fmt_sz,
37                  char *out, unsigned int out_len, void *priv);
38
39 int cpy_pattern(const char *pattern, unsigned int pattern_len,
40                 char *out, unsigned int out_len);
41
42 int cmp_pattern(const char *pattern, unsigned int pattern_size,
43                 unsigned int off, const char *buf, unsigned int len);
44
45 #endif