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 * 25229592Smm * $FreeBSD$ 26228753Smm */ 27228753Smm 28228753Smm#ifndef CPIO_H_INCLUDED 29228753Smm#define CPIO_H_INCLUDED 30228753Smm 31228753Smm#include "cpio_platform.h" 32228753Smm#include <stdio.h> 33228753Smm 34228753Smm#include "matching.h" 35228753Smm 36228753Smm/* 37228753Smm * The internal state for the "cpio" program. 38228753Smm * 39228753Smm * Keeping all of the state in a structure like this simplifies memory 40228753Smm * leak testing (at exit, anything left on the heap is suspect). A 41228753Smm * pointer to this structure is passed to most cpio internal 42228753Smm * functions. 43228753Smm */ 44228753Smmstruct cpio { 45228753Smm /* Option parsing */ 46228753Smm const char *optarg; 47228753Smm 48228753Smm /* Options */ 49228753Smm const char *filename; 50228753Smm char mode; /* -i -o -p */ 51228753Smm char compress; /* -j, -y, or -z */ 52228753Smm const char *format; /* -H format */ 53228753Smm int bytes_per_block; /* -b block_size */ 54228753Smm int verbose; /* -v */ 55228753Smm int quiet; /* --quiet */ 56228753Smm int extract_flags; /* Flags for extract operation */ 57228753Smm char symlink_mode; /* H or L, per BSD conventions */ 58228753Smm const char *compress_program; 59228753Smm int option_append; /* -A, only relevant for -o */ 60228753Smm int option_atime_restore; /* -a */ 61228753Smm int option_follow_links; /* -L */ 62228753Smm int option_link; /* -l */ 63228753Smm int option_list; /* -t */ 64228753Smm char option_null; /* --null */ 65228753Smm int option_numeric_uid_gid; /* -n */ 66228753Smm int option_rename; /* -r */ 67228753Smm char *destdir; 68228753Smm size_t pass_destpath_alloc; 69228753Smm char *pass_destpath; 70228753Smm int uid_override; 71229592Smm char *uname_override; 72228753Smm int gid_override; 73229592Smm char *gname_override; 74228753Smm int day_first; /* true if locale prefers day/mon */ 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. */ 91228753Smm struct lafe_matching *matching; 92228753Smm char *buff; 93228753Smm size_t buff_size; 94228753Smm}; 95228753Smm 96228753Smmconst char *owner_parse(const char *, int *, int *); 97228753Smm 98228753Smm 99228753Smm/* Fake short equivalents for long options that otherwise lack them. */ 100228753Smmenum { 101228753Smm OPTION_INSECURE = 1, 102228753Smm OPTION_LZMA, 103228753Smm OPTION_NO_PRESERVE_OWNER, 104228753Smm OPTION_PRESERVE_OWNER, 105228753Smm OPTION_QUIET, 106228753Smm OPTION_VERSION 107228753Smm}; 108228753Smm 109228753Smmint cpio_getopt(struct cpio *cpio); 110228753Smm 111228753Smm#endif 112