PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
compress_io.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * compress_io.h
4  * Interface to compress_io.c routines
5  *
6  * Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * IDENTIFICATION
10  * src/bin/pg_dump/compress_io.h
11  *
12  *-------------------------------------------------------------------------
13  */
14 
15 #ifndef __COMPRESS_IO__
16 #define __COMPRESS_IO__
17 
18 #include "pg_backup_archiver.h"
19 
20 /* Initial buffer sizes used in zlib compression. */
21 #define ZLIB_OUT_SIZE 4096
22 #define ZLIB_IN_SIZE 4096
23 
24 typedef enum
25 {
29 
30 /* Prototype for callback function to WriteDataToArchive() */
31 typedef void (*WriteFunc) (ArchiveHandle *AH, const char *buf, size_t len);
32 
33 /*
34  * Prototype for callback function to ReadDataFromArchive()
35  *
36  * ReadDataFromArchive will call the read function repeatedly, until it
37  * returns 0 to signal EOF. ReadDataFromArchive passes a buffer to read the
38  * data into in *buf, of length *buflen. If that's not big enough for the
39  * callback function, it can free() it and malloc() a new one, returning the
40  * new buffer and its size in *buf and *buflen.
41  *
42  * Returns the number of bytes read into *buf, or 0 on EOF.
43  */
44 typedef size_t (*ReadFunc) (ArchiveHandle *AH, char **buf, size_t *buflen);
45 
46 /* struct definition appears in compress_io.c */
48 
49 extern CompressorState *AllocateCompressor(int compression, WriteFunc writeF);
50 extern void ReadDataFromArchive(ArchiveHandle *AH, int compression,
51  ReadFunc readF);
53  const void *data, size_t dLen);
54 extern void EndCompressor(ArchiveHandle *AH, CompressorState *cs);
55 
56 
57 typedef struct cfp cfp;
58 
59 extern cfp *cfopen(const char *path, const char *mode, int compression);
60 extern cfp *cfopen_read(const char *path, const char *mode);
61 extern cfp *cfopen_write(const char *path, const char *mode, int compression);
62 extern int cfread(void *ptr, int size, cfp *fp);
63 extern int cfwrite(const void *ptr, int size, cfp *fp);
64 extern int cfgetc(cfp *fp);
65 extern char *cfgets(cfp *fp, char *buf, int len);
66 extern int cfclose(cfp *fp);
67 extern int cfeof(cfp *fp);
68 
69 #endif
cfp * cfopen_write(const char *path, const char *mode, int compression)
Definition: compress_io.c:504
CompressionAlgorithm
Definition: compress_io.h:24
void EndCompressor(ArchiveHandle *AH, CompressorState *cs)
Definition: compress_io.c:206
int cfread(void *ptr, int size, cfp *fp)
Definition: compress_io.c:583
WriteFunc writeF
Definition: compress_io.c:68
cfp * cfopen_read(const char *path, const char *mode)
Definition: compress_io.c:467
char * cfgets(cfp *fp, char *buf, int len)
Definition: compress_io.c:650
int cfclose(cfp *fp)
Definition: compress_io.c:661
void(* WriteFunc)(ArchiveHandle *AH, const char *buf, size_t len)
Definition: compress_io.h:31
void ReadDataFromArchive(ArchiveHandle *AH, int compression, ReadFunc readF)
Definition: compress_io.c:161
static char * buf
Definition: pg_test_fsync.c:65
int cfwrite(const void *ptr, int size, cfp *fp)
Definition: compress_io.c:609
cfp * cfopen(const char *path, const char *mode, int compression)
Definition: compress_io.c:533
size_t(* ReadFunc)(ArchiveHandle *AH, char **buf, size_t *buflen)
Definition: compress_io.h:44
void WriteDataToArchive(ArchiveHandle *AH, CompressorState *cs, const void *data, size_t dLen)
Definition: compress_io.c:183
CompressorState * AllocateCompressor(int compression, WriteFunc writeF)
Definition: compress_io.c:128
int cfgetc(cfp *fp)
Definition: compress_io.c:620
int cfeof(cfp *fp)
Definition: compress_io.c:688