LibOFX: ofx_preproc.cpp File Reference

LibOFX

Macros | Functions | Variables
ofx_preproc.cpp File Reference

Preprocessing of the OFX files before parsing. More...

Go to the source code of this file.

## Macros
#define | DIRSEP "/"
#define | LIBOFX_DEFAULT_INPUT_ENCODING "CP1252"
#define | LIBOFX_DEFAULT_OUTPUT_ENCODING "UTF-8"
#define | OPENSP_UTF8_WARNING_TEXT "ofx_proc_file(): OpenSP cannot process an UTF-8 XML file without garbling it. Furthermore, on windows the support for UTF-8 encode SGML files is broken. This is worked around by forcing a single byte encoding. If the file is indeed UTF-8, it should pass through unmolested, but you will likely get 'non SGML character number' errors, even though the output is correct."

## Functions
int | ofx_proc_file (LibofxContextPtr ctx, const char *p_filename)
| File pre-processing of OFX AND for OFC files. More...
static std::string | find_tag_open (std::string &input_string, size_t &pos_start, size_t &pos_end)
static void | find_tag_close (std::string &input_string, std::string &tag_name, size_t &pos)
std::string | sanitize_proprietary_tags (std::string input_string)
| Removes proprietary tags and comments. More...
std::string | find_dtd (LibofxContextPtr ctx, const std::string &dtd_filename)
| Find the appropriate DTD for the file version. More...

## Variables
const int | DTD_SEARCH_PATH_NUM = 3
| The number of different paths to search for DTDs.
const char * | DTD_SEARCH_PATH [DTD_SEARCH_PATH_NUM]
| The list of paths to search for the DTDs. More...

## Detailed Description

Preprocessing of the OFX files before parsing.

Implements the pre-treatement of the OFX file prior to parsing: OFX header striping, OFX proprietary tags and SGML comment striping, locating the appropriate DTD.

Definition in file ofx_preproc.cpp.

## Function Documentation

## ◆ find_dtd()

std::string find_dtd | ( | LibofxContextPtr | ctx,
|  | const std::string & | dtd_filename
| ) |  |

Find the appropriate DTD for the file version.

This function will try to find a DTD matching the requested_version and return the full path of the DTD found (or an empty string if unsuccessful)

Please note that currently the function will ALWAYS look for version 160, since OpenSP can't parse the 201 DTD correctly

It will look, in (order)

1- A folder set by libofx_set_dtd_dir(), if any 2- On windows only, a relative path specified by get_dtd_installation_directory() 3- The environment variable OFX_DTD_PATH (if present) 4- The path specified by the makefile in MAKEFILE_DTD_PATH, thru LIBOFX_DTD_DIR in configure (if present) 5- Any hardcoded paths in DTD_SEARCH_PATH

Definition at line 556 of file ofx_preproc.cpp.

## ◆ ofx_proc_file()

int ofx_proc_file | ( | LibofxContextPtr | ctx,
|  | const char * | p_filename
| ) |  |

File pre-processing of OFX AND for OFC files.

ofx_proc_file process an ofx or ofc file.

Takes care of comment striping, dtd locating, etc.

Definition at line 80 of file ofx_preproc.cpp.

## ◆ sanitize_proprietary_tags()

std::string sanitize_proprietary_tags | ( | std::string | input_string | ) |

Removes proprietary tags and comments.

This function will strip all the OFX proprietary tags and SGML comments from the SGML string passed to it Note this function assumes in case a proprietary tag comes in an open and closing pair, they both appear on the same line (and hence are part of the same input_string passed to this function). So an ofx file with a single line like this <proprietary>abc</proprietary> will properly sanitized But an ofx file where this is split on multiple lines will not: <proprietary> abc </proprietary>

Definition at line 482 of file ofx_preproc.cpp.

## Variable Documentation

## ◆ DTD_SEARCH_PATH

const char* DTD_SEARCH_PATH[DTD_SEARCH_PATH_NUM]

Initial value:
=
{
"/usr/local/share/libofx/dtd",
"/usr/share/libofx/dtd",
"~"
}

The list of paths to search for the DTDs.

Definition at line 66 of file ofx_preproc.cpp.