cpio.h revision 228759
1238104Sdes/*-
2238104Sdes * Copyright (c) 2003-2007 Tim Kientzle
3238104Sdes * All rights reserved.
4238104Sdes *
5238104Sdes * Redistribution and use in source and binary forms, with or without
6238104Sdes * modification, are permitted provided that the following conditions
7238104Sdes * are met:
8238104Sdes * 1. Redistributions of source code must retain the above copyright
9238104Sdes *    notice, this list of conditions and the following disclaimer.
10238104Sdes * 2. Redistributions in binary form must reproduce the above copyright
11238104Sdes *    notice, this list of conditions and the following disclaimer in the
12238104Sdes *    documentation and/or other materials provided with the distribution.
13238104Sdes *
14238104Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15238104Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16238104Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17238104Sdes * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18238104Sdes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19238104Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20238104Sdes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21238104Sdes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22238104Sdes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23238104Sdes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24238104Sdes *
25238104Sdes * $FreeBSD: src/usr.bin/cpio/cpio.h,v 1.7 2008/12/06 07:30:40 kientzle Exp $
26238104Sdes */
27238104Sdes
28238104Sdes#ifndef CPIO_H_INCLUDED
29238104Sdes#define CPIO_H_INCLUDED
30238104Sdes
31238104Sdes#include "cpio_platform.h"
32238104Sdes#include <stdio.h>
33238104Sdes
34238104Sdes#include "matching.h"
35238104Sdes
36238104Sdes/*
37238104Sdes * The internal state for the "cpio" program.
38238104Sdes *
39238104Sdes * Keeping all of the state in a structure like this simplifies memory
40238104Sdes * leak testing (at exit, anything left on the heap is suspect).  A
41238104Sdes * pointer to this structure is passed to most cpio internal
42238104Sdes * functions.
43238104Sdes */
44238104Sdesstruct cpio {
45238104Sdes	/* Option parsing */
46238104Sdes	const char	 *optarg;
47238104Sdes
48238104Sdes	/* Options */
49238104Sdes	const char	 *filename;
50238104Sdes	char		  mode; /* -i -o -p */
51238104Sdes	char		  compress; /* -j, -y, or -z */
52238104Sdes	const char	 *format; /* -H format */
53238104Sdes	int		  bytes_per_block; /* -b block_size */
54238104Sdes	int		  verbose;   /* -v */
55238104Sdes	int		  quiet;   /* --quiet */
56238104Sdes	int		  extract_flags; /* Flags for extract operation */
57238104Sdes	char		  symlink_mode; /* H or L, per BSD conventions */
58238104Sdes	const char	 *compress_program;
59238104Sdes	int		  option_append; /* -A, only relevant for -o */
60238104Sdes	int		  option_atime_restore; /* -a */
61238104Sdes	int		  option_follow_links; /* -L */
62238104Sdes	int		  option_link; /* -l */
63238104Sdes	int		  option_list; /* -t */
64238104Sdes	char		  option_null; /* --null */
65238104Sdes	int		  option_numeric_uid_gid; /* -n */
66238104Sdes	int		  option_rename; /* -r */
67238104Sdes	char		 *destdir;
68238104Sdes	size_t		  pass_destpath_alloc;
69238104Sdes	char		 *pass_destpath;
70238104Sdes	int		  uid_override;
71238104Sdes	int		  gid_override;
72238104Sdes	int		  day_first; /* true if locale prefers day/mon */
73238104Sdes
74238104Sdes	/* If >= 0, then close this when done. */
75238104Sdes	int		  fd;
76238104Sdes
77238104Sdes	/* Miscellaneous state information */
78238104Sdes	struct archive	 *archive;
79238104Sdes	struct archive	 *archive_read_disk;
80238104Sdes	int		  argc;
81238104Sdes	char		**argv;
82238104Sdes	int		  return_value; /* Value returned by main() */
83238104Sdes	struct archive_entry_linkresolver *linkresolver;
84238104Sdes
85238104Sdes	struct name_cache *uname_cache;
86238104Sdes	struct name_cache *gname_cache;
87238104Sdes
88238104Sdes	/* Work data. */
89238104Sdes	struct lafe_matching  *matching;
90238104Sdes	char		 *buff;
91238104Sdes	size_t		  buff_size;
92238104Sdes};
93238104Sdes
94238104Sdesconst char *owner_parse(const char *, int *, int *);
95238104Sdes
96238104Sdes
97238104Sdes/* Fake short equivalents for long options that otherwise lack them. */
98238104Sdesenum {
99238104Sdes	OPTION_INSECURE = 1,
100238104Sdes	OPTION_LZMA,
101238104Sdes	OPTION_NO_PRESERVE_OWNER,
102238104Sdes	OPTION_PRESERVE_OWNER,
103238104Sdes	OPTION_QUIET,
104238104Sdes	OPTION_VERSION
105238104Sdes};
106238104Sdes
107238104Sdesint	cpio_getopt(struct cpio *cpio);
108238104Sdes
109238104Sdes#endif
110238104Sdes