/[gentoo-projects]/pax-utils/paxinc.h
Gentoo

Contents of /pax-utils/paxinc.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.17 - (show annotations) (download) (as text)
Sun Nov 4 07:26:24 2012 UTC (2 years, 1 month ago) by vapier
Branch: MAIN
CVS Tags: HEAD
Changes since 1.16: +4 -4 lines
File MIME type: text/x-chdr
update copyright years

1 /*
2 * Copyright 2005-2012 Gentoo Foundation
3 * Distributed under the terms of the GNU General Public License v2
4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxinc.h,v 1.16 2010/12/08 01:16:01 vapier Exp $
5 *
6 * Copyright 2005-2012 Ned Ludd - <solar@gentoo.org>
7 * Copyright 2005-2012 Mike Frysinger - <vapier@gentoo.org>
8 *
9 * Make sure all of the common stuff is setup as we expect
10 */
11
12 #ifndef _PAX_INC_H
13 #define _PAX_INC_H
14
15 #include "porting.h"
16 #include "xfuncs.h"
17
18 #ifndef VERSION
19 # define VERSION "cvs"
20 #endif
21
22 /* ELF love */
23 #include "elf.h"
24 #include "paxelf.h"
25
26 /* Mach-O love */
27 #include "macho.h"
28 #include "paxmacho.h"
29
30 extern char do_reverse_endian;
31
32 #ifdef IN_paxinc
33 typedef struct {
34 int fd;
35 const char *filename;
36 size_t skip;
37 char *extfn;
38 } archive_handle;
39 #else
40 typedef void archive_handle;
41 #endif
42 typedef struct {
43 char name[__PAX_UTILS_PATH_MAX];
44 time_t date;
45 uid_t uid;
46 gid_t gid;
47 mode_t mode;
48 off_t size;
49 #ifdef IN_paxinc
50 union {
51 char raw[60];
52 struct {
53 char name[16];
54 char date[12];
55 char uid[6];
56 char gid[6];
57 char mode[8];
58 char size[10];
59 char magic[2];
60 } formatted;
61 } buf;
62 #endif
63 } archive_member;
64 archive_handle *ar_open_fd(const char *filename, int fd);
65 archive_handle *ar_open(const char *filename);
66 archive_member *ar_next(archive_handle *);
67
68 const char *strfileperms(const char *fname);
69
70 /* Get a value 'X', compensating for endianness. */
71 #define EGET(X) \
72 (__extension__ ({ \
73 uint64_t __res; \
74 if (!do_reverse_endian) { __res = (X); \
75 } else if (sizeof(X) == 1) { __res = (X); \
76 } else if (sizeof(X) == 2) { __res = bswap_16((X)); \
77 } else if (sizeof(X) == 4) { __res = bswap_32((X)); \
78 } else if (sizeof(X) == 8) { __res = bswap_64((X)); \
79 } else { errf("EGET failed :( (sizeof(X) == %i)", (int)sizeof(X)); } \
80 __res; \
81 }))
82
83 /* Set a value 'Y' to 'X', compensating for endianness. */
84 #define ESET(Y,X) \
85 do { \
86 if (!do_reverse_endian) { Y = (X); \
87 } else if (sizeof(Y) == 1) { Y = (X); \
88 } else if (sizeof(Y) == 2) { Y = bswap_16((uint16_t)(X)); \
89 } else if (sizeof(Y) == 4) { Y = bswap_32((uint32_t)(X)); \
90 } else if (sizeof(Y) == 8) { Y = bswap_64((uint64_t)(X)); \
91 } else { errf("ESET failed :( (size(Y) == %i)", (int)sizeof(Y)); } \
92 } while (0)
93
94 /* helper functions for showing errors */
95 extern const char *NORM, *RED, *YELLOW;
96 void color_init(bool disable);
97
98 /* constant pointer to a constant buffer ... each program needs to set this */
99 extern const char argv0[];
100
101 /* we need the space before the last comma or we trigger a bug in gcc-2 :( */
102 #define warn(fmt, args...) \
103 fprintf(stderr, "%s%s%s: " fmt "\n", RED, argv0, NORM , ## args)
104 #define warnf(fmt, args...) warn("%s%s%s(): " fmt, YELLOW, __FUNCTION__, NORM , ## args)
105 #define warnp(fmt, args...) warn(fmt ": %s" , ## args , strerror(errno))
106 #define warnfp(fmt, args...) warnf(fmt ": %s" , ## args , strerror(errno))
107 #define _err(wfunc, fmt, args...) \
108 do { \
109 wfunc(fmt, ## args); \
110 exit(EXIT_FAILURE); \
111 } while (0)
112 #define err(fmt, args...) _err(warn, fmt, ## args)
113 #define errf(fmt, args...) _err(warnf, fmt, ## args)
114 #define errp(fmt, args...) _err(warnp, fmt , ## args)
115
116 #endif /* _PAX_INC_H */

  ViewVC Help
Powered by ViewVC 1.1.20