High Performance OPC UA Server SDK  1.3.1.248
ua_bytestring Struct Reference

This Built-in DataType defines a value that is a sequence of Byte values. More...

#include <bytestring.h>

Public Member Functions

void ua_bytestring_init (struct ua_bytestring *bs)
 Initialize an ua_bytestring as empty bytestring.
 
void ua_bytestring_clear (struct ua_bytestring *bs)
 Clear an ua_bytestring and set to empty bytestring.
 
size_t ua_bytestring_length (const struct ua_bytestring *bs)
 Returns the length of the bytestring in bytes. More...
 
char * ua_bytestring_data (struct ua_bytestring *bs)
 Returns the raw data of bs. More...
 
const char * ua_bytestring_const_data (const struct ua_bytestring *bs)
 Returns the raw string data of bs. More...
 
const unsigned char * ua_bytestring_unsigned_const_data (const struct ua_bytestring *bs)
 Returns the raw string data of bs as unsigned byte array. More...
 
bool ua_bytestring_is_null (const struct ua_bytestring *bs)
 Returns true if the given bytestring is a NULL bytestring.
 
int ua_bytestring_compare (const struct ua_bytestring *a, const struct ua_bytestring *b)
 Compare to ua_bytestrings. More...
 
int ua_bytestring_copy (struct ua_bytestring *dst, const struct ua_bytestring *src)
 Copy ua_bytestring src to dst. More...
 
int ua_bytestring_set (struct ua_bytestring *bs, const char *src, int32_t len)
 Initializes the bytestring bs with the given data. More...
 
void ua_bytestring_set_null (struct ua_bytestring *bs)
 Initializes the bytestring bs as null bytestring. More...
 
void ua_bytestring_attach (struct ua_bytestring *bs, char *src, int32_t len)
 Initializes the bytestring bs with the given data. More...
 
int ua_bytestring_append (struct ua_bytestring *dst, const struct ua_bytestring *src)
 Appends the bytestring src to the bytestring dst. More...
 
int ua_bytestring_to_string (const struct ua_bytestring *bs, struct ua_string *dst)
 Creates a ua_string dst with base64 encoded content from a ua_bytestring bs. More...
 
int ua_bytestring_snprintf (char *dst, size_t size, const struct ua_bytestring *bs)
 Converts the given bytestring into a base64 string. More...
 
int ua_bytestring_from_string (struct ua_bytestring *bs, const struct ua_string *src)
 Creates a ua_bytestring bs from a given base46 string src. More...
 

Data Fields

int32_t len
 Number of bytes, or -1 for a ‘null’ bytestring. More...
 
char * data
 Pointer to actual array with bytes.
 

Related Functions

#define UA_BYTESTRING_INITIALIZER   { 0, NULL }
 Initializer for empty ua_bytestrings.
 

Detailed Description

This Built-in DataType defines a value that is a sequence of Byte values.

Member Function Documentation

◆ ua_bytestring_append()

int ua_bytestring_append ( struct ua_bytestring dst,
const struct ua_bytestring src 
)

Appends the bytestring src to the bytestring dst.

Returns
Zero on succes or errorcode on failure

◆ ua_bytestring_attach()

void ua_bytestring_attach ( struct ua_bytestring bs,
char *  src,
int32_t  len 
)

Initializes the bytestring bs with the given data.

This function takes ownership of src and will free it when calling ua_bytestring_clear().

◆ ua_bytestring_compare()

int ua_bytestring_compare ( const struct ua_bytestring a,
const struct ua_bytestring b 
)

Compare to ua_bytestrings.

Returns
Zero if both are the same.

◆ ua_bytestring_const_data()

const char * ua_bytestring_const_data ( const struct ua_bytestring bs)

Returns the raw string data of bs.

This version of the function returns a const pointer.

◆ ua_bytestring_copy()

int ua_bytestring_copy ( struct ua_bytestring dst,
const struct ua_bytestring src 
)

Copy ua_bytestring src to dst.

Returns
Zero on success or errorcode on failure.

◆ ua_bytestring_data()

char * ua_bytestring_data ( struct ua_bytestring bs)

Returns the raw data of bs.

This pointer can be used to access and modify the data that compose the bytestring.

◆ ua_bytestring_from_string()

int ua_bytestring_from_string ( struct ua_bytestring bs,
const struct ua_string src 
)

Creates a ua_bytestring bs from a given base46 string src.

Parameters
bsDestination for the base64 decoded bytestring. It is save to pass an uninitialized ua_bytestring.
srcua_string with base64 encoded content to be decoded.
Returns
Returns 0 on success.

◆ ua_bytestring_length()

size_t ua_bytestring_length ( const struct ua_bytestring bs)

Returns the length of the bytestring in bytes.

A value of 0 indicates an invalid argument or empty or null bytestring. To check for the latter use ua_bytestring_is_null.

◆ ua_bytestring_set()

int ua_bytestring_set ( struct ua_bytestring bs,
const char *  src,
int32_t  len 
)

Initializes the bytestring bs with the given data.

This function creates a copy of src.

◆ ua_bytestring_set_null()

void ua_bytestring_set_null ( struct ua_bytestring bs)

Initializes the bytestring bs as null bytestring.

Sometimes a distinction between empty and null bytestring is required, this function can set a null bytestring.

◆ ua_bytestring_snprintf()

int ua_bytestring_snprintf ( char *  dst,
size_t  size,
const struct ua_bytestring bs 
)

Converts the given bytestring into a base64 string.

Parameters
dstDestination string where the base64 string will be written to.
sizeSize in bytes of dst.
bsThe bytestring to be converted.
Returns
Upon successful return, these functions return the number of characters printed (excluding the null byte used to end output to strings). This function does not write more than size bytes (including the terminating null byte). If the output was truncated due to this limit then the return value is the number of characters (excluding the terminating null byte) which would have been written to the final string if enough space had been available. Thus, a return value of size or more means that the output was truncated.

◆ ua_bytestring_to_string()

int ua_bytestring_to_string ( const struct ua_bytestring bs,
struct ua_string dst 
)

Creates a ua_string dst with base64 encoded content from a ua_bytestring bs.

Parameters
bsua_bytestring to be converted to a base64 ua_string.
dstua_string to write the encoded data to. It is save to pass an uninitialized ua_string.
Returns
Returns 0 on success

◆ ua_bytestring_unsigned_const_data()

const unsigned char * ua_bytestring_unsigned_const_data ( const struct ua_bytestring bs)

Returns the raw string data of bs as unsigned byte array.

This is an alternative for ua_bytestring_const_data, because some APIs expect unsigned byte arrays and this way ugly casts can be avoided when passing the bytestring data to such APIs.

Field Documentation

◆ len

int32_t len

Number of bytes, or -1 for a ‘null’ bytestring.


The documentation for this struct was generated from the following files: