Home | History | Annotate | Line # | Download | only in cpio
      1      1.1     joerg /*-
      2  1.1.1.6  christos  * SPDX-License-Identifier: BSD-2-Clause
      3  1.1.1.6  christos  *
      4      1.1     joerg  * Copyright (c) 2003-2007 Tim Kientzle
      5      1.1     joerg  * All rights reserved.
      6      1.1     joerg  */
      7      1.1     joerg 
      8      1.1     joerg #ifndef CPIO_H_INCLUDED
      9      1.1     joerg #define CPIO_H_INCLUDED
     10      1.1     joerg 
     11      1.1     joerg #include "cpio_platform.h"
     12      1.1     joerg #include <stdio.h>
     13      1.1     joerg 
     14      1.1     joerg /*
     15      1.1     joerg  * The internal state for the "cpio" program.
     16      1.1     joerg  *
     17      1.1     joerg  * Keeping all of the state in a structure like this simplifies memory
     18      1.1     joerg  * leak testing (at exit, anything left on the heap is suspect).  A
     19      1.1     joerg  * pointer to this structure is passed to most cpio internal
     20      1.1     joerg  * functions.
     21      1.1     joerg  */
     22      1.1     joerg struct cpio {
     23  1.1.1.2     joerg 	/* Option parsing */
     24  1.1.1.3     joerg 	const char	 *argument;
     25  1.1.1.2     joerg 
     26      1.1     joerg 	/* Options */
     27  1.1.1.3     joerg 	int		  add_filter; /* --uuencode */
     28  1.1.1.2     joerg 	const char	 *filename;
     29  1.1.1.3     joerg 	int		  mode; /* -i -o -p */
     30  1.1.1.3     joerg 	int		  compress; /* -j, -y, or -z */
     31      1.1     joerg 	const char	 *format; /* -H format */
     32      1.1     joerg 	int		  bytes_per_block; /* -b block_size */
     33      1.1     joerg 	int		  verbose;   /* -v */
     34  1.1.1.3     joerg 	int		  dot;  /* -V */
     35      1.1     joerg 	int		  quiet;   /* --quiet */
     36      1.1     joerg 	int		  extract_flags; /* Flags for extract operation */
     37      1.1     joerg 	const char	 *compress_program;
     38      1.1     joerg 	int		  option_append; /* -A, only relevant for -o */
     39      1.1     joerg 	int		  option_atime_restore; /* -a */
     40      1.1     joerg 	int		  option_follow_links; /* -L */
     41      1.1     joerg 	int		  option_link; /* -l */
     42      1.1     joerg 	int		  option_list; /* -t */
     43  1.1.1.2     joerg 	char		  option_null; /* --null */
     44  1.1.1.2     joerg 	int		  option_numeric_uid_gid; /* -n */
     45  1.1.1.5  christos 	int		  option_pwb; /* -6 */
     46      1.1     joerg 	int		  option_rename; /* -r */
     47      1.1     joerg 	char		 *destdir;
     48  1.1.1.5  christos 	size_t		  destdir_len;
     49      1.1     joerg 	size_t		  pass_destpath_alloc;
     50      1.1     joerg 	char		 *pass_destpath;
     51      1.1     joerg 	int		  uid_override;
     52  1.1.1.3     joerg 	char		 *uname_override;
     53      1.1     joerg 	int		  gid_override;
     54  1.1.1.3     joerg 	char		 *gname_override;
     55  1.1.1.2     joerg 	int		  day_first; /* true if locale prefers day/mon */
     56  1.1.1.3     joerg 	const char	 *passphrase;
     57      1.1     joerg 
     58      1.1     joerg 	/* If >= 0, then close this when done. */
     59      1.1     joerg 	int		  fd;
     60      1.1     joerg 
     61      1.1     joerg 	/* Miscellaneous state information */
     62      1.1     joerg 	struct archive	 *archive;
     63  1.1.1.2     joerg 	struct archive	 *archive_read_disk;
     64      1.1     joerg 	int		  argc;
     65      1.1     joerg 	char		**argv;
     66      1.1     joerg 	int		  return_value; /* Value returned by main() */
     67      1.1     joerg 	struct archive_entry_linkresolver *linkresolver;
     68      1.1     joerg 
     69  1.1.1.2     joerg 	struct name_cache *uname_cache;
     70  1.1.1.2     joerg 	struct name_cache *gname_cache;
     71  1.1.1.2     joerg 
     72      1.1     joerg 	/* Work data. */
     73  1.1.1.3     joerg 	struct archive   *matching;
     74  1.1.1.3     joerg 	char		 *ppbuff;
     75      1.1     joerg };
     76      1.1     joerg 
     77  1.1.1.6  christos struct cpio_owner {
     78  1.1.1.6  christos         int uid;
     79  1.1.1.6  christos         int gid;
     80  1.1.1.6  christos         char *uname;
     81  1.1.1.6  christos         char *gname;
     82  1.1.1.6  christos };
     83      1.1     joerg 
     84  1.1.1.6  christos int owner_parse(const char *, struct cpio_owner *, const char **);
     85      1.1     joerg 
     86      1.1     joerg /* Fake short equivalents for long options that otherwise lack them. */
     87      1.1     joerg enum {
     88  1.1.1.3     joerg 	OPTION_B64ENCODE = 1,
     89  1.1.1.3     joerg 	OPTION_GRZIP,
     90  1.1.1.3     joerg 	OPTION_INSECURE,
     91  1.1.1.3     joerg 	OPTION_LRZIP,
     92  1.1.1.3     joerg 	OPTION_LZ4,
     93  1.1.1.2     joerg 	OPTION_LZMA,
     94  1.1.1.3     joerg 	OPTION_LZOP,
     95  1.1.1.3     joerg 	OPTION_PASSPHRASE,
     96  1.1.1.2     joerg 	OPTION_NO_PRESERVE_OWNER,
     97  1.1.1.2     joerg 	OPTION_PRESERVE_OWNER,
     98      1.1     joerg 	OPTION_QUIET,
     99  1.1.1.3     joerg 	OPTION_UUENCODE,
    100  1.1.1.4     joerg 	OPTION_VERSION,
    101  1.1.1.4     joerg 	OPTION_ZSTD,
    102      1.1     joerg };
    103      1.1     joerg 
    104      1.1     joerg int	cpio_getopt(struct cpio *cpio);
    105      1.1     joerg 
    106      1.1     joerg #endif
    107