lib/pattern: add set of functions to parse combined pattern input
authorRoman Pen <r.peniaev@gmail.com>
Wed, 19 Aug 2015 10:33:07 +0000 (12:33 +0200)
committerJens Axboe <axboe@fb.com>
Fri, 4 Sep 2015 19:33:02 +0000 (13:33 -0600)
commit634bd210c17a51c681adc6ed8e6a0abe04e9781b
treec0da73186a1df87b2a04f376300b3fe6acee5393
parentbd99994bdb37f34b7afb68a47d1ddffb1891ff8b
lib/pattern: add set of functions to parse combined pattern input

The idea of this patch is to have several helpers to parse combined
pattern input, which can consists of strings, numbers and formats.

For example now pattern can be combined and look like this string:

 input : 0xdeadbeef"123"0xdeadface
 output: de ad be ef 31 32 33 de ad fa ce

  or

 input : -99"some string"0x66
 output: 9d ff ff ff 73 6f 6d 65 20 73 74 72 69 6e 67 66

  or with formats

 input : 0xdeadface0xffff%o
 output: de ad fa ce ff ff 00 00 00 00 00 00 00 00

 where %o - offset of the block, reserved 8 bytes

 Space for formats is reserved in output buffer.
 When buffer will be ready to be written to disk - 'paste' callback
 should be called for each pattern format. Each callback is responsible
 for writing data inside the reserved space in the output buffer.

Format array can be extended at any time, all you need is to provide
the name of the format and correct 'paste' callback.

Signed-off-by: Roman Pen <r.peniaev@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Makefile
lib/pattern.c [new file with mode: 0644]
lib/pattern.h [new file with mode: 0644]