This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository terminology.

View the commit online.

commit 682edf79dc8a4897c8aa51ac3dfae7b8a050caa2
Author: Boris Faure <bill...@gmail.com>
AuthorDate: Wed Aug 16 17:28:59 2023 +0200

    utils: add ty_eina_unicode_base64_encode()
---
 src/bin/main.c       |  2 ++
 src/bin/tytest.c     |  3 +++
 src/bin/unit_tests.h |  1 +
 src/bin/utils.c      | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/bin/utils.h      |  1 +
 5 files changed, 62 insertions(+)

diff --git a/src/bin/main.c b/src/bin/main.c
index 854753a..5384e26 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -911,6 +911,7 @@ elm_main(int argc, char **argv)
         goto end;
      }
 
+   emile_init();
    ecore_con_init();
    ecore_con_url_init();
 
@@ -1069,6 +1070,7 @@ elm_main(int argc, char **argv)
 
    ecore_con_url_shutdown();
    ecore_con_shutdown();
+   emile_shutdown();
 
    instance.config = NULL;
  end:
diff --git a/src/bin/tytest.c b/src/bin/tytest.c
index 236c03a..b9d1d99 100644
--- a/src/bin/tytest.c
+++ b/src/bin/tytest.c
@@ -41,6 +41,7 @@ static struct {
        { "color_parse_css_rgb", tytest_color_parse_css_rgb},
        { "color_parse_css_hsl", tytest_color_parse_css_hsl},
        { "extn_matching", tytest_extn_matching},
+       { "base64", tytest_base64},
        { NULL, NULL},
 };
 
@@ -212,6 +213,7 @@ main(int argc, char **argv)
      return _run_tytests(argc, argv);
 
    eina_init();
+   emile_init();
 
    _log_domain = eina_log_domain_register("tytest", NULL);
 
@@ -223,6 +225,7 @@ main(int argc, char **argv)
 
    tytest_common_shutdown();
 
+   emile_shutdown();
    eina_shutdown();
 
    return 0;
diff --git a/src/bin/unit_tests.h b/src/bin/unit_tests.h
index 543ee8c..ed3ddd9 100644
--- a/src/bin/unit_tests.h
+++ b/src/bin/unit_tests.h
@@ -18,5 +18,6 @@ int tytest_color_parse_edc(void);
 int tytest_color_parse_css_rgb(void);
 int tytest_color_parse_css_hsl(void);
 int tytest_extn_matching(void);
+int tytest_base64(void);
 
 #endif
diff --git a/src/bin/utils.c b/src/bin/utils.c
index 0a90aaa..3f94d53 100644
--- a/src/bin/utils.c
+++ b/src/bin/utils.c
@@ -1,8 +1,12 @@
 #include "private.h"
 #include "utils.h"
 #include "sb.h"
+
 #include <Ecore.h>
 #include <Ecore_File.h>
+#include <Emile.h>
+
+#include <assert.h>
 #include <unistd.h>
 #include <pwd.h>
 
@@ -72,3 +76,54 @@ end:
    free(escaped);
    free(s);
 }
+
+char *
+ty_eina_unicode_base64_encode(Eina_Unicode *unicode)
+{
+   int utf8_len = 0;
+   Eina_Binbuf *bb;
+   char *src;
+   char *res;
+   Eina_Strbuf *sb;
+
+   src = "" &utf8_len);
+   bb = eina_binbuf_manage_new((const unsigned char*)src, utf8_len, EINA_FALSE);
+
+   sb = emile_base64_encode(bb);
+
+   eina_binbuf_free(bb);
+   res = (char*) eina_strbuf_string_steal(sb);
+   eina_strbuf_free(sb);
+   return res;
+}
+
+#if defined(BINARY_TYTEST)
+int tytest_base64(void)
+{
+   Eina_Unicode *src;
+   char *res;
+   const char *expected;
+
+
+   const char *terminology = "Terminology rox!";
+   src = "" NULL);
+   res = ty_eina_unicode_base64_encode(src);
+   assert(res);
+   expected = "VGVybWlub2xvZ3kgcm94IQ==";
+   assert(memcmp(res, expected, strlen(expected)) == 0);
+   free(src);
+   free(res);
+
+
+   const char *hearts = "♥♡👍🚲✿ ❀ ❁🙌";
+   src = "" NULL);
+   res = ty_eina_unicode_base64_encode(src);
+   assert(res);
+   expected = "4pml4pmh8J+RjfCfmrLinL8g4p2AIOKdgfCfmYw=";
+   assert(memcmp(res, expected, strlen(expected)) == 0);
+   free(src);
+   free(res);
+
+   return 0;
+}
+#endif
diff --git a/src/bin/utils.h b/src/bin/utils.h
index f905c48..92d7f41 100644
--- a/src/bin/utils.h
+++ b/src/bin/utils.h
@@ -7,4 +7,5 @@
 Eina_Bool homedir_get(char *buf, size_t size);
 void open_url(const Config *config, const char *url);
 
+char * ty_eina_unicode_base64_encode(Eina_Unicode *c);
 #endif

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to