1 /* $OpenBSD: compress_backend.c,v 1.10 2021/06/14 17:58:15 eric Exp $ */ 2 3 /* 4 * Copyright (c) 2012 Charles Longeau <chl@openbsd.org> 5 * Copyright (c) 2012 Gilles Chehade <gilles@poolp.org> 6 * 7 * Permission to use, copy, modify, and distribute this software for any 8 * purpose with or without fee is hereby granted, provided that the above 9 * copyright notice and this permission notice appear in all copies. 10 * 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 */ 19 20 #include <string.h> 21 22 #include "smtpd.h" 23 24 #define BUFFER_SIZE 16364 25 26 extern struct compress_backend compress_gzip; 27 28 struct compress_backend * 29 compress_backend_lookup(const char *name) 30 { 31 if (!strcmp(name, "gzip")) 32 return &compress_gzip; 33 34 return NULL; 35 } 36 37 size_t 38 compress_chunk(void *ib, size_t ibsz, void *ob, size_t obsz) 39 { 40 return (env->sc_comp->compress_chunk(ib, ibsz, ob, obsz)); 41 } 42 43 size_t 44 uncompress_chunk(void *ib, size_t ibsz, void *ob, size_t obsz) 45 { 46 return (env->sc_comp->uncompress_chunk(ib, ibsz, ob, obsz)); 47 } 48 49 int 50 compress_file(FILE *ifile, FILE *ofile) 51 { 52 return (env->sc_comp->compress_file(ifile, ofile)); 53 } 54 55 int 56 uncompress_file(FILE *ifile, FILE *ofile) 57 { 58 return (env->sc_comp->uncompress_file(ifile, ofile)); 59 } 60