|
Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
|
This header file contains functions that are used by the web-server.
The functions might also be useful for the code you design. Some of the functions are replacements for functions in the C Standard Library.
Classes | |
| struct | BaTm |
| Represents the components of calendar time. More... | |
| struct | BaTimeEx |
| UTC timestamp with a fractional second and an explicit timezone offset. More... | |
Typedefs | |
| typedef int8_t | S8 |
| Signed 8-bit integer. More... | |
| typedef int16_t | S16 |
| Signed 16-bit integer. More... | |
| typedef int32_t | S32 |
| Signed 32-bit integer. More... | |
| typedef int64_t | S64 |
| Signed 64-bit integer. More... | |
| typedef uint8_t | U8 |
| Unsigned 8-bit integer. More... | |
| typedef uint16_t | U16 |
| Unsigned 16-bit integer. More... | |
| typedef uint32_t | U32 |
| Unsigned 32-bit integer. More... | |
| typedef uint64_t | U64 |
| Unsigned 64-bit integer. More... | |
| typedef S64 | BaTime |
| An arithmetic type representing calendar time with epoch of 1970-01-01 00:00:00 UTC, that is, +/- number of seconds since the epoch of 1970-01-01. More... | |
| typedef U8 | BaBool |
| Boolean stored in an unsigned byte; FALSE is zero and TRUE is one. More... | |
| typedef U32 | BaFileSize |
| Unsigned file size or position in bytes; 32 bits without BA_FILESIZE64. More... | |
| typedef S32 | SBaFileSize |
| Signed file-size value in bytes; 32 bits without BA_FILESIZE64. More... | |
Functions | |
| BA_API void | baConvBin2Hex (void *hexOutData, U8 binIn) |
| Encode one byte as two lowercase hexadecimal characters. More... | |
| BA_API U8 | baConvHex2Bin (U8 c) |
| Decode one hexadecimal digit. More... | |
| BA_API void | baConvU32ToHex (void *to, U32 from) |
| Encode four bytes as eight lowercase hexadecimal characters. More... | |
| BA_API U32 | baConvHexToU32 (const void *from) |
| Decode eight hexadecimal characters into a U32. More... | |
| BA_API char * | baStrdup (const char *str) |
| Allocate a NUL-terminated copy of a string using baMalloc. More... | |
| BA_API const void * | baBSearch (const void *key, const void *base, int num, int size, int(*cmp)(const void *, const void *)) |
| Find a key in a sorted array without modifying it. More... | |
| BA_API int | baStrCaseCmp (const char *a, const char *b) |
| Compare two NUL-terminated strings using bTolower for case folding. More... | |
| BA_API int | baStrnCaseCmp (const char *a, const char *b, size_t len) |
| Compare at most len bytes, using bTolower for case folding. More... | |
| const char * | baGetToken (const char **str, const char *set) |
| Locate a token separated by characters in set. More... | |
| BA_API BaTime | baParseDate (const char *str) |
| Parse an HTTP date string as UTC. More... | |
| BA_API int | baB64Decode (unsigned char *outStr, int outStrSize, const char *b64EncStr, BaBool *overflow) |
| Decode base64 or base64url into a caller buffer. More... | |
| BA_API int | baElideDotDot (char *str) |
| Normalize a slash-separated path in place. More... | |
| BA_API void | baXmlUnescape (char *f) |
| Decode selected XML entity spellings in place. More... | |
| BA_API U8 | baDaysInMonth (U16 y, U16 m) |
| Return the number of days in a Gregorian calendar month. More... | |
| BA_API int | baTime2tm (struct BaTm *tmP, BaTime t) |
| Convert UTC epoch seconds to calendar fields. More... | |
| BA_API int | baTime2tmEx (const BaTimeEx *tex, const BaBool local, struct BaTm *tm) |
| Convert a timestamp to UTC or offset-adjusted calendar fields. More... | |
| BA_API BaTime | baTm2Time (struct BaTm *tmP) |
| Convert calendar fields to UTC epoch seconds. More... | |
| BA_API int | baTm2TimeEx (struct BaTm *tm, BaBool local, BaTimeEx *tex) |
| Convert calendar fields and an optional timezone offset to a timestamp. More... | |
| BA_API int | baISO8601ToTime (const char *str, size_t len, BaTimeEx *tex) |
| Parse an ISO 8601 calendar timestamp with an explicit timezone. More... | |
| BA_API int | baTime2ISO8601 (const BaTimeEx *tex, char *str, size_t len) |
| Format a timestamp as ISO 8601 using its timezone offset. More... | |
| typedef U32 BaFileSize |
Unsigned file size or position in bytes; 32 bits without BA_FILESIZE64.
| typedef int16_t S16 |
Signed 16-bit integer.
| typedef int32_t S32 |
Signed 32-bit integer.
| typedef int64_t S64 |
Signed 64-bit integer.
| typedef int8_t S8 |
Signed 8-bit integer.
| typedef S32 SBaFileSize |
Signed file-size value in bytes; 32 bits without BA_FILESIZE64.
| typedef uint16_t U16 |
Unsigned 16-bit integer.
| typedef uint32_t U32 |
Unsigned 32-bit integer.
| typedef uint64_t U64 |
Unsigned 64-bit integer.
| typedef uint8_t U8 |
Unsigned 8-bit integer.
| BA_API int baB64Decode | ( | unsigned char * | outStr, |
| int | outStrSize, | ||
| const char * | b64EncStr, | ||
| BaBool * | overflow | ||
| ) |
Decode base64 or base64url into a caller buffer.
| [out] | outStr | Buffer with outStrSize writable bytes; it may alias b64EncStr for in-place decoding. No NUL terminator is written. |
| [in] | outStrSize | Nonnegative capacity in bytes. |
| [in] | b64EncStr | Required NUL-terminated input. Bytes outside both base64 alphabets, including padding, are ignored rather than rejected. |
| [out] | overflow | Optional pointer, set to TRUE if decoded bytes were discarded because the output was full; otherwise FALSE. May be NULL. |
| BA_API const void * baBSearch | ( | const void * | key, |
| const void * | base, | ||
| int | num, | ||
| int | size, | ||
| int(*)(const void *, const void *) | cmp | ||
| ) |
Find a key in a sorted array without modifying it.
| [in] | key | Search key passed as the comparator's first argument. |
| [in] | base | Array of num records sorted in ascending comparator order. |
| [in] | num | Nonnegative number of records. |
| [in] | size | Positive size of each record in bytes. Array indexing and midpoint arithmetic must fit in int as used by this implementation. |
| [in] | cmp | Required comparison callback, called as cmp(key, record). It returns negative, zero or positive when key is less than, equal to or greater than the record's key. It must not reorder the array. |
| BA_API void baConvBin2Hex | ( | void * | hexOutData, |
| U8 | binIn | ||
| ) |
Encode one byte as two lowercase hexadecimal characters.
| [out] | hexOutData | Writable buffer of at least two bytes. No NUL is added. |
| [in] | binIn | Byte to encode. |
Decode one hexadecimal digit.
| [in] | c | Character from 0-9, a-f or A-F. |
| BA_API U32 baConvHexToU32 | ( | const void * | from | ) |
Decode eight hexadecimal characters into a U32.
| [in] | from | At least eight readable characters, or NULL. A terminator is not read. Invalid characters decode as zero-valued nibbles. |
| BA_API void baConvU32ToHex | ( | void * | to, |
| U32 | from | ||
| ) |
Encode four bytes as eight lowercase hexadecimal characters.
| [out] | to | Writable buffer of at least eight bytes; no NUL is added. |
| [in] | from | Value to encode. The implementation visits its memory bytes from offset 3 to offset 0, producing conventional most-significant-digit first notation on little-endian targets. See baConvHexToU32. |
Return the number of days in a Gregorian calendar month.
| [in] | y | Calendar year used for leap-year calculation. |
| [in] | m | Month from 1 (January) through 12 (December); not validated. |
| BA_API int baElideDotDot | ( | char * | str | ) |
Normalize a slash-separated path in place.
| [in,out] | str | Required writable NUL-terminated path. Repeated slashes, '.' components and matched parent components are removed without allocation. |
| const char * baGetToken | ( | const char ** | str, |
| const char * | set | ||
| ) |
Locate a token separated by characters in set.
| [in,out] | str | Required pointer to a nonempty NUL-terminated string. Leading delimiter characters are skipped by advancing *str. On success *str points to the first token byte; the function does not advance it to the returned end pointer. The string itself is not modified. |
| [in] | set | NUL-terminated delimiter character set. |
| BA_API int baISO8601ToTime | ( | const char * | str, |
| size_t | len, | ||
| BaTimeEx * | tex | ||
| ) |
Parse an ISO 8601 calendar timestamp with an explicit timezone.
| [in] | str | Required readable input, with format YYYY-MM-DDTHH:MM:SSZ or YYYY-MM-DDTHH:MM:SS+HH:MM (also allowing a negative offset). A space or lowercase t may replace T; lowercase z is accepted. An optional decimal point and 1..9 fractional digits may precede the timezone. |
| [in] | len | Exact byte length, excluding any NUL; at least 20. Supply a complete timezone suffix. No trailing characters are accepted. |
| [out] | tex | Required timestamp buffer, valid only on success. sec is UTC, nsec is scaled to nanoseconds, and offset retains the supplied minutes. |
| BA_API BaTime baParseDate | ( | const char * | str | ) |
Parse an HTTP date string as UTC.
| [in] | str | NUL-terminated IMF-fixdate, RFC 850, or asctime date, or NULL. Names are case-sensitive; the first two forms require GMT. Surrounding SP/HTAB is accepted; invalid calendar fields, trailing data, and date lists are rejected. RFC 850 years use the HTTP 50-year rule and the server clock. A recognized weekday name is required but is not compared to the date. |
| BA_API int baStrCaseCmp | ( | const char * | a, |
| const char * | b | ||
| ) |
Compare two NUL-terminated strings using bTolower for case folding.
| [in] | a | Required first string. |
| [in] | b | Required second string. This is a byte comparison, not Unicode case folding; character handling follows the platform bTolower definition. |
| BA_API char * baStrdup | ( | const char * | str | ) |
Allocate a NUL-terminated copy of a string using baMalloc.
| [in] | str | Source string or NULL; the source is not modified. |
| BA_API int baStrnCaseCmp | ( | const char * | a, |
| const char * | b, | ||
| size_t | len | ||
| ) |
Compare at most len bytes, using bTolower for case folding.
| [in] | a | First string, readable through its NUL or len bytes. |
| [in] | b | Second string, readable through its NUL or len bytes. |
| [in] | len | Maximum byte count; zero performs no character access. |
| BA_API int baTime2ISO8601 | ( | const BaTimeEx * | tex, |
| char * | str, | ||
| size_t | len | ||
| ) |
Format a timestamp as ISO 8601 using its timezone offset.
| [in] | tex | Required timestamp satisfying baTime2tmEx requirements. |
| [out] | str | Writable output buffer; NUL-terminated on success. The output uses T, a nine-digit fractional part when nsec is nonzero, and Z for offset zero or a signed HH:MM offset otherwise. |
| [in] | len | Buffer capacity in bytes, including the NUL. At least 36 bytes are required even when the particular result would be shorter. |
Convert UTC epoch seconds to calendar fields.
| [out] | tmP | Required output structure; valid only on success. tm_year is years since 1900, tm_mon is zero-based, nsec and offset are zero. |
| [in] | t | UTC seconds from -62135596800 through 253402300799 (years 0001 through 9999). |
Convert a timestamp to UTC or offset-adjusted calendar fields.
| [in] | tex | Required timestamp. nsec must be 0-999999999 and offset must be -1439..1439 minutes. sec + offset * 60 must fall in years 0001..9999; callers must also keep the calendar value selected by local in that range. |
| [in] | local | TRUE applies tex->offset; FALSE produces UTC fields. |
| [out] | tm | Required output, valid only on success. tm_year is the full calendar year, tm_mon is zero-based. nsec and offset are copied even when local is FALSE. Weekday and year-day fields are populated. |
Convert calendar fields to UTC epoch seconds.
| [in,out] | tmP | Required structure with tm_year as years since 1900, tm_mon in 0..11 and valid day/time fields. Initialize nsec and offset to zero. The function changes tm_year and tm_mon, including on failure; pass a copy if the original fields are needed afterward. tm_wday and tm_yday are ignored. |
Convert calendar fields and an optional timezone offset to a timestamp.
| [in,out] | tm | Required initialized structure. tm_year is the full year (use 1..9999), tm_mon is 0..11, and day, hour, minute and second must form a valid date/time. Supply valid nsec and offset values as described by BaTimeEx; these two fields are copied without validation. tm_wday and tm_yday are ignored. tm_mon and possibly tm_year are changed during conversion, including on failure; use a copy to preserve the input. |
| [in] | local | TRUE subtracts tm->offset to obtain UTC seconds; FALSE interprets the calendar fields as UTC. |
| [out] | tex | Required output timestamp, valid only on success. |
| BA_API void baXmlUnescape | ( | char * | f | ) |
Decode selected XML entity spellings in place.
| [in,out] | f | Required writable NUL-terminated string. The result remains NUL-terminated and is no longer than the input. Numeric character references and unrecognized entity spellings remain unchanged. The implementation handles lt, gt, apos and amp, but currently spells the quote entity as "qout" rather than the XML spelling "quot". No error status is returned. |