// file: $USFS/util/detect_edge/v6.2/de_gp_00.cc
//

// isip include files
//
#include "detect_edge.h"
#include "detect_edge_constants.h"

// function: get_parameters_cc
//
// arguments:
//  char_1*& in_img_filelist: (output) pointer to input image file list
//  char_1*& out_data_filelist: (output) pointer to output data file list
//  char_1*& out_img_filelist: (output) pointer to output image file list
//  int_4& pos: (output) position of the cursor in the command line
//  int_4 argc: (input) argc from the main program
//  char_1** argv: (input) argv from the main program
//
// return:
//  a logical_1 value indicating status
//
// this function parses command line arguments.
//
logical_1 get_parameters_cc(char_1*& in_img_filelist_a,
			    char_1*& out_data_filelist_a,
			    char_1*& out_img_filelist_a,
			    int_4& pos_a, int_4 argc, char_1** argv) {
    
  // main decoding loop
  //
  int_4 last_index = argc;

  char_1* tmp_string = new char_1[ISIP_MAX_STRING_LENGTH];
  
  // if no arguments are given then print out a help message
  //
  if (last_index == (int)1) {
    sprintf((char*)tmp_string,
	    (char*)ISIP_HELP_FORMAT, (char*)DE_HELP_FILE);
    system((char*)tmp_string);
  
    // exit gracefully
    //
    exit (ISIP_NO_ERROR);
  }

  for (int_4 index=1; index<last_index; index++) {

    // check for help
    //
    if (strcmp((char*)ISIP_HELP_OPTION, (char*)argv[index]) == (int)0) {
      sprintf((char*)tmp_string,
	      (char*)ISIP_HELP_FORMAT, (char*)DE_HELP_FILE);
      system((char*)tmp_string);

      // exit gracefully
      //
      exit(ISIP_NO_ERROR);
    }

    // check for input image file list
    //
    else if (strcmp((char*)DE_OPT_A, (char*)argv[index]) == (int)0) {
      strcpy ((char*)tmp_string, (char*)argv[index+1]);
      in_img_filelist_a = new char_1[strlen((char*)tmp_string)+1];
      strcpy ((char*)in_img_filelist_a, (char*)tmp_string);
      pos_a = index+2;
    }

    // check for output data file list
    //
    else if (strcmp((char*)DE_OPT_B, (char*)argv[index]) == (int)0) {
      strcpy ((char*)tmp_string, (char*)argv[index+1]);
      out_data_filelist_a = new char_1[strlen((char*)tmp_string)+1];
      strcpy ((char*)out_data_filelist_a, (char*)tmp_string);
      pos_a = index+2;
    }

    // check for output image file list
    //
    else if (strcmp((char*)DE_OPT_C, (char*)argv[index]) == (int)0) {
      strcpy ((char*)tmp_string, (char*)argv[index+1]);
      out_img_filelist_a = new char_1[strlen((char*)tmp_string)+1];
      strcpy ((char*)out_img_filelist_a, (char*)tmp_string);
      pos_a = index+2;
    }
  }

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