Implemented libcoap's tinyDTLS interface
[contrib/iotivity.git] / resource / csdk / stack / samples / linux / secure / common.cpp
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <ocstack.h>
24
25 const char *getResult(OCStackResult result) {
26     switch (result) {
27     case OC_STACK_OK:
28         return "OC_STACK_OK";
29     case OC_STACK_RESOURCE_CREATED:
30         return "OC_STACK_RESOURCE_CREATED";
31     case OC_STACK_RESOURCE_DELETED:
32         return "OC_STACK_RESOURCE_DELETED";
33     case OC_STACK_INVALID_URI:
34         return "OC_STACK_INVALID_URI";
35     case OC_STACK_INVALID_QUERY:
36         return "OC_STACK_INVALID_QUERY";
37     case OC_STACK_INVALID_IP:
38         return "OC_STACK_INVALID_IP";
39     case OC_STACK_INVALID_PORT:
40         return "OC_STACK_INVALID_PORT";
41     case OC_STACK_INVALID_CALLBACK:
42         return "OC_STACK_INVALID_CALLBACK";
43     case OC_STACK_INVALID_METHOD:
44         return "OC_STACK_INVALID_METHOD";
45     case OC_STACK_NO_MEMORY:
46         return "OC_STACK_NO_MEMORY";
47     case OC_STACK_COMM_ERROR:
48         return "OC_STACK_COMM_ERROR";
49     case OC_STACK_INVALID_PARAM:
50         return "OC_STACK_INVALID_PARAM";
51     case OC_STACK_NOTIMPL:
52         return "OC_STACK_NOTIMPL";
53     case OC_STACK_NO_RESOURCE:
54         return "OC_STACK_NO_RESOURCE";
55     case OC_STACK_RESOURCE_ERROR:
56         return "OC_STACK_RESOURCE_ERROR";
57     case OC_STACK_SLOW_RESOURCE:
58         return "OC_STACK_SLOW_RESOURCE";
59     case OC_STACK_NO_OBSERVERS:
60         return "OC_STACK_NO_OBSERVERS";
61     #ifdef WITH_PRESENCE
62     case OC_STACK_PRESENCE_DO_NOT_HANDLE:
63         return "OC_STACK_PRESENCE_DO_NOT_HANDLE";
64     case OC_STACK_PRESENCE_STOPPED:
65         return "OC_STACK_PRESENCE_STOPPED";
66     #endif
67     case OC_STACK_ERROR:
68         return "OC_STACK_ERROR";
69     default:
70         return "UNKNOWN";
71     }
72 }