diff options
Diffstat (limited to 'libraries/eina/src/examples/eina_error_01.c')
-rw-r--r-- | libraries/eina/src/examples/eina_error_01.c | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/libraries/eina/src/examples/eina_error_01.c b/libraries/eina/src/examples/eina_error_01.c deleted file mode 100644 index e264aee..0000000 --- a/libraries/eina/src/examples/eina_error_01.c +++ /dev/null | |||
@@ -1,80 +0,0 @@ | |||
1 | //Compile with: | ||
2 | //gcc -g eina_error_01.c -o eina_error_01 `pkg-config --cflags --libs eina` | ||
3 | |||
4 | #include <stdlib.h> | ||
5 | #include <stdio.h> | ||
6 | |||
7 | #include <eina_error.h> | ||
8 | |||
9 | Eina_Error MY_ERROR_NEGATIVE; | ||
10 | Eina_Error MY_ERROR_NULL; | ||
11 | |||
12 | void *data_new() | ||
13 | { | ||
14 | eina_error_set(0); | ||
15 | |||
16 | eina_error_set(MY_ERROR_NULL); | ||
17 | return NULL; | ||
18 | } | ||
19 | |||
20 | int test(int n) | ||
21 | { | ||
22 | eina_error_set(0); | ||
23 | |||
24 | if (n < 0) | ||
25 | { | ||
26 | eina_error_set(MY_ERROR_NEGATIVE); | ||
27 | return 0; | ||
28 | } | ||
29 | |||
30 | return 1; | ||
31 | } | ||
32 | |||
33 | int main(void) | ||
34 | { | ||
35 | void *data; | ||
36 | |||
37 | if (!eina_init()) | ||
38 | { | ||
39 | printf ("Error during the initialization of eina_error module\n"); | ||
40 | return EXIT_FAILURE; | ||
41 | } | ||
42 | |||
43 | MY_ERROR_NEGATIVE = eina_error_msg_static_register("Negative number"); | ||
44 | MY_ERROR_NULL = eina_error_msg_static_register("NULL pointer"); | ||
45 | |||
46 | data = data_new(); | ||
47 | if (!data) | ||
48 | { | ||
49 | Eina_Error err; | ||
50 | |||
51 | err = eina_error_get(); | ||
52 | if (err) | ||
53 | printf("Error during memory allocation: %s\n", | ||
54 | eina_error_msg_get(err)); | ||
55 | } | ||
56 | |||
57 | if (!test(0)) | ||
58 | { | ||
59 | Eina_Error err; | ||
60 | |||
61 | err = eina_error_get(); | ||
62 | if (err) | ||
63 | printf("Error during test function: %s\n", | ||
64 | eina_error_msg_get(err)); | ||
65 | } | ||
66 | |||
67 | if (!test(-1)) | ||
68 | { | ||
69 | Eina_Error err; | ||
70 | |||
71 | err = eina_error_get(); | ||
72 | if (err) | ||
73 | printf("Error during test function: %s\n", | ||
74 | eina_error_msg_get(err)); | ||
75 | } | ||
76 | |||
77 | eina_shutdown(); | ||
78 | |||
79 | return EXIT_SUCCESS; | ||
80 | } | ||