|
MegaWiFi 1.5
MegaWiFi API documentation
|
General purpose utilities. More...
Macros | |
| #define | TRUE 1 |
| TRUE value for boolean comparisons. More... | |
| #define | FALSE 0 |
| TRUE value for boolean comparisons. More... | |
| #define | NULL ((void*)0) |
| NULL Pointer. More... | |
| #define | _STR(item) #item |
| Helper for STR macro, to ensure item is expanded. More... | |
| #define | STR(item) _STR(item) |
| Converts a statically defined item to string. More... | |
| #define | IN_RANGE(num, lower, upper) (((number) >= (lower)) && ((number) <= (upper))) |
| Returns TRUE if number is in the specified range. More... | |
| #define | container_of(ptr, type, member) |
| The infamous container_of() macro directly the Linux kernel. More... | |
| #define | PACKED __attribute__((__packed__)) |
| Macro for packing structures and enumerates. More... | |
| #define | SECTION(name) __attribute__((section(#name))) |
| #define | ROM_TEXT(name) SECTION(.text.ro_text.name) |
| Put next symbol in named section .text.ro_text.symbol. More... | |
| #define | ROM_DATA(name) SECTION(.text.ro_data.name) |
| Put next symbol in named section .text.ro_data.symbol. More... | |
| #define | ARRAY_ROWS(array_2d) (sizeof(array_2d) / sizeof(array_2d[0]) / sizeof(array_2d[0][0])) |
| Get number of rows of a 2D array. More... | |
| #define | ARRAY_COLS(array_2d) (sizeof(array_2d[0]) / sizeof(array_2d[0][0])) |
| Get number of columns of a 2D array. More... | |
| #define | UNUSED_PARAM(x) (void)x |
| Remove compiler warnings when not using a function parameter. More... | |
| #define | MAX(a, b) ((a)>(b)?(a):(b)) |
| Returns the maximum of two numbers. More... | |
| #define | MIN(a, b) ((a)<(b)?(a):(b)) |
| Returns the minimum of two numbers. More... | |
| #define | ByteSwapWord(w) (uint16_t)((((uint16_t)(w))>>8) | (((uint16_t)(w))<<8)) |
| Swaps bytes from a word (16 bit) More... | |
| #define | ByteSwapDWord(dw) |
| Swaps bytes from a dword (32 bits) More... | |
Functions | |
| static void | to_upper (char *str) |
| Converts input string to uppercase. More... | |
| const char * | str_is_uint8 (const char *str) |
| Evaluates if a string points to a number that can be stored in a uint8_t type variable. More... | |
| int | ip_validate (const char *str) |
| This function evaluates the data entered on the input Menu structure, to guess if it corresponds to a valid IPv4. More... | |
| int | uint32_to_ip_str (uint32_t ip_u32, char *ip_str) |
| Writes the corresponding string representing an IPv4 stored in the input DWORD (32-bit) integer. More... | |
| uint32_t | ip_str_to_uint32 (const char *ip) |
| Returns the binary IP addres (uint32) corresponding to the input string. More... | |
| uint16_t | uint8_to_str (uint8_t num, char *str) |
| Converts an unsigned 8-bit number to its character string representation. More... | |
| int8_t | int8_to_str (int8_t num, char *str) |
| Converts an signed 8-bit number to its character string representation. More... | |
| uint8_t | uint16_to_str (uint16_t num, char *str) |
| Converts an unsigned 16-bit number to its character string representation. More... | |
| uint8_t | int16_to_str (int16_t num, char *str) |
| Converts an signed 16-bit number to its character string representation. More... | |
| const char * | str_to_uint8 (const char *strIn, uint8_t *result) |
| Converts a character string representing an 8-bit unsigned number, to its binary (uint8_t) representation. More... | |
| int | long_to_str (long num, char *str, int buf_len, int pad_len, char pad_chr) |
| Converts an integer to a character string. More... | |
| void | uint8_to_hex_str (uint8_t num, char *str) |
| Converts a 8-bit number to its hexadecimal string representation. More... | |
| int | uint32_to_hex_str (uint32_t num, char *str, int pad) |
| Converts a 32-bit number to its hexadecimal string representation. More... | |
| int | version_to_str (const uint8_t version[3], char *str) |
| Converts version numbers (major, minor, micro) into its string representation [major].[minor].[micro]. More... | |
| int | version_cmp (const uint8_t old[3], const uint8_t cur[3]) |
| Compares two version number arrays (major, minor, micro). More... | |
| uint16_t | concat_strings (const char **str, uint8_t num_strs, char *output, uint16_t max_len) |
| Concatenates an array of strings into an output string, separated by a '\0' character. More... | |
| uint16_t | concat_kv_pairs (const char **key, const char **value, uint8_t num_pairs, char *output, uint16_t max_len) |
| Concatenates two arrays of key/value pairs, into an output string, separating each key and value with a '\0' character. More... | |
General purpose utilities.
| #define _STR | ( | item | ) | #item |
| #define ARRAY_COLS | ( | array_2d | ) | (sizeof(array_2d[0]) / sizeof(array_2d[0][0])) |
| #define ARRAY_ROWS | ( | array_2d | ) | (sizeof(array_2d) / sizeof(array_2d[0]) / sizeof(array_2d[0][0])) |
| #define ByteSwapDWord | ( | dw | ) |
| #define ByteSwapWord | ( | w | ) | (uint16_t)((((uint16_t)(w))>>8) | (((uint16_t)(w))<<8)) |
| #define container_of | ( | ptr, | |
| type, | |||
| member | |||
| ) |
The infamous container_of() macro directly the Linux kernel.
| #define IN_RANGE | ( | num, | |
| lower, | |||
| upper | |||
| ) | (((number) >= (lower)) && ((number) <= (upper))) |
| #define MAX | ( | a, | |
| b | |||
| ) | ((a)>(b)?(a):(b)) |
| #define MIN | ( | a, | |
| b | |||
| ) | ((a)<(b)?(a):(b)) |
| #define PACKED __attribute__((__packed__)) |
| #define ROM_DATA | ( | name | ) | SECTION(.text.ro_data.name) |
| #define ROM_TEXT | ( | name | ) | SECTION(.text.ro_text.name) |
| #define SECTION | ( | name | ) | __attribute__((section(#name))) |
Section attribute definition for variables and functions. Examples:
| #define STR | ( | item | ) | _STR(item) |
| #define UNUSED_PARAM | ( | x | ) | (void)x |
| uint16_t concat_kv_pairs | ( | const char ** | key, |
| const char ** | value, | ||
| uint8_t | num_pairs, | ||
| char * | output, | ||
| uint16_t | max_len | ||
| ) |
Concatenates two arrays of key/value pairs, into an output string, separating each key and value with a '\0' character.
| [in] | key | Array of keys to concatenate into output. |
| [in] | value | Array of values to concatenate into output. |
| [in] | num_pairs | Number of key/value pairs in key and value arrays. |
| [out] | output | Output array that will hold concatenated strings. |
| [in] | max_len | Length of output. Function will error if not enough. |
| uint16_t concat_strings | ( | const char ** | str, |
| uint8_t | num_strs, | ||
| char * | output, | ||
| uint16_t | max_len | ||
| ) |
Concatenates an array of strings into an output string, separated by a '\0' character.
| [in] | str | Array of strings to concatenate into output. |
| [in] | num_strs | Number of strings in str array. |
| [out] | output | Output array that will hold concatenated strings. |
| [in] | max_len | Length of output. Function will error if not enough. |
| uint8_t int16_to_str | ( | int16_t | num, |
| char * | str | ||
| ) |
Converts an signed 16-bit number to its character string representation.
| [in] | num | Input number to convert. |
| [out] | str | String representing the input number. |
| int8_t int8_to_str | ( | int8_t | num, |
| char * | str | ||
| ) |
Converts an signed 8-bit number to its character string representation.
| [in] | num | Input number to convert. |
| [out] | str | String representing the input number. |
| uint32_t ip_str_to_uint32 | ( | const char * | ip | ) |
Returns the binary IP addres (uint32) corresponding to the input string.
| [in] | ip | String representing an IPv4 address. |
| int ip_validate | ( | const char * | str | ) |
This function evaluates the data entered on the input Menu structure, to guess if it corresponds to a valid IPv4.
| [in] | str | string to evaluate against an IPv4 pattern. |
| int long_to_str | ( | long | num, |
| char * | str, | ||
| int | buf_len, | ||
| int | pad_len, | ||
| char | pad_chr | ||
| ) |
Converts an integer to a character string.
| [in] | num | Number to convert to string. |
| [out] | str | String that will hold the converted number. |
| [in] | buf_len | Length of str buffer. |
| [in] | pad_len | Length of the padding to introduce. 0 for no padding. |
| [in] | pad_chr | Character used for padding (typically '0' or ' '). |
| const char * str_is_uint8 | ( | const char * | str | ) |
Evaluates if a string points to a number that can be stored in a uint8_t type variable.
| [in] | str | String to be evaluated as a number. |
| const char * str_to_uint8 | ( | const char * | strIn, |
| uint8_t * | result | ||
| ) |
Converts a character string representing an 8-bit unsigned number, to its binary (uint8_t) representation.
| [in] | strIn | Input string with the number to convert. |
| [out] | result | Converted number will be left here. |
|
inlinestatic |
| uint8_t uint16_to_str | ( | uint16_t | num, |
| char * | str | ||
| ) |
Converts an unsigned 16-bit number to its character string representation.
| [in] | num | Input number to convert. |
| [out] | str | String representing the input number. |
| int uint32_to_hex_str | ( | uint32_t | num, |
| char * | str, | ||
| int | pad | ||
| ) |
Converts a 32-bit number to its hexadecimal string representation.
| [in] | num | Number to convert. |
| [out] | str | Converted equivalent string. Must have room for at least 9 characters to guarantee an overrun will not accur. |
| [in] | pad | Padding. If greater than 0, left part of resulting number will be zero-padded to the specified length. |
| int uint32_to_ip_str | ( | uint32_t | ip_u32, |
| char * | ip_str | ||
| ) |
Writes the corresponding string representing an IPv4 stored in the input DWORD (32-bit) integer.
| [in] | ip_u32 | Input DWORD to translate into string. |
| [out] | ip_str | Resulting string matching the input DWORD. |
| void uint8_to_hex_str | ( | uint8_t | num, |
| char * | str | ||
| ) |
Converts a 8-bit number to its hexadecimal string representation.
| [in] | num | Number to convert. |
| [out] | str | Converted equivalent string. Must have room for at least 3 characters to guarantee an overrun will not accur. |
| uint16_t uint8_to_str | ( | uint8_t | num, |
| char * | str | ||
| ) |
Converts an unsigned 8-bit number to its character string representation.
| [in] | num | Input number to convert. |
| [out] | str | String representing the input number. |
| int version_cmp | ( | const uint8_t | old[3], |
| const uint8_t | cur[3] | ||
| ) |
Compares two version number arrays (major, minor, micro).
| [in] | old | Old version numbers |
| [in] | cur | New version numbers against to compare |
| int version_to_str | ( | const uint8_t | version[3], |
| char * | str | ||
| ) |
Converts version numbers (major, minor, micro) into its string representation [major].[minor].[micro].
| [in] | version | Version numbers |
| [out] | str | Converted version string from version numbers. |