From 18c3ee447771d9c3ae86d901d82ea74e1f6463a3 Mon Sep 17 00:00:00 2001
From: Dmtiriy Gerasimov <naeper@demlabs.net>
Date: Wed, 24 Apr 2019 14:45:37 +0700
Subject: [PATCH] [+] uint64 config get param [*] ifndef/define changed to
 pragma once [*] dap_strdupv() changed its argument:   char ** -> const char
 **

---
 core/dap_config.c   | 26 ++++++++++++++++++++++++++
 core/dap_config.h   |  3 +++
 core/dap_strfuncs.c |  2 +-
 core/dap_strfuncs.h |  8 ++++----
 4 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/core/dap_config.c b/core/dap_config.c
index 7ae3f11..5e835f1 100755
--- a/core/dap_config.c
+++ b/core/dap_config.c
@@ -350,6 +350,18 @@ int64_t dap_config_get_item_int64(dap_config_t * a_config, const char * a_sectio
     return atoll(dap_config_get_item_str(a_config,a_section_path,a_item_name));
 }
 
+/**
+ * @brief dap_config_get_item_uint64
+ * @param a_config
+ * @param a_section_path
+ * @param a_item_name
+ * @return
+ */
+uint64_t dap_config_get_item_uint64(dap_config_t * a_config, const char * a_section_path, const char * a_item_name)
+{
+    return (uint64_t) atoll(dap_config_get_item_str(a_config,a_section_path,a_item_name));
+}
+
 /**
  * @brief dap_config_get_item_uint16
  * @param a_config
@@ -405,6 +417,20 @@ int64_t dap_config_get_item_int64_default(dap_config_t * a_config, const char *
     return l_str_ret? (int64_t) atoll(l_str_ret):a_default;
 }
 
+/**
+ * @brief dap_config_get_item_int64_default
+ * @param a_config
+ * @param a_section_path
+ * @param a_item_name
+ * @param a_default
+ * @return
+ */
+uint64_t dap_config_get_item_int64_default(dap_config_t * a_config, const char * a_section_path, const char * a_item_name, uint64_t a_default)
+{
+    const char * l_str_ret = dap_config_get_item_str(a_config,a_section_path,a_item_name);
+    return l_str_ret? (uint64_t) atoll(l_str_ret):a_default;
+}
+
 
 /**
  * @brief dap_config_get_item Get the configuration as a item
diff --git a/core/dap_config.h b/core/dap_config.h
index c07b5db..227e281 100755
--- a/core/dap_config.h
+++ b/core/dap_config.h
@@ -54,6 +54,9 @@ int32_t dap_config_get_item_int32_default(dap_config_t * a_config, const char *
 int64_t dap_config_get_item_int64(dap_config_t * a_config, const char * a_section_path, const char * a_item_name);
 int64_t dap_config_get_item_int64_default(dap_config_t * a_config, const char * a_section_path, const char * a_item_name, int64_t a_default);
 
+uint64_t dap_config_get_item_uint64(dap_config_t * a_config, const char * a_section_path, const char * a_item_name);
+uint64_t dap_config_get_item_uint64_default(dap_config_t * a_config, const char * a_section_path, const char * a_item_name, uint64_t a_default);
+
 const char * dap_config_get_item_str(dap_config_t * a_config, const char * a_section_path, const char * a_item_name);
 const char * dap_config_get_item_str_default(dap_config_t * a_config, const char * a_section_path, const char * a_item_name, const char * a_value_default);
 char** dap_config_get_array_str(dap_config_t * a_config, const char * a_section_path,
diff --git a/core/dap_strfuncs.c b/core/dap_strfuncs.c
index 88dff5d..db69ec7 100755
--- a/core/dap_strfuncs.c
+++ b/core/dap_strfuncs.c
@@ -439,7 +439,7 @@ int dap_str_countv(char **a_str_array)
  *
  * Returns: (nullable): a new %NULL-terminated array of strings.
  */
-char** dap_strdupv(char **a_str_array)
+char** dap_strdupv(const char **a_str_array)
 {
     if(a_str_array)
     {
diff --git a/core/dap_strfuncs.h b/core/dap_strfuncs.h
index eb2d824..46051b4 100755
--- a/core/dap_strfuncs.h
+++ b/core/dap_strfuncs.h
@@ -1,7 +1,8 @@
 /* DAP String Functions */
 
-#ifndef __DAP_STR_FUNC_H
-#define __DAP_STR_FUNC_H
+#pragma once
+
+#include <sys/types.h>
 
 #include <limits.h>
 #include <stdbool.h>
@@ -42,7 +43,7 @@ char* dap_strjoin(const char *a_separator, ...);
 char** dap_strsplit(const char *a_string, const char *a_delimiter, int a_max_tokens);
 int dap_str_countv(char **a_str_array);
 // copies a NULL-terminated array of strings
-char** dap_strdupv(char **a_str_array);
+char** dap_strdupv(const char **a_str_array);
 // frees the array itself and all of its strings.
 void dap_strfreev(char **a_str_array);
 
@@ -62,4 +63,3 @@ char* dap_strreverse(char *a_string);
 #define DAP_USEC_PER_SEC 1000000
 void dap_usleep(time_t a_microseconds);
 
-#endif /* __DAP_STR_FUNC_H */
-- 
GitLab