testRunConfig.c

00001 #include "M3.h"
00002 /*******************************************************************************
00003 *   M3:  testRunConfig.c                                              *
00004 *                                                                              *
00005 *   Version 1.0 May 2004                                                       *
00006 *                                                                              *
00007 *   Copyright (C) 2004  C.M. Cantalupo                                         *
00008 *                                                                              *
00009 *   This program is free software; you can redistribute it and/or modify       *
00010 *   it under the terms of the GNU General Public License as published by       *
00011 *   the Free Software Foundation; either version 2 of the License, or          *
00012 *   (at your option) any later version.                                        *
00013 *                                                                              *
00014 *   This program is distributed in the hope that it will be useful,            *
00015 *   but WITHOUT ANY WARRANTY; without even the implied warranty of             *
00016 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
00017 *   GNU General Public License for more details.                               *
00018 *                                                                              *
00019 *   You should have received a copy of the GNU General Public License          *
00020 *   along with this program; if not, write to the Free Software                *
00021 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  *
00022 *                                                                              *
00023 *******************************************************************************/
00024 
00049 void M3_RunConfigStruct_shiftPointers( M3_RunConfigStruct *runConfig, int shiftDirection);
00050 
00051 
00052 int main( int argc, char **argv )
00053 {
00054   int runType;
00055   char fileName[512];
00056   char binFileName[512];
00057   size_t sizeOfRunConfig;
00058   FILE *fid;
00059   M3_RunConfigStruct *runConfig, *runConfigP;
00060   M3_DataSetLL *thisDataSet;
00061   M3_IntervalLL *thisInterval;
00062 
00063   if( argc < 3 )
00064   {
00065     fprintf(stderr, "Usage: %s runConfigFile runType\n", argv[0]);
00066     return 1;
00067   }
00068 
00069 
00070   strcpy( fileName, argv[1]);
00071   if( strcmp( argv[2], "MADnes" ) == 0 )
00072     runType = M3_MADNES_RUN_TYPE;
00073   else if( strcmp( argv[2], "MADmap") == 0 )
00074     runType = M3_MADMAP_RUN_TYPE;
00075   else if( strcmp( argv[2], "MADspec") == 0 )
00076     runType = M3_MADSPEC_RUN_TYPE;
00077   else if( strcmp( argv[2], "springtide") == 0 )
00078     runType = M3_SPRINGTIDE_RUN_TYPE;
00079   else 
00080   {
00081     fprintf(stderr, "ERROR:  runType is not recognized.  Must be one of (MADnes, MADmap, or MADspec)\n");
00082     return 1;
00083   }
00084 
00085   M3_RunConfigStruct_Read( &runConfig, fileName, runType );
00086 
00087   fprintf(stdout, "Run config file named %s is self-consistent.  \n\n", fileName);
00088 
00089   fprintf( stdout, "  Covered intervals:\n");
00090   for( thisDataSet = runConfig->dataSetList;
00091        thisDataSet;
00092        thisDataSet = thisDataSet->next )
00093   {
00094     fprintf( stdout, "    Data set named %s\n", thisDataSet->name );
00095     for( thisInterval = thisDataSet->coveredIntervalList; 
00096          thisInterval; 
00097          thisInterval = thisInterval->next )
00098       fprintf(stdout, "      %lli  %lli\n", thisInterval->interval.firstSample, thisInterval->interval.lastSample );
00099   }
00100 
00101   sprintf( binFileName, "%s.bin", fileName );
00102 
00103   strcat(fileName, ".parsed" );
00104 
00105   fprintf(stdout, "Writing out parsed version to file named %s\n", fileName);
00106 
00107   M3_RunConfigStruct_Write( runConfig, fileName );
00108 
00109   fprintf(stdout, "Creating binary version to file named %s\n", binFileName );
00110 
00111   sizeOfRunConfig = M3_RunConfigStruct_duplicateP( runConfig, &runConfigP, 1);  
00112 
00113   M3_RunConfigStruct_shiftPointers( runConfigP, -1 );
00114   
00115   fid = fopen( binFileName, "w");
00116 
00117   M3_ErrorCheck(-1, binFileName, (fid?1:0), M3_EFLAG_FOPEN_WRITE );
00118 
00119   fwrite( runConfigP, 1, sizeOfRunConfig, fid );
00120   
00121   fclose(fid);
00122 
00123   free( runConfigP );
00124 
00125   M3_RunConfigStruct_Destroy( runConfig );
00126   
00127   return 0;
00128 }
00129 

Generated on Mon Nov 24 10:05:12 2008 for M3 by  doxygen 1.5.3-20071008