Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/pax/paxlib.h
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 1987-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Glenn Fowler <[email protected]> *
18
* *
19
***********************************************************************/
20
#pragma prototyped
21
/*
22
* Glenn Fowler
23
* AT&T Research
24
*
25
* pax_lib() definitions
26
*/
27
28
#ifndef _PAXLIB_H
29
#define _PAXLIB_H 1
30
31
#include <ast.h>
32
#include <error.h>
33
#include <ls.h>
34
#include <modex.h>
35
36
#if _BLD_DEBUG
37
#include <vmalloc.h>
38
#endif
39
40
#define PAX_PLUGIN_VERSION AST_PLUGIN_VERSION(20100528L)
41
42
#define PAX_IN (1<<0) /* copy in */
43
#define PAX_OUT (1<<1) /* copy out */
44
#define PAX_ARCHIVE (1<<2) /* archive format */
45
#define PAX_COMPRESS (1<<3) /* compress format */
46
#define PAX_DELTA (1<<4) /* delta format */
47
#define PAX_DLL (1<<5) /* format from external dll */
48
#define PAX_DOS (1<<6) /* may contain dos names */
49
#define PAX_PSEUDO (1<<7) /* pseudo delta format */
50
#define PAX_COMPRESSED (1<<8) /* format already compressed */
51
#define PAX_CONV (1<<9) /* format handles ccode conv */
52
#define PAX_DELTAINFO (1<<10) /* format handles delta info */
53
#define PAX_KEEPSIZE (1<<11) /* retain non REG st_size */
54
#define PAX_LINKTYPE (1<<12) /* Paxfile_t.linktype supported */
55
#define PAX_NOHARDLINKS (1<<13) /* hard links not supported */
56
#define PAX_SLASHDIR (1<<14) /* trailing slash => directory */
57
#define PAX_STANDARD (1L<<15) /* the standard format */
58
#define PAX_SUM (1L<<16) /* inline member checksum */
59
#define PAX_DELTAIO (1L<<17) /* separate delta io */
60
#define PAX_APPEND (1L<<18) /* archive append */
61
62
#define PAX_FORMAT (1L<<24) /* first format specific flag */
63
64
#define PAX_BLOCK 512 /* io block size */
65
#define PAX_DEFBLOCKS 20 /* default blocking */
66
#define PAX_DEFBUFFER 16 /* default io buffer blocking */
67
68
#define PAX_NOLINK 0 /* not a link */
69
#define PAX_HARDLINK '1' /* hard link to previous entry */
70
#define PAX_SOFTLINK '2' /* soft link to previous entry */
71
72
#define PAX_EVENT_BUG_19951031 0x00000001 /* old write bug workaround */
73
#define PAX_EVENT_DELTA_EXTEND 0x00000002 /* add delta entension info */
74
#define PAX_EVENT_SKIP_JUNK 0x00000004 /* junk header test */
75
76
struct Pax_s; typedef struct Pax_s Pax_t;
77
#ifndef Paxarchive_t
78
struct Paxarchive_s; typedef struct Paxarchive_s Paxarchive_t;
79
#endif
80
#ifndef Paxfile_t
81
struct Paxfile_s; typedef struct Paxfile_s Paxfile_t;
82
#endif
83
#ifndef Paxformat_t
84
struct Paxformat_s; typedef struct Paxformat_s Paxformat_t;
85
#endif
86
struct Paxio_s; typedef struct Paxio_s Paxio_t;
87
struct Paxvalue_s; typedef struct Paxvalue_s Paxvalue_t;
88
89
typedef Paxformat_t* (*Paxlib_f)(Pax_t*);
90
91
struct Paxvalue_s /* string and/or number value */
92
{
93
char* string; /* string value */
94
int32_t number; /* numeric value */
95
int32_t fraction; /* fractional part */
96
size_t size; /* max string size */
97
};
98
99
struct Paxio_s /* io info */
100
{
101
int fd; /* file descriptor */
102
int eof; /* hit EOF */
103
off_t buffersize; /* buffer size */
104
105
#ifdef _PAX_IO_PRIVATE_
106
_PAX_IO_PRIVATE_
107
#endif
108
109
};
110
111
struct Paxfile_s /* common internal file info */
112
{
113
char* name; /* archive file name */
114
char* path; /* local file name for reading */
115
char* linkpath; /* link path */
116
struct stat* st; /* stat() info from ftwalk() */
117
off_t uncompressed; /* uncompressed size if != 0 */
118
int linktype; /* link type */
119
120
#ifdef _PAX_FILE_PRIVATE_
121
_PAX_FILE_PRIVATE_
122
#endif
123
124
};
125
126
struct Paxformat_s /* format info */
127
{
128
char* name; /* name */
129
char* match; /* name strgrpmatch pattern */
130
char* desc; /* description */
131
int variant; /* variant index */
132
int32_t flags; /* flags */
133
unsigned long regular; /* default regular blocking */
134
unsigned long special; /* default special blocking */
135
int align; /* trailer alignment */
136
struct Paxformat_s*next; /* next in list of all formats */
137
void* data; /* format specific data */
138
int (*done)(Pax_t*, Paxarchive_t*);
139
int (*getprologue)(Pax_t*, Paxformat_t*, Paxarchive_t*, Paxfile_t*, unsigned char*, size_t);
140
int (*getheader)(Pax_t*, Paxarchive_t*, Paxfile_t*);
141
int (*getdata)(Pax_t*, Paxarchive_t*, Paxfile_t*, int);
142
int (*gettrailer)(Pax_t*, Paxarchive_t*, Paxfile_t*);
143
int (*getepilogue)(Pax_t*, Paxarchive_t*);
144
int (*putprologue)(Pax_t*, Paxarchive_t*, int);
145
int (*putheader)(Pax_t*, Paxarchive_t*, Paxfile_t*);
146
int (*putdata)(Pax_t*, Paxarchive_t*, Paxfile_t*, int);
147
int (*puttrailer)(Pax_t*, Paxarchive_t*, Paxfile_t*);
148
off_t (*putepilogue)(Pax_t*, Paxarchive_t*);
149
int (*lookup)(Pax_t*, Paxarchive_t*, Paxfile_t*, int, char**, Sflong_t*);
150
int (*backup)(Pax_t*, Paxarchive_t*);
151
unsigned long (*checksum)(Pax_t*, Paxarchive_t*, Paxfile_t*, void*, size_t, unsigned long);
152
int (*validate)(Pax_t*, Paxarchive_t*, Paxfile_t*);
153
int (*event)(Pax_t*, Paxarchive_t*, Paxfile_t*, void*, unsigned long);
154
unsigned long events;
155
char* details; /* instance details */
156
};
157
158
struct Paxarchive_s /* archive info */
159
{
160
char* name; /* archive name */
161
void* data; /* format specific data */
162
Paxformat_t* format; /* format */
163
int32_t flags; /* format flags */
164
int incomplete; /* file requires new volume */
165
int volume; /* volume number */
166
size_t entries; /* total number of entries */
167
size_t entry; /* current entry index */
168
Paxio_t* io; /* current io */
169
struct /* paxstash() values */
170
{
171
Paxvalue_t comment; /* header comment */
172
Paxvalue_t head; /* header path name */
173
Paxvalue_t link; /* link text */
174
Paxvalue_t zip; /* zip header name */
175
} stash;
176
177
#ifdef _PAX_ARCHIVE_PRIVATE_
178
_PAX_ARCHIVE_PRIVATE_
179
#endif
180
181
};
182
183
struct Pax_s /* global state */
184
{
185
const char* id; /* interface id */
186
const char* passphrase; /* encryption passphrase */
187
int32_t flags; /* flags */
188
int gid; /* current group id */
189
int keepgoing; /* keep going on error */
190
int list; /* full file trace */
191
int modemask; /* ~umask() */
192
int strict; /* strict standard conformance */
193
int summary; /* output summary info */
194
int test; /* debug test bits */
195
int uid; /* current user id */
196
int verbose; /* trace files when acted upon */
197
int verify; /* verify action on file */
198
int warn; /* archive specific warnings */
199
long pid; /* main pid */
200
off_t buffersize; /* io buffer size */
201
202
char buf[SF_BUFSIZE];/* file io buffer */
203
204
Error_f errorf;
205
206
int (*dataf)(Pax_t*, Paxarchive_t*, Paxfile_t*, int, void*, off_t);
207
void* (*getf)(Pax_t*, Paxarchive_t*, off_t, off_t*);
208
Sfio_t* (*partf)(Pax_t*, Paxarchive_t*, off_t);
209
int (*putf)(Pax_t*, Paxarchive_t*, off_t);
210
off_t (*readf)(Pax_t*, Paxarchive_t*, void*, off_t, off_t, int);
211
off_t (*seekf)(Pax_t*, Paxarchive_t*, off_t, int, int);
212
char* (*stashf)(Pax_t*, Paxvalue_t*, const char*, size_t);
213
int (*syncf)(Pax_t*, Paxarchive_t*, int);
214
int (*unreadf)(Pax_t*, Paxarchive_t*, void*, off_t);
215
int (*writef)(Pax_t*, Paxarchive_t*, const void*, off_t);
216
217
int (*corruptf)(Pax_t*, Paxarchive_t*, Paxfile_t*, const char*);
218
int (*checksumf)(Pax_t*, Paxarchive_t*, Paxfile_t*, unsigned long, unsigned long);
219
int (*nospacef)(Pax_t*);
220
221
int (*nextf)(Pax_t*, Paxarchive_t*, size_t, size_t);
222
223
#ifdef _PAX_PRIVATE_
224
_PAX_PRIVATE_
225
#endif
226
227
};
228
229
#define paxchecksum(p,a,f,x,v) (*(p)->checksumf)(p,a,f,x,v)
230
#define paxcorrupt(p,a,f,m) (*(p)->corruptf)(p,a,f,m)
231
#define paxdata(p,a,f,d,b,n) (*(p)->dataf)(p,a,f,d,b,n)
232
#define paxget(p,a,o,r) (*(p)->getf)(p,a,o,r)
233
#define paxnext(p,a,c,n) (*(p)->nextf)(p,a,c,n)
234
#define paxnospace(p) (*(p)->nospacef)(p)
235
#define paxpart(p,a,n) (*(p)->partf)(p,a,n)
236
#define paxput(p,a,b,n) (*(p)->putf)(p,a,b,n)
237
#define paxread(p,a,b,n,m,f) (*(p)->readf)(p,a,b,n,m,f)
238
#define paxseek(p,a,o,w,f) (*(p)->seekf)(p,a,o,w,f)
239
#define paxstash(p,v,s,z) (*(p)->stashf)(p,v,s,z)
240
#define paxsync(p,a,f) (*(p)->syncf)(p,a,f)
241
#define paxunread(p,a,b,n) (*(p)->unreadf)(p,a,b,n)
242
#define paxwrite(p,a,b,n) (*(p)->writef)(p,a,b,n)
243
244
#ifdef _PAX_ARCHIVE_PRIVATE_
245
246
#define PAXLIB(m)
247
#define PAXNEXT(m) pax_##m##_next
248
249
#else
250
251
#ifdef __STDC__
252
#define PAXLIB(f) extern Paxformat_t* pax_lib(Pax_t* pax) {return &pax_##f##_format;} \
253
unsigned long plugin_version(void) {return PAX_PLUGIN_VERSION;}
254
#else
255
#define PAXLIB(f) extern Paxformat_t* pax_lib(pax) Pax_t* pax; {return &pax_##f##_format;} \
256
unsigned long plugin_version() {return PAX_PLUGIN_VERSION;}
257
#endif
258
259
#define PAXNEXT(m) 0
260
261
#if defined(__EXPORT__)
262
#define extern __EXPORT__
263
#endif
264
265
extern Paxformat_t* pax_lib(Pax_t*);
266
267
#undef extern
268
269
#endif
270
271
#endif
272
273