list_test.c
2.37 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <stdio.h>
#include <scot/exception.h>
#include <scot_common.h>
#define GEN_LOCAL
#include <scot/list.h>
#undef GEN_LOCAL
GEN_LIST (int);
int
main (void)
{
list_int_node_t *i_list,
*i_node,
*i_node_next;
int a1 = 5,
a2 = 2,
a3 = 8,
a4 = 12,
a5 = 3,
*val;
excenv_t *ee;
char *locale;
locale = setlocale (LC_ALL, "");
TRY
{
i_list = list_int_new (i_list);
i_node = i_list;
i_node = list_int_insert (i_node, &a1);
i_node = list_int_insert (i_node, &a2);
i_node = list_int_insert (i_node, &a3);
i_node = list_int_insert (i_node, &a4);
//list_int_insert (NULL, &a5);
i_node = i_list;
while (! list_int_eol (i_list, i_node))
{
i_node = list_int_next (i_node);
printf ("Wert: %d\n", * list_int_retrive (i_node));
}
if (list_int_find (i_list, &a5) != NULL)
printf("JO, Wert %d gefunden\n", a5);
if (list_int_find (i_list, &a3) != NULL)
printf("JO, Wert %d gefunden\n", a3);
list_int_free (i_list);
}
CATCH (ee)
{
exception_t *e;
while (e = retrive_exception (ee))
{
if (EXC_IN_THIS_TRY (e))
{
switch (exc_errnum_get (e))
{
/* i need to find more reasonable errors for list
* one must see if the creatin of a new list, or the creation
* of an node or the freeing of something or something else
* got wrong (for now i do the free in any case of an error,
* but this works only because i know that the list is
* already created.) */
case LIST_FREE_ERR:
fprintf (stderr, "list list remains unfreed.");
case LIST_FIND_ERR:
case LIST_RETR_ERR:
case LIST_NEXT_ERR:
case LIST_EOL_ERR:
case LIST_INSERT_ERR:
list_int_free (i_list);
break;
case LIST_NEW_ERR:
fprintf (stderr, "UHH, OHH i got no list, i must die.");
}
}
print_exception (e);
}
free_catched (ee);
}
exc_end ();
return 0;
}