cpio.h revision 1.1.1.6 1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
3 *
4 * Copyright (c) 2003-2007 Tim Kientzle
5 * All rights reserved.
6 */
7
8 #ifndef CPIO_H_INCLUDED
9 #define CPIO_H_INCLUDED
10
11 #include "cpio_platform.h"
12 #include <stdio.h>
13
14 /*
15 * The internal state for the "cpio" program.
16 *
17 * Keeping all of the state in a structure like this simplifies memory
18 * leak testing (at exit, anything left on the heap is suspect). A
19 * pointer to this structure is passed to most cpio internal
20 * functions.
21 */
22 struct cpio {
23 /* Option parsing */
24 const char *argument;
25
26 /* Options */
27 int add_filter; /* --uuencode */
28 const char *filename;
29 int mode; /* -i -o -p */
30 int compress; /* -j, -y, or -z */
31 const char *format; /* -H format */
32 int bytes_per_block; /* -b block_size */
33 int verbose; /* -v */
34 int dot; /* -V */
35 int quiet; /* --quiet */
36 int extract_flags; /* Flags for extract operation */
37 const char *compress_program;
38 int option_append; /* -A, only relevant for -o */
39 int option_atime_restore; /* -a */
40 int option_follow_links; /* -L */
41 int option_link; /* -l */
42 int option_list; /* -t */
43 char option_null; /* --null */
44 int option_numeric_uid_gid; /* -n */
45 int option_pwb; /* -6 */
46 int option_rename; /* -r */
47 char *destdir;
48 size_t destdir_len;
49 size_t pass_destpath_alloc;
50 char *pass_destpath;
51 int uid_override;
52 char *uname_override;
53 int gid_override;
54 char *gname_override;
55 int day_first; /* true if locale prefers day/mon */
56 const char *passphrase;
57
58 /* If >= 0, then close this when done. */
59 int fd;
60
61 /* Miscellaneous state information */
62 struct archive *archive;
63 struct archive *archive_read_disk;
64 int argc;
65 char **argv;
66 int return_value; /* Value returned by main() */
67 struct archive_entry_linkresolver *linkresolver;
68
69 struct name_cache *uname_cache;
70 struct name_cache *gname_cache;
71
72 /* Work data. */
73 struct archive *matching;
74 char *buff;
75 size_t buff_size;
76 char *ppbuff;
77 };
78
79 struct cpio_owner {
80 int uid;
81 int gid;
82 char *uname;
83 char *gname;
84 };
85
86 int owner_parse(const char *, struct cpio_owner *, const char **);
87
88 /* Fake short equivalents for long options that otherwise lack them. */
89 enum {
90 OPTION_B64ENCODE = 1,
91 OPTION_GRZIP,
92 OPTION_INSECURE,
93 OPTION_LRZIP,
94 OPTION_LZ4,
95 OPTION_LZMA,
96 OPTION_LZOP,
97 OPTION_PASSPHRASE,
98 OPTION_NO_PRESERVE_OWNER,
99 OPTION_PRESERVE_OWNER,
100 OPTION_QUIET,
101 OPTION_UUENCODE,
102 OPTION_VERSION,
103 OPTION_ZSTD,
104 };
105
106 int cpio_getopt(struct cpio *cpio);
107
108 #endif
109