104 return &streamer->
base;
175 nbytes =
Min(nbytes,
len);
244 pg_fatal(
"tar file trailer exceeds 2 blocks");
249 pg_fatal(
"unexpected state while parsing tar archive");
263 bool has_nonzero_byte =
false;
273 if (buffer[
i] !=
'\0')
275 has_nonzero_byte =
true;
284 if (!has_nonzero_byte)
292 pg_fatal(
"tar member has empty name");
326 pg_fatal(
"COPY stream ended before last file was finished");
365 return &streamer->
base;
420 memset(buffer, 0, pad_bytes);
static void astreamer_free(astreamer *streamer)
static void astreamer_content(astreamer *streamer, astreamer_member *member, const char *data, int len, astreamer_archive_context context)
static bool astreamer_buffer_until(astreamer *streamer, const char **data, int *len, int target_bytes)
static void astreamer_finalize(astreamer *streamer)
astreamer_archive_context
@ ASTREAMER_MEMBER_HEADER
@ ASTREAMER_MEMBER_CONTENTS
@ ASTREAMER_MEMBER_TRAILER
@ ASTREAMER_ARCHIVE_TRAILER
static void astreamer_buffer_bytes(astreamer *streamer, const char **data, int *len, int nbytes)
static const astreamer_ops astreamer_tar_terminator_ops
static const astreamer_ops astreamer_tar_parser_ops
struct astreamer_tar_parser astreamer_tar_parser
struct astreamer_tar_archiver astreamer_tar_archiver
static void astreamer_tar_parser_content(astreamer *streamer, astreamer_member *member, const char *data, int len, astreamer_archive_context context)
astreamer * astreamer_tar_parser_new(astreamer *next)
static void astreamer_tar_terminator_content(astreamer *streamer, astreamer_member *member, const char *data, int len, astreamer_archive_context context)
static void astreamer_tar_archiver_free(astreamer *streamer)
astreamer * astreamer_tar_archiver_new(astreamer *next)
astreamer * astreamer_tar_terminator_new(astreamer *next)
static bool astreamer_tar_header(astreamer_tar_parser *mystreamer)
static void astreamer_tar_parser_finalize(astreamer *streamer)
static void astreamer_tar_archiver_finalize(astreamer *streamer)
static const astreamer_ops astreamer_tar_archiver_ops
static void astreamer_tar_terminator_free(astreamer *streamer)
static void astreamer_tar_terminator_finalize(astreamer *streamer)
static void astreamer_tar_parser_free(astreamer *streamer)
static void astreamer_tar_archiver_content(astreamer *streamer, astreamer_member *member, const char *data, int len, astreamer_archive_context context)
#define Assert(condition)
void pfree(void *pointer)
void * palloc0(Size size)
uint64 read_tar_number(const char *s, int len)
static size_t tarPaddingBytesRequired(size_t len)
enum tarError tarCreateHeader(char *h, const char *filename, const char *linktarget, pgoff_t size, mode_t mode, uid_t uid, gid_t gid, time_t mtime)
size_t strlcpy(char *dst, const char *src, size_t siz)
void initStringInfo(StringInfo str)
char linktarget[MAXPGPATH]
void(* content)(astreamer *streamer, astreamer_member *member, const char *data, int len, astreamer_archive_context context)
astreamer_archive_context next_context
size_t pad_bytes_expected
StringInfoData bbs_buffer
const astreamer_ops * bbs_ops