31 const unsigned int READ_BUFFER_SIZE = 1024;
 
   38   const char * retval = 
"UNKNOWN (File format couldn't be successfully identified)";
 
   40   for (
int i = 0; LibofxImportFormatList[i].
format != 
LAST; i++)
 
   42     if (LibofxImportFormatList[i].format == file_format)
 
   56   for (
int i = 0; LibofxImportFormatList[i].
format != 
LAST; i++)
 
   58     if (strcmp(LibofxImportFormatList[i].format_name, file_type_string) == 0)
 
   60       retval = LibofxImportFormatList[i].
format;
 
   72     message_out(
INFO, std::string(
"libofx_proc_file(): File format not specified, autodetecting..."));
 
   74     message_out(
INFO, std::string(
"libofx_proc_file(): Detected file format: ") +
 
   76                     libofx_context->currentFileType() ));
 
   80     libofx_context->setCurrentFileType(p_file_type);
 
   82                 std::string(
"libofx_proc_file(): File format forced to: ") +
 
   84                     libofx_context->currentFileType() ));
 
   87   switch (libofx_context->currentFileType())
 
   94     message_out(
ERROR, std::string(
"libofx_proc_file(): Could not detect file format, or unsupported file format; aborting."));
 
  103   std::ifstream input_file;
 
  104   char buffer[READ_BUFFER_SIZE];
 
  105   std::string s_buffer;
 
  106   bool type_found = 
false;
 
  108   if (p_filename != NULL && strcmp(p_filename, 
"") != 0)
 
  110     message_out(
DEBUG, std::string(
"libofx_detect_file_type():Opening file: ") + p_filename);
 
  112     input_file.open(p_filename);
 
  116       message_out(
ERROR, 
"libofx_detect_file_type():Unable to open the input file " + std::string(p_filename));
 
  123         input_file.getline(buffer, 
sizeof(buffer), 
'\n');
 
  125         s_buffer.assign(buffer);
 
  127         if (input_file.gcount() < 
int(
sizeof(buffer) - 1))
 
  129           s_buffer.append(
"\n");
 
  131         else if ( !input_file.eof() && input_file.fail())
 
  136         if (s_buffer.find(
"<OFX") != std::string::npos || s_buffer.find(
"<ofx") != std::string::npos)
 
  142         else if (s_buffer.find(
"<OFC>") != std::string::npos || s_buffer.find(
"<ofc>") != std::string::npos)
 
  150       while (type_found == 
false && !input_file.eof() && !input_file.bad());
 
  159     message_out(
ERROR, 
"libofx_detect_file_type(): Failed to identify input file format");