This commit is contained in:
Edgar 2022-03-04 12:02:18 +01:00
parent 7fbcaa6d36
commit a7c25964f4
No known key found for this signature in database
GPG key ID: 8731E6C0166EAA85
2 changed files with 327 additions and 359 deletions

View file

@ -2257,7 +2257,7 @@ INCLUDE_FILE_PATTERNS =
# recursively expanded use the := operator instead of the = operator. # recursively expanded use the := operator instead of the = operator.
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
PREDEFINED = PREDEFINED = CONF_FAMILY_UNIX CONF_MYSQL CONF_DISCORD CONF_OPENSSL CONF_UPNP CONF_VIDEORECORDER CONF_ANTIBOT
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
# tag can be used to specify a list of macro names that should be expanded. The # tag can be used to specify a list of macro names that should be expanded. The

View file

@ -1050,433 +1050,401 @@ int net_tcp_send(NETSOCKET sock, const void *data, int size);
*/ */
int net_tcp_recv(NETSOCKET sock, void *data, int maxsize); int net_tcp_recv(NETSOCKET sock, void *data, int maxsize);
/* /**
Function: net_tcp_close * Closes a TCP socket.
Closes a TCP socket. *
* @ingroup Network-TCP
Parameters: *
sock - Socket to close. * @param sock Socket to close.
*
Returns: * @return 0 on success. Negative value on failure.
Returns 0 on success. Negative value on failure. */
*/
int net_tcp_close(NETSOCKET sock); int net_tcp_close(NETSOCKET sock);
#if defined(CONF_FAMILY_UNIX) #if defined(CONF_FAMILY_UNIX)
/* Group: Network Unix Sockets */ /**
* @defgroup Network-Unix-Sockets
* @ingroup Network-General
*/
/* /**
Function: net_unix_create_unnamed * Creates an unnamed unix datagram socket.
Creates an unnamed unix datagram socket. *
* @ingroup Network-Unix-Sockets
Returns: *
On success it returns a handle to the socket. On failure it returns -1. * @return On success it returns a handle to the socket. On failure it returns -1.
*/ */
UNIXSOCKET net_unix_create_unnamed(); UNIXSOCKET net_unix_create_unnamed();
/* /**
Function: net_unix_send * Sends data to a Unix socket.
Sends data to a Unix socket. *
* @ingroup Network-Unix-Sockets
Parameters: *
sock - Socket to use. * @param sock Socket to use.
addr - Where to send the packet. * @param addr Where to send the packet.
data - Pointer to the packet data to send. * @param data Pointer to the packet data to send.
size - Size of the packet. * @param size Size of the packet.
*
Returns: * @return Number of bytes sent. Negative value on failure.
Number of bytes sent. Negative value on failure. */
*/
int net_unix_send(UNIXSOCKET sock, UNIXSOCKETADDR *addr, void *data, int size); int net_unix_send(UNIXSOCKET sock, UNIXSOCKETADDR *addr, void *data, int size);
/* /**
Function: net_unix_set_addr * Sets the unixsocketaddress for a path to a socket file.
Sets the unixsocketaddress for a path to a socket file. *
* @ingroup Network-Unix-Sockets
Parameters: *
addr - Pointer to the addressstruct to fill. * @param addr Pointer to the addressstruct to fill.
path - Path to the (named) unix socket. * @param path Path to the (named) unix socket.
*/ */
void net_unix_set_addr(UNIXSOCKETADDR *addr, const char *path); void net_unix_set_addr(UNIXSOCKETADDR *addr, const char *path);
/* /**
Function: net_unix_close * Closes a Unix socket.
Closes a Unix socket. *
* @ingroup Network-Unix-Sockets
Parameters: *
sock - Socket to close. * @param sock Socket to close.
*/ */
void net_unix_close(UNIXSOCKET sock); void net_unix_close(UNIXSOCKET sock);
#endif #endif
/* Group: Strings */ /**
* @defgroup Strings
*
* String related functions.
*/
/* /**
Function: str_append * Appends a string to another.
Appends a string to another. *
* @ingroup Strings
Parameters: *
dst - Pointer to a buffer that contains a string. * @param dst Pointer to a buffer that contains a string.
src - String to append. * @param src String to append.
dst_size - Size of the buffer of the dst string. * @param dst_size Size of the buffer of the dst string.
*
Remarks: * @remark The strings are treated as zero-terminated strings.
- The strings are treated as zero-terminated strings. * @remark Guarantees that dst string will contain zero-termination.
- Guarantees that dst string will contain zero-termination. */
*/
void str_append(char *dst, const char *src, int dst_size); void str_append(char *dst, const char *src, int dst_size);
/* /**
Function: str_copy * Copies a string to another.
Copies a string to another. *
* @ingroup Strings
Parameters: *
dst - Pointer to a buffer that shall receive the string. * @param dst Pointer to a buffer that shall receive the string.
src - String to be copied. * @param src String to be copied.
dst_size - Size of the buffer dst. * @param dst_size Size of the buffer dst.
*
Remarks: * @remark The strings are treated as zero-terminated strings.
- The strings are treated as zero-terminated strings. * @remark Guarantees that dst string will contain zero-termination.
- Guarantees that dst string will contain zero-termination. */
*/
void str_copy(char *dst, const char *src, int dst_size); void str_copy(char *dst, const char *src, int dst_size);
/* /**
Function: str_utf8_truncate * Truncates a utf8 encoded string to a given length.
Truncates a utf8 encoded string to a given length. *
* @ingroup Strings
Parameters: *
dst - Pointer to a buffer that shall receive the string. * @param dst Pointer to a buffer that shall receive the string.
dst_size - Size of the buffer dst. * @param dst_size Size of the buffer dst.
str - String to be truncated. * @param str String to be truncated.
truncation_len - Maximum codepoints in the returned string. * @param truncation_len Maximum codepoints in the returned string.
*
Remarks: * @remark The strings are treated as utf8-encoded zero-terminated strings.
- The strings are treated as utf8-encoded zero-terminated strings. * @remark Guarantees that dst string will contain zero-termination.
- Guarantees that dst string will contain zero-termination. */
*/
void str_utf8_truncate(char *dst, int dst_size, const char *src, int truncation_len); void str_utf8_truncate(char *dst, int dst_size, const char *src, int truncation_len);
/* /**
Function: str_truncate * Truncates a string to a given length.
Truncates a string to a given length. *
* @ingroup Strings
Parameters: *
dst - Pointer to a buffer that shall receive the string. * @param dst Pointer to a buffer that shall receive the string.
dst_size - Size of the buffer dst. * @param dst_size Size of the buffer dst.
src - String to be truncated. * @param src String to be truncated.
truncation_len - Maximum length of the returned string (not * @param truncation_len Maximum length of the returned string (not
counting the zero termination). * counting the zero termination).
*
Remarks: * @remark The strings are treated as zero-terminated strings.
- The strings are treated as zero-terminated strings. * @remark Garantees that dst string will contain zero-termination.
- Garantees that dst string will contain zero-termination. */
*/
void str_truncate(char *dst, int dst_size, const char *src, int truncation_len); void str_truncate(char *dst, int dst_size, const char *src, int truncation_len);
/* /**
Function: str_length * Returns the length of a zero terminated string.
Returns the length of a zero terminated string. *
* @ingroup Strings
Parameters: *
str - Pointer to the string. * @param str Pointer to the string.
*
Returns: * @return Length of string in bytes excluding the zero termination.
Length of string in bytes excluding the zero termination.
*/ */
int str_length(const char *str); int str_length(const char *str);
/* /**
Function: str_format * Performs printf formatting into a buffer.
Performs printf formatting into a buffer. *
* @ingroup Strings
Parameters: *
buffer - Pointer to the buffer to receive the formatted string. * @param buffer Pointer to the buffer to receive the formatted string.
buffer_size - Size of the buffer. * @param buffer_size Size of the buffer.
format - printf formatting string. * @param format printf formatting string.
... - Parameters for the formatting. * @param ... Parameters for the formatting.
*
Returns: * @return Length of written string, even if it has been truncated
Length of written string, even if it has been truncated *
* @remark See the C manual for syntax for the printf formatting string.
Remarks: * @remark The strings are treated as zero-terminated strings.
- See the C manual for syntax for the printf formatting string. * @remark Guarantees that dst string will contain zero-termination.
- The strings are treated as zero-terminated strings. */
- Guarantees that dst string will contain zero-termination.
*/
int str_format(char *buffer, int buffer_size, const char *format, ...) int str_format(char *buffer, int buffer_size, const char *format, ...)
GNUC_ATTRIBUTE((format(printf, 3, 4))); GNUC_ATTRIBUTE((format(printf, 3, 4)));
/* /**
Function: str_trim_words * Trims specific number of words at the start of a string.
Trims specific number of words at the start of a string. *
* @ingroup Strings
Parameters: *
str - String to trim the words from. * @param str String to trim the words from.
words - Count of words to trim. * @param words Count of words to trim.
*
Returns: * @return Trimmed string
Trimmed string *
* @remark The strings are treated as zero-terminated strings.
Remarks: */
- The strings are treated as zero-terminated strings.
*/
char *str_trim_words(char *str, int words); char *str_trim_words(char *str, int words);
/* /**
Function: str_sanitize_cc * Replaces all characters below 32 with whitespace.
Replaces all characters below 32 with whitespace. *
* @ingroup Strings
Parameters: *
str - String to sanitize. * @param str String to sanitize.
*
Remarks: * @remark The strings are treated as zero-terminated strings.
- The strings are treated as zero-terminated strings. */
*/
void str_sanitize_cc(char *str); void str_sanitize_cc(char *str);
/* /**
Function: str_sanitize * Replaces all characters below 32 with whitespace with
Replaces all characters below 32 with whitespace with * exception to \t, \n and \r.
exception to \t, \n and \r. *
* @ingroup Strings
Parameters: *
str - String to sanitize. * @param str String to sanitize.
*
Remarks: * @remark The strings are treated as zero-terminated strings.
- The strings are treated as zero-terminated strings.
*/ */
void str_sanitize(char *str); void str_sanitize(char *str);
/* /**
Function: str_sanitize_filename * Replaces all invalid filename characters with whitespace.
Replaces all invalid filename characters with whitespace. *
* @param str String to sanitize.
Parameters: *
str - String to sanitize. * @remark The strings are treated as zero-terminated strings.
Remarks:
- The strings are treated as zero-terminated strings.
*/ */
void str_sanitize_filename(char *str); void str_sanitize_filename(char *str);
/* /**
Function: str_clean_whitespaces * Removes leading and trailing spaces and limits the use of multiple spaces.
Removes leading and trailing spaces and limits the use of multiple spaces. *
Parameters: * @ingroup Strings
str - String to clean up *
Remarks: * @param str String to clean up
- The strings are treated as zero-termineted strings. *
*/ * @remark The strings are treated as zero-termineted strings.
*/
void str_clean_whitespaces(char *str); void str_clean_whitespaces(char *str);
/* /**
Function: str_skip_to_whitespace * Skips leading non-whitespace characters(all but ' ', '\t', '\n', '\r').
Skips leading non-whitespace characters(all but ' ', '\t', '\n', '\r'). *
* @ingroup Strings
Parameters: *
str - Pointer to the string. * @param str Pointer to the string.
*
Returns: * @return Pointer to the first whitespace character found
Pointer to the first whitespace character found * within the string.
within the string. *
* @remark The strings are treated as zero-terminated strings.
Remarks: */
- The strings are treated as zero-terminated strings.
*/
char *str_skip_to_whitespace(char *str); char *str_skip_to_whitespace(char *str);
/* /**
Function: str_skip_to_whitespace_const * @ingroup Strings
See str_skip_to_whitespace. * @see str_skip_to_whitespace
*/ */
const char *str_skip_to_whitespace_const(const char *str); const char *str_skip_to_whitespace_const(const char *str);
/* /**
Function: str_skip_whitespaces * Skips leading whitespace characters(' ', '\t', '\n', '\r').
Skips leading whitespace characters(' ', '\t', '\n', '\r'). *
* @ingroup Strings
Parameters: *
str - Pointer to the string. * @param str Pointer to the string.
*
Returns: * Pointer to the first non-whitespace character found
Pointer to the first non-whitespace character found * within the string.
within the string. *
* @remark The strings are treated as zero-terminated strings.
Remarks:
- The strings are treated as zero-terminated strings.
*/ */
char *str_skip_whitespaces(char *str); char *str_skip_whitespaces(char *str);
/* /**
Function: str_skip_whitespaces_const * @ingroup Strings
See str_skip_whitespaces. * @see str_skip_whitespaces
*/ */
const char *str_skip_whitespaces_const(const char *str); const char *str_skip_whitespaces_const(const char *str);
/* /**
Function: str_comp_nocase * Compares to strings case insensitively.
Compares to strings case insensitively. *
* @ingroup Strings
Parameters: *
a - String to compare. * @param a String to compare.
b - String to compare. * @param b String to compare.
*
Returns: * @return `< 0` - String a is less than string b
<0 - String a is less than string b * @return `0` - String a is equal to string b
0 - String a is equal to string b * @return `> 0` - String a is greater than string b
>0 - String a is greater than string b *
* @remark Only guaranteed to work with a-z/A-Z.
Remarks: * @remark The strings are treated as zero-terminated strings.
- Only guaranteed to work with a-z/A-Z. */
- The strings are treated as zero-terminated strings.
*/
int str_comp_nocase(const char *a, const char *b); int str_comp_nocase(const char *a, const char *b);
/* /**
Function: str_comp_nocase_num * Compares up to num characters of two strings case insensitively.
Compares up to num characters of two strings case insensitively. *
* @ingroup Strings
Parameters: *
a - String to compare. * @param a String to compare.
b - String to compare. * @param b String to compare.
num - Maximum characters to compare * @param num Maximum characters to compare
*
Returns: * @return `< 0` - String a is less than string b
<0 - String a is less than string b * @return `0` - String a is equal to string b
0 - String a is equal to string b * @return `> 0` - String a is greater than string b
>0 - String a is greater than string b *
* @remark Only guaranteed to work with a-z/A-Z.
Remarks: * (use str_utf8_comp_nocase_num for unicode support)
- Only guaranteed to work with a-z/A-Z. * @remark The strings are treated as zero-terminated strings.
(use str_utf8_comp_nocase_num for unicode support) */
- The strings are treated as zero-terminated strings.
*/
int str_comp_nocase_num(const char *a, const char *b, int num); int str_comp_nocase_num(const char *a, const char *b, int num);
/* /**
Function: str_comp * Compares two strings case sensitive.
Compares two strings case sensitive. *
* @ingroup Strings
Parameters: *
a - String to compare. * @param a String to compare.
b - String to compare. * @param b String to compare.
*
Returns: * @return `< 0` - String a is less than string b
<0 - String a is less than string b * @return `0` - String a is equal to string b
0 - String a is equal to string b * @return `> 0` - String a is greater than string b
>0 - String a is greater than string b *
* @remark The strings are treated as zero-terminated strings.
Remarks: */
- The strings are treated as zero-terminated strings.
*/
int str_comp(const char *a, const char *b); int str_comp(const char *a, const char *b);
/* /**
Function: str_comp_num * Compares up to num characters of two strings case sensitive.
Compares up to num characters of two strings case sensitive. *
* @ingroup Strings
Parameters: *
a - String to compare. * @param a String to compare.
b - String to compare. * @param b String to compare.
num - Maximum characters to compare * @param num Maximum characters to compare
*
Returns: * @return `< 0` - String a is less than string b
<0 - String a is less than string b * @return `0` - String a is equal to string b
0 - String a is equal to string b * @return `> 0` - String a is greater than string b
>0 - String a is greater than string b *
* @remark The strings are treated as zero-terminated strings.
Remarks:
- The strings are treated as zero-terminated strings.
*/ */
int str_comp_num(const char *a, const char *b, int num); int str_comp_num(const char *a, const char *b, int num);
/* /**
Function: str_comp_filenames * Compares two strings case sensitive, digit chars will be compared as numbers.
Compares two strings case sensitive, digit chars will be compared as numbers. *
* @ingroup Strings
Parameters: *
a - String to compare. * @param a String to compare.
b - String to compare. * @param b String to compare.
*
Returns: * @return `< 0` - String a is less than string b
<0 - String a is less than string b * @return `0` - String a is equal to string b
0 - String a is equal to string b * @return `> 0` - String a is greater than string b
>0 - String a is greater than string b *
* @remark The strings are treated as zero-terminated strings.
Remarks: */
- The strings are treated as zero-terminated strings.
*/
int str_comp_filenames(const char *a, const char *b); int str_comp_filenames(const char *a, const char *b);
/* /**
Function: str_startswith * Checks whether the string begins with a certain prefix.
Checks whether the string begins with a certain prefix. *
* @ingroup Strings
Parameter: *
str - String to check. * @param str String to check.
prefix - Prefix to look for. * @param prefix Prefix to look for.
*
Returns: * @return A pointer to the string str after the string prefix, or 0 if
A pointer to the string str after the string prefix, or 0 if * the string prefix isn't a prefix of the string str.
the string prefix isn't a prefix of the string str. *
* @remark The strings are treated as zero-terminated strings.
Remarks: */
- The strings are treated as zero-terminated strings.
*/
const char *str_startswith(const char *str, const char *prefix); const char *str_startswith(const char *str, const char *prefix);
/* /**
Function: str_endswith * Checks whether the string ends with a certain suffix.
Checks whether the string ends with a certain suffix. *
* @ingroup Strings
Parameter: *
str - String to check. * @param str String to check.
suffix - Suffix to look for. * @param suffix Suffix to look for.
*
Returns: * @return A pointer to the beginning of the suffix in the string str, or
A pointer to the beginning of the suffix in the string str, or * 0 if the string suffix isn't a suffix of the string str.
0 if the string suffix isn't a suffix of the string str. *
* @return The strings are treated as zero-terminated strings.
Remarks:
- The strings are treated as zero-terminated strings.
*/ */
const char *str_endswith(const char *str, const char *suffix); const char *str_endswith(const char *str, const char *suffix);
/* /**
Function: str_utf8_dist * Computes the edit distance between two strings.
Computes the edit distance between two strings. *
* @param a First string for the edit distance.
Parameters: * @param b Second string for the edit distance.
a - First string for the edit distance. *
b - Second string for the edit distance. * @return The edit distance between the both strings.
*
Returns: * @remark The strings are treated as zero-terminated strings.
The edit distance between the both strings.
Remarks:
- The strings are treated as zero-terminated strings.
*/ */
int str_utf8_dist(const char *a, const char *b); int str_utf8_dist(const char *a, const char *b);
/* /**
Function: str_utf8_dist_buffer * Computes the edit distance between two strings, allows buffers
Computes the edit distance between two strings, allows buffers * to be passed in.
to be passed in. *
* @ingroup Strings
Parameters: *
a - First string for the edit distance. * @param a - First string for the edit distance.
b - Second string for the edit distance. * @param b - Second string for the edit distance.
buf - Buffer for the function. * @param buf - Buffer for the function.
buf_len - Length of the buffer, must be at least as long as * @param buf_len Length of the buffer, must be at least as long as
twice the length of both strings combined plus two. * twice the length of both strings combined plus two.
*
Returns: * @return The edit distance between the both strings.
The edit distance between the both strings. *
* @remark The strings are treated as zero-terminated strings.
Remarks:
- The strings are treated as zero-terminated strings.
*/ */
int str_utf8_dist_buffer(const char *a, const char *b, int *buf, int buf_len); int str_utf8_dist_buffer(const char *a, const char *b, int *buf, int buf_len);