1 /*****************************************************************************
2    Major portions of this software are copyrighted by the Medical College
3    of Wisconsin, 1994-2000, and are released under the Gnu General Public
4    License, Version 2.  See the file README.Copyright for details.
5 ******************************************************************************/
6 
7 #ifndef _MCW_COMPRESSOR_
8 #define _MCW_COMPRESSOR_
9 
10 #include <unistd.h>
11 #include <stdlib.h>
12 #include <stdio.h>
13 #include <string.h>
14 #include <errno.h>
15 #include <ctype.h>
16 #include <sys/types.h>
17 #include <sys/stat.h>
18 #include <sys/mman.h>
19 #include <fcntl.h>
20 
21 #include "mcw_malloc.h"
22 
23 #ifdef  __cplusplus
24 extern "C" {                    /* care of Greg Balls    7 Aug 2006 [rickr] */
25 #endif
26 
27 #define COMPRESS_NOFILE    -666
28 #define COMPRESS_NONE      -1
29 #define COMPRESS_GZIP       0
30 #define COMPRESS_BZIP2      1
31 #define COMPRESS_COMPRESS   2
32 #define COMPRESS_PIGZ       3
33 
34 /* PJR 07/22/98- adding brikcomp decompression to afni.
35    Compression with brikcomp is not supported because it needs the header information. */
36 
37 #define COMPRESS_BRIKCOMP   4
38 #define COMPRESS_LASTCODE   4
39 #define NUM_COMPRESS_elist  4
40 
41 static char * COMPRESS_suffix[]     = { ".gz" , ".bz2" , ".Z", ".gz", ".briz" } ;
42 static int    COMPRESS_suffix_len[] = { 3     , 4      , 2     , 3,   5} ;
43 
44 #if 0  /*----------- moved to thd_compress.c [10 May 2013] -----------------------*/
45 static char * COMPRESS_program[]    = { "gzip -1c > '%s'"  ,
46                                         "bzip2 -1c > '%s'" ,
47                                         "compress > '%s'"  ,
48                                         "pigz -1c > '%s'"  ,
49                                         "cat > '%s'"} ;         /* shouldn't be called */
50 
51 static int    COMPRESS_program_ok[] = { 1 , 1 , 1 , 1 , 0 } ;     /* RWCox 03 Aug 1998 */
52 
53 static char * COMPRESS_unprogram[]  = { "gzip -dc '%s'"  ,
54                                         "bzip2 -dc '%s'" ,
55                                         "uncompress -c '%s'",
56                                         "pigz -dc '%s'"  ,
57                                         "brikcomp -c '%s'" } ;
58 #endif /*-------------------------------------------------------------------------*/
59 
60 static char * COMPRESS_enviro[] = { "GZIP" , "BZIP2" , "COMPRESS" , "PIGZ" , "BRIKCOMP" } ;
61 
62 static char * COMPRESS_elist[] = { "GZIP" , "BZIP2" , "COMPRESS",  "PIGZ" } ;
63 
64 /*---------- prototypes ----------*/
65 
66 extern int COMPRESS_is_file( char * pathname ) ;
67 extern int COMPRESS_has_suffix( char * fname , int mode ) ;
68 extern int COMPRESS_filecode( char * fname ) ;
69 extern int COMPRESS_fclose( FILE * fp ) ;
70 extern FILE * COMPRESS_fopen_read( char * fname ) ;
71 extern FILE * COMPRESS_fopen_write( char * fname , int mm ) ;
72 
73 extern char * COMPRESS_filename( char * fname ) ; /* Feb 1998 */
74 extern int COMPRESS_unlink( char * fname ) ;      /* Feb 1998 */
75 
76 extern char * COMPRESS_add_suffix( char * fname , int mode ) ; /* May 1998 */
77 
78 #ifdef  __cplusplus
79 }
80 #endif
81 
82 #endif
83