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

File: [OMI] / omi / protocol / Attic / wsbuf.h (download)
Revision: 1.2, Mon Jun 25 18:59:25 2012 UTC (11 years, 11 months ago) by mike
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
1.0.2

/*
**==============================================================================
**
** Open Management Infrastructure (OMI)
**
** Copyright (c) Microsoft Corporation
** 
** Licensed under the Apache License, Version 2.0 (the "License"); you may not 
** use this file except in compliance with the License. You may obtain a copy 
** of the License at 
**
**     http://www.apache.org/licenses/LICENSE-2.0 
**
** THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
** KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
** WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
** MERCHANTABLITY OR NON-INFRINGEMENT. 
**
** See the Apache 2 License for the specific language governing permissions 
** and limitations under the License.
**
**==============================================================================
*/

#ifndef _omi_wsbuf_h
#define _omi_wsbuf_h

#include "config.h"
#include <string.h>
#include <common.h>
//#include <base/messages.h>
#include <base/batch.h>
#include <base/strings.h>

#if defined(_MSC_VER)
/* warning C4204: nonstandard extension used : non-constant aggregate initializer */
# pragma warning(disable : 4204)

#endif /* _MSC_VER */

#if defined(CONFIG_FAVORSIZE)
# define WSBUF_DISABLE_INLINING
#endif

BEGIN_EXTERNC

typedef enum _WSBUF_FAULT_CODE
{
    WSBUF_FAULT_INTERNAL_ERROR,
    WSBUF_FAULT_NOT_SUPPORTED,
    WSBUF_FAULT_NOT_UNDERSTOOD,
    WSBUF_FAULT_DESTINATION_UNREACHABLE,
    WSBUF_FAULT_ACCESS_DENIED,
    WSBUF_FAULT_ENCODING_LIMIT
}
WSBUF_FAULT_CODE;

typedef struct _WSBuf
{
    Page* page;
    MI_Uint32 position;
}
WSBuf;

MI_Result WSBuf_Init(
    WSBuf* buf,
    MI_Uint32 initialSize);

MI_Result WSBuf_Destroy(
    WSBuf* buf);

MI_Result __WSBuf_AddLit(
    WSBuf* buf,
    const MI_Char* str,
    MI_Uint32 size);

#if defined(WSBUF_DISABLE_INLINING)
MI_Result WSBuf_AddLit(
    WSBuf* buf,
    const MI_Char* str,
    MI_Uint32 size);

MI_Result WSBuf_AddLit1(
    WSBuf* buf,
    MI_Char c1);

MI_Result WSBuf_AddLit2(
    WSBuf* buf,
    MI_Char c1,
    MI_Char c2);

MI_Result WSBuf_AddLit3(
    WSBuf* buf,
    MI_Char c1,
    MI_Char c2,
    MI_Char c3);

MI_Result WSBuf_AddLit4(
    WSBuf* buf,
    MI_Char c1,
    MI_Char c2,
    MI_Char c3,
    MI_Char c4);
MI_Result WSBuf_AddStringNoEncoding(
    WSBuf* buf,
    const MI_Char* str);
#else
# include "wsbufinline.h"
#endif

MI_Result WSBuf_AddString(
    WSBuf* buf,
    const MI_Char* str);

#if (MI_CHAR_TYPE == 1)
#define WSBuf_AddCharStringNoEncoding  WSBuf_AddStringNoEncoding
#define WSBuf_AddCharLit               WSBuf_AddLit
#else
/* */
MI_Result WSBuf_AddCharStringNoEncoding(
    WSBuf* buf,
    const char* str);
MI_Result WSBuf_AddCharLit(
    WSBuf* buf,
    const char* str,
    MI_Uint32 size);

#endif

MI_Result WSBuf_AddUint32(
    WSBuf* buf,
    MI_Uint32 n);

Page* WSBuf_StealPage(
    WSBuf* buf);

/*
    Converts static/dynamic instance into wsman-xml,
    suitable for concatenating WS-soap xml-response.
    If successful, result buffer page is attached to the batch.
    Parameters:
    instance - instance to convert
    castToClassDecl [opt] - class-decl of output. Used only for 
        deep enumeration with 'base-property-only' flag set.
        If set, this parameter must point to a valid base class.
    batch - batch to borrow memory from
    flags - flags to control instance encoding mode (EPR/Object)
    ptrOut - pointer to result buffer (single string with xml fragment)
    sizeOut - size of result buffer
    Returns:
    OK, FAILED (out of memory)
*/
MI_Result WSBuf_InstanceToBuf(
    const MI_Instance* instance,
    MI_Boolean (*filterProperty)(const MI_Char* name, void* data),
    void* filterPropertyData,
    const MI_ClassDecl* castToClassDecl,
    Batch* batch,
    MI_Uint32 flags,
    void** ptrOut,
    MI_Uint32* sizeOut);

/* Utility */
#define WS_MSG_ID_SIZE      42

void WSBuf_GenerateMessageID(
    MI_Char msgID[WS_MSG_ID_SIZE]);

/* Maps CIMM error to the most relevant WS fault;
   Retuns description of CIM error (can be used as fault description) */
WSBUF_FAULT_CODE    WSBuf_CIMErrorToWSFault(
    MI_Uint32       cimErrorCode,
    const MI_Char** description );

/* Helper function to create a fault repsonse */
Page* WSBuf_CreateFaultResponsePage(
    WSBUF_FAULT_CODE faultCode,
    const char* notUnderstoodTag,
    const char* requestMessageID,
    const MI_Char* descriptionText);

Page* WSBuf_CreateReleaseResponsePage(
    const char* requestMessageID);

/* Creates soap header with provided action. 
    Funciotn leaves header open so extra header fields can be added */
MI_Result WSBuf_CreateSoapResponseHeader(
    WSBuf   *buf,
    const MI_Char*  action,
    MI_Uint32       actionSize,
    const char*     relatesTo);

#define LIT(str) str,(sizeof(str)/sizeof(str[0])-1)

END_EXTERNC

#endif /* _omi_wsbuf_h */

ViewCVS 0.9.2