diff options
author | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
commit | dd7595a3475407a7fa96a97393bae8c5220e8762 (patch) | |
tree | e341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/eina/src/examples/eina_array_01.c | |
parent | Add the skeleton. (diff) | |
download | SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2 SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz |
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to 'libraries/eina/src/examples/eina_array_01.c')
-rw-r--r-- | libraries/eina/src/examples/eina_array_01.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/libraries/eina/src/examples/eina_array_01.c b/libraries/eina/src/examples/eina_array_01.c new file mode 100644 index 0000000..25e0944 --- /dev/null +++ b/libraries/eina/src/examples/eina_array_01.c | |||
@@ -0,0 +1,51 @@ | |||
1 | //Compile with: | ||
2 | //gcc -g `pkg-config --cflags --libs eina` eina_array_01.c -o eina_array_01 | ||
3 | |||
4 | #include <stdio.h> | ||
5 | #include <string.h> | ||
6 | |||
7 | #include <Eina.h> | ||
8 | |||
9 | static Eina_Bool | ||
10 | _print(const void *container, void *data, void *fdata) | ||
11 | { | ||
12 | printf("%s\n", data); | ||
13 | return EINA_TRUE; | ||
14 | } | ||
15 | |||
16 | int | ||
17 | main(int argc, char **argv) | ||
18 | { | ||
19 | const char* strings[] = { | ||
20 | "helo", "hera", "starbuck", "kat", "boomer", | ||
21 | "hotdog", "longshot", "jammer", "crashdown", "hardball", | ||
22 | "duck", "racetrack", "apolo", "husker", "freaker", | ||
23 | "skulls", "bulldog", "flat top", "hammerhead", "gonzo" | ||
24 | }; | ||
25 | Eina_Array *array; | ||
26 | Eina_Array_Iterator iterator; | ||
27 | char *item; | ||
28 | unsigned int i; | ||
29 | |||
30 | eina_init(); | ||
31 | |||
32 | array = eina_array_new(10); | ||
33 | eina_array_step_set(array, sizeof(*array), 20); | ||
34 | |||
35 | for (i = 0; i < 20; i++) | ||
36 | eina_array_push(array, strdup(strings[i])); | ||
37 | |||
38 | printf("array count: %d\n", eina_array_count_get(array)); | ||
39 | eina_array_foreach(array, _print, NULL); | ||
40 | |||
41 | printf("Top gun: %s\n", (char*)eina_array_data_get(array, 2)); | ||
42 | |||
43 | while (eina_array_count_get(array)) | ||
44 | free(eina_array_pop(array)); | ||
45 | |||
46 | eina_array_free(array); | ||
47 | |||
48 | eina_shutdown(); | ||
49 | |||
50 | return 0; | ||
51 | } | ||