00001 #include "M3.h"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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