hl7parse
|
hl7 search utilities More...
Go to the source code of this file.
Classes | |
struct | flags_t |
command line parameters More... | |
struct | result_item_t |
search result More... | |
struct | search_res_t |
holds 0-N result items More... | |
Typedefs | |
typedef struct flags_t | flags_t |
command line parameters More... | |
typedef enum search_mode_t | search_mode_t |
search modes | |
typedef struct result_item_t | result_item_t |
search result More... | |
typedef struct search_res_t | search_res_t |
holds 0-N result items More... | |
Enumerations | |
enum | search_mode_t { SEARCH_SUBSTRING = 0, SEARCH_SEGMENT = 1, SEARCH_NODE = 2 } |
search modes More... | |
Functions | |
const char * | version_search () |
search version information | |
flags_t * | create_flags_t () |
create default values for flags_t More... | |
search_res_t * | create_search_res (unsigned char *search_term) |
initiaizes a result container More... | |
void | free_search_res (search_res_t *sr) |
frees all data associated with search result More... | |
hl7_addr_t ** | parse_address (char *addrstr, int *length) |
parse address string More... | |
void | free_addr_arr (hl7_addr_t **addr) |
free address array More... | |
int | search_file (char *filename, flags_t flags) |
search for files More... | |
int | search_substring (FILE *fd, search_res_t *sr) |
search substring More... | |
int | search_segment (FILE *fd, search_res_t *sr) |
this search variant is a line based search More... | |
int | search_subnodes (node_t *fieldlist, search_res_t *sr, int line_num, hl7_meta_t *meta, int segment_rep) |
int | search_node (FILE *fd, search_res_t *sr) |
parse line and find in sub elements More... | |
void | print_json_value (result_item_t *item, flags_t flags) |
JSON value, entities escaped. More... | |
void | print_xml_value (result_item_t *item, flags_t flags) |
XML value, entities escaped. More... | |
void | output_json (result_item_t *item, flags_t flags, int last) |
print a result item as json More... | |
void | output_xml (result_item_t *item, flags_t flags) |
print a result item as xml More... | |
void | output_csv (result_item_t *item, flags_t flags) |
print a result item as csv More... | |
void | output_string (result_item_t *item, flags_t flags) |
printf a result More... | |
hl7 search utilities
command line parameters
this structure holds the command line parameters.
typedef struct result_item_t result_item_t |
search result
pos is the position in the line (SEARCH_SEGMENT/SEARCH_SUBSTRING) or position in the segment (SEARCH_NODE)
typedef struct search_res_t search_res_t |
holds 0-N result items
Holds relevant search parameters and result items. This is used as buffer during search over various files.
enum search_mode_t |
flags_t* create_flags_t | ( | ) |
create default values for flags_t
search_res_t* create_search_res | ( | unsigned char * | search_term | ) |
initiaizes a result container
search_term | string to search for |
void free_addr_arr | ( | hl7_addr_t ** | addr | ) |
free address array
will free al lelements and the array itself.
[out] | addr | address array |
void free_search_res | ( | search_res_t * | sr | ) |
frees all data associated with search result
make sure to allocate data for every item.
[out] | sr | search result struct |
void output_csv | ( | result_item_t * | item, |
flags_t | flags | ||
) |
print a result item as csv
item | the item to print |
flags | command line search flags |
void output_json | ( | result_item_t * | item, |
flags_t | flags, | ||
int | last | ||
) |
print a result item as json
item | the item to print |
flags | command line search flags |
last | 1 if this is the last record, so we can ommit the the comma after the object |
void output_string | ( | result_item_t * | item, |
flags_t | flags | ||
) |
printf a result
item | the result item to print |
flags | command line arguments |
void output_xml | ( | result_item_t * | item, |
flags_t | flags | ||
) |
print a result item as xml
item | the item to print |
flags | command line search flags |
hl7_addr_t** parse_address | ( | char * | addrstr, |
int * | length | ||
) |
parse address string
split address strings by spaces.
The array is terminated by a sentinel.
addrstr | address string to parse |
length | length of string |
void print_json_value | ( | result_item_t * | item, |
flags_t | flags | ||
) |
JSON value, entities escaped.
Escape all "</tt> characters with <tt>\\\\</tt> + <tt>"
inside the string.
item | item containing item->str with data and item->length |
flags | command line search flags |
void print_xml_value | ( | result_item_t * | item, |
flags_t | flags | ||
) |
XML value, entities escaped.
make sure to escape all vital xml entities and wrap a tag around the value.
Special character | gets replaced by | escaped form |
---|---|---|
Ampersand | & | & |
Less-than | < | < |
Greater-than | > | > |
Quotes | " | " |
Apostrophe | ' | ' |
item | iem containing item->str with data and item->length |
flags | command line search flags |
int search_file | ( | char * | filename, |
flags_t | flags | ||
) |
search for files
Return codes:
filename | file to search |
flags | search configuration |
int search_node | ( | FILE * | fd, |
search_res_t * | sr | ||
) |
parse line and find in sub elements
Error codes:
fd | file to search in, seeking from the current position | |
[out] | sr | search result container |
int search_segment | ( | FILE * | fd, |
search_res_t * | sr | ||
) |
this search variant is a line based search
We fetch every line, compare the segment name with the ones which are sought after. If the segment name matches with one in the addr definitions we do a substring search.
If the greedy option is set, we are searching for all occourances of sr->search_term. If not, the function returns upon the first match or when the end of file is reached.
Results are stored in sr. sr->length holds the number of results, sr->items is an array of search results.
The user must take care to properly deallocate sr after use.
Return Codes:
fd | file to search in, seeking from the current position | |
[out] | sr | search result container |
int search_subnodes | ( | node_t * | fieldlist, |
search_res_t * | sr, | ||
int | line_num, | ||
hl7_meta_t * | meta, | ||
int | segment_rep | ||
) |
search sub nodes
concatenates all sub nodes of an address and searches for substring in sr->search_term. if sr->search_term is NULL, then the concatenated line is returned as new sr->items.
Return Codes:
fieldlist | the base node to search in | |
[out] | sr | pointer to search result |
line_num | needed to add positional information to sr | |
meta | the current hl7 file meta data | |
segment_rep | segment repetition, all == -1 |
int search_substring | ( | FILE * | fd, |
search_res_t * | sr | ||
) |
search substring
fd | file to search in, seeking from the current position | |
[out] | sr | search result container |