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