eina: add example for eina_tmpstr.
authorShilpa Singh <shilpa.singh@samsung.com>
Wed, 23 Sep 2015 21:27:43 +0000 (14:27 -0700)
committerCedric BAIL <cedric@osg.samsung.com>
Wed, 23 Sep 2015 21:27:56 +0000 (14:27 -0700)
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 <shilpa.singh@samsung.com>

Reviewers: cedric

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D3087

Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
src/examples/eina/Makefile.am
src/examples/eina/eina_tmpstr_01.c [new file with mode: 0644]

index 92819c7..bb108b5 100644 (file)
@@ -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 (file)
index 0000000..a8f8d36
--- /dev/null
@@ -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;
+}