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

Contents of /pax-utils/paxinc.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.16 - (hide annotations) (download) (as text)
Wed Dec 8 01:16:01 2010 UTC (4 years, 1 month ago) by vapier
Branch: MAIN
Changes since 1.15: +3 -6 lines
File MIME type: text/x-chdr
add a -C/--nocolor option and respect env $NOCOLOR #332289

1 vapier 1.1 /*
2 solar 1.9 * Copyright 2005-2007 Gentoo Foundation
3 vapier 1.1 * Distributed under the terms of the GNU General Public License v2
4 vapier 1.16 * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxinc.h,v 1.15 2010/12/08 00:54:40 vapier Exp $
5 vapier 1.1 *
6 solar 1.9 * Copyright 2005-2007 Ned Ludd - <solar@gentoo.org>
7     * Copyright 2005-2007 Mike Frysinger - <vapier@gentoo.org>
8 vapier 1.1 *
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 vapier 1.10 #include "xfuncs.h"
17 vapier 1.1
18     #ifndef VERSION
19     # define VERSION "cvs"
20     #endif
21    
22     /* ELF love */
23     #include "elf.h"
24     #include "paxelf.h"
25    
26 grobian 1.11 /* Mach-O love */
27     #include "macho.h"
28     #include "paxmacho.h"
29    
30 vapier 1.1 extern char do_reverse_endian;
31    
32 vapier 1.5 #ifdef IN_paxinc
33     typedef struct {
34     int fd;
35     const char *filename;
36 vapier 1.6 size_t skip;
37 grobian 1.12 char *extfn;
38 vapier 1.5 } 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 vapier 1.10 } formatted;
61 vapier 1.5 } buf;
62     #endif
63     } archive_member;
64 vapier 1.6 archive_handle *ar_open_fd(const char *filename, int fd);
65 vapier 1.5 archive_handle *ar_open(const char *filename);
66     archive_member *ar_next(archive_handle *);
67    
68 vapier 1.14 const char *strfileperms(const char *fname);
69    
70 vapier 1.1 /* 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 vapier 1.13 } else { errf("EGET failed :( (sizeof(X) == %i)", (int)sizeof(X)); } \
80 vapier 1.1 __res; \
81     }))
82    
83 vapier 1.4 /* 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 vapier 1.13 } else { errf("ESET failed :( (size(Y) == %i)", (int)sizeof(Y)); } \
92 vapier 1.4 } while (0)
93    
94 vapier 1.1 /* helper functions for showing errors */
95 vapier 1.16 extern const char *NORM, *RED, *YELLOW;
96     void color_init(bool disable);
97 vapier 1.1
98 vapier 1.10 /* constant pointer to a constant buffer ... each program needs to set this */
99 vapier 1.15 extern const char argv0[];
100 vapier 1.10
101 vapier 1.1 /* we need the space before the last comma or we trigger a bug in gcc-2 :( */
102     #define warn(fmt, args...) \
103 vapier 1.7 fprintf(stderr, "%s%s%s: " fmt "\n", RED, argv0, NORM , ## args)
104 vapier 1.1 #define warnf(fmt, args...) warn("%s%s%s(): " fmt, YELLOW, __FUNCTION__, NORM , ## args)
105 vapier 1.7 #define warnp(fmt, args...) warn(fmt ": %s" , ## args , strerror(errno))
106     #define warnfp(fmt, args...) warnf(fmt ": %s" , ## args , strerror(errno))
107 vapier 1.1 #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 vapier 1.7 #define errp(fmt, args...) _err(warnp, fmt , ## args)
115 vapier 1.1
116     #endif /* _PAX_INC_H */

  ViewVC Help
Powered by ViewVC 1.1.20