summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShilpa Singh <shilpa.singh@samsung.com>2015-09-23 14:27:43 -0700
committerCedric BAIL <cedric@osg.samsung.com>2015-09-23 14:27:56 -0700
commit65758a21606b07af6745f602473750986af648a2 (patch)
treed5862c57cdddcf2c83005a4be7218f9eb6ac501c
parent6eefe25dcf09adc9005efa137ab445a6596b9855 (diff)
downloadefl-65758a21606b07af6745f602473750986af648a2.tar.gz
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 <shilpa.singh@samsung.com> Reviewers: cedric Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D3087 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/examples/eina/Makefile.am2
-rw-r--r--src/examples/eina/eina_tmpstr_01.c33
2 files changed, 35 insertions, 0 deletions
diff --git a/src/examples/eina/Makefile.am b/src/examples/eina/Makefile.am
index 92819c705d..bb108b527d 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 0000000000..a8f8d36900
--- /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;
+}