// file: lton_cmd_0.cc
//

// isip include files
//
#include "lat_to_nbest.h"
#include "lat_to_nbest_constants.h"

// method: read_cmdline_cc
//
// arguments:
//  int_4 argc : (input) number of arguments
//  char_1** argv : (input) argument variables
//  char_1*& prm_file : (output) name of the parameters 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*& prm_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*)LTON_HELP_FILE);

  // check if the help message needs to be printed
  //
  if (argc_a < 2) {
    
    // print the help message and exit
    //
    system((char*)cmd_str);
    exit(ISIP_PROTO_ERROR);
  }
  
  // decipher the commandline arguments
  //
  for (int_4 i = 1; i < argc_a; i++) {
    
    // read the name of the parameter file
    //
    if (strcmp(LTON_PARAMS_OPT, (char*)argv_a[i]) == 0) {
      prm_file_a = new char_1[ISIP_MAX_STRING_LENGTH];
      strcpy((char*)prm_file_a, (char*)argv_a[++i]);
      Decoder::expand_filename_cc(prm_file_a);
    }
    
    // otherwise print the help message and exit
    //
    else {      
      system((char*)cmd_str);
      exit(ISIP_PROTO_ERROR);
    }
  }

  // free memory
  //
  delete [] cmd_str;
  
  // exit gracefully
  //
  return ISIP_TRUE;
}
