cedric pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=65758a21606b07af6745f602473750986af648a2
commit 65758a21606b07af6745f602473750986af648a2 Author: Shilpa Singh <[email protected]> Date: Wed Sep 23 14:27:43 2015 -0700 eina: add example for eina_tmpstr. Summary: Example for eina_tmpstr added. Example tests for eina_tmpstr_add_length, eina_tmpstr_len, eina_tmpstr_del and eina_tmpstr_strftime APIs Signed-Off By: Shilpa Singh <[email protected]> Reviewers: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D3087 Signed-off-by: Cedric BAIL <[email protected]> --- src/examples/eina/Makefile.am | 2 ++ src/examples/eina/eina_tmpstr_01.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/examples/eina/Makefile.am b/src/examples/eina/Makefile.am index 92819c7..bb108b5 100644 --- a/src/examples/eina/Makefile.am +++ b/src/examples/eina/Makefile.am @@ -39,6 +39,7 @@ eina_inlist_03.c \ eina_str_01.c \ eina_strbuf_01.c \ eina_stringshare_01.c \ +eina_tmpstr_01.c \ eina_tiler_01.c \ eina_simple_xml_parser_01.c \ eina_value_01.c \ @@ -84,6 +85,7 @@ eina_inlist_03 \ eina_str_01 \ eina_strbuf_01 \ eina_stringshare_01 \ +eina_tmpstr_01 \ eina_magic_01 \ eina_simple_xml_parser_01 \ eina_value_01 \ diff --git a/src/examples/eina/eina_tmpstr_01.c b/src/examples/eina/eina_tmpstr_01.c new file mode 100644 index 0000000..a8f8d36 --- /dev/null +++ b/src/examples/eina/eina_tmpstr_01.c @@ -0,0 +1,33 @@ +//Compile with: +//gcc -g eina_tmpstr_01.c -o eina_tmpstr_01 `pkg-config --cflags --libs eina` + +#include <stdio.h> +#include <Eina.h> + +int +main(int argc EINA_UNUSED, char **argv EINA_UNUSED) +{ + const char *str, *str2; + time_t curr_time; + struct tm * info; + const char *prologe = "The Cylons were created by man. They rebelled. They " + "evolved."; + + eina_init(); + + str = eina_tmpstr_add_length(prologe, 31); + printf("%s\n", str); + printf("length: %d\n", eina_tmpstr_len(str)); + eina_tmpstr_del(str); + + curr_time = time(NULL); + info = localtime(&curr_time); + str2 = eina_tmpstr_strftime("%I:%M%p", info); + printf("%s\n", str2); + printf("length: %d\n", eina_tmpstr_len(str2)); + eina_tmpstr_del(str2); + + eina_shutdown(); + + return 0; +} --
