32 const unsigned int READ_BUFFER_SIZE = 1024;
39 const char * retval =
"UNKNOWN (File format couldn't be successfully identified)";
41 for (
int i = 0; LibofxImportFormatList[i].
format !=
LAST; i++)
43 if (LibofxImportFormatList[i].format == file_format)
57 for (
int i = 0; LibofxImportFormatList[i].
format !=
LAST; i++)
59 if (strcmp(LibofxImportFormatList[i].format_name, file_type_string) == 0)
61 retval = LibofxImportFormatList[i].
format;
73 message_out(
INFO,
string(
"libofx_proc_file(): File format not specified, autodetecting..."));
75 message_out(
INFO,
string(
"libofx_proc_file(): Detected file format: ") +
77 libofx_context->currentFileType() ));
83 string(
"libofx_proc_file(): File format forced to: ") +
85 libofx_context->currentFileType() ));
88 switch (libofx_context->currentFileType())
97 message_out(
ERROR,
string(
"libofx_proc_file(): Detected file format not yet supported ou couldn't detect file format; aborting."));
106 char buffer[READ_BUFFER_SIZE];
108 bool type_found =
false;
110 if (p_filename != NULL && strcmp(p_filename,
"") != 0)
112 message_out(
DEBUG,
string(
"libofx_detect_file_type():Opening file: ") + p_filename);
114 input_file.open(p_filename);
118 message_out(
ERROR,
"libofx_detect_file_type():Unable to open the input file " +
string(p_filename));
125 input_file.getline(buffer,
sizeof(buffer),
'\n');
127 s_buffer.assign(buffer);
129 if (input_file.gcount() < (
sizeof(buffer) - 1))
131 s_buffer.append(
"\n");
133 else if ( !input_file.eof() && input_file.fail())
138 if (s_buffer.find(
"<OFX") != string::npos || s_buffer.find(
"<ofx") != string::npos)
144 else if (s_buffer.find(
"<OFC>") != string::npos || s_buffer.find(
"<ofc>") != string::npos)
152 while (type_found ==
false && !input_file.eof() && !input_file.bad());
161 message_out(
ERROR,
"libofx_detect_file_type(): Failed to identify input file format");
Preprocessing of the OFX files before parsing.
int ofx_proc_file(LibofxContextPtr ctx, const char *p_filename)
File pre-processing of OFX AND for OFC files.
const char * libofx_get_file_format_description(const struct LibofxFileFormatInfo format_list[], enum LibofxFileFormat file_format)
get_file_format_description returns a string description of a LibofxFileType.
int libofx_proc_file(LibofxContextPtr p_libofx_context, const char *p_filename, LibofxFileFormat p_file_type)
libofx_proc_file is the entry point of the library.
int message_out(OfxMsgType error_type, const string message)
Message output function.
enum LibofxFileFormat libofx_detect_file_type(const char *p_filename)
libofx_detect_file_type tries to analyze a file to determine it's format.
Message IO functionality.
Preprocessing of the OFX files before parsing.
enum LibofxFileFormat libofx_get_file_format_from_str(const struct LibofxFileFormatInfo format_list[], const char *file_type_string)
libofx_get_file_type returns a proper enum from a file type string.