Character string functions
These functions are more secure versions of several of the character string functions available in the standard C run-time library. More...Functions | |
EXTERNRT char * | rtxStrcat (char *dest, size_t bufsiz, const char *src) |
This function concatanates the given string onto the string buffer. | |
EXTERNRT char * | rtxStrncat (char *dest, size_t bufsiz, const char *src, size_t nchars) |
This function concatanates the given number of characters from the given string onto the string buffer. | |
EXTERNRT char * | rtxStrcpy (char *dest, size_t bufsiz, const char *src) |
This function copies a null-terminated string to a target buffer. | |
EXTERNRT char * | rtxStrncpy (char *dest, size_t bufsiz, const char *src, size_t nchars) |
This function copies the given number of characters from a string to a target buffer. | |
EXTERNRT int | rtxIntToCharStr (OSINT32 value, char *dest, size_t bufsiz, char padchar) |
This function converts a signed 32-bit integer into a character string. | |
EXTERNRT int | rtxUIntToCharStr (OSUINT32 value, char *dest, size_t bufsiz, char padchar) |
This function converts an unsigned 32-bit integer into a character string. | |
EXTERNRT int | rtxInt64ToCharStr (OSINT64 value, char *dest, size_t bufsiz, char padchar) |
This function converts a signed 64-bit integer into a character string. | |
EXTERNRT int | rtxUInt64ToCharStr (OSUINT64 value, char *dest, size_t bufsiz, char padchar) |
This function converts an unsigned 64-bit integer into a character string. | |
EXTERNRT int | rtxHexCharsToBinCount (const char *hexstr, size_t nchars) |
This function returns a count of the number of bytes the would result from the conversion of a hexadecimal character string to binary. | |
EXTERNRT int | rtxHexCharsToBin (const char *hexstr, size_t nchars, OSOCTET *binbuf, size_t bufsize) |
This function converts the given hex string to binary. |
Detailed Description
These functions are more secure versions of several of the character string functions available in the standard C run-time library.
Function Documentation
EXTERNRT int rtxHexCharsToBin | ( | const char * | hexstr, | |
size_t | nchars, | |||
OSOCTET * | binbuf, | |||
size_t | bufsize | |||
) |
This function converts the given hex string to binary.
The result is stored in the given binary buffer. Any whitespace characters in the string are ignored.
- Parameters:
-
hexstr Hex character string to convert. nchars Number of characters in string. If zero, characters are read up to null-terminator. binbuf Buffer to hold converted binary data. bufsize Size of the binary data buffer.
- Returns:
- Number of bytes or negative status value if fail.
EXTERNRT int rtxHexCharsToBinCount | ( | const char * | hexstr, | |
size_t | nchars | |||
) |
This function returns a count of the number of bytes the would result from the conversion of a hexadecimal character string to binary.
Any whitespace characters in the string are ignored.
- Parameters:
-
hexstr Hex character string to convert. nchars Number of characters in string. If zero, characters are read up to null-terminator.
- Returns:
- Number of bytes or negative status value if fail.
EXTERNRT int rtxInt64ToCharStr | ( | OSINT64 | value, | |
char * | dest, | |||
size_t | bufsiz, | |||
char | padchar | |||
) |
This function converts a signed 64-bit integer into a character string.
It is similar to the C itoa
function.
- Parameters:
-
value Integer to convert. dest Pointer to destination buffer to receive string. bufsiz Size of the destination buffer. padchar Left pad char, set to zero for no padding.
- Returns:
- Number of characters or negative status value if fail.
EXTERNRT int rtxIntToCharStr | ( | OSINT32 | value, | |
char * | dest, | |||
size_t | bufsiz, | |||
char | padchar | |||
) |
This function converts a signed 32-bit integer into a character string.
It is similar to the C itoa
function.
- Parameters:
-
value Integer to convert. dest Pointer to destination buffer to receive string. bufsiz Size of the destination buffer. padchar Left pad char, set to zero for no padding.
- Returns:
- Number of characters or negative status value if fail.
EXTERNRT char* rtxStrcat | ( | char * | dest, | |
size_t | bufsiz, | |||
const char * | src | |||
) |
This function concatanates the given string onto the string buffer.
It is similar to the C strcat
function except more secure because it checks for buffer overrun.
- Parameters:
-
dest Pointer to destination buffer to receive string. bufsiz Size of the destination buffer. src Pointer to null-terminated string to copy.
- Returns:
- Pointer to destination buffer or NULL if copy failed.
EXTERNRT char* rtxStrcpy | ( | char * | dest, | |
size_t | bufsiz, | |||
const char * | src | |||
) |
This function copies a null-terminated string to a target buffer.
It is similar to the C strcpy
function except more secure because it checks for buffer overrun.
- Parameters:
-
dest Pointer to destination buffer to receive string. bufsiz Size of the destination buffer. src Pointer to null-terminated string to copy.
- Returns:
- Pointer to destination buffer or NULL if copy failed.
EXTERNRT char* rtxStrncat | ( | char * | dest, | |
size_t | bufsiz, | |||
const char * | src, | |||
size_t | nchars | |||
) |
This function concatanates the given number of characters from the given string onto the string buffer.
It is similar to the C strncat
function except more secure because it checks for buffer overrun.
- Parameters:
-
dest Pointer to destination buffer to receive string. bufsiz Size of the destination buffer. src Pointer to null-terminated string to copy. nchars Number of characters to copy.
- Returns:
- Pointer to destination buffer or NULL if copy failed.
EXTERNRT char* rtxStrncpy | ( | char * | dest, | |
size_t | bufsiz, | |||
const char * | src, | |||
size_t | nchars | |||
) |
This function copies the given number of characters from a string to a target buffer.
It is similar to the C strncpy
function except more secure because it checks for buffer overrun and ensures a null-terminator is copied to the end of the target buffer
- Parameters:
-
dest Pointer to destination buffer to receive string. bufsiz Size of the destination buffer. src Pointer to null-terminated string to copy. nchars Number of characters to copy.
- Returns:
- Pointer to destination buffer or NULL if copy failed.
EXTERNRT int rtxUInt64ToCharStr | ( | OSUINT64 | value, | |
char * | dest, | |||
size_t | bufsiz, | |||
char | padchar | |||
) |
This function converts an unsigned 64-bit integer into a character string.
It is similar to the C itoa
function.
- Parameters:
-
value Integer to convert. dest Pointer to destination buffer to receive string. bufsiz Size of the destination buffer. padchar Left pad char, set to zero for no padding.
- Returns:
- Number of characters or negative status value if fail.
EXTERNRT int rtxUIntToCharStr | ( | OSUINT32 | value, | |
char * | dest, | |||
size_t | bufsiz, | |||
char | padchar | |||
) |
This function converts an unsigned 32-bit integer into a character string.
It is similar to the C itoa
function.
- Parameters:
-
value Integer to convert. dest Pointer to destination buffer to receive string. bufsiz Size of the destination buffer. padchar Left pad char, set to zero for no padding.
- Returns:
- Number of characters or negative status value if fail.