// file: convert_mmf.cc
//
// this program converts isip mmf files from ascii to binary and binary
// to ascii
//

// system include files
//

// isip include files
//
#include "convert_mmf.h"
#include "convert_mmf_constants.h"

// main program
//
int main(int_4 argc, char_1** argv) {

  char_1* input_file  = new char_1[ISIP_MAX_STRING_LENGTH];
  char_1* output_file  = new char_1[ISIP_MAX_STRING_LENGTH];  
  int_4 input_mode = CMMF_DEFAULT_INPUT_MODE;
  int_4 output_mode = CMMF_DEFAULT_OUTPUT_MODE;
  Train_State** state_list = (Train_State**)NULL;
  int_4 num_states = (int_4)0;
  int_4 num_features = (int_4)0;
  
  // read and decipher the commandline
  //
  if (get_params_cc(argc, argv, input_mode, output_mode, input_file,
		    output_file) == ISIP_FALSE) {

    fprintf(stderr, "%s: bad arguments on the command line\n",
	    argv[0]);
    exit(ISIP_PROTO_ERROR);
  }

  // read in the input file
  //
  state_list = read_states_cc(input_mode, num_states, num_features,
			      input_file);

  // write the output file
  //
  write_states_cc(output_mode, num_states, num_features, output_file,
  		  state_list);

  // delete memory and clean up
  //
  for (int_4 i = 1; i < num_states; i++) {
    delete state_list[i];
  }

  delete [] state_list;
  delete [] input_file;
  delete [] output_file;  

  // exit gracefully
  //
  exit(ISIP_NO_ERROR);
}


