compression.h revision f052a448696b1246ee9fc36b7c727237aed56058
89a126810703c666309310d0f3189e9834d70b5bTimo Sirainen#ifndef COMPRESSION_H
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#define COMPRESSION_H
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
16f816d3f3c32ae3351834253f52ddd0212bcbf3Timo Sirainenstruct compression_handler {
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen const char *name;
e015e2f7e7f48874495f9df8b0dd192b7ffcb5ccTimo Sirainen const char *ext;
58be9d6bcc3800f5b3d76a064ee767fbe31a5a8aTimo Sirainen bool (*is_compressed)(struct istream *input);
1098fc409a45e7603701dc94635927a673bee0c1Timo Sirainen struct istream *(*create_istream)(struct istream *input,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen bool log_errors);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen struct ostream *(*create_ostream)(struct ostream *output, int level);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen};
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenextern const struct compression_handler compression_handlers[];
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Lookup handler by its name (gz, bz2) */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenconst struct compression_handler *compression_lookup_handler(const char *name);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Detect handler by looking at the first few bytes of the input stream. */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenconst struct compression_handler *
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainencompression_detect_handler(struct istream *input);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen/* Lookup handler based on filename extension in the path */
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenconst struct compression_handler *
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainencompression_lookup_handler_from_ext(const char *path);
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#endif
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen