blob: 114582e1749815509f238e243f8d3bc3b8b0c4de [file] [log] [blame]
Colin Cross28fa5bc2012-05-20 13:28:05 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _OUTPUT_FILE_H_
18#define _OUTPUT_FILE_H_
19
Chris Friesa7eeb222017-04-17 21:53:16 -050020#ifdef __cplusplus
21extern "C" {
22#endif
23
Colin Cross28fa5bc2012-05-20 13:28:05 -070024#include <sparse/sparse.h>
Jerry Zhangdb69f0d2018-06-14 16:58:58 -070025#include <sys/types.h>
Colin Cross28fa5bc2012-05-20 13:28:05 -070026
27struct output_file;
28
Jerry Zhang7b444f02018-06-12 16:42:09 -070029struct output_file* output_file_open_fd(int fd, unsigned int block_size, int64_t len, int gz,
30 int sparse, int chunks, int crc);
Jerry Zhangdb69f0d2018-06-14 16:58:58 -070031struct output_file* output_file_open_callback(int (*data_write)(void*, const void*, size_t),
32 int (*fd_write)(void*, int, size_t),
33 int (*fill_write)(void*, uint32_t, size_t),
34 int (*skip_write)(void*, off64_t), void* priv,
35 unsigned int block_size, int64_t len, int sparse,
36 int chunks, int crc);
Jerry Zhang7b444f02018-06-12 16:42:09 -070037int write_data_chunk(struct output_file* out, unsigned int len, void* data);
38int write_fill_chunk(struct output_file* out, unsigned int len, uint32_t fill_val);
39int write_file_chunk(struct output_file* out, unsigned int len, const char* file, int64_t offset);
40int write_fd_chunk(struct output_file* out, unsigned int len, int fd, int64_t offset);
41int write_skip_chunk(struct output_file* out, int64_t len);
42void output_file_close(struct output_file* out);
Colin Cross28fa5bc2012-05-20 13:28:05 -070043
Jerry Zhang7b444f02018-06-12 16:42:09 -070044int read_all(int fd, void* buf, size_t len);
Colin Cross13a56062012-06-19 16:45:48 -070045
Chris Friesa7eeb222017-04-17 21:53:16 -050046#ifdef __cplusplus
47}
48#endif
49
Colin Cross28fa5bc2012-05-20 13:28:05 -070050#endif