Alex Deymo | a5cff22 | 2015-04-08 14:10:30 -0700 | [diff] [blame] | 1 | // Copyright 2015 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef _BSDIFF_EXTENTS_H_ |
| 6 | #define _BSDIFF_EXTENTS_H_ |
Gilad Arnold | 99b5374 | 2013-04-30 09:24:14 -0700 | [diff] [blame] | 7 | |
Alex Deymo | 03f1deb | 2015-10-13 02:15:31 -0700 | [diff] [blame^] | 8 | #include "extents_file.h" |
Gilad Arnold | 99b5374 | 2013-04-30 09:24:14 -0700 | [diff] [blame] | 9 | |
Alex Deymo | 03f1deb | 2015-10-13 02:15:31 -0700 | [diff] [blame^] | 10 | namespace bsdiff { |
Gilad Arnold | 99b5374 | 2013-04-30 09:24:14 -0700 | [diff] [blame] | 11 | |
| 12 | /* Parses a string representation |ex_str| and populates an array |ex_arr| |
| 13 | * consisting of |*ex_count_p| extents. The string is expected to be a |
| 14 | * comma-separated list of pairs of the form "offset:length". An offset may be |
| 15 | * -1 or a non-negative integer; the former indicates a sparse extent |
| 16 | * (consisting of zeros). A length is a positive integer. If |ex_arr| is NULL, |
| 17 | * |*ex_count_p| is ignored and a new array is allocated based on the actual |
| 18 | * number of extents parsed. Upon success, returns a pointer to the populated |
| 19 | * array of extents and stores the actual number of extents at the location |
| 20 | * pointed to be |ex_count_p| (if provided). If the string parses correctly but |
| 21 | * the operation otherwise fails (allocation error, array too small), returns |
| 22 | * NULL but still store the number of parsed extents. Otherwise, returns NULL |
| 23 | * and does not store anything. If a new array was allocated, then it should be |
| 24 | * deallocated with free(3). */ |
Alex Deymo | e1526cf | 2015-10-12 17:48:28 -0700 | [diff] [blame] | 25 | ex_t* extents_parse(const char* ex_str, ex_t* ex_arr, size_t* ex_count_p); |
Gilad Arnold | 99b5374 | 2013-04-30 09:24:14 -0700 | [diff] [blame] | 26 | |
Alex Deymo | 03f1deb | 2015-10-13 02:15:31 -0700 | [diff] [blame^] | 27 | } // namespace bsdiff |
| 28 | |
Alex Deymo | e1526cf | 2015-10-12 17:48:28 -0700 | [diff] [blame] | 29 | #endif /* _BSDIFF_EXTENTS_H_ */ |