summaryrefslogtreecommitdiff
path: root/src/examples/eina/eina_list_03.c
blob: a7d942d6bd80c27b2fe9956fe70d06bcc4313b53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//Compile with:
//gcc -g eina_list_03.c -o eina_list_03 `pkg-config --cflags --libs eina`

#include <stdio.h>
#include <Eina.h>

int
main(int argc, char **argv)
{
   (void)argc;
   (void)argv;
   Eina_List *list = NULL, *r_list;
   Eina_List *l;
   Eina_Iterator *itr;
   void *list_data;

   eina_init();

   list = eina_list_append(list, "caprica");
   list = eina_list_append(list, "sagittarius");
   list = eina_list_append(list, "aerilon");
   list = eina_list_append(list, "gemenon");

   list = eina_list_promote_list(list, eina_list_nth_list(list, 2));
   list = eina_list_demote_list(list, eina_list_nth_list(list, 2));

   list = eina_list_remove(list, "sagittarius");

   l = eina_list_data_find_list(list, "aerilon");
   eina_list_data_set(l, "aquarius");

   printf("size: %d\n", eina_list_count(list));

   r_list = eina_list_reverse_clone(list);

   itr = eina_list_iterator_new(r_list);
   EINA_ITERATOR_FOREACH(itr, list_data)
     printf("%s\n", (char*)list_data);
   eina_iterator_free(itr);

   eina_list_free(list);
   eina_list_free(r_list);

   eina_shutdown();

   return 0;
}