You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.4 KiB
94 lines
2.4 KiB
#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;
|
|
}
|