2 * libdpkg - Debian packaging suite library routines
3 * ar.h - primitives for ar handling
5 * Copyright © 2010 Guillem Jover <guillem@debian.org>
7 * This is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 #include <sys/types.h>
29 #include <dpkg/macros.h>
34 * @defgroup ar Ar archive handling
35 * @ingroup dpkg-public
39 #define DPKG_AR_MAGIC "!<arch>\n"
40 #define DPKG_AR_FMAG "`\n"
43 * An on-disk archive header.
46 char ar_name
[16]; /* Member file name, sometimes / terminated. */
47 char ar_date
[12]; /* File date, decimal seconds since Epoch. */
48 char ar_uid
[6], ar_gid
[6]; /* User and group IDs, in ASCII decimal. */
49 char ar_mode
[8]; /* File mode, in ASCII octal. */
50 char ar_size
[10]; /* File size, in ASCII decimal. */
55 * An archive (Unix ar) file.
66 * In-memory archive member information.
68 struct dpkg_ar_member
{
69 struct dpkg_ar_member
*next
;
80 dpkg_ar_fdopen(const char *filename
, int fd
);
81 struct dpkg_ar
*dpkg_ar_open(const char *filename
);
82 struct dpkg_ar
*dpkg_ar_create(const char *filename
, mode_t mode
);
83 void dpkg_ar_set_mtime(struct dpkg_ar
*ar
, intmax_t mtime
);
84 void dpkg_ar_close(struct dpkg_ar
*ar
);
86 void dpkg_ar_normalize_name(struct dpkg_ar_hdr
*arh
);
87 bool dpkg_ar_member_is_illegal(struct dpkg_ar_hdr
*arh
);
89 void dpkg_ar_put_magic(struct dpkg_ar
*ar
);
90 void dpkg_ar_member_put_header(struct dpkg_ar
*ar
,
91 struct dpkg_ar_member
*member
);
92 void dpkg_ar_member_put_file(struct dpkg_ar
*ar
, const char *name
,
94 void dpkg_ar_member_put_mem(struct dpkg_ar
*ar
, const char *name
,
95 const void *data
, size_t size
);
96 off_t
dpkg_ar_member_get_size(struct dpkg_ar
*ar
, struct dpkg_ar_hdr
*arh
);
102 #endif /* LIBDPKG_AR_H */