2010-12-02 20:39:03 +01:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* compress_io.h
|
2011-04-10 17:42:00 +02:00
|
|
|
* Interface to compress_io.c routines
|
2010-12-02 20:39:03 +01:00
|
|
|
*
|
2017-01-03 19:48:53 +01:00
|
|
|
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
|
2010-12-02 20:39:03 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2011-04-10 17:42:00 +02:00
|
|
|
* src/bin/pg_dump/compress_io.h
|
2010-12-02 20:39:03 +01:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __COMPRESS_IO__
|
|
|
|
#define __COMPRESS_IO__
|
|
|
|
|
|
|
|
#include "pg_backup_archiver.h"
|
|
|
|
|
|
|
|
/* Initial buffer sizes used in zlib compression. */
|
|
|
|
#define ZLIB_OUT_SIZE 4096
|
|
|
|
#define ZLIB_IN_SIZE 4096
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
COMPR_ALG_NONE,
|
|
|
|
COMPR_ALG_LIBZ
|
|
|
|
} CompressionAlgorithm;
|
|
|
|
|
|
|
|
/* Prototype for callback function to WriteDataToArchive() */
|
2014-05-06 02:27:16 +02:00
|
|
|
typedef void (*WriteFunc) (ArchiveHandle *AH, const char *buf, size_t len);
|
2010-12-02 20:39:03 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Prototype for callback function to ReadDataFromArchive()
|
|
|
|
*
|
|
|
|
* ReadDataFromArchive will call the read function repeatedly, until it
|
|
|
|
* returns 0 to signal EOF. ReadDataFromArchive passes a buffer to read the
|
|
|
|
* data into in *buf, of length *buflen. If that's not big enough for the
|
|
|
|
* callback function, it can free() it and malloc() a new one, returning the
|
|
|
|
* new buffer and its size in *buf and *buflen.
|
|
|
|
*
|
|
|
|
* Returns the number of bytes read into *buf, or 0 on EOF.
|
|
|
|
*/
|
2011-04-10 17:42:00 +02:00
|
|
|
typedef size_t (*ReadFunc) (ArchiveHandle *AH, char **buf, size_t *buflen);
|
2010-12-02 20:39:03 +01:00
|
|
|
|
2010-12-02 21:38:49 +01:00
|
|
|
/* struct definition appears in compress_io.c */
|
|
|
|
typedef struct CompressorState CompressorState;
|
2010-12-02 20:39:03 +01:00
|
|
|
|
|
|
|
extern CompressorState *AllocateCompressor(int compression, WriteFunc writeF);
|
|
|
|
extern void ReadDataFromArchive(ArchiveHandle *AH, int compression,
|
2011-04-10 17:42:00 +02:00
|
|
|
ReadFunc readF);
|
2014-05-06 02:27:16 +02:00
|
|
|
extern void WriteDataToArchive(ArchiveHandle *AH, CompressorState *cs,
|
2011-04-10 17:42:00 +02:00
|
|
|
const void *data, size_t dLen);
|
2010-12-02 20:39:03 +01:00
|
|
|
extern void EndCompressor(ArchiveHandle *AH, CompressorState *cs);
|
|
|
|
|
2011-01-23 22:10:15 +01:00
|
|
|
|
|
|
|
typedef struct cfp cfp;
|
|
|
|
|
|
|
|
extern cfp *cfopen(const char *path, const char *mode, int compression);
|
|
|
|
extern cfp *cfopen_read(const char *path, const char *mode);
|
|
|
|
extern cfp *cfopen_write(const char *path, const char *mode, int compression);
|
2011-04-10 17:42:00 +02:00
|
|
|
extern int cfread(void *ptr, int size, cfp *fp);
|
|
|
|
extern int cfwrite(const void *ptr, int size, cfp *fp);
|
|
|
|
extern int cfgetc(cfp *fp);
|
2011-01-23 22:10:15 +01:00
|
|
|
extern char *cfgets(cfp *fp, char *buf, int len);
|
2011-04-10 17:42:00 +02:00
|
|
|
extern int cfclose(cfp *fp);
|
|
|
|
extern int cfeof(cfp *fp);
|
2011-01-23 22:10:15 +01:00
|
|
|
|
2010-12-02 20:39:03 +01:00
|
|
|
#endif
|