// file: itri_cmd_0.cc
//

// isip include files
//
#include "init_triphones.h"
#include "init_triphones_constants.h"

// method: read_cmdline_cc
//
// arguments:
//  int_4 argc : (input) number of arguments
//  char_1** argv : (input) argument variables
//  char_1* params_file : (output) name of the parameter file
//
//  return: a logical_1 flag indicating success
//
// this method reads the commandline and deciphers the various
// arguments and options
//
logical_1 read_cmdline_cc(int_4 argc_a, char_1** argv_a,
			  char_1* param_file_a) {

  // create the help message
  //
  char_1* cmd_str = new char_1[ISIP_MAX_STRING_LENGTH];
  sprintf((char*)cmd_str, (char*)ISIP_HELP_FORMAT, (char*)ITRI_HELP_FILE);

  // decipher the commandline arguments
  //
  for (int_4 i = 0; i < argc_a; i++) {
 
    // check if the help message needs to be printed
    //
    if (argc_a < 2) {
      
      // print the help message
      //
      system((char*)cmd_str);

      // exit gracefully
      //
      exit(ISIP_PROTO_ERROR);
    }

    // decipher the commandline
    //
    if (i > 0) {
      
      // read the name of the input file
      //
      if (strcmp(ITRI_PARAM_OPT, (char*)argv_a[i]) == 0) {
	strcpy((char*)param_file_a, (char*)argv_a[++i]);
      }

      // otherwise print the help message
      //
      else {
	
	system((char*)cmd_str);
	
	// exit gracefully
	//
	exit(ISIP_PROTO_ERROR);
      }
    }
  }
  
  // free memory
  //
  delete [] cmd_str;
  
  // exit gracefully
  //
  return ISIP_TRUE;
}


