summaryrefslogtreecommitdiff
path: root/src/examples
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 /src/examples
parent6eefe25dcf09adc9005efa137ab445a6596b9855 (diff)
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>
Diffstat (limited to 'src/examples')
-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 \
39eina_str_01.c \ 39eina_str_01.c \
40eina_strbuf_01.c \ 40eina_strbuf_01.c \
41eina_stringshare_01.c \ 41eina_stringshare_01.c \
42eina_tmpstr_01.c \
42eina_tiler_01.c \ 43eina_tiler_01.c \
43eina_simple_xml_parser_01.c \ 44eina_simple_xml_parser_01.c \
44eina_value_01.c \ 45eina_value_01.c \
@@ -84,6 +85,7 @@ eina_inlist_03 \
84eina_str_01 \ 85eina_str_01 \
85eina_strbuf_01 \ 86eina_strbuf_01 \
86eina_stringshare_01 \ 87eina_stringshare_01 \
88eina_tmpstr_01 \
87eina_magic_01 \ 89eina_magic_01 \
88eina_simple_xml_parser_01 \ 90eina_simple_xml_parser_01 \
89eina_value_01 \ 91eina_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 @@
1//Compile with:
2//gcc -g eina_tmpstr_01.c -o eina_tmpstr_01 `pkg-config --cflags --libs eina`
3
4#include <stdio.h>
5#include <Eina.h>
6
7int
8main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
9{
10 const char *str, *str2;
11 time_t curr_time;
12 struct tm * info;
13 const char *prologe = "The Cylons were created by man. They rebelled. They "
14 "evolved.";
15
16 eina_init();
17
18 str = eina_tmpstr_add_length(prologe, 31);
19 printf("%s\n", str);
20 printf("length: %d\n", eina_tmpstr_len(str));
21 eina_tmpstr_del(str);
22
23 curr_time = time(NULL);
24 info = localtime(&curr_time);
25 str2 = eina_tmpstr_strftime("%I:%M%p", info);
26 printf("%s\n", str2);
27 printf("length: %d\n", eina_tmpstr_len(str2));
28 eina_tmpstr_del(str2);
29
30 eina_shutdown();
31
32 return 0;
33}