]> icculus.org git repositories - icculus/xz.git/blob - src/lzma/io.h
Sort of garbage collection commit. :-| Many things are still
[icculus/xz.git] / src / lzma / io.h
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file       io.h
4 /// \brief      I/O types and functions
5 //
6 //  Copyright (C) 2007 Lasse Collin
7 //
8 //  This program is free software; you can redistribute it and/or
9 //  modify it under the terms of the GNU Lesser General Public
10 //  License as published by the Free Software Foundation; either
11 //  version 2.1 of the License, or (at your option) any later version.
12 //
13 //  This program is distributed in the hope that it will be useful,
14 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
15 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 //  Lesser General Public License for more details.
17 //
18 ///////////////////////////////////////////////////////////////////////////////
19
20 #ifndef IO_H
21 #define IO_H
22
23 #include "private.h"
24
25 #if BUFSIZ <= 1024
26 #       define IO_BUFFER_SIZE 8192
27 #else
28 #       define IO_BUFFER_SIZE BUFSIZ
29 #endif
30
31
32 typedef struct {
33         const char *src_name;
34         char *dest_name;
35
36         int dir_fd;
37         int src_fd;
38         int dest_fd;
39
40         struct stat src_st;
41         ino_t dest_ino;
42
43         bool src_eof;
44 } file_pair;
45
46
47 extern void io_init(void);
48
49 extern void io_finish(void);
50
51 extern file_pair *io_open(const char *src_name);
52
53 extern void io_close(file_pair *pair, bool success);
54
55 extern size_t io_read(file_pair *pair, uint8_t *buf, size_t size);
56
57 extern int io_write(const file_pair *pair, const uint8_t *buf, size_t size);
58
59
60 #endif