APG
… an ABNF Parser Generator
|
A few commonly used functions. More...
#include "lib.h"
Go to the source code of this file.
Functions | |
int | iStriCmp (const char *cpLeft, const char *cpRight) |
Compare two strings. A case-insensitive version of strcmp(). More... | |
abool | bIsBigEndian (void) |
Determine if the current machine uses big endian word storage. More... | |
abool | bMultiplyLong (luint luiL, luint luiR, luint *luipA) |
Multiply two long unsigned integers with overflow notification. More... | |
abool | bSumLong (luint uiL, luint uiR, luint *uipA) |
Add two long unsigned integers with overflow notification. More... | |
abool | bMultiply32 (uint32_t uiL, uint32_t uiR, uint32_t *uipA) |
Multiply two 32-bit unsigned integers with overflow notification. More... | |
abool | bSum32 (uint32_t uiL, uint32_t uiR, uint32_t *uipA) |
Sum two 32-bit unsigned integers with overflow notification. More... | |
abool | bMultiply (aint uiL, aint uiR, aint *uipA) |
Multiply two APG unsigned integers with overflow notification. More... | |
abool | bSum (aint uiL, aint uiR, aint *uipA) |
Sum two unsigned integers with overflow notification. More... | |
apg_phrase * | spStrToPhrase (const char *cpStr, apg_phrase *spPhrase) |
Convert an ASCII, null-terminated string to an achar phrase. More... | |
char * | cpPhraseToStr (apg_phrase *spPhrase, char *cpStr) |
Convert a phrase of achar characters to a null-terminated ASCII string. More... | |
abool | bIsPhraseAscii (apg_phrase *spPhrase) |
Determine if a phrase consists entirely of printable ASCII characters. More... | |
uint32_t * | uipStrToUint32 (const char *cpStr, uint32_t *uipBuf, aint *uipLen) |
Convert an ASCII, null-terminated string to an 32-bit unsigned integer array. More... | |
char * | cpUint32ToStr (uint32_t *uipBuf, aint uiLen, char *cpStr) |
Convert an array of 32-bit unsigned integers to a null-terminated ASCII string. More... | |
u32_phrase | sStrToPhrase32 (const char *cpStr, uint32_t *uipBuf) |
Convert an ASCII, null-terminated string to a 32-bit phrase. More... | |
char * | cpPhrase32ToStr (u32_phrase *spPhrase, char *cpStr) |
Convert a 32-bit phrase to a null-terminated ASCII string. More... | |
abool | bIsPhrase32Ascii (u32_phrase *spPhrase) |
Determine if a 32-bit phrase consists entirely of printable ASCII characters. More... | |
A few commonly used functions.
Definition in file tools.c.
abool bIsBigEndian | ( | void | ) |
abool bIsPhrase32Ascii | ( | u32_phrase * | spPhrase | ) |
Determine if a 32-bit phrase consists entirely of printable ASCII characters.
When displaying a phrase it is often convenient to use the C-language string functions if possible. This function will tell when that is possible.
spPhrase | The 32-bit phrase to check. It may not be NULL or have a NULL character pointer. |
abool bIsPhraseAscii | ( | apg_phrase * | spPhrase | ) |
Determine if a phrase consists entirely of printable ASCII characters.
When displaying a phrase it is often convenient to use the C-language string functions if possible. This function will tell when that is possible.
spPhrase | The phrase to check. It may not be NULL or have a NULL character pointer. |
abool bMultiply32 | ( | uint32_t | uiL, |
uint32_t | uiR, | ||
uint32_t * | uipA | ||
) |
abool bSum32 | ( | uint32_t | uiL, |
uint32_t | uiR, | ||
uint32_t * | uipA | ||
) |
char* cpPhrase32ToStr | ( | u32_phrase * | spPhrase, |
char * | cpStr | ||
) |
Convert a 32-bit phrase to a null-terminated ASCII string.
Any 32-bit integers that are not valid printing ASCII characters will be represented with a period ('.' or 46).
spPhrase | Pointer to the u32_phrase to convert. May not be NULL or have a NULL array pointer. |
cpStr | Pointer to the buffer of characters to receive the string. It is the caller's responsibility to ensure that cpStr points to an array of at least (spPhrase->uiLength + 1) characters. Otherwise buffer overrun will occur. |
char* cpPhraseToStr | ( | apg_phrase * | spPhrase, |
char * | cpStr | ||
) |
Convert a phrase of achar
characters to a null-terminated ASCII string.
Any achar
characters that are not valid printing ASCII characters will be represented with a period ('.' or 46).
spPhrase | Pointer to the apg_phrase to convert. May not be NULL or have a NULL array pointer. |
cpStr | Pointer to the buffer of characters to receive the string. It is the caller's responsibility to ensure that cpStr points to an array of at least (spPhrase->uiLength + 1) characters. Otherwise buffer overrun will occur. |
char* cpUint32ToStr | ( | uint32_t * | uipBuf, |
aint | uiLen, | ||
char * | cpStr | ||
) |
Convert an array of 32-bit unsigned integers to a null-terminated ASCII string.
Any 32-bit unsigned integers that are not valid printing ASCII characters will be represented with a period ('.' or 46).
uipBuf | Pointer to an 32-bit unsigned integer array to convert. May not be NULL. |
uiLen | The number of characters in the uipBuf array. |
cpStr | Pointer to the buffer of characters to receive the string. It is the caller's responsibility to ensure that cpStr points to an array of at least (uiLen + 1) characters. Otherwise buffer overrun will occur. |
int iStriCmp | ( | const char * | cpLeft, |
const char * | cpRight | ||
) |
Compare two strings. A case-insensitive version of strcmp().
Two strings are considered equal if
cpLeft | Pointer to the left string. |
cpRight | Pointer to the right string. |
apg_phrase* spStrToPhrase | ( | const char * | cpStr, |
apg_phrase * | spPhrase | ||
) |
Convert an ASCII, null-terminated string to an achar
phrase.
cpStr | Pointer to the string to convert. |
spPhrase | Pointer to a phrase.
|
achar
charactersOn failure returns NULL. However,
This can be used to adjust the buffer size for successful conversion.
u32_phrase sStrToPhrase32 | ( | const char * | cpStr, |
uint32_t * | uipBuf | ||
) |
Convert an ASCII, null-terminated string to a 32-bit phrase.
cpStr | Pointer to the string to convert. May not be NULL. |
uipBuf | Pointer to the 32-bit array to receive the converted string characters. May not be NULL. It is the caller's responsibility to ensure that the array is at least strlen(cpStr) in length. Otherwise buffer overrun will result. |
uint32_t* uipStrToUint32 | ( | const char * | cpStr, |
uint32_t * | uipBuf, | ||
aint * | uipLen | ||
) |
Convert an ASCII, null-terminated string to an 32-bit unsigned integer array.
cpStr | Pointer to the string to convert. May not be NULL. |
uipBuf | Pointer to an 32-bit unsigned integer array to receive the converted string characters. May not be NULL. It is the caller's responsibility to ensure that the array is at least strlen(cpStr) in length. Otherwise buffer overrun will result. |
uipLen | Pointer to an unsigned integer to receive the number of characters in the ucpBuf array. May be NULL if no returned length is needed. |