cpio.h revision 1.1.1.2 1 1.1 joerg /*-
2 1.1 joerg * Copyright (c) 2003-2007 Tim Kientzle
3 1.1 joerg * All rights reserved.
4 1.1 joerg *
5 1.1 joerg * Redistribution and use in source and binary forms, with or without
6 1.1 joerg * modification, are permitted provided that the following conditions
7 1.1 joerg * are met:
8 1.1 joerg * 1. Redistributions of source code must retain the above copyright
9 1.1 joerg * notice, this list of conditions and the following disclaimer.
10 1.1 joerg * 2. Redistributions in binary form must reproduce the above copyright
11 1.1 joerg * notice, this list of conditions and the following disclaimer in the
12 1.1 joerg * documentation and/or other materials provided with the distribution.
13 1.1 joerg *
14 1.1 joerg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15 1.1 joerg * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 1.1 joerg * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 1.1 joerg * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18 1.1 joerg * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 1.1 joerg * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 1.1 joerg * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 1.1 joerg * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 1.1 joerg * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 1.1 joerg * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 1.1 joerg *
25 1.1.1.2 joerg * $FreeBSD: src/usr.bin/cpio/cpio.h,v 1.7 2008/12/06 07:30:40 kientzle Exp $
26 1.1 joerg */
27 1.1 joerg
28 1.1 joerg #ifndef CPIO_H_INCLUDED
29 1.1 joerg #define CPIO_H_INCLUDED
30 1.1 joerg
31 1.1 joerg #include "cpio_platform.h"
32 1.1 joerg #include <stdio.h>
33 1.1 joerg
34 1.1.1.2 joerg #include "matching.h"
35 1.1 joerg
36 1.1 joerg /*
37 1.1 joerg * The internal state for the "cpio" program.
38 1.1 joerg *
39 1.1 joerg * Keeping all of the state in a structure like this simplifies memory
40 1.1 joerg * leak testing (at exit, anything left on the heap is suspect). A
41 1.1 joerg * pointer to this structure is passed to most cpio internal
42 1.1 joerg * functions.
43 1.1 joerg */
44 1.1 joerg struct cpio {
45 1.1.1.2 joerg /* Option parsing */
46 1.1.1.2 joerg const char *optarg;
47 1.1.1.2 joerg
48 1.1 joerg /* Options */
49 1.1.1.2 joerg const char *filename;
50 1.1 joerg char mode; /* -i -o -p */
51 1.1 joerg char compress; /* -j, -y, or -z */
52 1.1 joerg const char *format; /* -H format */
53 1.1 joerg int bytes_per_block; /* -b block_size */
54 1.1 joerg int verbose; /* -v */
55 1.1 joerg int quiet; /* --quiet */
56 1.1 joerg int extract_flags; /* Flags for extract operation */
57 1.1 joerg char symlink_mode; /* H or L, per BSD conventions */
58 1.1 joerg const char *compress_program;
59 1.1 joerg int option_append; /* -A, only relevant for -o */
60 1.1 joerg int option_atime_restore; /* -a */
61 1.1 joerg int option_follow_links; /* -L */
62 1.1 joerg int option_link; /* -l */
63 1.1 joerg int option_list; /* -t */
64 1.1.1.2 joerg char option_null; /* --null */
65 1.1.1.2 joerg int option_numeric_uid_gid; /* -n */
66 1.1 joerg int option_rename; /* -r */
67 1.1 joerg char *destdir;
68 1.1 joerg size_t pass_destpath_alloc;
69 1.1 joerg char *pass_destpath;
70 1.1 joerg int uid_override;
71 1.1 joerg int gid_override;
72 1.1.1.2 joerg int day_first; /* true if locale prefers day/mon */
73 1.1 joerg
74 1.1 joerg /* If >= 0, then close this when done. */
75 1.1 joerg int fd;
76 1.1 joerg
77 1.1 joerg /* Miscellaneous state information */
78 1.1 joerg struct archive *archive;
79 1.1.1.2 joerg struct archive *archive_read_disk;
80 1.1 joerg int argc;
81 1.1 joerg char **argv;
82 1.1 joerg int return_value; /* Value returned by main() */
83 1.1 joerg struct archive_entry_linkresolver *linkresolver;
84 1.1 joerg
85 1.1.1.2 joerg struct name_cache *uname_cache;
86 1.1.1.2 joerg struct name_cache *gname_cache;
87 1.1.1.2 joerg
88 1.1 joerg /* Work data. */
89 1.1.1.2 joerg struct lafe_matching *matching;
90 1.1 joerg char *buff;
91 1.1 joerg size_t buff_size;
92 1.1 joerg };
93 1.1 joerg
94 1.1.1.2 joerg const char *owner_parse(const char *, int *, int *);
95 1.1 joerg
96 1.1 joerg
97 1.1 joerg /* Fake short equivalents for long options that otherwise lack them. */
98 1.1 joerg enum {
99 1.1 joerg OPTION_INSECURE = 1,
100 1.1.1.2 joerg OPTION_LZMA,
101 1.1.1.2 joerg OPTION_NO_PRESERVE_OWNER,
102 1.1.1.2 joerg OPTION_PRESERVE_OWNER,
103 1.1 joerg OPTION_QUIET,
104 1.1 joerg OPTION_VERSION
105 1.1 joerg };
106 1.1 joerg
107 1.1 joerg int cpio_getopt(struct cpio *cpio);
108 1.1 joerg
109 1.1 joerg #endif
110