// file: dec_read_3.cc
//
 
// isip include files
//
#include "decoder.h"
#include "decoder_constants.h"
 
// method: read_ci_models_cc
//
// arguments:
//  FILE* fp: (input) file pointer
//  
// return: a logical_1 indicating status
//
// this method reads in the context-independent models data from file
// into an array of strings
//
logical_1 Decoder::read_ci_models_cc(FILE* fp_a) {

  // check file
  //
  if (fp_a == (FILE*)NULL) {
    error_handler_cc((char_1*)"read_ci_models_cc",
		     (char_1*)"NULL input file pointer");
  }
  
  // variables to read data
  //
  char_1* tmp = new char_1[ISIP_MAX_STRING_LENGTH];
  
  // read data from file
  //
  while (fscanf(fp_a, "%s", tmp) != EOF) {
    
    // ignore comment lines
    //
    if (tmp[0] == (char_1)'#') {
      
      // do nothing
      //
      fscanf(fp_a, "%[^\n]", tmp);
      fscanf(fp_a, "%[\n]", tmp);
    }
    
    // read the ci model data
    //
    else if (strcmp((char*)tmp, "num_monophones") == 0) {
      
      // read the number of ci models
      //
      fscanf(fp_a, "%s", tmp);
      fscanf(fp_a, "%ld", &num_ci_d);
      
      // allocate space for the ci model list
      //
      ci_models_d = new char_1*[num_ci_d];
      
      // now read the data
      //
      for (int_4 i = 0; i < num_ci_d; i++) {
	
	// read the string and copy it
	//
	fscanf(fp_a, "%s", tmp);
	ci_models_d[i] = new char_1[strlen((char*)tmp) + 1];
	strcpy((char*)ci_models_d[i], (char*)tmp);
      }
    }
  }

  // free memory
  //
  delete [] tmp;

  // exit gracefully
  //
  return ISIP_TRUE;
}
