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: stable/11/contrib/libarchive/cpio/cpio.h 370535 2021-09-10 08:34:36Z git2svn $
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 */
65370535Sgit2svn	int		  option_pwb; /* -6 */
66228753Smm	int		  option_rename; /* -r */
67228753Smm	char		 *destdir;
68358926Smm	size_t		  destdir_len;
69228753Smm	size_t		  pass_destpath_alloc;
70228753Smm	char		 *pass_destpath;
71228753Smm	int		  uid_override;
72228777Smm	char		 *uname_override;
73228753Smm	int		  gid_override;
74228777Smm	char		 *gname_override;
75228753Smm	int		  day_first; /* true if locale prefers day/mon */
76299529Smm	const char	 *passphrase;
77228753Smm
78228753Smm	/* If >= 0, then close this when done. */
79228753Smm	int		  fd;
80228753Smm
81228753Smm	/* Miscellaneous state information */
82228753Smm	struct archive	 *archive;
83228753Smm	struct archive	 *archive_read_disk;
84228753Smm	int		  argc;
85228753Smm	char		**argv;
86228753Smm	int		  return_value; /* Value returned by main() */
87228753Smm	struct archive_entry_linkresolver *linkresolver;
88228753Smm
89228753Smm	struct name_cache *uname_cache;
90228753Smm	struct name_cache *gname_cache;
91228753Smm
92228753Smm	/* Work data. */
93238856Smm	struct archive   *matching;
94228753Smm	char		 *buff;
95228753Smm	size_t		  buff_size;
96299529Smm	char		 *ppbuff;
97228753Smm};
98228753Smm
99228753Smmconst char *owner_parse(const char *, int *, int *);
100228753Smm
101228753Smm
102228753Smm/* Fake short equivalents for long options that otherwise lack them. */
103228753Smmenum {
104248616Smm	OPTION_B64ENCODE = 1,
105248616Smm	OPTION_GRZIP,
106248616Smm	OPTION_INSECURE,
107248616Smm	OPTION_LRZIP,
108299529Smm	OPTION_LZ4,
109228753Smm	OPTION_LZMA,
110248616Smm	OPTION_LZOP,
111299529Smm	OPTION_PASSPHRASE,
112228753Smm	OPTION_NO_PRESERVE_OWNER,
113228753Smm	OPTION_PRESERVE_OWNER,
114228753Smm	OPTION_QUIET,
115248616Smm	OPTION_UUENCODE,
116324417Smm	OPTION_VERSION,
117324417Smm	OPTION_ZSTD,
118228753Smm};
119228753Smm
120228753Smmint	cpio_getopt(struct cpio *cpio);
121228753Smm
122228753Smm#endif
123