This file reader implements a SAX like parser for the UA binary file format.
More...
|
typedef int(* | fct_add_namespace )(uint16_t nsidx, const char *uri, enum namespace_type type, struct ua_file_node_stat *stat, void *userdata) |
|
typedef int(* | fct_add_extension_namespace )(uint16_t nsidx, const char *uri, void *userdata) |
|
typedef int(* | fct_add_string_table )(unsigned int table_index, const char *locale, size_t size, void *userdata) |
|
typedef int(* | fct_add_string )(unsigned int table_index, unsigned int string_index, const char *text, void *userdata) |
|
typedef int(* | fct_add_node )(struct ua_file_reader_basenode *nodeinfo, void *userdata) |
|
typedef int(* | fct_add_reference )(struct ua_nodeid *src, struct ua_nodeid *dst, struct ua_nodeid *type, void *userdata) |
|
typedef void(* | fct_report_stat )(enum ua_file_reader_statistic_type type, size_t size, void *userdata) |
|
|
enum | namespace_type { NS_PROVIDED = 0,
NS_REQUIRED
} |
|
enum | ua_file_reader_statistic_type {
UAF_STAT_HEADER = 0,
UAF_STAT_EXT_NAMESPACES,
UAF_STAT_GLOBAL_EXTENSIONS,
UAF_STAT_STRINGTABLES,
UAF_STAT_NAMESPACES,
UAF_STAT_DATATYPES,
UAF_STAT_REFERENCETYPES,
UAF_STAT_VARIABLETYPES,
UAF_STAT_OBJECTTYPES,
UAF_STAT_VARIABLES,
UAF_STAT_OBJECTS,
UAF_STAT_METHODS,
UAF_STAT_VIEWS,
UAF_STAT_REFERENCES
} |
|
|
int | ua_file_reader_init (struct ua_file_reader *r, fct_add_namespace add_namespace_cb, fct_add_extension_namespace add_ext_namespace_cb, fct_add_string_table add_string_table_cb, fct_add_string add_string_cb, fct_add_node add_node_cb, fct_add_reference add_reference_cb, fct_report_stat report_stat_cb, void *userdata) |
| Initializes the file reader context. More...
|
|
int | ua_file_reader_load_file (struct ua_file_reader *r, const char *filename) |
| Loads the given file. More...
|
|
int | ua_file_reader_load_file_info (struct ua_file_reader *r, const char *filename) |
| Only loads the file header info, not the complete file. More...
|
|
int | ua_file_reader_get_version (struct ua_file_reader *r, unsigned char version[2]) |
| Returns the file version of the last loaded file. More...
|
|
This file reader implements a SAX like parser for the UA binary file format.
For each parsed element a callback is called that the caller can use to create an address space from the file data.
int ua_file_reader_get_version |
( |
struct ua_file_reader * |
r, |
|
|
unsigned char |
version[2] |
|
) |
| |
Returns the file version of the last loaded file.
You need to call ua_file_reader_load_file_info() or ua_file_reader_load_file() before calling this function.
- Parameters
-
r | File reader context. |
version[2] | Vesion info. The first byte contains the major version, the second byte the minor version of the file. |
- Returns
- Zero on success.
int ua_file_reader_init |
( |
struct ua_file_reader * |
r, |
|
|
fct_add_namespace |
add_namespace_cb, |
|
|
fct_add_extension_namespace |
add_ext_namespace_cb, |
|
|
fct_add_string_table |
add_string_table_cb, |
|
|
fct_add_string |
add_string_cb, |
|
|
fct_add_node |
add_node_cb, |
|
|
fct_add_reference |
add_reference_cb, |
|
|
fct_report_stat |
report_stat_cb, |
|
|
void * |
userdata |
|
) |
| |
Initializes the file reader context.
- Parameters
-
r | The file reader context. |
add_namespace_cb | Callback for adding a new namespace. |
add_ext_namespace_cb | Callback for adding a new extension namespace. |
add_string_table_cb | Callback for adding a new string table. |
add_string_cb | Callback for adding a new string to an existing string table. |
add_node_cb | Callback for adding a new node. |
add_reference_cb | Callback for adding a new reference. |
report_stat_cb | Callback for reporting the file statistics. This contains the number of all nodes, references, etc. This is called first before any other callback is invoked. This can be used to setup the required memory pools. |
- Returns
- Always returns 0.
int ua_file_reader_load_file |
( |
struct ua_file_reader * |
r, |
|
|
const char * |
filename |
|
) |
| |
Loads the given file.
- Parameters
-
r | Initializes file reader context. |
filename | Filename of file to load. |
Example code:
1 struct ua_file_reader reader;
4 ua_file_reader_init(&reader, my_add_namespace, my_ext_namespace_cb, my_add_string_table, my_add_string, my_add_node, my_add_reference, my_report_stat);
6 ret = ua_file_reader_load_file(&reader, filename);
- Returns
- Zero on success.
int ua_file_reader_load_file_info |
( |
struct ua_file_reader * |
r, |
|
|
const char * |
filename |
|
) |
| |
Only loads the file header info, not the complete file.
- Parameters
-
r | Initializes file reader context with the file's meta data. |
filename | Filename of file to load. |
- Returns
- Zero on success.