diff --git a/dap-sdk/core/src/dap_common.c b/dap-sdk/core/src/dap_common.c index 0a7aa08e40deba922de8896e0a0a13b1f330d6a5..d36d88e4575a670ce1774896f706fbe4436932a1 100755 --- a/dap-sdk/core/src/dap_common.c +++ b/dap-sdk/core/src/dap_common.c @@ -190,7 +190,7 @@ const char * dap_get_appname() } /** - * @brief dap_set_appname + * @brief dap_set_appname set application name in global s_appname variable * @param a_appname * @return */ @@ -222,6 +222,16 @@ void dap_set_log_tag_width(size_t a_width) { * @param[in] a_log_file * @return */ + +/** + * @brief dap_common_init call this function before using dap sdk modules + * + * @param a_console_title set console title. Can be result of dap_get_appname() + * @param a_log_file_path path to log file. Saved in s_log_file_path variable + * @param a_log_dirpath path to log directory. Saved in s_log_dir_path variable + * @return int (0 if succcess, -1 if error) + */ + int dap_common_init( const char *a_console_title, const char *a_log_file_path, const char *a_log_dirpath) { // init randomer diff --git a/dap-sdk/core/src/dap_file_utils.c b/dap-sdk/core/src/dap_file_utils.c index 5844fcf3d712beaa08b1c617d4c8da43dfdebce3..30b3f7dc98effc0e4a69c5e6a0de728dcf81386f 100755 --- a/dap-sdk/core/src/dap_file_utils.c +++ b/dap-sdk/core/src/dap_file_utils.c @@ -114,12 +114,14 @@ bool dap_dir_test(const char * a_dir_path) return false; } + /** - * Create a new directory with intermediate sub-directories - * - * @dir_path new directory pathname - * @return 0, if the directory was created or already exist, else -1 + * @brief dap_mkdir_with_parents Create a new directory with intermediate sub-directories + * + * @param a_dir_path new directory pathname + * @return int 0, if the directory was created or already exist, else -1 */ + int dap_mkdir_with_parents(const char *a_dir_path) { // validation of a pointer diff --git a/dap-sdk/core/src/dap_strfuncs.c b/dap-sdk/core/src/dap_strfuncs.c index 118c040d0c300e38f7914faf20ca40bd923d5f15..f8944b88b34ef8fb956dfcb35036a7c188b07211 100755 --- a/dap-sdk/core/src/dap_strfuncs.c +++ b/dap-sdk/core/src/dap_strfuncs.c @@ -185,6 +185,14 @@ char *dap_itoa128(char *a_str, int128_t a_value, int a_base) * * Returns: length of the string */ + +/** + * @brief dap_strlen get length of the string + * + * @param a_str pointer to string + * @return size_t + */ + size_t dap_strlen(const char *a_str) { size_t l_length = 0; @@ -196,12 +204,13 @@ size_t dap_strlen(const char *a_str) } /** - * dap_strcmp: - * @a_str1: (nullable): the string - * @a_str2: (nullable): the string - * - * Compare a_str1 and a_str2 + * @brief dap_strcmp a_str1 and a_str2 + * + * @param a_str1 (nullable): the string + * @param a_str2 (nullable): the string + * @return int */ + int dap_strcmp(const char *a_str1, const char *a_str2) { if(a_str1 && a_str2) { @@ -211,12 +220,14 @@ int dap_strcmp(const char *a_str1, const char *a_str2) } /** - * dap_strcmp: - * @a_str1: (nullable): the string - * @a_str2: (nullable): the string - * - * Compare a_n characters of a_str1 and a_str2 + * @brief dap_strcmp + * + * @param a_str1 (nullable): the string + * @param a_str2 (nullable): the string + * @param a_n Compare a_n characters of a_str1 and a_str2 + * @return int */ + int dap_strncmp(const char *a_str1, const char *a_str2, size_t a_n) { if(a_str1 && a_str2) { @@ -225,16 +236,17 @@ int dap_strncmp(const char *a_str1, const char *a_str2, size_t a_n) return -1; } + /** - * dap_strdup: - * @a_str: (nullable): the string to duplicate - * + * @brief dap_strdup: * Duplicates a string. If @a_str is %NULL it returns %NULL. * The returned string should be freed * when no longer needed. * - * Returns: a newly-allocated copy of @a_str + * @param a_str (nullable): the string to duplicate + * @return char* duplicated string */ + char* dap_strdup(const char *a_str) { char *l_new_str; @@ -255,18 +267,21 @@ char* dap_strdup(const char *a_str) } /** - * dap_strdup_vprintf: - * @a_format: a standard printf() format string, but notice - * [string precision pitfalls][string-precision] - * @a_args: the list of parameters to insert into the format string - * + * @brief dap_strdup_vprintf + * * Similar to the standard C vsprintf() function but safer, since it * calculates the maximum space required and allocates memory to hold * the result. The returned string should be freed with DAP_DELETE() * when no longer needed. * * Returns: a newly-allocated string holding the result + * + * @param a_format a standard printf() format string, but notice + * [string precision pitfalls][string-precision] + * @param a_args the list of parameters to insert into the format string + * @return char* */ + char* dap_strdup_vprintf(const char *a_format, va_list a_args) { char *l_string = NULL; @@ -277,16 +292,18 @@ char* dap_strdup_vprintf(const char *a_format, va_list a_args) } /** - * dap_strdup_printf: - * @a_format: a standard printf() format string - * - * Similar to the standard C sprintf() function but safer, since it + * @brief dap_strdup_printf: + * + * * Similar to the standard C sprintf() function but safer, since it * calculates the maximum space required and allocates memory to hold * the result. The returned string should be freed with DAP_DELETE() * when no longer needed. - * - * Returns: a newly-allocated string holding the result + * + * @param a_format a standard printf() format string + * @param ... + * @return char* a newly-allocated string holding the result */ + char* dap_strdup_printf(const char *a_format, ...) { char *l_buffer; @@ -630,6 +647,13 @@ char** dap_strsplit(const char *a_string, const char *a_delimiter, int a_max_tok return l_str_array; } +/** + * @brief dap_str_countv + * + * @param a_str_array + * @return size_t + */ + size_t dap_str_countv(char **a_str_array) { size_t l_i = 0; @@ -642,16 +666,19 @@ size_t dap_str_countv(char **a_str_array) } /** - * dap_strdupv: - * @a_str_array: (nullable): a %NULL-terminated array of strings - * + * @brief dap_strdupv: + * + * @param a_str_array (nullable): a %NULL-terminated array of strings * Copies %NULL-terminated array of strings. The copy is a deep copy; * the new array should be freed by first freeing each string, then * the array itself. g_strfreev() does this for you. If called * on a %NULL value, g_strdupv() simply returns %NULL. * * Returns: (nullable): a new %NULL-terminated array of strings. + * + * @return char** */ + char** dap_strdupv(const char **a_str_array) { if(a_str_array) @@ -680,14 +707,16 @@ char** dap_strdupv(const char **a_str_array) } /** - * dap_strfreev: - * @a_str_array: (nullable): a %NULL-terminated array of strings to free - * + * @brief dap_strfreev: + * * Frees a %NULL-terminated array of strings, as well as each * string it contains. * * If @a_str_array is %NULL, this function simply returns. + * + * @param a_str_array (nullable): a %NULL-terminated array of strings to free */ + void dap_strfreev(char **a_str_array) { if(a_str_array) @@ -701,9 +730,8 @@ void dap_strfreev(char **a_str_array) } /** - * dap_strchug: - * @a_string: a string to remove the leading whitespace from - * + * @brief dap_strchug: + * * Removes leading whitespace from a string, by moving the rest * of the characters forward. * @@ -713,7 +741,11 @@ void dap_strfreev(char **a_str_array) * * The pointer to @a_string is returned to allow the nesting of functions. * Returns: @a_string + * + * @param a_string a string to remove the leading whitespace from + * @return char* */ + char* dap_strchug(char *a_string) { unsigned char *l_start; @@ -760,15 +792,18 @@ char* dap_strchomp(char *a_string) } /** - * dap_strup: - * @a_str: a string - * @a_len: length of @a_str in bytes, or -1 if @a_str is nul-terminated - * + * @brief dap_strup + * * Converts all lower case ASCII letters to upper case ASCII letters. * * Returns: a newly allocated string, with all the lower case * characters in @a_str converted to upper case + * + * @param a_str a string + * @param a_len length of @a_str in bytes, or -1 if @a_str is nul-terminated + * @return char* */ + char* dap_strup(const char *a_str, ssize_t a_len) { char *l_result, *l_s; @@ -786,15 +821,17 @@ char* dap_strup(const char *a_str, ssize_t a_len) } /** - * dap_strdown: - * @a_str: a string - * @a_len: length of @a_str in bytes, or -1 if @a_str is nul-terminated - * - * Converts all upper case ASCII letters to lower case ASCII letters. + * @brief dap_strdown + * Converts all upper case ASCII letters to lower case ASCII letters. * * Returns: a newly-allocated string, with all the upper case * characters in @a_str converted to lower case + * + * @param a_str a string + * @param a_len length of @a_str in bytes, or -1 if @a_str is nul-terminated + * @return char* */ + char* dap_strdown(const char *a_str, ssize_t a_len) { char *l_result, *l_s; @@ -811,10 +848,9 @@ char* dap_strdown(const char *a_str, ssize_t a_len) return l_result; } + /** - * dap_strreverse: - * @a_string: the string to reverse - * + * @brief dap_strreverse * Reverses all of the bytes in a string. For example, * `dap_strreverse("abcdef")` will result in "fedcba". * @@ -822,7 +858,11 @@ char* dap_strdown(const char *a_str, ssize_t a_len) * containing multibyte characters. * * Returns: the same pointer passed in as @a_string + * + * @param a_string the string to reverse + * @return char* */ + char* dap_strreverse(char *a_string) { dap_return_val_if_fail(a_string != NULL, NULL); @@ -857,6 +897,14 @@ char *strptime( char *buff, const char *fmt, struct tm *tm ) { return buff + len; } +/** + * @brief _strndup + * + * @param str + * @param len + * @return char* + */ + char *_strndup(const char *str, unsigned long len) { char *buf = (char*)memchr(str, '\0', len); if (buf) diff --git a/dap-sdk/crypto/src/dap_cert.c b/dap-sdk/crypto/src/dap_cert.c index 920e16678ad35a37c074412ef3e620b6850ffceb..131b7415c5a152a088c75a78f4715d181bbb83d9 100755 --- a/dap-sdk/crypto/src/dap_cert.c +++ b/dap-sdk/crypto/src/dap_cert.c @@ -73,7 +73,7 @@ static dap_cert_item_t * s_certs = NULL; static dap_cert_folder_t * s_cert_folders = NULL; /** - * @brief dap_cert_init + * @brief dap_cert_init empty stub for certificate init * @return */ int dap_cert_init() diff --git a/dap-sdk/crypto/src/dap_enc.c b/dap-sdk/crypto/src/dap_enc.c index bb388202b73abac4f794c96408768490c7ad4102..507d62b52553d8e6e0eaab3ff8147b3bf351037d 100755 --- a/dap-sdk/crypto/src/dap_enc.c +++ b/dap-sdk/crypto/src/dap_enc.c @@ -35,9 +35,11 @@ #define LOG_TAG "dap_enc" /** - * @brief enc_init - * @return + * @brief dap_enc_init if you want to use crypto functions from dap-sdk call that function + * + * @return int */ + int dap_enc_init() { srand(time(NULL)); diff --git a/dap-sdk/crypto/src/dap_enc_base58.c b/dap-sdk/crypto/src/dap_enc_base58.c index 84282f26f97c1b9da2101a7b8274f93091f89f06..ad6c897a31beddb1ee04489d91bdbc19c10e389f 100755 --- a/dap-sdk/crypto/src/dap_enc_base58.c +++ b/dap-sdk/crypto/src/dap_enc_base58.c @@ -46,10 +46,10 @@ const int8_t c_b58digits_map[] = { }; /** - * @brief dap_enc_base58_decode - * @param a_in - * @param a_out - * @return + * @brief dap_enc_base58_decode decode string using base58 alghoritm + * @param a_in - encoded string + * @param a_out - output buffer + * @return size_t output buffer size */ size_t dap_enc_base58_decode(const char * a_in, void * a_out) { @@ -152,8 +152,14 @@ size_t dap_enc_base58_decode(const char * a_in, void * a_out) } - -//bool b58enc(char *a_out, size_t *l_out_size, const void *a_in, size_t a_in_size) +/** + * @brief dap_enc_base58_encode encode string in Base58 alghorithm + * + * @param a_in - input buffer + * @param a_in_size - buffer size + * @param a_out - string with results + * @return size_t - returned string size (in bytes) + */ size_t dap_enc_base58_encode(const void * a_in, size_t a_in_size, char * a_out) { const uint8_t *l_in_u8 = a_in; diff --git a/dap-sdk/crypto/src/dap_enc_key.c b/dap-sdk/crypto/src/dap_enc_key.c index 580127163d885d223b3d0857a501dde984c170f7..8d4c458ae07f8f42cae459bfb52610cc448de940 100755 --- a/dap-sdk/crypto/src/dap_enc_key.c +++ b/dap-sdk/crypto/src/dap_enc_key.c @@ -351,7 +351,7 @@ struct dap_enc_key_callbacks{ const size_t c_callbacks_size = sizeof(s_callbacks) / sizeof(s_callbacks[0]); /** - * @brief dap_enc_key_init + * @brief dap_enc_key_init empty stub * @return */ int dap_enc_key_init()