160b4ad09SPeter Avalos /*- 260b4ad09SPeter Avalos * Copyright (c) 2003-2007 Tim Kientzle 360b4ad09SPeter Avalos * All rights reserved. 460b4ad09SPeter Avalos * 560b4ad09SPeter Avalos * Redistribution and use in source and binary forms, with or without 660b4ad09SPeter Avalos * modification, are permitted provided that the following conditions 760b4ad09SPeter Avalos * are met: 860b4ad09SPeter Avalos * 1. Redistributions of source code must retain the above copyright 960b4ad09SPeter Avalos * notice, this list of conditions and the following disclaimer. 1060b4ad09SPeter Avalos * 2. Redistributions in binary form must reproduce the above copyright 1160b4ad09SPeter Avalos * notice, this list of conditions and the following disclaimer in the 1260b4ad09SPeter Avalos * documentation and/or other materials provided with the distribution. 1360b4ad09SPeter Avalos * 1460b4ad09SPeter Avalos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 1560b4ad09SPeter Avalos * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1660b4ad09SPeter Avalos * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1760b4ad09SPeter Avalos * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 1860b4ad09SPeter Avalos * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 1960b4ad09SPeter Avalos * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2060b4ad09SPeter Avalos * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2160b4ad09SPeter Avalos * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2260b4ad09SPeter Avalos * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2360b4ad09SPeter Avalos * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2460b4ad09SPeter Avalos * 258029ab02SPeter Avalos * $FreeBSD: src/usr.bin/cpio/cpio.h,v 1.7 2008/12/06 07:30:40 kientzle Exp $ 2660b4ad09SPeter Avalos */ 2760b4ad09SPeter Avalos 2860b4ad09SPeter Avalos #ifndef CPIO_H_INCLUDED 2960b4ad09SPeter Avalos #define CPIO_H_INCLUDED 3060b4ad09SPeter Avalos 3160b4ad09SPeter Avalos #include "cpio_platform.h" 3260b4ad09SPeter Avalos #include <stdio.h> 3360b4ad09SPeter Avalos 3460b4ad09SPeter Avalos /* 3560b4ad09SPeter Avalos * The internal state for the "cpio" program. 3660b4ad09SPeter Avalos * 3760b4ad09SPeter Avalos * Keeping all of the state in a structure like this simplifies memory 3860b4ad09SPeter Avalos * leak testing (at exit, anything left on the heap is suspect). A 3960b4ad09SPeter Avalos * pointer to this structure is passed to most cpio internal 4060b4ad09SPeter Avalos * functions. 4160b4ad09SPeter Avalos */ 4260b4ad09SPeter Avalos struct cpio { 438029ab02SPeter Avalos /* Option parsing */ 44c09f92d2SPeter Avalos const char *argument; 458029ab02SPeter Avalos 4660b4ad09SPeter Avalos /* Options */ 47d4d8193eSPeter Avalos int add_filter; /* --uuencode */ 488029ab02SPeter Avalos const char *filename; 49c09f92d2SPeter Avalos int mode; /* -i -o -p */ 50c09f92d2SPeter Avalos int compress; /* -j, -y, or -z */ 5160b4ad09SPeter Avalos const char *format; /* -H format */ 5260b4ad09SPeter Avalos int bytes_per_block; /* -b block_size */ 5360b4ad09SPeter Avalos int verbose; /* -v */ 54c09f92d2SPeter Avalos int dot; /* -V */ 5560b4ad09SPeter Avalos int quiet; /* --quiet */ 5660b4ad09SPeter Avalos int extract_flags; /* Flags for extract operation */ 5760b4ad09SPeter Avalos const char *compress_program; 5860b4ad09SPeter Avalos int option_append; /* -A, only relevant for -o */ 5960b4ad09SPeter Avalos int option_atime_restore; /* -a */ 6060b4ad09SPeter Avalos int option_follow_links; /* -L */ 6160b4ad09SPeter Avalos int option_link; /* -l */ 6260b4ad09SPeter Avalos int option_list; /* -t */ 639c82a63eSPeter Avalos char option_null; /* --null */ 648029ab02SPeter Avalos int option_numeric_uid_gid; /* -n */ 65*50f8aa9cSAntonio Huete Jimenez int option_pwb; /* -6 */ 6660b4ad09SPeter Avalos int option_rename; /* -r */ 6760b4ad09SPeter Avalos char *destdir; 68085658deSDaniel Fojt size_t destdir_len; 6960b4ad09SPeter Avalos size_t pass_destpath_alloc; 7060b4ad09SPeter Avalos char *pass_destpath; 7160b4ad09SPeter Avalos int uid_override; 72c09f92d2SPeter Avalos char *uname_override; 7360b4ad09SPeter Avalos int gid_override; 74c09f92d2SPeter Avalos char *gname_override; 758029ab02SPeter Avalos int day_first; /* true if locale prefers day/mon */ 766b384f39SPeter Avalos const char *passphrase; 7760b4ad09SPeter Avalos 7860b4ad09SPeter Avalos /* If >= 0, then close this when done. */ 7960b4ad09SPeter Avalos int fd; 8060b4ad09SPeter Avalos 8160b4ad09SPeter Avalos /* Miscellaneous state information */ 8260b4ad09SPeter Avalos struct archive *archive; 839c82a63eSPeter Avalos struct archive *archive_read_disk; 8460b4ad09SPeter Avalos int argc; 8560b4ad09SPeter Avalos char **argv; 8660b4ad09SPeter Avalos int return_value; /* Value returned by main() */ 8760b4ad09SPeter Avalos struct archive_entry_linkresolver *linkresolver; 8860b4ad09SPeter Avalos 898029ab02SPeter Avalos struct name_cache *uname_cache; 908029ab02SPeter Avalos struct name_cache *gname_cache; 918029ab02SPeter Avalos 9260b4ad09SPeter Avalos /* Work data. */ 9359bf7050SPeter Avalos struct archive *matching; 9460b4ad09SPeter Avalos char *buff; 9560b4ad09SPeter Avalos size_t buff_size; 966b384f39SPeter Avalos char *ppbuff; 9760b4ad09SPeter Avalos }; 9860b4ad09SPeter Avalos 999c82a63eSPeter Avalos const char *owner_parse(const char *, int *, int *); 10060b4ad09SPeter Avalos 10160b4ad09SPeter Avalos 10260b4ad09SPeter Avalos /* Fake short equivalents for long options that otherwise lack them. */ 10360b4ad09SPeter Avalos enum { 104d4d8193eSPeter Avalos OPTION_B64ENCODE = 1, 105d4d8193eSPeter Avalos OPTION_GRZIP, 106d4d8193eSPeter Avalos OPTION_INSECURE, 107d4d8193eSPeter Avalos OPTION_LRZIP, 1086b384f39SPeter Avalos OPTION_LZ4, 1099c82a63eSPeter Avalos OPTION_LZMA, 110d4d8193eSPeter Avalos OPTION_LZOP, 1116b384f39SPeter Avalos OPTION_PASSPHRASE, 1128029ab02SPeter Avalos OPTION_NO_PRESERVE_OWNER, 1139c82a63eSPeter Avalos OPTION_PRESERVE_OWNER, 11460b4ad09SPeter Avalos OPTION_QUIET, 115d4d8193eSPeter Avalos OPTION_UUENCODE, 116e95abc47Szrj OPTION_VERSION, 117e95abc47Szrj OPTION_ZSTD, 11860b4ad09SPeter Avalos }; 11960b4ad09SPeter Avalos 12060b4ad09SPeter Avalos int cpio_getopt(struct cpio *cpio); 12160b4ad09SPeter Avalos 12260b4ad09SPeter Avalos #endif 123