f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainen#ifndef COMPRESSION_H
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainen#define COMPRESSION_H
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainen
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainenstruct compression_handler {
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainen const char *name;
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainen const char *ext;
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainen bool (*is_compressed)(struct istream *input);
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainen struct istream *(*create_istream)(struct istream *input,
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainen bool log_errors);
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainen struct ostream *(*create_ostream)(struct ostream *output, int level);
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainen};
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainen
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainenextern const struct compression_handler compression_handlers[];
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainen
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainen/* Lookup handler by its name (gz, bz2) */
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainenconst struct compression_handler *compression_lookup_handler(const char *name);
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainen/* Detect handler by looking at the first few bytes of the input stream. */
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainenconst struct compression_handler *
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainencompression_detect_handler(struct istream *input);
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainen/* Lookup handler based on filename extension in the path */
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainenconst struct compression_handler *
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainencompression_lookup_handler_from_ext(const char *path);
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainen
f052a448696b1246ee9fc36b7c727237aed56058Timo Sirainen#endif