]> git.ipfire.org Git - thirdparty/libarchive.git/blame - cpio/cpio.h
Resolve TODO: Return uname and gname overrides (#2141)
[thirdparty/libarchive.git] / cpio / cpio.h
CommitLineData
32b675ba
TK
1/*-
2 * Copyright (c) 2003-2007 Tim Kientzle
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32b675ba
TK
24 */
25
26#ifndef CPIO_H_INCLUDED
27#define CPIO_H_INCLUDED
28
29#include "cpio_platform.h"
30#include <stdio.h>
31
32b675ba
TK
32/*
33 * The internal state for the "cpio" program.
34 *
35 * Keeping all of the state in a structure like this simplifies memory
36 * leak testing (at exit, anything left on the heap is suspect). A
37 * pointer to this structure is passed to most cpio internal
38 * functions.
39 */
40struct cpio {
948548dc 41 /* Option parsing */
3450dd3a 42 const char *argument;
948548dc 43
32b675ba 44 /* Options */
1cbc562a 45 int add_filter; /* --uuencode */
948548dc 46 const char *filename;
fb50435c
TK
47 int mode; /* -i -o -p */
48 int compress; /* -j, -y, or -z */
32b675ba
TK
49 const char *format; /* -H format */
50 int bytes_per_block; /* -b block_size */
51 int verbose; /* -v */
32100c65 52 int dot; /* -V */
32b675ba
TK
53 int quiet; /* --quiet */
54 int extract_flags; /* Flags for extract operation */
32b675ba
TK
55 const char *compress_program;
56 int option_append; /* -A, only relevant for -o */
57 int option_atime_restore; /* -a */
58 int option_follow_links; /* -L */
59 int option_link; /* -l */
60 int option_list; /* -t */
79b85a84 61 char option_null; /* --null */
8c33e270 62 int option_numeric_uid_gid; /* -n */
6c03f55c 63 int option_pwb; /* -6 */
32b675ba
TK
64 int option_rename; /* -r */
65 char *destdir;
ba0478d3 66 size_t destdir_len;
32b675ba
TK
67 size_t pass_destpath_alloc;
68 char *pass_destpath;
69 int uid_override;
4100d478 70 char *uname_override;
32b675ba 71 int gid_override;
4100d478 72 char *gname_override;
2fa0c563 73 int day_first; /* true if locale prefers day/mon */
361600b9 74 const char *passphrase;
32b675ba
TK
75
76 /* If >= 0, then close this when done. */
77 int fd;
78
79 /* Miscellaneous state information */
80 struct archive *archive;
2c29f87f 81 struct archive *archive_read_disk;
32b675ba
TK
82 int argc;
83 char **argv;
84 int return_value; /* Value returned by main() */
85 struct archive_entry_linkresolver *linkresolver;
86
2fa0c563
TK
87 struct name_cache *uname_cache;
88 struct name_cache *gname_cache;
89
32b675ba 90 /* Work data. */
718b5cc7 91 struct archive *matching;
32b675ba
TK
92 char *buff;
93 size_t buff_size;
9769e6f7 94 char *ppbuff;
32b675ba
TK
95};
96
826c0afe
MM
97struct cpio_owner {
98 int uid;
99 int gid;
100 char *uname;
101 char *gname;
102};
32b675ba 103
826c0afe 104int owner_parse(const char *, struct cpio_owner *, const char **);
32b675ba
TK
105
106/* Fake short equivalents for long options that otherwise lack them. */
107enum {
ba3b5811 108 OPTION_B64ENCODE = 1,
630ead78 109 OPTION_GRZIP,
ba3b5811 110 OPTION_INSECURE,
08e59858 111 OPTION_LRZIP,
8c4be28f 112 OPTION_LZ4,
d100741a 113 OPTION_LZMA,
f51924bb 114 OPTION_LZOP,
361600b9 115 OPTION_PASSPHRASE,
5268756c 116 OPTION_NO_PRESERVE_OWNER,
67b02086 117 OPTION_PRESERVE_OWNER,
32b675ba 118 OPTION_QUIET,
1cbc562a 119 OPTION_UUENCODE,
cd63bdcd
SP
120 OPTION_VERSION,
121 OPTION_ZSTD,
32b675ba
TK
122};
123
124int cpio_getopt(struct cpio *cpio);
32b675ba
TK
125
126#endif