1 2 #ifndef COMPRESS_H 3 #define COMPRESS_H 4 5 /* "Species" - a CoreWars evolver. Copyright (C) 2003 'Varfar' 6 * 7 * This program is free software; you can redistribute it and/or modify it 8 * under the terms of the GNU General Public License as published by the Free 9 * Software Foundation; either version 1, or (at your option) any later 10 * version. 11 * 12 * This program is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 15 * more details. 16 * 17 * You should have received a copy of the GNU General Public License along 18 * with this program; if not, write to the Free Software Foundation, Inc., 19 * 675 Mass Ave, Cambridge, MA 02139, USA. 20 */ 21 22 #include <stdio.h> 23 24 #define COMPRESS_BUFFER ((int)12000) 25 #define COMPRESS_SAFE_BUFFER ((int)((COMPRESS_BUFFER * 1.1) + 13)) 26 27 typedef struct { 28 FILE *f; 29 unsigned long len; 30 unsigned char buf[COMPRESS_SAFE_BUFFER]; 31 } comp_buf_t; 32 33 // metrics 34 void init_compress_metrics(); 35 unsigned long long get_physical_bytes(); 36 unsigned long long get_logical_bytes(); 37 38 // block access 39 void block_compress(comp_buf_t *src); 40 void block_decompress(comp_buf_t *dest); 41 42 // byte-by-byte writer 43 void flush_compressed(comp_buf_t *src); 44 void write_compressed(comp_buf_t *src,unsigned char ch); 45 46 #endif // ifndef COMPRESS_H 47