uncompression.h 2.53 KB
Newer Older
1 2 3 4 5
#ifndef REPREPRO_UNCOMPRESS_H
#define REPREPRO_UNCOMPRESS_H

/* "", ".gz", ... */
extern const char * const uncompression_suffix[c_COUNT];
6
extern /*@null@*/ char *extern_uncompressors[c_COUNT];
7 8
/* so help messages know which option to cite: */
extern const char * const uncompression_option[c_COUNT];
Bernhard Link's avatar
Bernhard Link committed
9
extern const char * const uncompression_config[c_COUNT];
10 11 12 13 14

/* there are two different modes: uncompress a file to memory,
 * or uncompress (possibly multiple files) on the filesystem,
 * controled by aptmethods */

15 16 17 18 19 20
#ifdef HAVE_LIBLZMA
# ifdef HAVE_LIBBZ2
#define uncompression_builtin(c) ((c) == c_xz || (c) == c_lzma || (c) == c_bzip2 || (c) == c_gzip)
# else
#define uncompression_builtin(c) ((c) == c_xz || (c) == c_lzma || (c) == c_gzip)
# endif
21
#else
22 23 24
# ifdef HAVE_LIBBZ2
#define uncompression_builtin(c) ((c) == c_bzip2 || (c) == c_gzip)
# else
25
#define uncompression_builtin(c) ((c) == c_gzip)
26
# endif
27
#endif
28
#define uncompression_supported(c) ((c) == c_none || \
29
		uncompression_builtin(c) || \
30 31
		extern_uncompressors[c] != NULL)

32 33
enum compression compression_by_suffix(const char *, size_t *);

34
/**** functions for aptmethod.c ****/
35 36 37 38 39 40

/* we got an pid, check if it is a uncompressor we care for */
retvalue uncompress_checkpid(pid_t, int);
/* still waiting for a client to exit */
bool uncompress_running(void);

41
typedef retvalue finishaction(void *, const char *, bool /*failed*/);
42
/* uncompress and call action when finished */
43
retvalue uncompress_queue_file(const char *, const char *, enum compression, finishaction *, void *);
44

45 46
/**** functions for update.c (uncompressing an earlier downloaded file) ****/

47 48
retvalue uncompress_file(const char *, const char *, enum compression);

49
/**** functions for indexfile.c (uncompressing to memory) and ar.c ****/
50 51 52 53 54 55
// and perhaps also sourceextraction.c

struct compressedfile;

retvalue uncompress_open(/*@out@*/struct compressedfile **, const char *, enum compression);
int uncompress_read(struct compressedfile *, void *buffer, int);
56 57
retvalue uncompress_error(/*@const@*/struct compressedfile *);
void uncompress_abort(/*@only@*/struct compressedfile *);
58
retvalue uncompress_close(/*@only@*/struct compressedfile *);
59 60 61
retvalue uncompress_fdclose(/*@only@*/struct compressedfile *, int *, const char **);

retvalue uncompress_fdopen(/*@out@*/struct compressedfile **, int, off_t, enum compression, int *, const char **);
62 63 64

/**** general initialisation ****/

65
/* check for existence of external programs */
66
void uncompressions_check(const char *gunzip, const char *bunzip2, const char *unlzma, const  char *unxz, const char *lunzip);
67 68 69

#endif