// file: $USFS/class/image_analysis/v6.1/imaga_get_08.cc
//

// system include files
//
#include <string.h>

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

// method: get_winsize_cc
//
// arguments:
//  FILE* fp: (input) the file pointer to the parameter file
//
// return:
//  a logical_1 value indicating status
//
// this method reads the window size from the parameter file
//
logical_1 Image_analysis::get_winsize_cc(FILE* fp_a) {

  // rewind the file
  //
  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);
      
      // check for the window size keyword
      //
      if (strcmp ((char*)str_key, (char*)IMAGA_WINDOW_SIZE_KEY) == 0) {

	// read the window size
	//
	win_size_d = (int_4)atoi((char*)str_val);
      }

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

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

  // release memory
  //
  delete [] buf;

  // exit gracefully
  //
  return ISIP_TRUE;
}
