(file) Return to wsbuf.h CVS log (file) (dir) Up to [OMI] / omi / wsman

  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/messages.h>
 32           #include <base/batch.h>
 33           #include <base/strings.h>
 34           
 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 mike  1.1 #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               WSBUF_FAULT_ENCODING_LIMIT
 55           }
 56           WSBUF_FAULT_CODE;
 57           
 58           typedef struct _WSBuf
 59           {
 60               Page* page;
 61               MI_Uint32 position;
 62           }
 63           WSBuf;
 64 mike  1.1 
 65           MI_Result WSBuf_Init(
 66               WSBuf* buf,
 67               MI_Uint32 initialSize);
 68           
 69           MI_Result WSBuf_Destroy(
 70               WSBuf* buf);
 71           
 72           MI_Result __WSBuf_AddLit(
 73               WSBuf* buf,
 74               const MI_Char* str,
 75               MI_Uint32 size);
 76           
 77           #if defined(WSBUF_DISABLE_INLINING)
 78           MI_Result WSBuf_AddLit(
 79               WSBuf* buf,
 80               const MI_Char* str,
 81               MI_Uint32 size);
 82           
 83           MI_Result WSBuf_AddLit1(
 84               WSBuf* buf,
 85 mike  1.1     MI_Char c1);
 86           
 87           MI_Result WSBuf_AddLit2(
 88               WSBuf* buf,
 89               MI_Char c1,
 90               MI_Char c2);
 91           
 92           MI_Result WSBuf_AddLit3(
 93               WSBuf* buf,
 94               MI_Char c1,
 95               MI_Char c2,
 96               MI_Char c3);
 97           
 98           MI_Result WSBuf_AddLit4(
 99               WSBuf* buf,
100               MI_Char c1,
101               MI_Char c2,
102               MI_Char c3,
103               MI_Char c4);
104           MI_Result WSBuf_AddStringNoEncoding(
105               WSBuf* buf,
106 mike  1.1     const MI_Char* str);
107           #else
108           # include "wsbufinline.h"
109           #endif
110           
111           MI_Result WSBuf_AddString(
112               WSBuf* buf,
113               const MI_Char* str);
114           
115           #if (MI_CHAR_TYPE == 1)
116           #define WSBuf_AddCharStringNoEncoding  WSBuf_AddStringNoEncoding
117           #define WSBuf_AddCharLit               WSBuf_AddLit
118           #else
119           /* */
120           MI_Result WSBuf_AddCharStringNoEncoding(
121               WSBuf* buf,
122               const char* str);
123           MI_Result WSBuf_AddCharLit(
124               WSBuf* buf,
125               const char* str,
126               MI_Uint32 size);
127 mike  1.1 
128           #endif
129           
130           MI_Result WSBuf_AddUint32(
131               WSBuf* buf,
132               MI_Uint32 n);
133           
134           Page* WSBuf_StealPage(
135               WSBuf* buf);
136           
137           /*
138               Converts static/dynamic instance into wsman-xml,
139               suitable for concatenating WS-soap xml-response.
140               If successful, result buffer page is attached to the batch.
141               Parameters:
142               instance - instance to convert
143               castToClassDecl [opt] - class-decl of output. Used only for 
144                   deep enumeration with 'base-property-only' flag set.
145                   If set, this parameter must point to a valid base class.
146               batch - batch to borrow memory from
147               flags - flags to control instance encoding mode (EPR/Object)
148 mike  1.1     ptrOut - pointer to result buffer (single string with xml fragment)
149               sizeOut - size of result buffer
150               Returns:
151               OK, FAILED (out of memory)
152           */
153           MI_Result WSBuf_InstanceToBuf(
154               const MI_Instance* instance,
155               MI_Boolean (*filterProperty)(const MI_Char* name, void* data),
156               void* filterPropertyData,
157               const MI_ClassDecl* castToClassDecl,
158               Batch* batch,
159               MI_Uint32 flags,
160               void** ptrOut,
161               MI_Uint32* sizeOut);
162           
163           /* Utility */
164           #define WS_MSG_ID_SIZE      42
165           
166           void WSBuf_GenerateMessageID(
167               MI_Char msgID[WS_MSG_ID_SIZE]);
168           
169 mike  1.1 /* Maps CIMM error to the most relevant WS fault;
170              Retuns description of CIM error (can be used as fault description) */
171           WSBUF_FAULT_CODE    WSBuf_CIMErrorToWSFault(
172               MI_Uint32       cimErrorCode,
173               const MI_Char** description );
174           
175           /* Helper function to create a fault repsonse */
176           Page* WSBuf_CreateFaultResponsePage(
177               WSBUF_FAULT_CODE faultCode,
178               const char* notUnderstoodTag,
179               const char* requestMessageID,
180               const MI_Char* descriptionText);
181           
182           Page* WSBuf_CreateReleaseResponsePage(
183               const char* requestMessageID);
184           
185           /* Creates soap header with provided action. 
186               Funciotn leaves header open so extra header fields can be added */
187           MI_Result WSBuf_CreateSoapResponseHeader(
188               WSBuf   *buf,
189               const MI_Char*  action,
190 mike  1.1     MI_Uint32       actionSize,
191               const char*     relatesTo);
192           
193           #define LIT(str) str,(sizeof(str)/sizeof(str[0])-1)
194           
195           END_EXTERNC
196           
197           #endif /* _omi_wsman_wsbuf_h */

ViewCVS 0.9.2