// file: $USFS/class/ppm/v6.0/ppm_is_0.cc
//

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

// isip include files
//
#include "ppm.h"

#include <integral_constants.h>

// method: is_ppm_cc
//
// arguments: 
//  char_1* fname: (input) image file to be opened
//
// return:
//  a logical_1 value indicating status
//     
// This method determines whether a file is a ppm file, and returns
// ISIP_TRUE if it is.
//
logical_1 Ppm::is_ppm_cc(char_1* filename_a) {
  
  // expand the filename
  //
  char_1* expand_name = new char_1[ISIP_MAX_STRING_LENGTH];

  if (expand_cc(expand_name, filename_a) == ISIP_FALSE) {
    return ISIP_FALSE;
  }
  
  // check if file exists
  //
  FILE* fp = fopen((char*)expand_name, "r");
    
  // check if there is an error in opening this file
  //
  if (fp == (FILE*)NULL) {
    return ISIP_FALSE;
  }
    
  // load the ppm header for read modes
  //
  logical_1 status = read_header_cc(fp);

  // close the file pointer
  //
  fclose(fp);

  // release memory
  //
  delete [] expand_name;
  
  // exit gracefully
  //
  return status;
}
