// file: $USFS/class/image_analysis/v6.0/imaga_get_6.cc
//

// isip include files
//
#include "image_analysis.h"
#include "image_analysis_constants.h"

// method: get_trans_cc
//
// arguments:
//  
//  FILE* fp: (input) the file pointer of the parameter file
//
// return: a logical_1 value indicating the status
//
// this method reads the transcription for segmentation from the parameter file
//
logical_1 Image_analysis::get_trans_cc(FILE* fp_a) {
  
  // set the transcription to a null value
  //
  if (transcription_d != (char_1*)NULL) {
    delete [] transcription_d;
  }
  transcription_d = (char_1*)NULL;
  
  // setting the position of the pointer to the desired position
  //
  rewind(fp_a);
  
  // declare local variables
  //
  char_1* buf = new char_1[ISIP_MAX_STRING_LENGTH];
  
  while (fgets((char*)buf, ISIP_MAX_STRING_LENGTH, fp_a) != (char*)NULL) { 
    
    // checking for a comment line and/or a blank line
    //
    char_1* nonwhitespace = new char_1[2];
    
    if ((buf[0] != ISIP_POUND) &&
	(sscanf((char*)buf, "%1s", nonwhitespace) > (int)0)) {
      
      // parse the line
      //
      char_1* str_key = new char_1[ISIP_MAX_STRING_LENGTH];
      char_1* str_val = new char_1[ISIP_MAX_STRING_LENGTH];
      sscanf((char*)buf, (char*)IMAGA_FORMAT_0 , str_key, str_val);
      
      // checking for the transcription keyword
      //
      if (strcmp ((char*)str_key, (char*)IMAGA_TRANSCRIPTION) == (int)0) {
	transcription_d = new char_1[strlen((char*)str_val) + 1];
	strcpy((char*)transcription_d, (char*)str_val);
      }

      // delete memory
      //
      delete [] str_key;
      delete [] str_val;
    }

    // delete memory
    //
    delete [] nonwhitespace;
  }

  // delete memory
  //
  delete [] buf;
  
  // exit gracefully
  //
  return ISIP_TRUE;
}
