Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __COMPRESS_IO__
00016 #define __COMPRESS_IO__
00017
00018 #include "postgres_fe.h"
00019 #include "pg_backup_archiver.h"
00020
00021
00022 #define ZLIB_OUT_SIZE 4096
00023 #define ZLIB_IN_SIZE 4096
00024
00025 typedef enum
00026 {
00027 COMPR_ALG_NONE,
00028 COMPR_ALG_LIBZ
00029 } CompressionAlgorithm;
00030
00031
00032 typedef size_t (*WriteFunc) (ArchiveHandle *AH, const char *buf, size_t len);
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 typedef size_t (*ReadFunc) (ArchiveHandle *AH, char **buf, size_t *buflen);
00046
00047
00048 typedef struct CompressorState CompressorState;
00049
00050 extern CompressorState *AllocateCompressor(int compression, WriteFunc writeF);
00051 extern void ReadDataFromArchive(ArchiveHandle *AH, int compression,
00052 ReadFunc readF);
00053 extern size_t WriteDataToArchive(ArchiveHandle *AH, CompressorState *cs,
00054 const void *data, size_t dLen);
00055 extern void EndCompressor(ArchiveHandle *AH, CompressorState *cs);
00056
00057
00058 typedef struct cfp cfp;
00059
00060 extern cfp *cfopen(const char *path, const char *mode, int compression);
00061 extern cfp *cfopen_read(const char *path, const char *mode);
00062 extern cfp *cfopen_write(const char *path, const char *mode, int compression);
00063 extern int cfread(void *ptr, int size, cfp *fp);
00064 extern int cfwrite(const void *ptr, int size, cfp *fp);
00065 extern int cfgetc(cfp *fp);
00066 extern char *cfgets(cfp *fp, char *buf, int len);
00067 extern int cfclose(cfp *fp);
00068 extern int cfeof(cfp *fp);
00069
00070 #endif