Home | History | Annotate | Line # | Download | only in cpio
cpio.h revision 1.1
      1  1.1  joerg /*-
      2  1.1  joerg  * Copyright (c) 2003-2007 Tim Kientzle
      3  1.1  joerg  * All rights reserved.
      4  1.1  joerg  *
      5  1.1  joerg  * Redistribution and use in source and binary forms, with or without
      6  1.1  joerg  * modification, are permitted provided that the following conditions
      7  1.1  joerg  * are met:
      8  1.1  joerg  * 1. Redistributions of source code must retain the above copyright
      9  1.1  joerg  *    notice, this list of conditions and the following disclaimer.
     10  1.1  joerg  * 2. Redistributions in binary form must reproduce the above copyright
     11  1.1  joerg  *    notice, this list of conditions and the following disclaimer in the
     12  1.1  joerg  *    documentation and/or other materials provided with the distribution.
     13  1.1  joerg  *
     14  1.1  joerg  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
     15  1.1  joerg  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     16  1.1  joerg  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     17  1.1  joerg  * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
     18  1.1  joerg  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     19  1.1  joerg  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     20  1.1  joerg  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     21  1.1  joerg  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22  1.1  joerg  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     23  1.1  joerg  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24  1.1  joerg  *
     25  1.1  joerg  * $FreeBSD: src/usr.bin/cpio/cpio.h,v 1.2 2008/06/21 02:20:20 kientzle Exp $
     26  1.1  joerg  */
     27  1.1  joerg 
     28  1.1  joerg #ifndef CPIO_H_INCLUDED
     29  1.1  joerg #define CPIO_H_INCLUDED
     30  1.1  joerg 
     31  1.1  joerg #include "cpio_platform.h"
     32  1.1  joerg #include <stdio.h>
     33  1.1  joerg 
     34  1.1  joerg #define	DEFAULT_BYTES_PER_BLOCK	(20*512)
     35  1.1  joerg 
     36  1.1  joerg /*
     37  1.1  joerg  * The internal state for the "cpio" program.
     38  1.1  joerg  *
     39  1.1  joerg  * Keeping all of the state in a structure like this simplifies memory
     40  1.1  joerg  * leak testing (at exit, anything left on the heap is suspect).  A
     41  1.1  joerg  * pointer to this structure is passed to most cpio internal
     42  1.1  joerg  * functions.
     43  1.1  joerg  */
     44  1.1  joerg struct cpio {
     45  1.1  joerg 	/* Options */
     46  1.1  joerg 	char		 *filename;
     47  1.1  joerg 	char		  mode; /* -i -o -p */
     48  1.1  joerg 	char		  compress; /* -j, -y, or -z */
     49  1.1  joerg 	const char	 *format; /* -H format */
     50  1.1  joerg 	int		  bytes_per_block; /* -b block_size */
     51  1.1  joerg 	int		  verbose;   /* -v */
     52  1.1  joerg 	int		  quiet;   /* --quiet */
     53  1.1  joerg 	int		  extract_flags; /* Flags for extract operation */
     54  1.1  joerg 	char		  symlink_mode; /* H or L, per BSD conventions */
     55  1.1  joerg 	const char	 *compress_program;
     56  1.1  joerg 	char		  line_separator; /* --null ? '\0' : '\n' */
     57  1.1  joerg 	int		  option_append; /* -A, only relevant for -o */
     58  1.1  joerg 	int		  option_atime_restore; /* -a */
     59  1.1  joerg 	int		  option_follow_links; /* -L */
     60  1.1  joerg 	int		  option_link; /* -l */
     61  1.1  joerg 	int		  option_list; /* -t */
     62  1.1  joerg 	int		  option_rename; /* -r */
     63  1.1  joerg 	char		 *destdir;
     64  1.1  joerg 	size_t		  pass_destpath_alloc;
     65  1.1  joerg 	char		 *pass_destpath;
     66  1.1  joerg 	int		  uid_override;
     67  1.1  joerg 	int		  gid_override;
     68  1.1  joerg 
     69  1.1  joerg 	/* If >= 0, then close this when done. */
     70  1.1  joerg 	int		  fd;
     71  1.1  joerg 
     72  1.1  joerg 	/* Miscellaneous state information */
     73  1.1  joerg 	struct archive	 *archive;
     74  1.1  joerg 	int		  argc;
     75  1.1  joerg 	char		**argv;
     76  1.1  joerg 	int		  return_value; /* Value returned by main() */
     77  1.1  joerg 	struct archive_entry_linkresolver *linkresolver;
     78  1.1  joerg 
     79  1.1  joerg 	/* Work data. */
     80  1.1  joerg 	struct matching  *matching;
     81  1.1  joerg 	char		 *buff;
     82  1.1  joerg 	size_t		  buff_size;
     83  1.1  joerg };
     84  1.1  joerg 
     85  1.1  joerg /* Name of this program; used in error reporting, initialized in main(). */
     86  1.1  joerg const char *cpio_progname;
     87  1.1  joerg 
     88  1.1  joerg void	cpio_errc(int _eval, int _code, const char *fmt, ...);
     89  1.1  joerg void	cpio_warnc(int _code, const char *fmt, ...);
     90  1.1  joerg 
     91  1.1  joerg int	owner_parse(const char *, int *, int *);
     92  1.1  joerg 
     93  1.1  joerg 
     94  1.1  joerg /* Fake short equivalents for long options that otherwise lack them. */
     95  1.1  joerg enum {
     96  1.1  joerg 	OPTION_INSECURE = 1,
     97  1.1  joerg 	OPTION_QUIET,
     98  1.1  joerg 	OPTION_VERSION
     99  1.1  joerg };
    100  1.1  joerg 
    101  1.1  joerg struct line_reader;
    102  1.1  joerg 
    103  1.1  joerg struct line_reader *process_lines_init(const char *, char separator);
    104  1.1  joerg const char *process_lines_next(struct line_reader *);
    105  1.1  joerg void	process_lines_free(struct line_reader *);
    106  1.1  joerg 
    107  1.1  joerg int	cpio_getopt(struct cpio *cpio);
    108  1.1  joerg int	include_from_file(struct cpio *, const char *);
    109  1.1  joerg 
    110  1.1  joerg #endif
    111