Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
plug_compress.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include "afni.h"
00008
00009 #ifndef ALLOW_PLUGINS
00010 # error "Plugins not properly set up -- see machdep.h"
00011 #endif
00012
00013
00014
00015
00016
00017
00018
00019 static char helpstring[] =
00020 "Purpose: control the way AFNI compresses datasets.\n"
00021 "\n"
00022 "The input 'Mode' specifies how dataset .BRIK files will be\n"
00023 "compress when written to disk. The options are\n"
00024 "\n"
00025 " NONE = no compression\n"
00026 " GZIP = use program 'gzip'\n"
00027 " BZIP2 = use program 'bzip2' [very slow; most compression]\n"
00028 " COMPRESS = use program 'compress'\n"
00029 "\n"
00030 "Compressed datasets will save disk space. The principal cost is\n"
00031 "the CPU time it takes to read and write compressed files."
00032 "\n"
00033 "After you make your choice, you must press one of the\n"
00034 "'Set' buttons for the plugin to send its data to AFNI.\n"
00035 "Author -- RW Cox"
00036 ;
00037
00038
00039
00040 static char * comp_strings[] = {
00041 "NONE" , "GZIP" , "BZIP2" , "COMPRESS"
00042 } ;
00043
00044 #define NUM_COMP_STRINGS (sizeof(comp_strings)/sizeof(char *))
00045
00046
00047
00048 static char * COMP_main( PLUGIN_interface * ) ;
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 DEFINE_PLUGIN_PROTOTYPE
00065
00066 PLUGIN_interface * PLUGIN_init( int ncall )
00067 {
00068 PLUGIN_interface * plint ;
00069 int meth ;
00070
00071 if( ncall > 0 ) return NULL ;
00072
00073
00074
00075 plint = PLUTO_new_interface( "BRIK Compressor" ,
00076 "Control .BRIK compression" ,
00077 helpstring ,
00078 PLUGIN_CALL_VIA_MENU , COMP_main ) ;
00079
00080 PLUTO_add_hint( plint , "Control .BRIK compression" ) ;
00081
00082 PLUTO_set_sequence( plint , "A:afnicontrol:dset" ) ;
00083
00084 PLUTO_set_runlabels( plint , "Set+Keep" , "Set+Close" ) ;
00085
00086
00087
00088 PLUTO_add_option( plint ,
00089 "Input" ,
00090 "Input" ,
00091 TRUE
00092 ) ;
00093
00094 meth = THD_get_write_compression()+1 ;
00095 if( meth < 0 || meth >= NUM_COMP_STRINGS ) meth = 0 ;
00096
00097 PLUTO_add_string( plint ,
00098 "Mode" ,
00099 NUM_COMP_STRINGS ,
00100 comp_strings ,
00101 meth
00102 ) ;
00103
00104
00105
00106 return plint ;
00107 }
00108
00109
00110
00111
00112
00113
00114
00115 static char * COMP_main( PLUGIN_interface * plint )
00116 {
00117 char * str ;
00118 int meth ;
00119
00120 PLUTO_next_option(plint) ;
00121
00122 str = PLUTO_get_string(plint) ;
00123 meth = PLUTO_string_index(str,NUM_COMP_STRINGS,comp_strings) - 1 ;
00124 if( meth < 0 || meth > COMPRESS_LASTCODE ) meth = COMPRESS_NONE ;
00125 THD_set_write_compression(meth) ;
00126 return NULL ;
00127 }