Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/pax/pax.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 common definitions
26
*/
27
28
#ifndef _PAX_H
29
#define _PAX_H 1
30
31
#include <ast.h>
32
#include <ls.h>
33
#include <sig.h>
34
#include <ftwalk.h>
35
#include <ctype.h>
36
#include <ccode.h>
37
#include <hash.h>
38
#include <proc.h>
39
#include <regex.h>
40
#include <error.h>
41
#include <times.h>
42
#include <swap.h>
43
#include <align.h>
44
#include <debug.h>
45
#include <stdarg.h>
46
#include <sum.h>
47
#include <tv.h>
48
#include <fnv.h>
49
50
#define header Tarheader_s
51
#include <tar.h>
52
#undef header
53
54
typedef struct Tarheader_s Tarheader_t;
55
56
#include "FEATURE/local"
57
58
#define VENDOR "ATT"
59
#define ID "PAX"
60
#define VERSION "1"
61
62
#define IMPLEMENTATION VENDOR ID VERSION
63
64
#define PANIC ERROR_PANIC|ERROR_SOURCE,__FILE__,__LINE__
65
66
#define bcount(ap) ((ap)->io->last-(ap)->io->next)
67
#define bsave(ap) (state.backup=(*(ap)->io),error(-7, "bsave(%s,@%I*d)", ap->name, sizeof(ap->io->count), ap->io->count))
68
#define tvmtime(t,s) (tvgetmtime(t,s),t)
69
70
#define BUFFER_FD_MAX (-2)
71
#define BUFFER_FD_MIN (-3)
72
73
#undef getbuffer
74
#define getbuffer(n) (((n)>=BUFFER_FD_MIN&&(n)<=BUFFER_FD_MAX)?&state.buffer[BUFFER_FD_MAX-(n)]:(Buffer_t*)0)
75
#undef setbuffer
76
#define setbuffer(n) (BUFFER_FD_MAX-(n))
77
78
#define HOLE_MIN 1024
79
80
#define holeinit(fd) (state.hole=0)
81
#define holedone(fd) do if(state.hole){lseek(fd,state.hole-1,SEEK_CUR);state.hole=0;write(fd,"",1);} while(0)
82
83
#define ropath(p) (p[0]=='.'&&(p[1]==0||p[1]=='.'&&(p[2]==0||p[2]=='.'&&p[3]==0))||p[0]=='-'&&p[1]==0)
84
85
#define SECTION_CONTROL 1 /* control io */
86
#define SECTION_DATA 2 /* data io */
87
88
#define SECTION_MAX 3
89
90
#define SECTION(p) (p)->section
91
92
#define METER_parts 20
93
#define METER_width (METER_parts + 7)
94
95
#define NOW time(NiL)
96
97
/*
98
* format generic definitions
99
*/
100
101
#define HDR_atime (1<<0)
102
#define HDR_charset (1<<1)
103
#define HDR_ctime (1<<2)
104
#define HDR_gid (1<<3)
105
#define HDR_gname (1<<4)
106
#define HDR_linkpath (1<<5)
107
#define HDR_mtime (1<<6)
108
#define HDR_path (1<<7)
109
#define HDR_size (1<<8)
110
#define HDR_uid (1<<9)
111
#define HDR_uname (1<<10)
112
113
#define FMT_COMPRESS "gzip" /* default compress format */
114
#define FMT_DEFAULT "pax" /* default output format */
115
#define FMT_DELTA "delta" /* default delta output format */
116
#define FMT_IGNORE "ignore" /* delta ignore output format */
117
#define FMT_PATCH "patch" /* delta patch output format */
118
119
#define IN PAX_IN /* copy in */
120
#define OUT PAX_OUT /* copy out */
121
#define ARCHIVE PAX_ARCHIVE /* archive format */
122
#define COMPRESS PAX_COMPRESS /* compress format */
123
#define DELTA PAX_DELTA /* delta format */
124
#define DELTAIO PAX_DELTAIO /* separate delta io */
125
#define DLL PAX_DLL /* format from dll */
126
#define DOS PAX_DOS /* may contain dos names */
127
#define PSEUDO PAX_PSEUDO /* pseudo delta format */
128
#define COMPRESSED PAX_COMPRESSED /* format already compressed */
129
#define CONV PAX_CONV /* format handles ccode conv */
130
#define DELTAINFO PAX_DELTAINFO /* format handles delta info */
131
#define KEEPSIZE PAX_KEEPSIZE /* retain non REG st_size */
132
#define LINKTYPE PAX_LINKTYPE /* File_t.linktype supported */
133
#define NOHARDLINKS PAX_NOHARDLINKS /* hard links not supported */
134
#define SLASHDIR PAX_SLASHDIR /* trailing slash => directory */
135
#define STANDARD PAX_STANDARD /* the standard format */
136
#define SUM PAX_SUM /* inline member checksum */
137
#define APPEND PAX_APPEND /* archive append */
138
139
#define SETIDS (1<<0) /* set explicit uid and gid */
140
141
#define INFO_MATCH "*([A-Z0-9!])!!!"/* info header file name match */
142
#define INFO_SEP '!' /* info header field separator */
143
#define INFO_ORDERED 'O' /* delta on ordered base */
144
145
#define IDLEN (sizeof(ID)-1) /* strlen(ID) */
146
147
#define DELTA_94 1
148
#define DELTA_88 2
149
#define DELTA_IGNORE 3
150
#define DELTA_PATCH 4
151
152
#define TYPE_COMPRESS 'C' /* compress encoding type */
153
#define TYPE_DELTA 'D' /* delta encoding type */
154
155
#define DELTA_SRC 0 /* source info */
156
#define DELTA_TAR 1 /* target info */
157
#define DELTA_DEL 2 /* delta info */
158
#define DELTA_DATA 3 /* data info mask */
159
#define DELTA_BIO (1<<2) /* bio (no arg) */
160
#define DELTA_BUFFER (1<<3) /* buffer arg */
161
#define DELTA_FD (1<<4) /* fd arg */
162
#define DELTA_HOLE (1<<5) /* holewrite() fd arg */
163
#define DELTA_OFFSET (1<<6) /* offset arg */
164
#define DELTA_SIZE (1<<7) /* size arg */
165
#define DELTA_OUTPUT (1<<8) /* output data */
166
#define DELTA_TEMP (1<<9) /* temp output fd */
167
#define DELTA_FREE (1<<10) /* free fd or buffer */
168
#define DELTA_COUNT (1<<11) /* set in|out count */
169
#define DELTA_LIST (1<<12) /* listentry() if ok */
170
171
#define DELTA_create 'c' /* delta create data op */
172
#define DELTA_delete 'd' /* delta delete data op */
173
#define DELTA_nop 'x' /* no delta operation pseudo op */
174
#define DELTA_pass 'p' /* delta pass pseudo op */
175
#define DELTA_update 'u' /* delta update data op */
176
#define DELTA_verify 'v' /* delta verify data op */
177
178
#define DELTA_TRAILER 10 /* delta trailer output size */
179
180
#define DELTA_checksum 'c' /* delta member checksum */
181
#define DELTA_index 'i' /* delta header index */
182
#define DELTA_trailer 't' /* delta trailer size */
183
184
#define DELTA_WINDOW (128*1024L) /* delta window buffer size */
185
186
#define DELTA_LO(c) ((c)&0xffff) /* lo order checksum bits */
187
#define DELTA_HI(c) DELTA_LO(c>>16) /* hi order checksum bits */
188
189
#define HEADER_EXTENDED "@PaxHeaders/%(sequence)s"
190
#define HEADER_EXTENDED_STD "%(dir)s/PaxHeaders/%(file)s"
191
#define HEADER_GLOBAL "@PaxGlobals/%(sequence)s"
192
#define HEADER_GLOBAL_STD "%(tmp)s/GlobalHead/%(entry)s"
193
194
#define INVALID_binary 0 /* binary for unencodable data */
195
#define INVALID_ignore 1 /* silently ignore */
196
#define INVALID_prompt 2 /* prompt for new name */
197
#define INVALID_translate 3 /* translate and/or truncate */
198
#define INVALID_UTF8 4 /* convert to UTF8 */
199
200
#define NOLINK PAX_NOLINK /* not a link */
201
#define HARDLINK PAX_HARDLINK /* hard link to previous entry */
202
#define SOFTLINK PAX_SOFTLINK /* soft link to previous entry */
203
204
#define BLOCKSIZE PAX_BLOCK /* block size */
205
#define IOALIGN ALIGN_BOUND1 /* io buffer alignment */
206
#define MINBLOCK 1 /* smallest block size */
207
#define DEFBLOCKS PAX_DEFBLOCKS /* default blocking */
208
#define DEFBUFFER PAX_DEFBUFFER /* default io buffer blocking */
209
#define FILBLOCKS 1024 /* file to file blocking */
210
#define MAXUNREAD (8*BLOCKSIZE) /* max bunread() count */
211
#define MINID 80 /* min ident buffer size */
212
#define MAXID BLOCKSIZE /* max ident buffer size */
213
#define RESETABLE (-1) /* default option can be reset */
214
215
#define MAP_INDEX 0x01 /* append .%d index on match */
216
217
typedef int (*Link_f)(const char*, const char*);
218
typedef int (*Stat_f)(const char*, struct stat*);
219
220
struct Archive_s; typedef struct Archive_s Archive_t;
221
struct File_s; typedef struct File_s File_t;
222
struct Filter_s; typedef struct Filter_s Filter_t;
223
struct Format_s; typedef struct Format_s Format_t;
224
struct List_s; typedef struct List_s List_t;
225
struct Map_s; typedef struct Map_s Map_t;
226
struct Member_s; typedef struct Member_s Member_t;
227
228
#define _PAX_IO_PRIVATE_ \
229
char* next; /* next char pointer */ \
230
char* last; /* last char+1 pointer */ \
231
char* buffer; /* io buffer */ \
232
off_t count; /* char transfer count */ \
233
off_t expand; /* add to count at end */ \
234
off_t offset; /* volume offset */ \
235
off_t size; /* total size if seekable */ \
236
unsigned int fill; /* bsave fill serial */ \
237
int skip; /* volume skip */ \
238
int keep; /* volume keep after skip */ \
239
int mode; /* open() O_* mode */ \
240
int unread; /* max unread size */ \
241
unsigned int all:1; /* read all volumes */ \
242
unsigned int blocked:1; /* blocked device io */ \
243
unsigned int blok:1; /* BLOK io file */ \
244
unsigned int blokeof:1; /* BLOK io eof */ \
245
unsigned int blokflag:1; /* io file BLOK flag */ \
246
unsigned int empty:1; /* last read was empty */ \
247
unsigned int seekable:1; /* seekable */ \
248
unsigned int unblocked:1; /* set unblocked device io */
249
250
typedef struct Buffer_s /* pseudo fd buffer */
251
{
252
char* base; /* buffer base */
253
char* next; /* current position */
254
char* past; /* overflow position */
255
} Buffer_t;
256
257
typedef struct Fileid_s /* unique file identifier */
258
{
259
int dev; /* device */
260
int ino; /* inode */
261
} Fileid_t;
262
263
typedef struct Link_s /* link info */
264
{
265
char* name; /* name */
266
char* checksum; /* hard link checksum */
267
int namesize; /* name size with null byte */
268
Fileid_t id; /* generated link file id */
269
} Link_t;
270
271
#define _PAX_FILE_PRIVATE_ \
272
Archive_t* ap; /* !=0 if from buffer */ \
273
unsigned long checksum; /* data checksum */ \
274
off_t datasize; /* non-reg has data anyway */ \
275
struct \
276
{ \
277
int op; /* op */ \
278
int same; /* SRC and TAR same */ \
279
unsigned long checksum; /* data checksum */ \
280
unsigned long index; /* index */ \
281
Member_t* base; /* base file pointer */ \
282
} delta; /* delta info */ \
283
int extended; /* extended header file */ \
284
int fd; /* >=0 read fd */ \
285
char* id; /* archive file id */ \
286
char* intermediate; /* intermediate output name */ \
287
int linkpathsize; /* linkname size with null byte */ \
288
int magic; /* header magic number */ \
289
int namesize; /* name size with null byte */ \
290
int perm; /* original st_mode perm */ \
291
int type; /* st_mode type */ \
292
Link_t* link; /* hard link state */ \
293
char* uidname; /* user id name */ \
294
char* gidname; /* group id name */ \
295
struct \
296
{ \
297
char* partial; /* partial record buffer */ \
298
int blocks; /* io block count */ \
299
int format; /* format */ \
300
int section; /* file section number */ \
301
} record; /* record format info */ \
302
unsigned int chmod:1; /* must restore mode */ \
303
unsigned int longlink:1; /* f->linkpath too long */ \
304
unsigned int longname:1; /* f->name too long */ \
305
unsigned int ordered:1; /* ordered fileout() override */ \
306
unsigned int ro:1; /* readonly { . .. ... - } */ \
307
unsigned int skip:1; /* skip this entry */
308
309
struct Member_s /* cached member info */
310
{
311
File_t* info; /* deltapass() file info */
312
Tv_t atime; /* access time */
313
Tv_t mtime; /* modify time */
314
off_t offset; /* data offset */
315
off_t size; /* data size */
316
off_t uncompressed; /* uncompressed size */
317
short dev; /* dev */
318
short ino; /* ino */
319
short mode; /* mode */
320
unsigned int mark:1; /* visit mark */
321
};
322
323
typedef uint32_t Magic_t;
324
325
typedef struct Compress_format_s /* compress format data */
326
{
327
char* variant; /* variant qualifier/flag */
328
char* undo[2]; /* compress undo name and arg */
329
char* undotoo[2]; /* alternate undo */
330
} Compress_format_t;
331
332
typedef struct Delta_format_s /* delta format data */
333
{
334
char* variant; /* variant qualifier/flag */
335
} Delta_format_t;
336
337
struct List_s /* generic list */
338
{
339
List_t* next; /* next in list */
340
void* item; /* list item pointer */
341
};
342
343
struct Map_s /* file name map list */
344
{
345
Map_t* next; /* next in list */
346
regex_t re; /* compiled match re */
347
int flags; /* MAP_* flags */
348
};
349
350
typedef struct Post_s /* post processing restoration */
351
{
352
Tv_t atime; /* access time */
353
Tv_t mtime; /* modify time */
354
int mode; /* permissions */
355
int uid; /* user id */
356
int gid; /* group id */
357
unsigned int chmod:1; /* must restore mode */
358
} Post_t;
359
360
typedef union Integral_u /* byte|half swap probe */
361
{
362
uint32_t l;
363
uint16_t s[2];
364
uint8_t c[4];
365
} Integral_t;
366
367
typedef struct Convert_s /* char code conversion */
368
{
369
int on; /* do the conversion */
370
unsigned char* f2t; /* from=>to map */
371
unsigned char* t2f; /* to=>from map */
372
unsigned char* f2a; /* from=>CC_ASCII map */
373
unsigned char* t2a; /* to=>CC_ASCII map */
374
} Convert_t;
375
376
typedef struct Delta_s /* delta archive info */
377
{
378
Archive_t* base; /* base archive */
379
unsigned long checksum; /* expected base checksum */
380
int compress; /* delta source is /dev/null */
381
int epilogue; /* epilogue hit */
382
int index; /* member index */
383
int initialized; /* delta base initialized */
384
Format_t* format; /* delta format */
385
char* hdr; /* header pointer */
386
char hdrbuf[64]; /* header buffer */
387
int ordered; /* members ordered by file name */
388
off_t size; /* expected base size */
389
Hash_table_t* tab; /* entry table */
390
int trailer; /* optional trailer size */
391
char* version; /* optional delta version */
392
} Delta_t;
393
394
typedef struct Part_s
395
{
396
Sfdisc_t disc;
397
off_t n;
398
struct State_s* pax;
399
Archive_t* ap;
400
Sfio_t* sp;
401
} Part_t;
402
403
struct Filter_s
404
{
405
Filter_t* next; /* next in list */
406
regex_t* re; /* path pattern or default if 0 */
407
char* command; /* original command line */
408
char** argv; /* command argv */
409
char** patharg; /* file arg in argv */
410
};
411
412
typedef struct Pattern_s
413
{
414
char* pattern;
415
unsigned char directory;
416
unsigned char matched;
417
} Pattern_t;
418
419
#define _PAX_ARCHIVE_PRIVATE_ \
420
unsigned long checksum; /* running checksum */ \
421
int checkdelta; /* getprologue delta check */ \
422
Format_t* compress; /* compression format */ \
423
Convert_t convert[SECTION_MAX];/* data/header conversion */ \
424
Delta_t* delta; /* delta info */ \
425
int errors; /* intermediate error count */ \
426
Format_t* expected; /* expected format */ \
427
File_t file; /* current member file info */ \
428
File_t* info; /* last deltabase() member */ \
429
int locked; /* newio() recursion lock */ \
430
Bio_t mio; /* main buffered io */ \
431
unsigned long memsum; /* member checksum */ \
432
off_t offset; /* relative byte offset */ \
433
int ordered; /* archive members ordered */ \
434
struct \
435
{ \
436
unsigned long checksum; /* old running checksum */ \
437
unsigned long memsum; /* old checksum */ \
438
int warned; /* old checksum warning */ \
439
} old; \
440
char* package; /* package id */ \
441
Archive_t* parent; /* parent (delta) for base */ \
442
int part; /* media change count */ \
443
Part_t* partio; /* archive part sfio info */ \
444
struct /* stash() values */ \
445
{ \
446
Paxvalue_t copy; /* copy() path buffer */ \
447
Paxvalue_t name; /* real path name */ \
448
Paxvalue_t path; /* access path */ \
449
Paxvalue_t peek; /* peek file */ \
450
Paxvalue_t prev; /* previous entry order check */ \
451
char temp[PATH_MAX]; /* temp intermediate name */ \
452
} path; \
453
int peek; /* already peeked at file entry */ \
454
File_t* record; /* record output file */ \
455
int raw; /* don't convert sections */ \
456
int section; /* current archive section */ \
457
size_t selected; /* number of selected members */ \
458
off_t size; /* size */ \
459
off_t skip; /* base archive skip offset */ \
460
struct stat st; /* memver stat */ \
461
int sum; /* collect running checksum */ \
462
int swap; /* swap operation */ \
463
int swapio; /* io swap operation */ \
464
Hash_table_t* tab; /* verification table */ \
465
Bio_t tio; /* temporary buffered io */ \
466
struct \
467
{ \
468
Sfio_t* extended; /* extend() temporary */ \
469
Sfio_t* global; /* extend() temporary */ \
470
Sfio_t* hdr; /* headname() temporary */ \
471
Sfio_t* key; /* extend() temporary */ \
472
} tmp; /* temporary stuff */ \
473
off_t total; /* newio() total io check */ \
474
char* type; /* archive type */ \
475
off_t uncompressed; /* uncompressed size estimate */ \
476
Hash_table_t* update; /* update info */ \
477
size_t updated; /* number of updated members */ \
478
int warnlinkhead; /* invalid hard link header */
479
480
#define _PAX_PRIVATE_ \
481
int acctime; /* preserve member access times */ \
482
int append; /* append -- must be 0 or 1 !!! */ \
483
Bio_t backup; /* backup() position */ \
484
long blocksize; /* explicit buffer size */ \
485
Buffer_t buffer[BUFFER_FD_MAX-BUFFER_FD_MIN+1];/* fd buf */ \
486
struct \
487
{ \
488
char* name; /* archive member name */ \
489
char* path; /* local file path */ \
490
Sfio_t* sp; /* tmp stream */ \
491
Sum_t* sum; /* method handle */ \
492
} checksum; /* --checksum state */ \
493
int chmod; /* must preserve mode */ \
494
int clobber; /* overwrite output files */ \
495
int complete; /* files completely in volume */ \
496
int current; /* current file[] index */ \
497
struct \
498
{ \
499
int bufferindex; /* delta buffer index */ \
500
int buffersize; /* delta buffer size */ \
501
int update; /* update only delta members */ \
502
} delta; /* delta info */ \
503
int delta2delta; /* -rz- -wz- : retain delta info*/ \
504
int descend; /* dir names self+descendents */ \
505
char* destination; /* pass mode destination dir */ \
506
dev_t dev; /* . device number */ \
507
unsigned short devcnt; /* dev assignment count */ \
508
int drop; /* drop a `.' for each file */ \
509
int dropcount; /* current line drop count */ \
510
int exact; /* exact archive read */ \
511
char** files; /* alternate file name list */ \
512
struct \
513
{ \
514
Filter_t* list; /* filter list */ \
515
Filter_t* last; /* filter list tail */ \
516
Filter_t* all; /* match all filter */ \
517
char* options; /* line mode options */ \
518
char* command; /* line mode command */ \
519
char* path; /* line mode physical path */ \
520
char* name; /* line mode logical path */ \
521
int line; /* line mode */ \
522
} filter; /* file output filter state */ \
523
int forceconvert; /* force binary conversion */ \
524
Format_t* format; /* default output format */ \
525
int ftwflags; /* ftwalk() flags */ \
526
struct \
527
{ \
528
char* comment; /* comment text */ \
529
int invalid; /* invalid path INVALID_ action */ \
530
int linkdata; /* data with each hard link */ \
531
char* listformat; /* verbose listing format */ \
532
char* global; /* global header name format */ \
533
char* extended; /* extended name format */ \
534
} header; /* header specific options */ \
535
off_t hole; /* one past last hole */ \
536
Archive_t* in; /* input archive info */ \
537
unsigned short inocnt; /* ino assignment count */ \
538
struct \
539
{ \
540
char* name; /* archive member name */ \
541
char* path; /* local file path */ \
542
Sfio_t* sp; /* tmp stream */ \
543
} install; /* --install state */ \
544
int intermediate; /* intermediate ouput - rename */ \
545
int interrupt; /* this signal caused exit */ \
546
Link_f linkf; /* -L=pathsetlink() -P=link() */ \
547
Hash_table_t* linktab; /* hard link table */ \
548
char* listformat; /* verbose listing format */ \
549
int local; /* reject files/links outside . */ \
550
struct \
551
{ \
552
unsigned char* a2n; /* CC_ASCII=>CC_NATIVE */ \
553
unsigned char* e2n; /* CC_EBCDIC=>CC_NATIVE */ \
554
unsigned char* n2e; /* CC_NATIVE=>CC_EBCDIC */ \
555
} map; /* ccode maps */ \
556
Map_t* maps; /* file name maps */ \
557
int matchsense; /* pattern match sense */ \
558
off_t maxout; /* max volume/part output count */ \
559
struct \
560
{ \
561
Sfio_t* tmp; /* tmp buffer */ \
562
off_t size; /* total size */ \
563
int fancy; /* fancy display */ \
564
int last; /* length of last display path */ \
565
int on; /* meter progress */ \
566
int width; /* display line width */ \
567
} meter; /* meter state */ \
568
int mkdir; /* make intermediate dirs */ \
569
struct \
570
{ \
571
char* magic; /* separator magic */ \
572
size_t length; /* separator magic length */ \
573
size_t fill; /* last member filler size */ \
574
} mime; \
575
char* mode; /* output chmod(1) mode */ \
576
int modtime; /* retain mtime */ \
577
char* mtime; /* output date(1) mtime */ \
578
int newer; /* append only if newer */ \
579
int operation; /* IN|OUT operation mode */ \
580
Hash_table_t* options; /* option table */ \
581
int ordered; /* sorted base and file list */ \
582
int owner; /* set owner info */ \
583
Archive_t* out; /* output archive info */ \
584
int pass; /* archive to archive */ \
585
Pattern_t* pattern; /* current name match pattern */ \
586
Pattern_t* patterns; /* name match patterns */ \
587
char* peekfile; /* stdin file list peek */ \
588
int peeklen; /* peekfile length */ \
589
char pwd[PATH_MAX]; /* full path of . */ \
590
int pwdlen; /* pwd length sans null */ \
591
List_t* proc; /* procopen() list for finish */ \
592
struct \
593
{ \
594
int charset; /* convert record charset */ \
595
int delimiter; /* directory delimiter */ \
596
File_t* file; /* current output file */ \
597
int format; /* record format */ \
598
char* header; /* file header */ \
599
int headerlen; /* file header length */ \
600
int line; /* convert records<->lines */ \
601
int pad; /* pad output record blocks */ \
602
char* pattern; /* format match pattern */ \
603
int offset; /* data buffer offset */ \
604
long size; /* io size */ \
605
char* trailer; /* file trailer */ \
606
int trailerlen; /* file trailer length */ \
607
} record; /* record info */ \
608
int resetacctime; /* reset input file access times*/ \
609
Hash_table_t* restore; /* post proc restoration table */ \
610
Sfio_t* rtty; /* tty file read pointer */ \
611
int scanned; /* scanned for format libs */ \
612
size_t selected; /* total of selected members */ \
613
int setgid; /* set file gid to this value */ \
614
int setuid; /* set file uid to this value */ \
615
Stat_f statf; /* -L=pathstat() -P=lstat() */ \
616
int sync; /* fsync() each file after copy */ \
617
unsigned long testdate; /* listformat test date */ \
618
struct \
619
{ \
620
char* buffer; /* temporary buffer */ \
621
long buffersize; /* temporary buffer size */ \
622
char* delta; /* tmp delta file name */ \
623
char* file; /* tmp file name */ \
624
Sfio_t* fmt; /* temporary format stream */ \
625
Sfio_t* lst; /* temporary list stream */ \
626
Sfio_t* mac; /* temporary print macro stream */ \
627
Sfio_t* str; /* temporary string stream */ \
628
} tmp; /* temporary stuff */ \
629
int update; /* copy file only if newer */ \
630
size_t updated; /* total of updated members */ \
631
char* usage; /* optget() usage string */ \
632
char volume[64]; /* volume id */ \
633
int warnmkdir; /* --mkdir hint issued */ \
634
int warnlinknum; /* too many hard links */ \
635
Sfio_t* wtty; /* tty file write pointer */ \
636
int yesno; /* interactive answer is yes/no */
637
638
#define Pax_t State_t
639
#define Pax_s State_s
640
#define Paxarchive_t Archive_t
641
#define Paxarchive_s Archive_s
642
#define Paxfile_t File_t
643
#define Paxfile_s File_s
644
#define Paxformat_t Format_t
645
#define Paxformat_s Format_s
646
#define Paxio_t Bio_t
647
#define Paxio_s Bio_s
648
#define Paxvalue_t Value_t
649
#define Paxvalue_s Value_s
650
651
#include "paxlib.h"
652
#include "options.h"
653
654
extern char* definput;
655
extern char* defoutput;
656
extern char* eomprompt;
657
extern Format_t* formats;
658
extern State_t state;
659
660
extern int addlink(Archive_t*, File_t*);
661
extern int apply(Archive_t*, File_t*, Filter_t*);
662
extern long asc_checksum(char*, int, unsigned long);
663
extern void backup(Archive_t*);
664
extern long bblock(int);
665
extern void bflushin(Archive_t*, int);
666
extern void bflushout(Archive_t*);
667
extern char* bget(Archive_t*, off_t, off_t*);
668
extern void binit(Archive_t*);
669
extern void bput(Archive_t*, off_t);
670
extern off_t bread(Archive_t*, void*, off_t, off_t, int);
671
extern off_t bseek(Archive_t*, off_t, int, int);
672
extern int bskip(Archive_t*);
673
extern void bunread(Archive_t*, void*, int);
674
extern void bwrite(Archive_t*, void*, off_t);
675
extern int closein(Archive_t*, File_t*, int);
676
extern int closeout(Archive_t*, File_t*, int);
677
extern int cmpftw(Ftw_t*, Ftw_t*);
678
extern void complete(Archive_t*, File_t*, size_t);
679
extern void convert(Archive_t*, int, int, int);
680
extern void copy(Archive_t*, int(*)(Ftw_t*));
681
extern void copyin(Archive_t*);
682
extern int copyinout(Ftw_t*);
683
extern int copyout(Ftw_t*);
684
extern void deltabase(Archive_t*);
685
extern int deltacheck(Archive_t*, File_t*);
686
extern void deltadelete(Archive_t*);
687
extern void deltaout(Archive_t*, Archive_t*, File_t*);
688
extern void deltapass(Archive_t*, Archive_t*);
689
extern void deltaset(Archive_t*, char*);
690
extern void deltaverify(Archive_t*);
691
extern int dirprefix(char*, char*, int);
692
extern void filein(Archive_t*, File_t*);
693
extern void fileout(Archive_t*, File_t*);
694
extern void fileskip(Archive_t*, File_t*);
695
extern Filter_t* filter(Archive_t*, File_t*);
696
extern void finish(int);
697
extern Archive_t* getarchive(int);
698
extern void getdeltaheader(Archive_t*, File_t*);
699
extern void getdeltatrailer(Archive_t*, File_t*);
700
extern int getepilogue(Archive_t*);
701
extern int getfile(Archive_t*, File_t*, Ftw_t*);
702
extern Format_t* getformat(char*, int);
703
extern int getheader(Archive_t*, File_t*);
704
extern void getidnames(File_t*);
705
extern int getprologue(Archive_t*);
706
extern void gettrailer(Archive_t*, File_t*);
707
extern ssize_t holewrite(int, void*, size_t);
708
extern Archive_t* initarchive(const char*, int);
709
extern void initdelta(Archive_t*, Format_t*);
710
extern void initfile(Archive_t*, File_t*, struct stat*, char*, int);
711
extern void initmatch(char**);
712
extern void interactive(void);
713
extern void listentry(File_t*);
714
extern int listprintf(Sfio_t*, Archive_t*, File_t*, const char*);
715
extern char* map(Archive_t*, char*);
716
extern int match(char*);
717
extern void newio(Archive_t*, int, int);
718
extern Format_t* nextformat(Format_t*);
719
extern void nospace(void);
720
extern unsigned long omemsum(const void*, int, unsigned long);
721
extern int openin(Archive_t*, File_t*);
722
extern int openout(Archive_t*, File_t*);
723
extern int paxdelta(Archive_t*, Archive_t*, File_t*, int, ...);
724
extern void paxinit(Pax_t*, const char*);
725
extern int portable(Archive_t*, const char*);
726
extern int prune(Archive_t*, File_t*, struct stat*);
727
extern void putdeltaheader(Archive_t*, File_t*);
728
extern void putdeltatrailer(Archive_t*, File_t*);
729
extern void putepilogue(Archive_t*);
730
extern int putheader(Archive_t*, File_t*);
731
extern void putinfo(Archive_t*, char*, unsigned long, unsigned long);
732
extern void putkey(Archive_t*, Sfio_t*, Option_t*, const char*, Sfulong_t);
733
extern void putprologue(Archive_t*, int);
734
extern void puttrailer(Archive_t*, File_t*);
735
extern char* release(void);
736
extern int restore(const char*, char*, void*);
737
extern void seekable(Archive_t*);
738
extern int selectfile(Archive_t*, File_t*);
739
extern void setdeltaheader(Archive_t*, File_t*);
740
extern void setfile(Archive_t*, File_t*);
741
extern void setidnames(File_t*);
742
extern void setinfo(Archive_t*, File_t*);
743
extern void setoptions(char*, size_t, char**, char*, Archive_t*, int);
744
extern void settime(const char*, Tv_t*, Tv_t*, Tv_t*);
745
extern char* stash(Value_t*, const char*, size_t);
746
extern char* strlower(char*);
747
extern char* strupper(char*);
748
extern void undoable(Archive_t*, Format_t*);
749
extern void undos(File_t*);
750
extern int validout(Archive_t*, File_t*);
751
extern int verify(Archive_t*, File_t*, char*);
752
753
#endif
754
755