/Users/huttone/Devel/sedflux-new/sedflux/trunk/ew/sedutils/sed2binary.c

Go to the documentation of this file.
00001 //---
00002 //
00003 // This file is part of sedflux.
00004 //
00005 // sedflux is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 2 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // sedflux is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with sedflux; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 //
00019 //---
00020 
00021 #include <stdio.h>
00022 
00023 #include <math.h>
00024 #include <string.h>
00025 #include <unistd.h>
00026 
00027 #include <utils/utils.h>
00028 #include <sed/sed_sedflux.h>
00029 
00030 /*** Self Documentation ***/
00031 char *help_msg[] =
00032 {
00033 "                                                                             ",
00034 " sed2binary [options] [parameters] [filein]                                  ",
00035 "  convert a sedflux property output file into flat binary format.            ",
00036 "                                                                             ",
00037 " Options                                                                     ",
00038 "  -v          - be verbose. [off]                                            ",
00039 "  -h          - print this help message.                                     ",
00040 "  -hfile      - print a help message on the file formats.                    ",
00041 "                                                                             ",
00042 NULL
00043 };
00044 
00045 #define FORGET_THIS_FOR_NOW
00046 
00047 int main(int argc, char *argv[])
00048 {
00049 #if !defined( FORGET_THIS_FOR_NOW )
00050    Sed_file *fpin;
00051    FILE *fpout;
00052    char *infile, *outfile;
00053    char *verbose;
00054    Profile_header *hdr;
00055    double **data;
00056    Eh_args *args;
00057 
00058    args = eh_opts_init(argc,argv);
00059    if ( eh_check_opts( args , NULL , NULL , NULL )!=0 )
00060       eh_exit(-1);
00061 
00062    infile  = eh_get_opt_str( args , "in"      , NULL );
00063    outfile = eh_get_opt_str( args , "out"     , NULL );
00064    verbose = eh_get_opt_str( args , "verbose" , "no" );
00065 
00066    fpin = sed_open_sedflux_file_r( infile , NULL );
00067    sed_read_sedflux_profile( fpin );
00068    hdr = sed_get_sedflux_file_header( fpin );
00069 
00070    if ( !outfile )
00071       fpout = stdout;
00072    else
00073       if ( !(fpout=fopen(outfile,"w")) )
00074          perror(outfile), eh_exit(-1);
00075 
00076    if ( g_strcasecmp( verbose , "yes" )==0 )
00077    {
00078       eh_open_log(NULL);
00079       eh_print_log(DEFAULT_ERROR_LOG,"number of rows    : %d",hdr->n_rows);
00080       eh_print_log(DEFAULT_ERROR_LOG,"number of columns : %d",hdr->n_cols);
00081    }
00082 
00083    data = sed_get_sedflux_file_data( fpin );
00084 
00085    fwrite( data[0] , sizeof(double) , hdr->n_rows*hdr->n_cols , fpout );
00086 
00087    g_free(infile);
00088    g_free(outfile);
00089 
00090    sed_close_sedflux_file( fpin );
00091    fclose(fpout);
00092 #endif
00093 
00094    return 0;
00095 }
00096 
00097 #undef FORGET_THIS_FOR_NOW
00098 

Generated on Fri Jan 4 18:04:16 2008 for sedflux by  doxygen 1.5.2