Import libarchive 2.1.9.
[dragonfly.git] / contrib / libarchive-2.1 / libarchive / archive_write_private.h
1 /*-
2  * Copyright (c) 2003-2007 Tim Kientzle
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  * $FreeBSD: src/lib/libarchive/archive_write_private.h,v 1.1 2007/03/03 07:37:36 kientzle Exp $
26  */
27
28 #ifndef ARCHIVE_WRITE_PRIVATE_H_INCLUDED
29 #define ARCHIVE_WRITE_PRIVATE_H_INCLUDED
30
31 #include "archive.h"
32 #include "archive_string.h"
33 #include "archive_private.h"
34
35 struct archive_write {
36         struct archive  archive;
37
38         /* Dev/ino of the archive being written. */
39         dev_t             skip_file_dev;
40         ino_t             skip_file_ino;
41
42         /* Utility:  Pointer to a block of nulls. */
43         const unsigned char     *nulls;
44         size_t                   null_length;
45
46         /* Callbacks to open/read/write/close archive stream. */
47         archive_open_callback   *client_opener;
48         archive_write_callback  *client_writer;
49         archive_close_callback  *client_closer;
50         void                    *client_data;
51
52         /*
53          * Blocking information.  Note that bytes_in_last_block is
54          * misleadingly named; I should find a better name.  These
55          * control the final output from all compressors, including
56          * compression_none.
57          */
58         int               bytes_per_block;
59         int               bytes_in_last_block;
60
61         /*
62          * These control whether data within a gzip/bzip2 compressed
63          * stream gets padded or not.  If pad_uncompressed is set,
64          * the data will be padded to a full block before being
65          * compressed.  The pad_uncompressed_byte determines the value
66          * that will be used for padding.  Note that these have no
67          * effect on compression "none."
68          */
69         int               pad_uncompressed;
70         int               pad_uncompressed_byte; /* TODO: Support this. */
71
72         /*
73          * On write, the client just invokes an archive_write_set function
74          * which sets up the data here directly.
75          */
76         struct {
77                 void     *data;
78                 void     *config;
79                 int     (*init)(struct archive_write *);
80                 int     (*finish)(struct archive_write *);
81                 int     (*write)(struct archive_write *, const void *, size_t);
82         } compressor;
83
84         /*
85          * Again, write support is considerably simpler because there's
86          * no need for an auction.
87          */
88         int               archive_format;
89         const char       *archive_format_name;
90
91         /*
92          * Pointers to format-specific functions for writing.  They're
93          * initialized by archive_write_set_format_XXX() calls.
94          */
95         void     *format_data;
96         int     (*format_init)(struct archive_write *);
97         int     (*format_finish)(struct archive_write *);
98         int     (*format_destroy)(struct archive_write *);
99         int     (*format_finish_entry)(struct archive_write *);
100         int     (*format_write_header)(struct archive_write *,
101                     struct archive_entry *);
102         ssize_t (*format_write_data)(struct archive_write *,
103                     const void *buff, size_t);
104 };
105
106 /*
107  * Utility function to format a USTAR header into a buffer.  If
108  * "strict" is set, this tries to create the absolutely most portable
109  * version of a ustar header.  If "strict" is set to 0, then it will
110  * relax certain requirements.
111  *
112  * Generally, format-specific declarations don't belong in this
113  * header; this is a rare example of a function that is shared by
114  * two very similar formats (ustar and pax).
115  */
116 int
117 __archive_write_format_header_ustar(struct archive_write *, char buff[512],
118     struct archive_entry *, int tartype, int strict);
119
120 #endif