hl7parse
Macros | Functions
util.h File Reference

hl7 utilitiy functions More...

#include <stddef.h>
#include <string.h>
#include "node.h"
Include dependency graph for util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SIZE_T_L   "%ld"
 
#define MARKER_T   "\u251C"
 
#define MARKER_L   "\u2514"
 
#define MARKER_D   "\u2500"
 

Functions

void * memdup (void *src, size_t length)
 copy a chunck of memory More...
 
void dump_structure (message_t *message)
 print a parsed HL7 structure More...
 
char * trim (char *str)
 trim white space at the beginnign and end of a string More...
 
char * escape (char *str, char *quote_char, char escape_char)
 escape a character in a string More...
 

Detailed Description

hl7 utilitiy functions

Macro Definition Documentation

◆ MARKER_D

#define MARKER_D   "\u2500"

console marker for none

◆ MARKER_L

#define MARKER_L   "\u2514"

console marker for leaf

◆ MARKER_T

#define MARKER_T   "\u251C"

console marker for node

◆ SIZE_T_L

#define SIZE_T_L   "%ld"

unix long int

Function Documentation

◆ dump_structure()

void dump_structure ( message_t message)

print a parsed HL7 structure

debug function, used by 7parse to display an ASCII tree of the file content.

Parameters
messagethe message to print

◆ escape()

char* escape ( char *  str,
char *  quote_char,
char  escape_char 
)

escape a character in a string

This function will allcoate a new string with all occourances of quote_char prepended with escape_char.

You must take care of freeing the result!

Parameters
strstring to escape
quote_charthe character to find and escape
escape_charthe character to prepend in front of quote char
Returns
char array with double quote backslash escaped

◆ memdup()

void* memdup ( void *  src,
size_t  length 
)

copy a chunck of memory

Will allocate memory for you, you are in charge to free it later.

Parameters
srcbyte array to copy
lengthlength of input array
Returns
pointer to copy byte array

◆ trim()

char* trim ( char *  str)

trim white space at the beginnign and end of a string

Note
all trailing bytes of whitespace are replaced with '\0' in the original string and the pointer is shifted at the beginning to the first non whitespace character. You will loos track of the original beginning of the memory chunk. Use with care (always use a copy of the original pointer).
Parameters
[out]strto string
Returns
pointer to the new beginning of the string