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