1 //******************************************************************
3 // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
33 typedef struct OCResource OCResource;
35 void OCPayloadDestroy(OCPayload* payload);
37 // Representation Payload
38 OCRepPayload* OCRepPayloadCreate();
40 size_t calcDimTotal(const size_t dimensions[MAX_REP_ARRAY_DEPTH]);
42 OCRepPayload* OCRepPayloadClone(const OCRepPayload* payload);
44 void OCRepPayloadAppend(OCRepPayload* parent, OCRepPayload* child);
46 bool OCRepPayloadSetUri(OCRepPayload* payload, const char* uri);
48 bool OCRepPayloadAddResourceType(OCRepPayload* payload, const char* resourceType);
49 bool OCRepPayloadAddInterface(OCRepPayload* payload, const char* interface);
51 bool OCRepPayloadAddResourceTypeAsOwner(OCRepPayload* payload, char* resourceType);
52 bool OCRepPayloadAddInterfaceAsOwner(OCRepPayload* payload, char* interface);
54 bool OCRepPayloadIsNull(const OCRepPayload* payload, const char* name);
55 bool OCRepPayloadSetNull(OCRepPayload* payload, const char* name);
57 bool OCRepPayloadSetPropInt(OCRepPayload* payload, const char* name, int64_t value);
58 bool OCRepPayloadGetPropInt(const OCRepPayload* payload, const char* name, int64_t* value);
60 bool OCRepPayloadSetPropDouble(OCRepPayload* payload, const char* name, double value);
61 bool OCRepPayloadGetPropDouble(const OCRepPayload* payload, const char* name, double* value);
64 * This function allocates memory for the byte string and sets it in the payload.
66 * @param payload Pointer to the payload to which byte string needs to be added.
67 * @param name Name of the byte string.
68 * @param value Byte string and it's length.
70 * @return true on success, false upon failure.
72 bool OCRepPayloadSetPropByteString(OCRepPayload* payload, const char* name, OCByteString value);
75 * This function sets the byte string in the payload.
77 * @param payload Pointer to the payload to which byte string needs to be added.
78 * @param name Name of the byte string.
79 * @param value Byte string and it's length.
81 * @return true on success, false upon failure.
83 bool OCRepPayloadSetPropByteStringAsOwner(OCRepPayload* payload, const char* name,
87 * This function gets the byte string from the payload.
89 * @param payload Pointer to the payload from which byte string needs to be retrieved.
90 * @param name Name of the byte string.
91 * @param value Byte string and it's length.
93 * @note: Caller needs to invoke OCFree on value.bytes after it is finished using the byte string.
95 * @return true on success, false upon failure.
97 bool OCRepPayloadGetPropByteString(const OCRepPayload* payload, const char* name,
100 bool OCRepPayloadSetPropString(OCRepPayload* payload, const char* name, const char* value);
101 bool OCRepPayloadSetPropStringAsOwner(OCRepPayload* payload, const char* name, char* value);
102 bool OCRepPayloadGetPropString(const OCRepPayload* payload, const char* name, char** value);
104 bool OCRepPayloadSetPropBool(OCRepPayload* payload, const char* name, bool value);
105 bool OCRepPayloadGetPropBool(const OCRepPayload* payload, const char* name, bool* value);
107 bool OCRepPayloadSetPropObject(OCRepPayload* payload, const char* name, const OCRepPayload* value);
108 bool OCRepPayloadSetPropObjectAsOwner(OCRepPayload* payload, const char* name,
109 OCRepPayload* value);
110 bool OCRepPayloadGetPropObject(const OCRepPayload* payload, const char* name, OCRepPayload** value);
113 * This function allocates memory for the byte string array and sets it in the payload.
115 * @param payload Pointer to the payload to which byte string array needs to be added.
116 * @param name Name of the byte string.
117 * @param array Byte string array.
118 * @param dimensions Number of byte strings in above array.
120 * @return true on success, false upon failure.
122 bool OCRepPayloadSetByteStringArrayAsOwner(OCRepPayload* payload, const char* name,
123 OCByteString* array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
126 * This function sets the byte string array in the payload.
128 * @param payload Pointer to the payload to which byte string array needs to be added.
129 * @param name Name of the byte string.
130 * @param array Byte string array.
131 * @param dimensions Number of byte strings in above array.
133 * @return true on success, false upon failure.
135 bool OCRepPayloadSetByteStringArray(OCRepPayload* payload, const char* name,
136 const OCByteString* array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
139 * This function gets the byte string array from the payload.
141 * @param payload Pointer to the payload from which byte string array needs to be retrieved.
142 * @param name Name of the byte string array.
143 * @param value Byte string array.
144 * @param dimensions Number of byte strings in above array.
146 * @note: Caller needs to invoke OICFree on 'bytes' field of all array elements after it is
147 * finished using the byte string array.
149 * @return true on success, false upon failure.
151 bool OCRepPayloadGetByteStringArray(const OCRepPayload* payload, const char* name,
152 OCByteString** array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
154 bool OCRepPayloadSetIntArrayAsOwner(OCRepPayload* payload, const char* name,
155 int64_t* array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
156 bool OCRepPayloadSetIntArray(OCRepPayload* payload, const char* name,
157 const int64_t* array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
158 bool OCRepPayloadGetIntArray(const OCRepPayload* payload, const char* name,
159 int64_t** array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
161 bool OCRepPayloadSetDoubleArrayAsOwner(OCRepPayload* payload, const char* name,
162 double* array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
163 bool OCRepPayloadSetDoubleArray(OCRepPayload* payload, const char* name,
164 const double* array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
165 bool OCRepPayloadGetDoubleArray(const OCRepPayload* payload, const char* name,
166 double** array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
168 bool OCRepPayloadSetStringArrayAsOwner(OCRepPayload* payload, const char* name,
169 char** array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
170 bool OCRepPayloadSetStringArray(OCRepPayload* payload, const char* name,
171 const char** array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
172 bool OCRepPayloadGetStringArray(const OCRepPayload* payload, const char* name,
173 char*** array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
175 bool OCRepPayloadSetBoolArrayAsOwner(OCRepPayload* payload, const char* name,
176 bool* array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
177 bool OCRepPayloadSetBoolArray(OCRepPayload* payload, const char* name,
178 const bool* array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
179 bool OCRepPayloadGetBoolArray(const OCRepPayload* payload, const char* name,
180 bool** array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
182 bool OCRepPayloadSetPropObjectArrayAsOwner(OCRepPayload* payload, const char* name,
183 OCRepPayload** array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
184 bool OCRepPayloadSetPropObjectArray(OCRepPayload* payload, const char* name,
185 const OCRepPayload** array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
186 bool OCRepPayloadGetPropObjectArray(const OCRepPayload* payload, const char* name,
187 OCRepPayload*** array, size_t dimensions[MAX_REP_ARRAY_DEPTH]);
189 void OCRepPayloadDestroy(OCRepPayload* payload);
192 OCDiscoveryPayload* OCDiscoveryPayloadCreate();
194 OCSecurityPayload* OCSecurityPayloadCreate(const char* securityData);
195 void OCSecurityPayloadDestroy(OCSecurityPayload* payload);
197 void OCDiscoveryPayloadAddResource(OCDiscoveryPayload* payload, const OCResource* res,
199 void OCDiscoveryPayloadAddNewResource(OCDiscoveryPayload* payload, OCResourcePayload* res);
200 bool OCResourcePayloadAddResourceType(OCResourcePayload* payload, const char* resourceType);
201 bool OCResourcePayloadAddInterface(OCResourcePayload* payload, const char* interface);
203 size_t OCDiscoveryPayloadGetResourceCount(OCDiscoveryPayload* payload);
204 OCResourcePayload* OCDiscoveryPayloadGetResource(OCDiscoveryPayload* payload, size_t index);
206 void OCDiscoveryPayloadDestroy(OCDiscoveryPayload* payload);
209 OCDevicePayload* OCDevicePayloadCreate(const uint8_t* sid, const char* dname,
210 const char* specVer, const char* dmVer);
211 void OCDevicePayloadDestroy(OCDevicePayload* payload);
214 OCPlatformPayload* OCPlatformPayloadCreate(const OCPlatformInfo* platformInfo);
215 OCPlatformPayload* OCPlatformPayloadCreateAsOwner(OCPlatformInfo* platformInfo);
217 void OCPlatformPayloadDestroy(OCPlatformPayload* payload);
220 OCPresencePayload* OCPresencePayloadCreate(uint32_t seqNum, uint32_t maxAge,
221 OCPresenceTrigger trigger, const char* resourceType);
222 void OCPresencePayloadDestroy(OCPresencePayload* payload);
225 OCStringLL* CloneOCStringLL (OCStringLL* ll);
226 void OCFreeOCStringLL(OCStringLL* ll);