1 /*
2  * Copyright (C) 2001, 2002, and 2003  Roy Keene
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  *
18  *      email: dact@rkeene.org
19  */
20 
21 
22 #include "dact.h"
23 #include "comp_bitsums.h"
24 #include <stdio.h>
25 #ifdef HAVE_UNISTD_H
26 #include <unistd.h>
27 #endif
28 #ifdef HAVE_STDLIB_H
29 #include <stdlib.h>
30 #endif
31 
32 
33 /*
34 	mode 		- DACT_MODE_COMPR or DACT_MODE_DECMP
35 			    Determine whether to compress or decompress.
36 	prev_block	- Previous (uncompressed) block.
37 	curr_block	- The data to be compressed.
38 	out_block	- Where to put data after compression.
39 	blk_size	- Size of prev_block and curr_block.
40 */
41 
42 
43 #if defined(AS_MODULE) && defined(USE_MODULES)
44 #include "module.h"
45 uint32_t DC_NUM=11;
46 uint32_t DC_TYPE=DACT_MOD_TYPE_COMP;
47 void *DC_ALGO=comp_bitsums_algo;
48 char *DC_NAME="Bitsums Compression (MOD)";
49 
50 #endif
51 
comp_bitsums_algo(int mode,unsigned char * prev_block,unsigned char * curr_block,char * out_block,int blk_size,int bufsize)52 int comp_bitsums_algo(int mode, unsigned char *prev_block, unsigned char *curr_block, char *out_block, int blk_size, int bufsize) {
53 	switch(mode) {
54 		case DACT_MODE_COMPR:
55 			return(comp_bitsums_compress(prev_block, curr_block, out_block, blk_size, bufsize));
56 			break; /* Heh */
57 		case DACT_MODE_DECMP:
58 			return(comp_bitsums_decompress(prev_block, curr_block, out_block, blk_size, bufsize));
59 			break;
60 		default:
61 			fprintf(stderr, "Unsupported mode: %i\n", mode);
62 			return(-1);
63 	}
64 }
65 
comp_bitsums_compress(unsigned char * prev_block,unsigned char * curr_block,char * out_block,int blk_size,int bufsize)66 int comp_bitsums_compress(unsigned char *prev_block, unsigned char *curr_block, char *out_block, int blk_size, int bufsize) {
67 	return(-1);
68 }
69 
comp_bitsums_decompress(unsigned char * prev_block,unsigned char * curr_block,char * out_block,int blk_size,int bufsize)70 int comp_bitsums_decompress(unsigned char *prev_block, unsigned char *curr_block, char *out_block, int blk_size, int bufsize) {
71 	fprintf(stderr, "Not yet supported.\n");
72 	return(0);
73 }
74