revise build scripts
[platform/upstream/iotivity.git] / resource / csdk / stack / include / ocpayload.h
1 //******************************************************************
2 //
3 // Copyright 2015 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 OCPAYLOAD_H_
22 #define OCPAYLOAD_H_
23
24 #include <stdbool.h>
25 #include <inttypes.h>
26 #include "octypes.h"
27
28 #ifdef __cplusplus
29 extern "C"
30 {
31 #endif
32
33 typedef struct OCResource OCResource;
34
35 void OCPayloadDestroy(OCPayload* payload);
36
37 // Representation Payload
38 OCRepPayload* OCRepPayloadCreate();
39
40 size_t calcDimTotal(const size_t dimensions[MAX_REP_ARRAY_DEPTH]);
41
42 OCRepPayload* OCRepPayloadClone(const OCRepPayload* payload);
43
44 void OCRepPayloadAppend(OCRepPayload* parent, OCRepPayload* child);
45
46 bool OCRepPayloadSetUri(OCRepPayload* payload, const char* uri);
47
48 bool OCRepPayloadAddResourceType(OCRepPayload* payload, const char* resourceType);
49 bool OCRepPayloadAddInterface(OCRepPayload* payload, const char* interface);
50
51 bool OCRepPayloadAddResourceTypeAsOwner(OCRepPayload* payload, char* resourceType);
52 bool OCRepPayloadAddInterfaceAsOwner(OCRepPayload* payload, char* interface);
53
54 bool OCRepPayloadIsNull(const OCRepPayload* payload, const char* name);
55 bool OCRepPayloadSetNull(OCRepPayload* payload, const char* name);
56
57 bool OCRepPayloadSetPropInt(OCRepPayload* payload, const char* name, int64_t value);
58 bool OCRepPayloadGetPropInt(const OCRepPayload* payload, const char* name, int64_t* value);
59
60 bool OCRepPayloadSetPropDouble(OCRepPayload* payload, const char* name, double value);
61 bool OCRepPayloadGetPropDouble(const OCRepPayload* payload, const char* name, double* value);
62
63 bool OCRepPayloadSetPropString(OCRepPayload* payload, const char* name, const char* value);
64 bool OCRepPayloadSetPropStringAsOwner(OCRepPayload* payload, const char* name, char* value);
65 bool OCRepPayloadGetPropString(const OCRepPayload* payload, const char* name, char** value);
66
67 bool OCRepPayloadSetPropBool(OCRepPayload* payload, const char* name, bool value);
68 bool OCRepPayloadGetPropBool(const OCRepPayload* payload, const char* name, bool* value);
69
70 bool OCRepPayloadSetPropObject(OCRepPayload* payload, const char* name, const OCRepPayload* value);
71 bool OCRepPayloadSetPropObjectAsOwner(OCRepPayload* payload, const char* name,
72         OCRepPayload* value);
73 bool OCRepPayloadGetPropObject(const OCRepPayload* payload, const char* name, OCRepPayload** value);
74
75 bool OCRepPayloadSetIntArrayAsOwner(OCRepPayload* payload, const char* name,
76         int64_t* array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
77 bool OCRepPayloadSetIntArray(OCRepPayload* payload, const char* name,
78         const int64_t* array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
79 bool OCRepPayloadGetIntArray(const OCRepPayload* payload, const char* name,
80         int64_t** array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
81
82 bool OCRepPayloadSetDoubleArrayAsOwner(OCRepPayload* payload, const char* name,
83         double* array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
84 bool OCRepPayloadSetDoubleArray(OCRepPayload* payload, const char* name,
85         const double* array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
86 bool OCRepPayloadGetDoubleArray(const OCRepPayload* payload, const char* name,
87         double** array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
88
89 bool OCRepPayloadSetStringArrayAsOwner(OCRepPayload* payload, const char* name,
90         char** array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
91 bool OCRepPayloadSetStringArray(OCRepPayload* payload, const char* name,
92         const char** array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
93 bool OCRepPayloadGetStringArray(const OCRepPayload* payload, const char* name,
94         char*** array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
95
96 bool OCRepPayloadSetBoolArrayAsOwner(OCRepPayload* payload, const char* name,
97         bool* array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
98 bool OCRepPayloadSetBoolArray(OCRepPayload* payload, const char* name,
99         const bool* array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
100 bool OCRepPayloadGetBoolArray(const OCRepPayload* payload, const char* name,
101         bool** array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
102
103 bool OCRepPayloadSetPropObjectArrayAsOwner(OCRepPayload* payload, const char* name,
104         OCRepPayload** array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
105 bool OCRepPayloadSetPropObjectArray(OCRepPayload* payload, const char* name,
106         const OCRepPayload** array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
107 bool OCRepPayloadGetPropObjectArray(const OCRepPayload* payload, const char* name,
108         OCRepPayload*** array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
109
110 void OCRepPayloadDestroy(OCRepPayload* payload);
111
112 // Discovery Payload
113 OCDiscoveryPayload* OCDiscoveryPayloadCreate();
114
115 OCSecurityPayload* OCSecurityPayloadCreate(const char* securityData);
116 void OCSecurityPayloadDestroy(OCSecurityPayload* payload);
117
118 void OCDiscoveryPayloadAddResource(OCDiscoveryPayload* payload, const OCResource* res,
119         uint16_t port);
120 void OCDiscoveryPayloadAddNewResource(OCDiscoveryPayload* payload, OCResourcePayload* res);
121 bool OCResourcePayloadAddResourceType(OCResourcePayload* payload, const char* resourceType);
122 bool OCResourcePayloadAddInterface(OCResourcePayload* payload, const char* interface);
123
124 size_t OCDiscoveryPayloadGetResourceCount(OCDiscoveryPayload* payload);
125 OCResourcePayload* OCDiscoveryPayloadGetResource(OCDiscoveryPayload* payload, size_t index);
126
127 void OCDiscoveryPayloadDestroy(OCDiscoveryPayload* payload);
128
129 // Device Payload
130 OCDevicePayload* OCDevicePayloadCreate(const char* uri, const uint8_t* sid, const char* dname,
131         const char* specVer, const char* dmVer);
132 void OCDevicePayloadDestroy(OCDevicePayload* payload);
133
134 // Platform Payload
135 OCPlatformPayload* OCPlatformPayloadCreate(const char* uri, const OCPlatformInfo* platformInfo);
136 OCPlatformPayload* OCPlatformPayloadCreateAsOwner(char* uri, OCPlatformInfo* platformInfo);
137
138 void OCPlatformPayloadDestroy(OCPlatformPayload* payload);
139
140 // Presence Payload
141 OCPresencePayload* OCPresencePayloadCreate(uint32_t seqNum, uint32_t maxAge,
142         OCPresenceTrigger trigger, const char* resourceType);
143 void OCPresencePayloadDestroy(OCPresencePayload* payload);
144
145 // Helper API
146 OCStringLL* CloneOCStringLL (OCStringLL* ll);
147 void OCFreeOCStringLL(OCStringLL* ll);
148
149 #ifdef __cplusplus
150 }
151 #endif
152
153 #endif