High Performance OPC UA Server SDK  1.2.0.193
string

String utility functions. More...

Functions

size_t util_strlcpy (char *dst, const char *src, size_t len)
 Size limited copy string function. More...
 
size_t util_strlcat (char *dst, const char *src, size_t len)
 Size limited concatenate string function. More...
 
int util_snprintf (char *str, size_t size, const char *format,...)
 Like snprintf(), but returns errorcode also on truncation. More...
 
void util_print_aligned (char *line, size_t size, const char *left, char fillchar, const char *fmt,...)
 Special helper function for printing aligned text. More...
 

Detailed Description

String utility functions.

Function Documentation

int void util_print_aligned ( char *  line,
size_t  size,
const char *  left,
char  fillchar,
const char *  fmt,
  ... 
)

Special helper function for printing aligned text.

Format: "left aligned text.........right aligned text"

Parameters
linebuffer to print to
sizesize of line in bytes
leftleft text which is a kind of label
fillchara character used to fill the gap to the right text
fmtformat specifier of right side text
int util_snprintf ( char *  str,
size_t  size,
const char *  format,
  ... 
)

Like snprintf(), but returns errorcode also on truncation.

This function works similar to the original snprintf, except that it returns a negative errorcode in case of failure. For most error the universal errocodeo UA_EBAD is returned. If an argument is NULL respectively 0 UA_EBADINVALIDARGUMENT is returned. In case of truncation either UA_EBADTRUNCATED or UA_EBAD is returned depending on the platform. If str is NULL and size is 0, the number of bytes that would have been written is returned or a negative errorcode on failure.

Parameters
strPreallocated string to write output to.
sizeMaximum number of bytes written to str including terminating null byte.
formatAs specified by snprintf().
Returns
Number of bytes written (excluding the terminating null byte) on success or negative errorcode on failure.
size_t util_strlcat ( char *  dst,
const char *  src,
size_t  len 
)

Size limited concatenate string function.

This function guaranties that dst will be zero terminated, as long as dst is at least one byte long. Note that strlcat works on true 'C' strings, which means both src and dst must be zero terminated. If len <= strlen(dst) strlcat cannot write any characters, strlen(dst) will be returned.

Parameters
dstdestination buffer
srcsource buffer
lenlength of destination
Returns
total length of the created string in dst
size_t util_strlcpy ( char *  dst,
const char *  src,
size_t  len 
)

Size limited copy string function.

This function guaranties that dst will be zero terminated, as long as dst is at least one byte long. Note that strlcpy works on true 'C' strings, which means both src and dst must be zero terminated.

Parameters
dstdestination buffer
srcsource buffer
lenlength of destination
Returns
total length of the created string in dst