po: Update German man pages translation
[dpkg.git] / lib / dpkg / buffer.h
blobe29766014478f63694652d61000053667df61658
1 /*
2 * libdpkg - Debian packaging suite library routines
3 * buffer.h - buffer I/O handling routines
5 * Copyright © 1999, 2000 Wichert Akkerman <wakkerma@debian.org>
6 * Copyright © 2000-2003 Adam Heath <doogie@debian.org>
7 * Copyright © 2005 Scott James Remnant
8 * Copyright © 2008-2011 Guillem Jover <guillem@debian.org>
10 * This is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 #ifndef LIBDPKG_BUFFER_H
25 #define LIBDPKG_BUFFER_H
27 #include <sys/types.h>
29 #include <dpkg/macros.h>
30 #include <dpkg/error.h>
32 DPKG_BEGIN_DECLS
34 /**
35 * @defgroup buffer Buffer I/O
36 * @ingroup dpkg-internal
37 * @{
40 #define DPKG_BUFFER_SIZE (32 * 1024)
42 #define BUFFER_WRITE_VBUF 1
43 #define BUFFER_WRITE_FD 2
44 #define BUFFER_WRITE_NULL 3
46 #define BUFFER_DIGEST_NULL 4
47 #define BUFFER_DIGEST_MD5 5
49 #define BUFFER_READ_FD 0
51 struct buffer_data {
52 union {
53 void *ptr;
54 int i;
55 } arg;
56 int type;
59 # define buffer_md5(buf, hash, limit) \
60 buffer_digest(buf, hash, BUFFER_DIGEST_MD5, limit)
62 # define fd_md5(fd, hash, limit, err) \
63 buffer_copy_IntPtr(fd, BUFFER_READ_FD, \
64 hash, BUFFER_DIGEST_MD5, \
65 NULL, BUFFER_WRITE_NULL, \
66 limit, err)
67 # define fd_fd_copy(fd1, fd2, limit, err) \
68 buffer_copy_IntInt(fd1, BUFFER_READ_FD, \
69 NULL, BUFFER_DIGEST_NULL, \
70 fd2, BUFFER_WRITE_FD, \
71 limit, err)
72 # define fd_fd_copy_and_md5(fd1, fd2, hash, limit, err) \
73 buffer_copy_IntInt(fd1, BUFFER_READ_FD, \
74 hash, BUFFER_DIGEST_MD5, \
75 fd2, BUFFER_WRITE_FD, \
76 limit, err)
77 # define fd_vbuf_copy(fd, buf, limit, err) \
78 buffer_copy_IntPtr(fd, BUFFER_READ_FD, \
79 NULL, BUFFER_DIGEST_NULL, \
80 buf, BUFFER_WRITE_VBUF, \
81 limit, err)
82 # define fd_skip(fd, limit, err) \
83 buffer_skip_Int(fd, BUFFER_READ_FD, limit, err)
86 off_t buffer_copy_IntPtr(int i, int typeIn,
87 void *f, int typeDigest,
88 void *p, int typeOut,
89 off_t limit, struct dpkg_error *err)
90 DPKG_ATTR_REQRET;
91 off_t buffer_copy_IntInt(int i1, int typeIn,
92 void *f, int typeDigest,
93 int i2, int typeOut,
94 off_t limit, struct dpkg_error *err)
95 DPKG_ATTR_REQRET;
96 off_t buffer_skip_Int(int I, int T, off_t limit, struct dpkg_error *err)
97 DPKG_ATTR_REQRET;
98 off_t buffer_digest(const void *buf, void *hash, int typeDigest, off_t length);
100 /** @} */
102 DPKG_END_DECLS
104 #endif /* LIBDPKG_BUFFER_H */