EPICS Base 7.0.8.0
|
Collection of string utility functions. More...
Go to the source code of this file.
Macros | |
#define | epicsStrSnPrintEscaped epicsStrnEscapedFromRaw |
Functions | |
LIBCOM_API int | epicsStrnRawFromEscaped (char *outbuf, size_t outsize, const char *inbuf, size_t inlen) |
Converts C-style escape sequences to their binary form. | |
LIBCOM_API int | epicsStrnEscapedFromRaw (char *outbuf, size_t outsize, const char *inbuf, size_t inlen) |
Converts non-printable characters into C-style escape sequences. | |
LIBCOM_API size_t | epicsStrnEscapedFromRawSize (const char *buf, size_t len) |
Scans string and returns size of output buffer needed to escape that string. | |
LIBCOM_API int | epicsStrCaseCmp (const char *s1, const char *s2) |
Does case-insensitive comparison of two strings. | |
LIBCOM_API int | epicsStrnCaseCmp (const char *s1, const char *s2, size_t len) |
Does case-insensitive comparision of two strings. | |
LIBCOM_API char * | epicsStrDup (const char *s) |
Duplicates a string. | |
LIBCOM_API char * | epicsStrnDup (const char *s, size_t len) |
Duplicates a string. | |
LIBCOM_API int | epicsStrPrintEscaped (FILE *fp, const char *s, size_t n) |
Prints escaped version of string. | |
LIBCOM_API size_t | epicsStrnLen (const char *s, size_t maxlen) |
Calculates length of string. | |
LIBCOM_API int | epicsStrGlobMatch (const char *str, const char *pattern) |
Matches a string against a pattern. | |
LIBCOM_API int | epicsStrnGlobMatch (const char *str, size_t len, const char *pattern) |
Matches a string against a pattern. | |
LIBCOM_API char * | epicsStrtok_r (char *s, const char *delim, char **lasts) |
Extract tokens from string. | |
LIBCOM_API unsigned int | epicsStrHash (const char *str, unsigned int seed) |
Calculates a hash of a null-terminated string. | |
LIBCOM_API unsigned int | epicsMemHash (const char *str, size_t length, unsigned int seed) |
Calculates a hash of a memory buffer. | |
LIBCOM_API double | epicsStrSimilarity (const char *A, const char *B) |
Compare two strings and return a number in the range [0.0, 1.0] or -1.0 on error. | |
LIBCOM_API int | dbTranslateEscape (char *s, const char *ct) |
DEPRECATED. | |
#define epicsStrSnPrintEscaped epicsStrnEscapedFromRaw |
Definition at line 125 of file epicsString.h.
LIBCOM_API int epicsStrnRawFromEscaped | ( | char * | outbuf, |
size_t | outsize, | ||
const char * | inbuf, | ||
size_t | inlen | ||
) |
Copies characters from string to an output buffer and converts C-style escape sequences to their binary form. Since the output string can never be longer than the source, it is legal for inbuf
and outbuf
to point to the same buffer and outsize
and inlen
be equal, thus performing the character translation in-place.
outbuf | buffer to copy string to. The resulting string will be zero-terminated as long as outsize is non-zero. |
outsize | length of output buffer not including the null-terminator. |
inbuf | buffer to copy from. Null byte terminates the string. |
inlen | maximum number of characters to copy from input buffer. |
LIBCOM_API int epicsStrnEscapedFromRaw | ( | char * | outbuf, |
size_t | outsize, | ||
const char * | inbuf, | ||
size_t | inlen | ||
) |
Copies characters from the string into a output buffer converting non-printable characters into C-style escape sequences. In-place translations are not allowed since the escaped results will usually be larger than the input string.
The following escaped character constants will be used in the output:
\a \b \f \n \r \t \v \\ \’ \" \0
All other non-printable characters appear in form \xHH
where HH are two hex digits. Non-printable characters are determined by the C runtime library’s isprint() function.
outbuf | buffer to copy string to. The resulting string will be zero-terminated as long as outsize is non-zero. |
outsize | length of output buffer not including the null-terminator. |
inbuf | buffer to copy from. Null byte will not terminates the string. |
inlen | Number of characters to copy from input buffer. |
outbuf
== inbuf
. Scans up to len
characters of the string that may contain non-printable characters, and returns the size of the output buffer that would be needed to escape that string. This routine is faster than calling epicsStrnEscapedFromRaw() with a zero length output buffer; both should return the same result.
buf | string to scan |
len | length of input string |
Implements strcmp from the C standard library, except is case insensitive
Implements strncmp from the C standard library, except is case insensitive
Implements strdup from the C standard library. Calls mallocMustSucceed() to allocate memory
implements strndup from the C standard library. Calls mallocMustSucceed() to allocate memory
Prints the contents of its input buffer to given file descriptor, substituting escape sequences for non-printable characters.
fp | File descriptor to print to |
s | String to print |
n | Length of string |
Implements strnlen from the C standard library.
Checks if str matches the glob style pattern, which may contain ? or * wildcards. A ? matches any single character. A * matched any sub-string.
Like epicsStrGlobMatch() but with limited string length. If the length of str is less than len, the full string is matched.
Implements strtok_r from the C standard library
Calculates a hash of a null-terminated string. Initial seed may be provided which permits multiple strings to be combined into a single hash result.
str | null-terminated string |
seed | Optionally provide seed to combine multiple strings in a single hash. Otherwise set to 0. |
Calculates a hash of a memory buffer that may contain null values. Initial seed may be provided which permits multiple buffers to be combined into a single hash result.
str | buffer |
length | size of buffer |
seed | Optionally provide seed to combine multiple buffers in a single hash. Otherwise set to 0. |