Updated Makefiles and CMakeLists.txt to point to resource, not oic-resource
[platform/upstream/iotivity.git] / resource / csdk / stack / include / internal / ocresource.h
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 #ifndef OC_RESOURCE_H
22 #define OC_RESOURCE_H
23
24 #include "ocstack.h"
25 #include "ocstackinternal.h"
26
27 #define OC_RSRVD_OC                     "oc"
28 #define OC_RSRVD_PAYLOAD                "payload"
29 #define OC_RSRVD_HREF                   "href"
30 #define OC_RSRVD_RESOURCE_TYPE          "rt"
31 #define OC_RSRVD_INTERFACE              "if"
32 #define OC_RSRVD_INTERFACE_DEFAULT      "oc.mi.def"
33 #define OC_RSRVD_INTERFACE_LL           "oc.mi.ll"
34 #define OC_RSRVD_INTERFACE_BATCH        "oc.mi.b"
35 #define OC_RSRVD_OBSERVABLE             "obs"
36
37 #define OC_JSON_PREFIX                     "{\"oc\":["
38 #define OC_JSON_PREFIX_LEN                 (sizeof(OC_JSON_PREFIX) - 1)
39 #define OC_JSON_SUFFIX                     "]}"
40 #define OC_JSON_SUFFIX_LEN                 (sizeof(OC_JSON_SUFFIX) - 1)
41 #define OC_JSON_SEPARATOR                  ','
42
43 #define OC_RESOURCE_OBSERVABLE   1
44
45 typedef enum {
46     STACK_RES_DISCOVERY_NOFILTER = 0,
47     STACK_RES_DISCOVERY_IF_FILTER,
48     STACK_RES_DISCOVERY_RT_FILTER
49 } StackQueryTypes;
50
51 typedef enum {
52     OC_RESOURCE_VIRTUAL = 0,
53     OC_RESOURCE_NOT_COLLECTION_WITH_ENTITYHANDLER,
54     OC_RESOURCE_NOT_COLLECTION_DEFAULT_ENTITYHANDLER,
55     OC_RESOURCE_COLLECTION_WITH_ENTITYHANDLER,
56     OC_RESOURCE_COLLECTION_DEFAULT_ENTITYHANDLER,
57     OC_RESOURCE_DEFAULT_DEVICE_ENTITYHANDLER,
58     OC_RESOURCE_NOT_SPECIFIED
59 } ResourceHandling;
60
61 OCEntityHandlerResult defaultResourceEHandler(OCEntityHandlerFlag flag, OCEntityHandlerRequest * request);
62
63 const char * GetVirtualResourceUri( OCVirtualResources resource);
64 OCResource *FindResourceByUri(const char* resourceUri);
65 uint8_t IsVirtualResource(const char* resourceUri);
66
67 OCStackResult DetermineResourceHandling (OCRequest *request,
68                                          ResourceHandling *handling,
69                                          OCResource **resource);
70
71 OCStackResult
72 BuildJSONResponse(ResourceHandling resHandling, OCResource *resource, OCRequest *request);
73
74 OCEntityHandlerResult
75 BuildObsJSONResponse(OCResource *resource, OCEntityHandlerRequest *ehRequest);
76
77 OCStackResult
78 BuildVirtualResourceResponse(OCResource *resourcePtr, uint8_t filterOn,
79                         char *filterValue, char * out, uint16_t *remaining);
80
81 OCStackResult EntityHandlerCodeToOCStackCode(OCEntityHandlerResult ehResult);
82
83 #endif //OC_RESOURCE_H