blob: 7af14580601502c1081662464e0ffc709e3a31f1 [file] [log] [blame]
Gilad Arnold99b53742013-04-30 09:24:14 -07001#ifndef __EXTENTS_H
2#define __EXTENTS_H
3
4#include "exfile.h"
5
6
7/* Parses a string representation |ex_str| and populates an array |ex_arr|
8 * consisting of |*ex_count_p| extents. The string is expected to be a
9 * comma-separated list of pairs of the form "offset:length". An offset may be
10 * -1 or a non-negative integer; the former indicates a sparse extent
11 * (consisting of zeros). A length is a positive integer. If |ex_arr| is NULL,
12 * |*ex_count_p| is ignored and a new array is allocated based on the actual
13 * number of extents parsed. Upon success, returns a pointer to the populated
14 * array of extents and stores the actual number of extents at the location
15 * pointed to be |ex_count_p| (if provided). If the string parses correctly but
16 * the operation otherwise fails (allocation error, array too small), returns
17 * NULL but still store the number of parsed extents. Otherwise, returns NULL
18 * and does not store anything. If a new array was allocated, then it should be
19 * deallocated with free(3). */
20ex_t *extents_parse(const char *ex_str, ex_t *ex_arr, size_t *ex_count_p);
21
22#endif /* __EXTENTS_H */