Merge branch 'upstream' into tizen
[platform/upstream/iotivity.git] / extlibs / tinycbor / tinycbor / src / cborerrorstrings.c
1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 Intel Corporation
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 **
12 ** The above copyright notice and this permission notice shall be included in
13 ** all copies or substantial portions of the Software.
14 **
15 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 ** THE SOFTWARE.
22 **
23 ****************************************************************************/
24
25 #include "cbor.h"
26
27 #ifndef _
28 #  define _(msg)    msg
29 #endif
30
31 const char *cbor_error_string(CborError error)
32 {
33     switch (error) {
34     case CborNoError:
35         return "";
36
37     case CborUnknownError:
38         return _("unknown error");
39
40     case CborErrorOutOfMemory:
41         return _("out of memory/need more memory");
42
43     case CborErrorUnknownLength:
44         return _("unknown length (attempted to get the length of a map/array/string of indeterminate length");
45
46     case CborErrorAdvancePastEOF:
47         return _("attempted to advance past EOF");
48
49     case CborErrorIO:
50         return _("I/O error");
51
52     case CborErrorGarbageAtEnd:
53         return _("garbage after the end of the content");
54
55     case CborErrorUnexpectedEOF:
56         return _("unexpected end of data");
57
58     case CborErrorUnexpectedBreak:
59         return _("unexpected 'break' byte");
60
61     case CborErrorUnknownType:
62         return _("illegal byte (encodes future extension type)");
63
64     case CborErrorIllegalType:
65         return _("mismatched string type in chunked string");
66
67     case CborErrorIllegalNumber:
68         return _("illegal initial byte (encodes unspecified additional information)");
69
70     case CborErrorIllegalSimpleType:
71         return _("illegal encoding of simple type smaller than 32");
72
73     case CborErrorUnknownSimpleType:
74         return _("unknown simple type");
75
76     case CborErrorUnknownTag:
77         return _("unknown tag");
78
79     case CborErrorInappropriateTagForType:
80         return _("inappropriate tag for type");
81
82     case CborErrorDuplicateObjectKeys:
83         return _("duplicate keys in object");
84
85     case CborErrorInvalidUtf8TextString:
86         return _("invalid UTF-8 content in string");
87
88     case CborErrorTooManyItems:
89         return _("too many items added to encoder");
90
91     case CborErrorTooFewItems:
92         return _("too few items added to encoder");
93
94     case CborErrorDataTooLarge:
95         return _("internal error: data too large");
96
97     case CborErrorNestingTooDeep:
98         return _("internal error: too many nested containers found in recursive function");
99
100     case CborErrorUnsupportedType:
101         return _("unsupported type");
102
103     case CborErrorJsonObjectKeyIsAggregate:
104         return _("conversion to JSON failed: key in object is an array or map");
105
106     case CborErrorJsonObjectKeyNotString:
107         return _("conversion to JSON failed: key in object is not a string");
108
109
110     case CborErrorInternalError:
111         return _("internal error");
112     }
113     return cbor_error_string(CborUnknownError);
114 }