Doxygen Source Code Documentation
Main Page Alphabetical List Data Structures File List Data Fields Globals Search
bbb.c
Go to the documentation of this file.00001 #include "mrilib.h"
00002
00003 #define ERR (fprintf(stderr,"\aerror\n"),exit(1))
00004
00005 int main( int argc , char * argv[] )
00006 {
00007 byte *b64 , *bin;
00008 int nb64 , nbin ;
00009 double cpu , clk ;
00010
00011 if( argc < 3 ) ERR ;
00012
00013 if( argv[1][0] == 'd' ){
00014 clk = COX_clock_time() ;
00015 b64 = AFNI_suck_file( argv[2] ) ;
00016 clk = COX_clock_time() - clk ;
00017 if( b64 == NULL ) ERR ;
00018 nb64 = strlen(b64) ; if( nb64 < 4 ) ERR ;
00019
00020 cpu = COX_cpu_time() ;
00021 B64_to_binary( nb64,b64 , &nbin,&bin ) ;
00022 cpu = COX_cpu_time() - cpu ;
00023 fprintf(stderr,"nbin=%d nb64=%d cpu=%g I/O=%g\n",nbin,nb64,cpu,clk) ;
00024 if( nbin == 0 ) ERR ;
00025 fwrite( bin,1,nbin,stdout ) ; exit(0) ;
00026 } else if( argv[1][0] == 'e' ){
00027 B64_set_crlf(1) ;
00028 B64_set_linelen( 72 ) ;
00029 clk = COX_clock_time() ;
00030 bin = AFNI_suck_file( argv[2] ) ;
00031 clk = COX_clock_time() - clk ;
00032 if( bin == NULL ) ERR ;
00033 nbin = THD_filesize( argv[2] ) ;
00034 if( nbin <= 0 ) ERR ;
00035 cpu = COX_cpu_time() ;
00036 B64_to_base64( nbin,bin , &nb64,&b64 ) ;
00037 cpu = COX_cpu_time() - cpu ;
00038 fprintf(stderr,"nb64=%d nbin=%d cpu=%g I/O=%g\n",nb64,nbin,cpu,clk) ;
00039 if( nb64 == 0 ) ERR ;
00040 fwrite( b64,1,nb64,stdout ) ; exit(0) ;
00041 } else {
00042 ERR ;
00043 }
00044 }