Squash  0.7.0
file.h
1 /* Copyright (c) 2015 The Squash Authors
2  *
3  * Permission is hereby granted, free of charge, to any person
4  * obtaining a copy of this software and associated documentation
5  * files (the "Software"), to deal in the Software without
6  * restriction, including without limitation the rights to use, copy,
7  * modify, merge, publish, distribute, sublicense, and/or sell copies
8  * of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be
12  * included in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
18  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21  * SOFTWARE.
22  *
23  * Authors:
24  * Evan Nemerson <evan@nemerson.com>
25  */
26 
27 #ifndef SQUASH_FILE_H
28 #define SQUASH_FILE_H
29 
30 #if !defined (SQUASH_H_INSIDE) && !defined (SQUASH_COMPILATION)
31 #error "Only <squash/squash.h> can be included directly."
32 #endif
33 
34 #include <stdbool.h>
35 #include <stdio.h>
36 
37 SQUASH_BEGIN_DECLS
38 
39 SQUASH_API SquashFile* squash_file_open (const char* codec,
40  const char* filename,
41  const char* mode,
42  ...);
43 SQUASH_API SquashFile* squash_file_open_codec (SquashCodec* codec,
44  const char* filename,
45  const char* mode,
46  ...);
47 SQUASH_API SquashFile* squash_file_open_with_options (const char* codec,
48  const char* filename,
49  const char* mode,
50  SquashOptions* options);
51 SQUASH_API SquashFile* squash_file_open_codec_with_options (SquashCodec* codec,
52  const char* filename,
53  const char* mode,
54  SquashOptions* options);
55 
56 SQUASH_API SquashFile* squash_file_steal (const char* codec,
57  FILE* fp,
58  ...);
59 SQUASH_API SquashFile* squash_file_steal_codec (SquashCodec* codec,
60  FILE* fp,
61  ...);
62 SQUASH_API SquashFile* squash_file_steal_with_options (const char* codec,
63  FILE* fp,
64  SquashOptions* options);
65 SQUASH_API SquashFile* squash_file_steal_codec_with_options (SquashCodec* codec,
66  FILE* fp,
67  SquashOptions* options);
68 
69 SQUASH_API SquashStatus squash_file_read (SquashFile* file,
70  size_t* decompressed_length,
71  uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_length)]);
72 SQUASH_API SquashStatus squash_file_write (SquashFile* file,
73  size_t uncompressed_length,
74  const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_length)]);
75 SQUASH_API SquashStatus squash_file_flush (SquashFile* file);
76 
77 SQUASH_API SquashStatus squash_splice (const char* codec,
78  SquashStreamType stream_type,
79  FILE* fp_out,
80  FILE* fp_in,
81  size_t length,
82  ...);
83 SQUASH_API SquashStatus squash_splice_codec (SquashCodec* codec,
84  SquashStreamType stream_type,
85  FILE* fp_out,
86  FILE* fp_in,
87  size_t length,
88  ...);
89 SQUASH_API SquashStatus squash_splice_with_options (const char* codec,
90  SquashStreamType stream_type,
91  FILE* fp_out,
92  FILE* fp_in,
93  size_t length,
94  SquashOptions* options);
95 SQUASH_API SquashStatus squash_splice_codec_with_options (SquashCodec* codec,
96  SquashStreamType stream_type,
97  FILE* fp_out,
98  FILE* fp_in,
99  size_t length,
100  SquashOptions* options);
101 
102 SQUASH_API SquashStatus squash_file_close (SquashFile* file);
103 SQUASH_API SquashStatus squash_file_free (SquashFile* file,
104  FILE** fp);
105 SQUASH_API bool squash_file_eof (SquashFile* file);
106 
107 SQUASH_END_DECLS
108 
109 #endif /* SQUASH_FILE_H */
SQUASH_API SquashStatus squash_splice_codec_with_options(SquashCodec *codec, SquashStreamType stream_type, FILE *fp_out, FILE *fp_in, size_t length, SquashOptions *options)
compress or decompress the contents of one file to another
Definition: file.c:960
SQUASH_API bool squash_file_eof(SquashFile *file)
Determine whether the file has reached the end of file.
Definition: file.c:632
SQUASH_BEGIN_DECLS SQUASH_API SquashFile * squash_file_open(const char *codec, const char *filename, const char *mode,...)
Open a file.
Definition: file.c:213
SQUASH_API SquashStatus squash_file_read(SquashFile *file, size_t *decompressed_length, uint8_t decompressed[SQUASH_ARRAY_PARAM(*decompressed_length)])
Read from a compressed file.
Definition: file.c:439
SQUASH_API SquashStatus squash_file_flush(SquashFile *file)
immediately write any buffered data to a file
Definition: file.c:619
SQUASH_API SquashFile * squash_file_open_codec_with_options(SquashCodec *codec, const char *filename, const char *mode, SquashOptions *options)
Open a file using a codec instance with the specified options.
Definition: file.c:293
SQUASH_API SquashFile * squash_file_open_with_options(const char *codec, const char *filename, const char *mode, SquashOptions *options)
Open a file with the specified options.
Definition: file.c:270
SquashStatus
Status codes.
Definition: status.h:36
SQUASH_API SquashFile * squash_file_steal_codec(SquashCodec *codec, FILE *fp,...)
Open an existing stdio file using a codec instance.
Definition: file.c:347
SQUASH_API SquashStatus squash_file_close(SquashFile *file)
Close a file.
Definition: file.c:1003
SQUASH_API SquashStatus squash_splice_with_options(const char *codec, SquashStreamType stream_type, FILE *fp_out, FILE *fp_in, size_t length, SquashOptions *options)
compress or decompress the contents of one file to another
Definition: file.c:726
SQUASH_API SquashFile * squash_file_steal_codec_with_options(SquashCodec *codec, FILE *fp, SquashOptions *options)
Open an existing stdio file using a codec instance with the specified options.
Definition: file.c:396
SQUASH_API SquashStatus squash_splice(const char *codec, SquashStreamType stream_type, FILE *fp_out, FILE *fp_in, size_t length,...)
compress or decompress the contents of one file to another
Definition: file.c:655
SQUASH_API SquashStatus squash_file_free(SquashFile *file, FILE **fp)
Free a file.
Definition: file.c:1026
SQUASH_API SquashFile * squash_file_steal_with_options(const char *codec, FILE *fp, SquashOptions *options)
Open an existing stdio file with the specified options.
Definition: file.c:373
SQUASH_API SquashFile * squash_file_open_codec(SquashCodec *codec, const char *filename, const char *mode,...)
Open a file using a codec instance.
Definition: file.c:244
SQUASH_API SquashStatus squash_splice_codec(SquashCodec *codec, SquashStreamType stream_type, FILE *fp_out, FILE *fp_in, size_t length,...)
compress or decompress the contents of one file to another
Definition: file.c:692
SquashStreamType
Stream type.
Definition: stream.h:38
SQUASH_API SquashFile * squash_file_steal(const char *codec, FILE *fp,...)
Open an existing stdio file.
Definition: file.c:318
SQUASH_API SquashStatus squash_file_write(SquashFile *file, size_t uncompressed_length, const uint8_t uncompressed[SQUASH_ARRAY_PARAM(uncompressed_length)])
Write data to a compressed file.
Definition: file.c:601