cpio.h revision 299529
1228753Smm/*-
2228753Smm * Copyright (c) 2003-2007 Tim Kientzle
3228753Smm * All rights reserved.
4228753Smm *
5228753Smm * Redistribution and use in source and binary forms, with or without
6228753Smm * modification, are permitted provided that the following conditions
7228753Smm * are met:
8228753Smm * 1. Redistributions of source code must retain the above copyright
9228753Smm *    notice, this list of conditions and the following disclaimer.
10228753Smm * 2. Redistributions in binary form must reproduce the above copyright
11228753Smm *    notice, this list of conditions and the following disclaimer in the
12228753Smm *    documentation and/or other materials provided with the distribution.
13228753Smm *
14228753Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15228753Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16228753Smm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17228753Smm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18228753Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19228753Smm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20228753Smm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21228753Smm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22228753Smm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23228753Smm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24228753Smm *
25228763Smm * $FreeBSD: head/contrib/libarchive/cpio/cpio.h 299529 2016-05-12 10:16:16Z mm $
26228753Smm */
27228753Smm
28228753Smm#ifndef CPIO_H_INCLUDED
29228753Smm#define CPIO_H_INCLUDED
30228753Smm
31228753Smm#include "cpio_platform.h"
32228753Smm#include <stdio.h>
33228753Smm
34228753Smm/*
35228753Smm * The internal state for the "cpio" program.
36228753Smm *
37228753Smm * Keeping all of the state in a structure like this simplifies memory
38228753Smm * leak testing (at exit, anything left on the heap is suspect).  A
39228753Smm * pointer to this structure is passed to most cpio internal
40228753Smm * functions.
41228753Smm */
42228753Smmstruct cpio {
43228753Smm	/* Option parsing */
44232153Smm	const char	 *argument;
45228753Smm
46228753Smm	/* Options */
47248616Smm	int		  add_filter; /* --uuencode */
48228753Smm	const char	 *filename;
49232153Smm	int		  mode; /* -i -o -p */
50232153Smm	int		  compress; /* -j, -y, or -z */
51228753Smm	const char	 *format; /* -H format */
52228753Smm	int		  bytes_per_block; /* -b block_size */
53228753Smm	int		  verbose;   /* -v */
54232153Smm	int		  dot;  /* -V */
55228753Smm	int		  quiet;   /* --quiet */
56228753Smm	int		  extract_flags; /* Flags for extract operation */
57228753Smm	const char	 *compress_program;
58228753Smm	int		  option_append; /* -A, only relevant for -o */
59228753Smm	int		  option_atime_restore; /* -a */
60228753Smm	int		  option_follow_links; /* -L */
61228753Smm	int		  option_link; /* -l */
62228753Smm	int		  option_list; /* -t */
63228753Smm	char		  option_null; /* --null */
64228753Smm	int		  option_numeric_uid_gid; /* -n */
65228753Smm	int		  option_rename; /* -r */
66228753Smm	char		 *destdir;
67228753Smm	size_t		  pass_destpath_alloc;
68228753Smm	char		 *pass_destpath;
69228753Smm	int		  uid_override;
70228777Smm	char		 *uname_override;
71228753Smm	int		  gid_override;
72228777Smm	char		 *gname_override;
73228753Smm	int		  day_first; /* true if locale prefers day/mon */
74299529Smm	const char	 *passphrase;
75228753Smm
76228753Smm	/* If >= 0, then close this when done. */
77228753Smm	int		  fd;
78228753Smm
79228753Smm	/* Miscellaneous state information */
80228753Smm	struct archive	 *archive;
81228753Smm	struct archive	 *archive_read_disk;
82228753Smm	int		  argc;
83228753Smm	char		**argv;
84228753Smm	int		  return_value; /* Value returned by main() */
85228753Smm	struct archive_entry_linkresolver *linkresolver;
86228753Smm
87228753Smm	struct name_cache *uname_cache;
88228753Smm	struct name_cache *gname_cache;
89228753Smm
90228753Smm	/* Work data. */
91238856Smm	struct archive   *matching;
92228753Smm	char		 *buff;
93228753Smm	size_t		  buff_size;
94299529Smm	char		 *ppbuff;
95228753Smm};
96228753Smm
97228753Smmconst char *owner_parse(const char *, int *, int *);
98228753Smm
99228753Smm
100228753Smm/* Fake short equivalents for long options that otherwise lack them. */
101228753Smmenum {
102248616Smm	OPTION_B64ENCODE = 1,
103248616Smm	OPTION_GRZIP,
104248616Smm	OPTION_INSECURE,
105248616Smm	OPTION_LRZIP,
106299529Smm	OPTION_LZ4,
107228753Smm	OPTION_LZMA,
108248616Smm	OPTION_LZOP,
109299529Smm	OPTION_PASSPHRASE,
110228753Smm	OPTION_NO_PRESERVE_OWNER,
111228753Smm	OPTION_PRESERVE_OWNER,
112228753Smm	OPTION_QUIET,
113248616Smm	OPTION_UUENCODE,
114228753Smm	OPTION_VERSION
115228753Smm};
116228753Smm
117228753Smmint	cpio_getopt(struct cpio *cpio);
118228753Smm
119228753Smm#endif
120