1 mike 1.1 /*
2 **==============================================================================
3 **
4 ** Open Management Infrastructure (OMI)
5 **
6 ** Copyright (c) Microsoft Corporation
7 **
8 ** Licensed under the Apache License, Version 2.0 (the "License"); you may not
9 ** use this file except in compliance with the License. You may obtain a copy
10 ** of the License at
11 **
12 ** http://www.apache.org/licenses/LICENSE-2.0
13 **
14 ** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 ** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
16 ** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
17 ** MERCHANTABLITY OR NON-INFRINGEMENT.
18 **
19 ** See the Apache 2 License for the specific language governing permissions
20 ** and limitations under the License.
21 **
22 mike 1.1 **==============================================================================
23 */
24
25 #ifndef _omi_wsman_wsbuf_h
26 #define _omi_wsman_wsbuf_h
27
28 #include "config.h"
29 #include <string.h>
30 #include <common.h>
31 #include <base/batch.h>
|
32 krisbash 1.3 #include <pal/strings.h>
33 #include <base/messages.h>
|
34 mike 1.1
35 #if defined(_MSC_VER)
36 /* warning C4204: nonstandard extension used : non-constant aggregate initializer */
37 # pragma warning(disable : 4204)
38
39 #endif /* _MSC_VER */
40
41 #if defined(CONFIG_FAVORSIZE)
42 # define WSBUF_DISABLE_INLINING
43 #endif
44
45 BEGIN_EXTERNC
46
47 typedef enum _WSBUF_FAULT_CODE
48 {
49 WSBUF_FAULT_INTERNAL_ERROR,
50 WSBUF_FAULT_NOT_SUPPORTED,
51 WSBUF_FAULT_NOT_UNDERSTOOD,
52 WSBUF_FAULT_DESTINATION_UNREACHABLE,
53 WSBUF_FAULT_ACCESS_DENIED,
|
54 krisbash 1.3 WSBUF_FAULT_ENCODING_LIMIT,
55 WSBUF_FAULT_INVALID_EXPIRATION_TIME,
56 WSBUF_FAULT_UNSUPPORTED_EXPIRATION_TIME,
57 WSBUF_FAULT_TIMED_OUT,
58 WSBUF_FAULT_INVALID_MESSAGE_INFORMATION_HEADER,
59 WSBUF_FAULT_INVALID_HEARTBEAT,
60 WSBUF_FAULT_ACTION_NOT_SUPPORTED,
61 WSBUF_FAULT_CONNECTION_RETRY_NOT_SUPPORTED,
62 WSBUF_FAULT_BOOKMARK_INVALID_FORMAT
|
63 mike 1.1 }
64 WSBUF_FAULT_CODE;
65
66 typedef struct _WSBuf
67 {
68 Page* page;
69 MI_Uint32 position;
70 }
71 WSBuf;
72
73 MI_Result WSBuf_Init(
74 WSBuf* buf,
75 MI_Uint32 initialSize);
76
77 MI_Result WSBuf_Destroy(
78 WSBuf* buf);
79
80 MI_Result __WSBuf_AddLit(
81 WSBuf* buf,
|
82 krisbash 1.3 const ZChar* str,
83 MI_Uint32 size);
84
85 MI_Result WSBuf_AddVerbatim(
86 WSBuf* buf,
87 const void* data,
88 MI_Uint32 size);
89
90 MI_Result WSBuf_AddStartTag(
91 WSBuf* buf,
92 const ZChar* tag,
93 MI_Uint32 size);
94
95 MI_Result WSBuf_AddEndTag(
96 WSBuf* buf,
97 const ZChar* tag,
|
98 mike 1.1 MI_Uint32 size);
99
100 #if defined(WSBUF_DISABLE_INLINING)
101 MI_Result WSBuf_AddLit(
102 WSBuf* buf,
|
103 krisbash 1.3 const ZChar* str,
|
104 mike 1.1 MI_Uint32 size);
105
106 MI_Result WSBuf_AddLit1(
107 WSBuf* buf,
|
108 krisbash 1.3 ZChar c1);
|
109 mike 1.1
110 MI_Result WSBuf_AddLit2(
111 WSBuf* buf,
|
112 krisbash 1.3 ZChar c1,
113 ZChar c2);
|
114 mike 1.1
115 MI_Result WSBuf_AddLit3(
116 WSBuf* buf,
|
117 krisbash 1.3 ZChar c1,
118 ZChar c2,
119 ZChar c3);
|
120 mike 1.1
121 MI_Result WSBuf_AddLit4(
122 WSBuf* buf,
|
123 krisbash 1.3 ZChar c1,
124 ZChar c2,
125 ZChar c3,
126 ZChar c4);
|
127 mike 1.1 MI_Result WSBuf_AddStringNoEncoding(
128 WSBuf* buf,
|
129 krisbash 1.3 const ZChar* str);
|
130 mike 1.1 #else
131 # include "wsbufinline.h"
132 #endif
133
134 MI_Result WSBuf_AddString(
135 WSBuf* buf,
|
136 krisbash 1.3 const ZChar* str);
|
137 mike 1.1
|
138 krisbash 1.3 #if defined(CONFIG_ENABLE_WCHAR)
|
139 mike 1.1 MI_Result WSBuf_AddCharStringNoEncoding(
140 WSBuf* buf,
141 const char* str);
|
142 krisbash 1.3
|
143 mike 1.1 MI_Result WSBuf_AddCharLit(
144 WSBuf* buf,
145 const char* str,
146 MI_Uint32 size);
|
147 krisbash 1.3 #else
148 # define WSBuf_AddCharStringNoEncoding WSBuf_AddStringNoEncoding
149 # define WSBuf_AddCharLit WSBuf_AddLit
|
150 mike 1.1 #endif
151
152 MI_Result WSBuf_AddUint32(
153 WSBuf* buf,
154 MI_Uint32 n);
155
156 Page* WSBuf_StealPage(
157 WSBuf* buf);
158
159 /*
160 Converts static/dynamic instance into wsman-xml,
161 suitable for concatenating WS-soap xml-response.
162 If successful, result buffer page is attached to the batch.
163 Parameters:
164 instance - instance to convert
165 castToClassDecl [opt] - class-decl of output. Used only for
166 deep enumeration with 'base-property-only' flag set.
167 If set, this parameter must point to a valid base class.
168 batch - batch to borrow memory from
169 flags - flags to control instance encoding mode (EPR/Object)
170 ptrOut - pointer to result buffer (single string with xml fragment)
171 mike 1.1 sizeOut - size of result buffer
172 Returns:
173 OK, FAILED (out of memory)
174 */
175 MI_Result WSBuf_InstanceToBuf(
|
176 krisbash 1.3 UserAgent userAgent,
|
177 mike 1.1 const MI_Instance* instance,
|
178 krisbash 1.3 MI_Boolean (*filterProperty)(const ZChar* name, void* data),
|
179 mike 1.1 void* filterPropertyData,
180 const MI_ClassDecl* castToClassDecl,
181 Batch* batch,
182 MI_Uint32 flags,
183 void** ptrOut,
184 MI_Uint32* sizeOut);
185
|
186 krisbash 1.3 MI_Result WSBuf_ClassToBuf(_In_ const MI_Class *classObject,
187 MI_Uint32 flags,
188 Batch* batch,
189 void** ptrOut,
190 MI_Uint32* sizeOut);
191
|
192 mike 1.1 /* Utility */
193 #define WS_MSG_ID_SIZE 42
194
195 void WSBuf_GenerateMessageID(
|
196 krisbash 1.3 _Pre_writable_size_(WS_MSG_ID_SIZE) ZChar msgID[WS_MSG_ID_SIZE]);
|
197 mike 1.1
198 /* Maps CIMM error to the most relevant WS fault;
199 Retuns description of CIM error (can be used as fault description) */
200 WSBUF_FAULT_CODE WSBuf_CIMErrorToWSFault(
201 MI_Uint32 cimErrorCode,
|
202 krisbash 1.3 const ZChar** description );
|
203 mike 1.1
204 /* Helper function to create a fault repsonse */
205 Page* WSBuf_CreateFaultResponsePage(
206 WSBUF_FAULT_CODE faultCode,
|
207 krisbash 1.3 const ZChar* notUnderstoodTag,
208 const ZChar* requestMessageID,
209 const PostResultMsg* message);
|
210 mike 1.1
211 Page* WSBuf_CreateReleaseResponsePage(
|
212 krisbash 1.3 const ZChar* requestMessageID);
|
213 mike 1.1
214 /* Creates soap header with provided action.
215 Funciotn leaves header open so extra header fields can be added */
216 MI_Result WSBuf_CreateSoapResponseHeader(
217 WSBuf *buf,
|
218 krisbash 1.3 const ZChar* action,
|
219 mike 1.1 MI_Uint32 actionSize,
|
220 krisbash 1.3 const ZChar* relatesTo);
|
221 mike 1.1
222 #define LIT(str) str,(sizeof(str)/sizeof(str[0])-1)
223
|
224 krisbash 1.3 INLINE ZChar* PageData(Page* page)
225 {
226 return (ZChar*)(page + 1);
227 }
228
229 INLINE ZChar* BufData(WSBuf* buf)
230 {
231 return PageData(buf->page);
232 }
233
|
234 mike 1.1 END_EXTERNC
235
236 #endif /* _omi_wsman_wsbuf_h */
|
237 krisbash 1.3
|