1 // Copyright 2012 Intel Corporation
2 //
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // - Redistributions of source code must retain the above copyright notice, this
9 //   list of conditions and the following disclaimer.
10 //
11 // - Redistributions in binary form must reproduce the above copyright notice,
12 //   this list of conditions and the following disclaimer in the documentation
13 //   and/or other materials provided with the distribution.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #include <string.h>
27 
28 #include "api_priv.h"
29 
30 #include "wcore_error.h"
31 
32 WAFFLE_API enum waffle_error
waffle_error_get_code(void)33 waffle_error_get_code(void)
34 {
35     return wcore_error_get_code();
36 }
37 
38 WAFFLE_API const struct waffle_error_info*
waffle_error_get_info(void)39 waffle_error_get_info(void)
40 {
41     return wcore_error_get_info();
42 }
43 
44 WAFFLE_API const char*
waffle_error_to_string(enum waffle_error e)45 waffle_error_to_string(enum waffle_error e)
46 {
47     switch (e) {
48 #define CASE(x) case x: return #x
49         CASE(WAFFLE_NO_ERROR);
50         CASE(WAFFLE_ERROR_FATAL);
51         CASE(WAFFLE_ERROR_UNKNOWN);
52         CASE(WAFFLE_ERROR_INTERNAL);
53         CASE(WAFFLE_ERROR_BAD_ALLOC);
54         CASE(WAFFLE_ERROR_NOT_INITIALIZED);
55         CASE(WAFFLE_ERROR_ALREADY_INITIALIZED);
56         CASE(WAFFLE_ERROR_BAD_ATTRIBUTE);
57         CASE(WAFFLE_ERROR_BAD_PARAMETER);
58         CASE(WAFFLE_ERROR_BAD_DISPLAY_MATCH);
59         CASE(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM);
60         CASE(WAFFLE_ERROR_BUILT_WITHOUT_SUPPORT);
61         default: return 0;
62 #undef CASE
63     }
64 }
65