2 * Copyright (c) 2003-2007 Tim Kientzle
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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.
25 * $FreeBSD: src/lib/libarchive/archive_write_private.h,v 1.1 2007/03/03 07:37:36 kientzle Exp $
28 #ifndef ARCHIVE_WRITE_PRIVATE_H_INCLUDED
29 #define ARCHIVE_WRITE_PRIVATE_H_INCLUDED
32 #include "archive_string.h"
33 #include "archive_private.h"
35 struct archive_write {
36 struct archive archive;
38 /* Dev/ino of the archive being written. */
42 /* Utility: Pointer to a block of nulls. */
43 const unsigned char *nulls;
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;
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
59 int bytes_in_last_block;
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."
70 int pad_uncompressed_byte; /* TODO: Support this. */
73 * On write, the client just invokes an archive_write_set function
74 * which sets up the data here directly.
79 int (*init)(struct archive_write *);
80 int (*finish)(struct archive_write *);
81 int (*write)(struct archive_write *, const void *, size_t);
85 * Again, write support is considerably simpler because there's
86 * no need for an auction.
89 const char *archive_format_name;
92 * Pointers to format-specific functions for writing. They're
93 * initialized by archive_write_set_format_XXX() calls.
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);
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.
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).
117 __archive_write_format_header_ustar(struct archive_write *, char buff[512],
118 struct archive_entry *, int tartype, int strict);