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 28229592Smm#ifndef __LIBARCHIVE_BUILD 29228753Smm#error This header is only to be used internally to libarchive. 30228753Smm#endif 31228753Smm 32228753Smm#ifndef ARCHIVE_WRITE_PRIVATE_H_INCLUDED 33228753Smm#define ARCHIVE_WRITE_PRIVATE_H_INCLUDED 34228753Smm 35228753Smm#include "archive.h" 36228753Smm#include "archive_string.h" 37228753Smm#include "archive_private.h" 38228753Smm 39228753Smmstruct archive_write { 40228753Smm struct archive archive; 41229592Smm 42228753Smm /* Dev/ino of the archive being written. */ 43228753Smm dev_t skip_file_dev; 44228753Smm int64_t skip_file_ino; 45228753Smm 46228753Smm /* Utility: Pointer to a block of nulls. */ 47228753Smm const unsigned char *nulls; 48228753Smm size_t null_length; 49228753Smm 50228753Smm /* Callbacks to open/read/write/close archive stream. */ 51228753Smm archive_open_callback *client_opener; 52228753Smm archive_write_callback *client_writer; 53228753Smm archive_close_callback *client_closer; 54228753Smm void *client_data; 55228753Smm 56228753Smm /* 57228753Smm * Blocking information. Note that bytes_in_last_block is 58228753Smm * misleadingly named; I should find a better name. These 59228753Smm * control the final output from all compressors, including 60228753Smm * compression_none. 61228753Smm */ 62228753Smm int bytes_per_block; 63228753Smm int bytes_in_last_block; 64228753Smm 65228753Smm /* 66228753Smm * These control whether data within a gzip/bzip2 compressed 67228753Smm * stream gets padded or not. If pad_uncompressed is set, 68228753Smm * the data will be padded to a full block before being 69228753Smm * compressed. The pad_uncompressed_byte determines the value 70228753Smm * that will be used for padding. Note that these have no 71228753Smm * effect on compression "none." 72228753Smm */ 73228753Smm int pad_uncompressed; 74228753Smm int pad_uncompressed_byte; /* TODO: Support this. */ 75228753Smm 76229592Smm /* 77228753Smm * On write, the client just invokes an archive_write_set function 78228753Smm * which sets up the data here directly. 79228753Smm */ 80228753Smm struct { 81228753Smm void *data; 82228753Smm void *config; 83228753Smm int (*init)(struct archive_write *); 84228753Smm int (*options)(struct archive_write *, 85228753Smm const char *key, const char *value); 86228753Smm int (*finish)(struct archive_write *); 87228753Smm int (*write)(struct archive_write *, const void *, size_t); 88228753Smm } compressor; 89228753Smm 90228753Smm /* 91228753Smm * Pointers to format-specific functions for writing. They're 92228753Smm * initialized by archive_write_set_format_XXX() calls. 93228753Smm */ 94228753Smm void *format_data; 95228753Smm const char *format_name; 96228753Smm int (*format_init)(struct archive_write *); 97228753Smm int (*format_options)(struct archive_write *, 98228753Smm const char *key, const char *value); 99228753Smm int (*format_finish)(struct archive_write *); 100228753Smm int (*format_destroy)(struct archive_write *); 101228753Smm int (*format_finish_entry)(struct archive_write *); 102228753Smm int (*format_write_header)(struct archive_write *, 103228753Smm struct archive_entry *); 104228753Smm ssize_t (*format_write_data)(struct archive_write *, 105228753Smm const void *buff, size_t); 106228753Smm}; 107228753Smm 108228753Smm/* 109228753Smm * Utility function to format a USTAR header into a buffer. If 110228753Smm * "strict" is set, this tries to create the absolutely most portable 111228753Smm * version of a ustar header. If "strict" is set to 0, then it will 112228753Smm * relax certain requirements. 113228753Smm * 114228753Smm * Generally, format-specific declarations don't belong in this 115228753Smm * header; this is a rare example of a function that is shared by 116228753Smm * two very similar formats (ustar and pax). 117228753Smm */ 118228753Smmint 119228753Smm__archive_write_format_header_ustar(struct archive_write *, char buff[512], 120228753Smm struct archive_entry *, int tartype, int strict); 121228753Smm 122228753Smm#endif 123228753Smm