diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/eina/src/examples/eina_str_01.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/libraries/eina/src/examples/eina_str_01.c b/libraries/eina/src/examples/eina_str_01.c new file mode 100644 index 0000000..089a766 --- /dev/null +++ b/libraries/eina/src/examples/eina_str_01.c | |||
@@ -0,0 +1,65 @@ | |||
1 | //Compile with: | ||
2 | //gcc -Wall -o eina_str_01 eina_str_01.c `pkg-config --cflags --libs eina` | ||
3 | |||
4 | #include <stdio.h> | ||
5 | #include <Eina.h> | ||
6 | |||
7 | int main(int argc, char **argv) | ||
8 | { | ||
9 | char *names = "Calvin;Leoben;D'anna;Simon;Doral;Six;Daniel;Sharon"; | ||
10 | char *str; | ||
11 | char *tmp; | ||
12 | char *prologue; | ||
13 | char *part1 = "The Cylons were created by man. They evolved. They rebelled."; | ||
14 | char *part2 = "There are many copies. And they have a plan."; | ||
15 | char **arr; | ||
16 | int i; | ||
17 | |||
18 | eina_init(); | ||
19 | |||
20 | arr = eina_str_split(names, ";", 0); | ||
21 | for (i = 0; arr[i]; i++) | ||
22 | printf("%s\n", arr[i]); | ||
23 | |||
24 | free(arr[0]); | ||
25 | free(arr); | ||
26 | |||
27 | str = malloc(sizeof(char) * 4); | ||
28 | strcpy(str, "bsd"); | ||
29 | |||
30 | eina_str_toupper((char **)&str); | ||
31 | printf("%s\n", str); | ||
32 | eina_str_tolower(&str); | ||
33 | printf("%s\n", str); | ||
34 | |||
35 | if (eina_str_has_prefix(names, "Calvin")) | ||
36 | printf("Starts with 'Calvin'\n"); | ||
37 | if (eina_str_has_suffix(names, "sharon")) | ||
38 | printf("Ends with 'sharon'\n"); | ||
39 | if (eina_str_has_extension(names, "sharon")) | ||
40 | printf("Has extension 'sharon'\n"); | ||
41 | |||
42 | tmp = eina_str_escape("They'll start going ripe on us pretty soon."); | ||
43 | printf("%s\n", tmp); | ||
44 | free(tmp); | ||
45 | |||
46 | prologue = malloc(sizeof(char) * 106); | ||
47 | eina_str_join_len(prologue, 106, ' ', part1, strlen(part1), part2, strlen(part2)); | ||
48 | printf("%s\n", prologue); | ||
49 | |||
50 | eina_strlcpy(str, prologue, 4); | ||
51 | printf("%s\n", str); | ||
52 | |||
53 | free(prologue); | ||
54 | free(str); | ||
55 | |||
56 | str = malloc(sizeof(char) * 14); | ||
57 | sprintf(str, "%s", "cylons+"); | ||
58 | eina_strlcat(str, "humans", 14); | ||
59 | printf("%s\n", str); | ||
60 | free(str); | ||
61 | |||
62 | eina_shutdown(); | ||
63 | |||
64 | return 0; | ||
65 | } | ||