(file) Return to messages.c CVS log (file) (dir) Up to [OMI] / omi / base

Diff for /omi/base/messages.c between version 1.2 and 1.3

version 1.2, 2015/04/20 18:10:09 version 1.3, 2015/04/20 18:19:49
Line 25 
Line 25 
 #include "messages.h" #include "messages.h"
 #include "packing.h" #include "packing.h"
 #include <assert.h> #include <assert.h>
   #include <stdio.h>
 #include "result.h" #include "result.h"
 #include "io.h"  #include <pal/format.h>
   #include "log.h"
   #include "miextras.h"
  
 /* /*
 **============================================================================== **==============================================================================
Line 36 
Line 39 
 **============================================================================== **==============================================================================
 */ */
  
 typedef enum _FieldType  
 {  
     FT_BOOLEAN = MI_BOOLEAN,  
     FT_UINT8 = MI_UINT8,  
     FT_SINT8 = MI_SINT8,  
     FT_UINT16 = MI_UINT16,  
     FT_SINT16 = MI_SINT16,  
     FT_UINT32 = MI_UINT32,  
     FT_SINT32 = MI_SINT32,  
     FT_UINT64 = MI_UINT64,  
     FT_SINT64 = MI_SINT64,  
     FT_REAL32 = MI_REAL32,  
     FT_REAL64 = MI_REAL64,  
     FT_CHAR16 = MI_CHAR16,  
     FT_DATETIME = MI_DATETIME,  
     FT_STRING = MI_STRING,  
     FT_REFERENCE = MI_REFERENCE,  
     FT_INSTANCE = MI_INSTANCE,  
     FT_BOOLEANA = MI_BOOLEANA,  
     FT_UINT8A = MI_UINT8A,  
     FT_SINT8A = MI_SINT8A,  
     FT_UINT16A = MI_UINT16A,  
     FT_SINT16A = MI_SINT16A,  
     FT_UINT32A = MI_UINT32A,  
     FT_SINT32A = MI_SINT32A,  
     FT_UINT64A = MI_UINT64A,  
     FT_SINT64A = MI_SINT64A,  
     FT_REAL32A = MI_REAL32A,  
     FT_REAL64A = MI_REAL64A,  
     FT_CHAR16A = MI_CHAR16A,  
     FT_DATETIMEA = MI_DATETIMEA,  
     FT_STRINGA = MI_STRINGA,  
     FT_REFERENCEA = MI_REFERENCEA,  
     FT_INSTANCEA = MI_INSTANCEA,  
     FT_RESULT,  
     FT_ATOMIC  
 }  
 FieldType;  
   
 /* Defines meta data for message field (to support printing) */  
 typedef struct Field  
 {  
     /* Name of field */  
     const char* name;  
   
     /* (T=Tag, S=String, B=Boolean, A=StringArray, O=Object) */  
     FieldType type;  
   
     /* Byte off within structure to this field */  
     size_t off;  
 }  
 Field;  
   
 typedef enum _MessageFieldType typedef enum _MessageFieldType
 { {
     MFT_END_OF_LIST,    /* special type to terminate list of fields */     MFT_END_OF_LIST,    /* special type to terminate list of fields */
Line 103 
Line 53 
 /* Defines meta data for message field (to support packing/unpacking) */ /* Defines meta data for message field (to support packing/unpacking) */
 typedef struct _MessageField typedef struct _MessageField
 { {
     /* (T=Tag, S=String, B=Boolean, A=StringArray, O=Object) */      /* (ZT=Tag, S=String, B=Boolean, A=StringArray, O=Object) */
     MessageFieldType type;     MessageFieldType type;
  
     /* Byte off within structure to this field and (for instance) to packed pointer/size */     /* Byte off within structure to this field and (for instance) to packed pointer/size */
Line 117 
Line 67 
 { {
     {MFT_POINTER_SET_NULL,offsetof(Message, next),0,0},     {MFT_POINTER_SET_NULL,offsetof(Message, next),0,0},
     {MFT_POINTER_SET_NULL,offsetof(Message, prev),0,0},     {MFT_POINTER_SET_NULL,offsetof(Message, prev),0,0},
     {MFT_POINTER_SET_NULL,offsetof(Message, request),0,0},  
     {MFT_POINTER_SET_NULL,offsetof(Message, callback),0,0},  
     {MFT_POINTER_SET_NULL,offsetof(Message, callbackData),0,0},  
     {MFT_POINTER_SET_NULL,offsetof(Message, dtor),0,0},     {MFT_POINTER_SET_NULL,offsetof(Message, dtor),0,0},
     {MFT_POINTER_SET_NULL,offsetof(Message, dtorData),0,0},     {MFT_POINTER_SET_NULL,offsetof(Message, dtorData),0,0},
     {MFT_POINTER_OPT,offsetof(Message, libraryName),0,0},  
     {MFT_END_OF_LIST, 0, 0, 0}     {MFT_END_OF_LIST, 0, 0, 0}
 }; };
  
Line 131 
Line 77 
     {MFT_END_OF_LIST, 0, 0, 0}     {MFT_END_OF_LIST, 0, 0, 0}
 }; };
  
   static const MessageField requestMessageFields[] =
   {
       {MFT_POINTER_OPT,offsetof(RequestMsg, libraryName),0,0},
       {MFT_INSTANCE_OPT,offsetof(RequestMsg, options),offsetof(RequestMsg, packedOptionsPtr),offsetof(RequestMsg, packedOptionsSize)},
       {MFT_END_OF_LIST, 0, 0, 0}
   };
   
   static const MessageField getClassMessageFields[] =
   {
       {MFT_POINTER,offsetof(GetClassReq, nameSpace),0,0},
       {MFT_POINTER,offsetof(GetClassReq, className),0,0},
       {MFT_END_OF_LIST, 0, 0, 0}
   };
   
 static const MessageField getInstanceMessageFields[] = static const MessageField getInstanceMessageFields[] =
 { {
     {MFT_POINTER,offsetof(GetInstanceReq, nameSpace),0,0},     {MFT_POINTER,offsetof(GetInstanceReq, nameSpace),0,0},
Line 144 
Line 104 
     {MFT_END_OF_LIST, 0, 0, 0}     {MFT_END_OF_LIST, 0, 0, 0}
 }; };
  
   static const MessageField postSchemaMessageFields[] =
   {
       {MFT_INSTANCE_OPT,offsetof(PostSchemaMsg, schemaInstance),offsetof(PostSchemaMsg, packedSchemaInstancePtr),offsetof(PostSchemaMsg, packedSchemaInstanceSize)},
       {MFT_POINTER_OPT,offsetof(PostSchemaMsg, packedSchemaWsmanPtr),0, 0},
       {MFT_END_OF_LIST, 0, 0, 0}
   };
   
 static const MessageField enumerateInstancesMessageFields[] = static const MessageField enumerateInstancesMessageFields[] =
 { {
     {MFT_POINTER,offsetof(EnumerateInstancesReq, nameSpace),0,0},     {MFT_POINTER,offsetof(EnumerateInstancesReq, nameSpace),0,0},
     {MFT_POINTER,offsetof(EnumerateInstancesReq, className),0,0},      {MFT_POINTER_OPT,offsetof(EnumerateInstancesReq, className),0,0},
     {MFT_POINTER_OPT,offsetof(EnumerateInstancesReq, requestClassName),0,0},     {MFT_POINTER_OPT,offsetof(EnumerateInstancesReq, requestClassName),0,0},
     {MFT_POINTER_OPT,offsetof(EnumerateInstancesReq, queryLanguage),0,0},     {MFT_POINTER_OPT,offsetof(EnumerateInstancesReq, queryLanguage),0,0},
     {MFT_POINTER_OPT,offsetof(EnumerateInstancesReq, queryExpression),0,0},     {MFT_POINTER_OPT,offsetof(EnumerateInstancesReq, queryExpression),0,0},
       {MFT_POINTER_SET_NULL,offsetof(EnumerateInstancesReq, propertySet),0,0},
       {MFT_POINTER_SET_NULL,offsetof(EnumerateInstancesReq, wql),0,0},
     {MFT_END_OF_LIST, 0, 0, 0}     {MFT_END_OF_LIST, 0, 0, 0}
 }; };
  
Line 166 
Line 135 
  
 static const MessageField associatorsOfMessageFields[] = static const MessageField associatorsOfMessageFields[] =
 { {
     {MFT_POINTER,offsetof(AssociatorsOfReq, nameSpace),0,0},      {MFT_POINTER,offsetof(AssociationsOfReq, nameSpace),0,0},
     {MFT_POINTER_OPT,offsetof(AssociatorsOfReq, className),0,0},      {MFT_POINTER_OPT,offsetof(AssociationsOfReq, className),0,0},
     {MFT_POINTER_OPT,offsetof(AssociatorsOfReq, assocClass),0,0},      {MFT_POINTER_OPT,offsetof(AssociationsOfReq, assocClass),0,0},
     {MFT_POINTER_OPT,offsetof(AssociatorsOfReq, resultClass),0,0},      {MFT_POINTER_OPT,offsetof(AssociationsOfReq, resultClass),0,0},
     {MFT_POINTER_OPT,offsetof(AssociatorsOfReq, role),0,0},      {MFT_POINTER_OPT,offsetof(AssociationsOfReq, role),0,0},
     {MFT_POINTER_OPT,offsetof(AssociatorsOfReq, resultRole),0,0},      {MFT_POINTER_OPT,offsetof(AssociationsOfReq, resultRole),0,0},
     {MFT_INSTANCE,offsetof(AssociatorsOfReq, instance),offsetof(AssociatorsOfReq, packedInstancePtr),offsetof(AssociatorsOfReq, packedInstanceSize)},      {MFT_INSTANCE,offsetof(AssociationsOfReq, instance),offsetof(AssociationsOfReq, packedInstancePtr),offsetof(AssociationsOfReq, packedInstanceSize)},
     {MFT_END_OF_LIST, 0, 0, 0}     {MFT_END_OF_LIST, 0, 0, 0}
 }; };
  
 static const MessageField referencesOfMessageFields[] = static const MessageField referencesOfMessageFields[] =
 { {
     {MFT_POINTER,offsetof(ReferencesOfReq, nameSpace),0,0},      {MFT_POINTER,offsetof(AssociationsOfReq, nameSpace),0,0},
     {MFT_POINTER_OPT,offsetof(ReferencesOfReq, className),0,0},      {MFT_POINTER_OPT,offsetof(AssociationsOfReq, className),0,0},
     {MFT_POINTER_OPT,offsetof(ReferencesOfReq, assocClass),0,0},      {MFT_POINTER_OPT,offsetof(AssociationsOfReq, assocClass),0,0},
     {MFT_POINTER_OPT,offsetof(ReferencesOfReq, role),0,0},      {MFT_POINTER_OPT,offsetof(AssociationsOfReq, resultClass),0,0},
     {MFT_INSTANCE,offsetof(ReferencesOfReq, instance),offsetof(ReferencesOfReq, packedInstancePtr),offsetof(ReferencesOfReq, packedInstanceSize)},      {MFT_POINTER_OPT,offsetof(AssociationsOfReq, role),0,0},
       {MFT_POINTER_OPT,offsetof(AssociationsOfReq, resultRole),0,0},
       {MFT_INSTANCE,offsetof(AssociationsOfReq, instance),offsetof(AssociationsOfReq, packedInstancePtr),offsetof(AssociationsOfReq, packedInstanceSize)},
     {MFT_END_OF_LIST, 0, 0, 0}     {MFT_END_OF_LIST, 0, 0, 0}
 }; };
  
 static const MessageField subscribeRequestMessageFields[] = static const MessageField subscribeRequestMessageFields[] =
 { {
     {MFT_POINTER,offsetof(SubscribeReq, nameSpace),0,0},     {MFT_POINTER,offsetof(SubscribeReq, nameSpace),0,0},
     {MFT_POINTER,offsetof(SubscribeReq, className),0,0},      {MFT_POINTER_OPT,offsetof(SubscribeReq, className),0,0},
       {MFT_POINTER_OPT,offsetof(SubscribeReq, bookmark),0,0},
     {MFT_POINTER,offsetof(SubscribeReq, filter),0,0},     {MFT_POINTER,offsetof(SubscribeReq, filter),0,0},
     {MFT_POINTER,offsetof(SubscribeReq, language),0,0},     {MFT_POINTER,offsetof(SubscribeReq, language),0,0},
     {MFT_END_OF_LIST, 0, 0, 0}     {MFT_END_OF_LIST, 0, 0, 0}
 }; };
  
 static const MessageField subscribeResponseMessageFields[] =  
 {  
     {MFT_POINTER,offsetof(SubscribeRes, subscriptionID),0,0},  
     {MFT_END_OF_LIST, 0, 0, 0}  
 };  
   
 static const MessageField deleteInstanceMessageFields[] = static const MessageField deleteInstanceMessageFields[] =
 { {
     {MFT_POINTER,offsetof(DeleteInstanceReq, nameSpace),0,0},     {MFT_POINTER,offsetof(DeleteInstanceReq, nameSpace),0,0},
Line 230 
Line 196 
     {MFT_END_OF_LIST, 0, 0, 0}     {MFT_END_OF_LIST, 0, 0, 0}
 }; };
  
 /* Entries in this array corresponds to MessageTag values:  static const MessageField binPostResultMsgFields[] =
     GetInstanceReqTag = 1,  {
     PostInstanceMsgTag = 2,      {MFT_POINTER_OPT,offsetof(PostResultMsg, errorMessage),0,0},
     EnumerateInstancesReqTag = 3,      {MFT_INSTANCE_OPT,offsetof(PostResultMsg, cimError),offsetof(PostResultMsg, packedInstancePtr),offsetof(PostResultMsg, packedInstanceSize)},
     PostResultMsgTag = 4,      {MFT_POINTER_OPT,offsetof(PostResultMsg, cimErrorClassName),0,0},
     NoOpReqTag = 5,      {MFT_END_OF_LIST, 0, 0, 0}
     NoOpRspTag = 6,  };
     DispResultMsgTag = 7,  
     InvokeReqTag = 8,  static const MessageField postIndicationMessageFields[] =
     AssociatorsOfReqTag = 9,  {
     ReferencesOfReqTag = 10,      {MFT_POINTER_OPT,offsetof(PostIndicationMsg, machineID), 0, 0},
     SubscribeReqTag = 11,      {MFT_POINTER_OPT,offsetof(PostIndicationMsg, bookmark), 0, 0},
     SubscribeResTag = 12,      {MFT_INSTANCE,offsetof(PostInstanceMsg, instance),offsetof(PostInstanceMsg, packedInstancePtr),offsetof(PostInstanceMsg, packedInstanceSize)},
     DeleteInstanceReqTag = 13,      {MFT_END_OF_LIST, 0, 0, 0}
     CreateInstanceReqTag = 14,  };
     ModifyInstanceReqTag = 15,  
     BinProtocolNotificationTag = 16  /* Entries in this array corresponds to MessageTag values */
 */  
 typedef struct _MessageDeclaration typedef struct _MessageDeclaration
 { {
     const MessageField* fields;     const MessageField* fields;
Line 260 
Line 225 
     {baseMessageFields,                 0,                       MI_FALSE},     {baseMessageFields,                 0,                       MI_FALSE},
     {getInstanceMessageFields,          sizeof(GetInstanceReq),   MI_TRUE},     {getInstanceMessageFields,          sizeof(GetInstanceReq),   MI_TRUE},
     {postInstanceMessageFields,         sizeof(PostInstanceMsg),        MI_TRUE},     {postInstanceMessageFields,         sizeof(PostInstanceMsg),        MI_TRUE},
     {enumerateInstancesMessageFields,   sizeof(EnumerateInstancesReq),      MI_FALSE},      {enumerateInstancesMessageFields,   sizeof(EnumerateInstancesReq),  MI_TRUE},
     {emptyMessageFields,                sizeof(PostResultMsg),      MI_FALSE},      {binPostResultMsgFields,            sizeof(PostResultMsg),          MI_FALSE},
     {emptyMessageFields,                sizeof(NoOpReq),        MI_FALSE},     {emptyMessageFields,                sizeof(NoOpReq),        MI_FALSE},
     {emptyMessageFields,                sizeof(NoOpRsp),        MI_FALSE},     {emptyMessageFields,                sizeof(NoOpRsp),        MI_FALSE},
     {emptyMessageFields,                sizeof(DispResultMsg),      MI_FALSE},  
     {invokeMessageFields,               sizeof(InvokeReq),      MI_TRUE},     {invokeMessageFields,               sizeof(InvokeReq),      MI_TRUE},
     {associatorsOfMessageFields,        sizeof(AssociatorsOfReq),       MI_TRUE},      {associatorsOfMessageFields,        sizeof(AssociationsOfReq),      MI_TRUE},
     {referencesOfMessageFields,         sizeof(ReferencesOfReq),        MI_TRUE},      {referencesOfMessageFields,         sizeof(AssociationsOfReq),      MI_TRUE},
     {subscribeRequestMessageFields,     sizeof(SubscribeReq),       MI_FALSE},      {subscribeRequestMessageFields,     sizeof(SubscribeReq),           MI_TRUE},
     {subscribeResponseMessageFields,    sizeof(SubscribeRes),       MI_FALSE},      {emptyMessageFields,                sizeof(UnsubscribeReq),         MI_FALSE},
     {deleteInstanceMessageFields,       sizeof(DeleteInstanceReq),      MI_TRUE},     {deleteInstanceMessageFields,       sizeof(DeleteInstanceReq),      MI_TRUE},
     {createInstanceMessageFields,       sizeof(CreateInstanceReq),      MI_TRUE},     {createInstanceMessageFields,       sizeof(CreateInstanceReq),      MI_TRUE},
     {modifyInstanceMessageFields,       sizeof(ModifyInstanceReq),      MI_TRUE},     {modifyInstanceMessageFields,       sizeof(ModifyInstanceReq),      MI_TRUE},
     {binProtocolNotificationFields,     sizeof(BinProtocolNotification),MI_FALSE}      {binProtocolNotificationFields,     sizeof(BinProtocolNotification),MI_FALSE},
       {getClassMessageFields,             sizeof(GetClassReq),            MI_TRUE},
       {postSchemaMessageFields,           sizeof(PostSchemaMsg),          MI_TRUE},
       {emptyMessageFields,                sizeof(HttpRequestMsg),         MI_FALSE},  // this doesnt go thru agent connection anyway
       {emptyMessageFields,                sizeof(HttpResponseMsg),        MI_FALSE},  // this doesnt go thru agent connection anyway
       {postIndicationMessageFields,       sizeof(PostIndicationMsg),      MI_TRUE},
       {emptyMessageFields,                sizeof(SubscribeRes),           MI_FALSE},
       {emptyMessageFields,                sizeof(CancelMsg),              MI_FALSE},
       {emptyMessageFields,                sizeof(ProtocolEventConnect),   MI_FALSE},  // this doesnt go thru agent connection anyway
 }; };
  
 /* /*
Line 287 
Line 259 
 Message* __Message_New( Message* __Message_New(
     MessageTag tag,     MessageTag tag,
     size_t structSize,     size_t structSize,
     MI_Uint64 msgID,      MI_Uint64 operationId,
     MI_Uint32 flags)      MI_Uint32 flags,
       CallSite cs)
 { {
     Batch *batch;     Batch *batch;
     Message* self;     Message* self;
Line 299 
Line 272 
         return NULL;         return NULL;
  
     /* Allocate heap space for message */     /* Allocate heap space for message */
     self = Batch_Get(batch, structSize);      self = (Message*) Batch_Get(batch, structSize);
  
     if (!self)     if (!self)
         return NULL;         return NULL;
Line 311 
Line 284 
     self->tag = tag;     self->tag = tag;
  
     /* Set the message id and flags */     /* Set the message id and flags */
     self->msgID = msgID;      self->operationId = operationId;
     self->flags = flags;     self->flags = flags;
  
     /* ref-counter is set to 1, to balance NewMessage/Release Message pair*/     /* ref-counter is set to 1, to balance NewMessage/Release Message pair*/
Line 320 
Line 293 
     /* Copy batch onto message (released by delete method) */     /* Copy batch onto message (released by delete method) */
     self->batch = batch;     self->batch = batch;
  
     return self;      (void)cs;
 }  #if defined(CONFIG_ENABLE_DEBUG)
   
 /*  
     Decrements message's ref-counter and destroys  
     mesage if last reference was released  
     Parameters:  
     self - message to decref/release  
 */  
 void Message_Release(  
     Message* self)  
 {  
     if (AtomicDec(&self->refCounter))  
     {  
         /* Call destructor */  
         if (self->dtor)  
             (*self->dtor)(self, self->dtorData);  
   
         /* Release linked request */  
         if (self->request)  
             Message_Release(self->request);  
   
         Batch_Destroy(self->batch);  
     }  
 }  
   
 static void _Message_Print(  
     const void* msg,  
     FILE* os,  
     const char* structName,  
     const Field fields[])  
 {  
     size_t i;  
   
     fprintf(os, "%s\n", structName);  
     fprintf(os, "{\n");  
   
     for (i = 0; fields[i].name; i++)  
     {  
         const Field* f = &fields[i];  
   
         /* Print name */  
         fprintf(os, "    %s=", f->name);  
   
         /* Print value */  
         switch (f->type)  
         {  
             case FT_UINT32:  
             {  
                 MessageTag* p = (MessageTag*)((char*)msg + f->off);  
                 fprintf(os, "%u", *p);  
                 break;  
             }  
             case FT_RESULT:  
             {  
                 MI_Result* p = (MI_Result*)((char*)msg + f->off);  
                 Fzprintf(os, MI_T("%u [%s]"),*p, Result_ToString(*p));  
   
                 break;  
             }  
             case FT_ATOMIC:  
             {  
                 AtomicInt* p = (AtomicInt*)((char*)msg + f->off);  
                 Fzprintf(os, MI_T("%d"),(int)(*p));  
   
                 break;  
             }  
             case FT_UINT64:  
             {  
                 MI_Uint64* p = (MI_Uint64*)((char*)msg + f->off);  
                 fprintf(os, UINT64_FMT, *p);  
                 break;  
             }  
             case FT_BOOLEAN:  
             {  
                 MI_Boolean* p = (MI_Boolean*)((char*)msg + f->off);  
                 fprintf(os, "%s", *p ? "TRUE" : "FALSE");  
                 break;  
             }  
             case FT_STRING:  
             {  
                 MI_Char** p = (MI_Char**)((char*)msg + f->off);  
   
                 if (*p)  
                     Fzprintf(os, MI_T("\"%s\""), *p);  
                 else  
                     fprintf(os, "NULL");  
                 break;  
             }  
             case FT_STRINGA:  
             {  
                 StringArray** p = (StringArray**)((char*)msg + f->off);  
   
                 if (*p)  
                     StringArray_Print(*p, os);  
                 else  
                     fprintf(os, "NULL");  
                 break;  
             }  
             case FT_INSTANCE:  
             {  
                 MI_Instance** p = (MI_Instance**)((char*)msg + f->off);  
   
                 if (*p)  
                 {                 {
                     fputc('\n', os);          const char* file = "";
                     MI_Instance_Print(*p, os, 1);          size_t line = 0;
           const PAL_Char* name = MessageName(self->tag);
           file = cs.file;
           line = cs.line;
           trace_Message_New(file, (MI_Uint32)line, name, self, (unsigned int)self->refCounter);
                 }                 }
                 else  #endif /* defined(CONFIG_ENABLE_DEBUG) */
                     fprintf(os, "NULL\n");  
                 break;  
             }  
             default:  
                 break;  
         }  
   
         if (f->type != FT_INSTANCE)  
             fputc('\n', os);  
     }  
   
     fprintf(os, "}\n");  
 }  
   
 void MessagePrint(const Message* msg, FILE* os)  
 {  
     switch ( msg->tag )  
     {  
         case GetInstanceReqTag:  
             {  
                 const GetInstanceReq* m = (const GetInstanceReq*)msg;  
                 GetInstanceReq_Print(m, os);  
             }  
             break;  
   
         case PostInstanceMsgTag:  
             {  
                 const PostInstanceMsg* m = (const PostInstanceMsg*)msg;  
                 PostInstanceMsg_Print(m, os);  
             }  
             break;  
   
         case EnumerateInstancesReqTag:  
             {  
                 const EnumerateInstancesReq* m = (const EnumerateInstancesReq*)msg;  
                 EnumerateInstancesReq_Print(m, os);  
             }  
             break;  
   
         case PostResultMsgTag:  
             {  
                 const PostResultMsg* m = (const PostResultMsg*)msg;  
                 PostResultMsg_Print(m, os);  
             }  
             break;  
   
         case NoOpReqTag:  
             {  
                 const NoOpReq* m = (const NoOpReq*)msg;  
                 NoOpReq_Print(m, os);  
             }  
             break;  
   
         case NoOpRspTag:  
             {  
                 const NoOpRsp* m = (const NoOpRsp*)msg;  
                 NoOpRsp_Print(m, os);  
             }  
             break;  
   
         case DispResultMsgTag:  
             {  
                 const DispResultMsg* m = (const DispResultMsg*)msg;  
                 DispResultMsg_Print(m, os);  
             }  
             break;  
   
         case InvokeReqTag:  
             {  
                 const InvokeReq* m = (const InvokeReq*)msg;  
                 InvokeReq_Print(m, os);  
             }  
             break;  
   
         case AssociatorsOfReqTag:  
             {  
                 const AssociatorsOfReq* m = (const AssociatorsOfReq*)msg;  
                 AssociatorsOfReq_Print(m, os);  
             }  
             break;  
   
         case ReferencesOfReqTag:  
             {  
                 const ReferencesOfReq* m = (const ReferencesOfReq*)msg;  
                 ReferencesOfReq_Print(m, os);  
             }  
             break;  
   
         case SubscribeReqTag:  
             {  
                 const SubscribeReq* m = (const SubscribeReq*)msg;  
                 SubscribeReq_Print(m, os);  
             }  
             break;  
   
         case SubscribeResTag:  
             {  
                 const SubscribeRes* m = (const SubscribeRes*)msg;  
                 SubscribeRes_Print(m, os);  
             }  
             break;  
   
         case DeleteInstanceReqTag:  
             {  
                 const DeleteInstanceReq* m = (const DeleteInstanceReq*)msg;  
                 DeleteInstanceReq_Print(m, os);  
             }  
             break;  
   
         case CreateInstanceReqTag:  
             {  
                 const CreateInstanceReq* m = (const CreateInstanceReq*)msg;  
                 CreateInstanceReq_Print(m, os);  
             }  
             break;  
  
         case ModifyInstanceReqTag:      return self;
             {  
                 const ModifyInstanceReq* m = (const ModifyInstanceReq*)msg;  
                 ModifyInstanceReq_Print(m, os);  
             }             }
             break;  
   
         case BinProtocolNotificationTag:  
             {  
                 const BinProtocolNotification* m = (const BinProtocolNotification*)msg;  
                 BinProtocolNotification_Print(m, os);  
             }  
             break;  
   
         default:  
             fprintf(os, "unknown message tag %d\n", msg->tag);  
             break;  
  
   void __Message_AddRef(
       Message* self,
       CallSite cs)
   {
       ptrdiff_t refs = Atomic_Inc(&self->refCounter);
       (void)refs;
       (void)cs;
   #if defined(CONFIG_ENABLE_DEBUG)
       {
           const char* file = "";
           size_t line = 0;
           const PAL_Char* name = MessageName(self->tag);
           file = cs.file;
           line = cs.line;
           trace_Message_AddRef(file, (MI_Uint32)line, name, self, (unsigned int)(refs));
     }     }
   #endif /* defined(CONFIG_ENABLE_DEBUG) */
 } }
  
 /* /*
 **==============================================================================      Decrements message's ref-counter and destroys
 **      mesage if last reference was released
 ** Field information.      Parameters:
 **      self - message to decref/release
 **==============================================================================  
 */ */
   void __Message_Release(
 void GetInstanceReq_Print(const GetInstanceReq* msg, FILE* os)      Message* self,
 {      CallSite cs)
     typedef GetInstanceReq Self;  
     static const Field fields[] =  
     {  
         {"tag", FT_UINT32, offsetof(Self, base.tag)},  
         {"msgID", FT_UINT64, offsetof(Self, base.msgID)},  
         {"clientID", FT_UINT64, offsetof(Self, base.clientID)},  
         {"instanceName", FT_INSTANCE, offsetof(Self, instanceName)},  
         {"includeClassOrigin", FT_BOOLEAN, offsetof(Self, includeClassOrigin)},  
         {"propertySet", FT_STRINGA, offsetof(Self, propertySet)},  
         {NULL, 0, 0},  
     };  
     _Message_Print(msg, os, "GetInstanceReq", fields);  
 }  
   
 void CreateInstanceReq_Print(const CreateInstanceReq* msg, FILE* os)  
 {  
     typedef CreateInstanceReq Self;  
     static const Field fields[] =  
     {     {
         {"tag", FT_UINT32, offsetof(Self, base.tag)},      ptrdiff_t refs;
         {"msgID", FT_UINT64, offsetof(Self, base.msgID)},      MI_Uint32 tag = self->tag;
         {"clientID", FT_UINT64, offsetof(Self, base.clientID)},  
         {"instanceName", FT_INSTANCE, offsetof(Self, instance)},  
         {"propertySet", FT_STRINGA, offsetof(Self, propertySet)},  
         {NULL, 0, 0},  
     };  
     _Message_Print(msg, os, "CreateInstanceReq", fields);  
 }  
  
 void ModifyInstanceReq_Print(const ModifyInstanceReq* msg, FILE* os)      DEBUG_ASSERT(Atomic_Read(&self->refCounter) > 0);
 {  
     typedef ModifyInstanceReq Self;  
     static const Field fields[] =  
     {  
         {"tag", FT_UINT32, offsetof(Self, base.tag)},  
         {"msgID", FT_UINT64, offsetof(Self, base.msgID)},  
         {"clientID", FT_UINT64, offsetof(Self, base.clientID)},  
         {"instanceName", FT_INSTANCE, offsetof(Self, instance)},  
         {"propertySet", FT_STRINGA, offsetof(Self, propertySet)},  
         {NULL, 0, 0},  
     };  
     _Message_Print(msg, os, "ModifyInstanceReq", fields);  
 }  
  
 void DeleteInstanceReq_Print(const DeleteInstanceReq* msg, FILE* os)      if (Atomic_Dec(&self->refCounter) == 0)
 { {
     typedef DeleteInstanceReq Self;          refs = self->refCounter;
     static const Field fields[] =  
     {  
         {"tag", FT_UINT32, offsetof(Self, base.tag)},  
         {"msgID", FT_UINT64, offsetof(Self, base.msgID)},  
         {"clientID", FT_UINT64, offsetof(Self, base.clientID)},  
         {"instanceName", FT_INSTANCE, offsetof(Self, instanceName)},  
         {NULL, 0, 0},  
     };  
     _Message_Print(msg, os, "DeleteInstanceReq", fields);  
 }  
  
 void InvokeReq_Print(const InvokeReq* msg, FILE* os)          /* Call destructor */
 {          if (self->dtor)
     typedef InvokeReq Self;  
     static const Field fields[] =  
     {  
         {"tag", FT_UINT32, offsetof(Self, base.tag)},  
         {"msgID", FT_UINT64, offsetof(Self, base.msgID)},  
         {"clientID", FT_UINT64, offsetof(Self, base.clientID)},  
         {"nameSpace", FT_STRING, offsetof(Self, nameSpace)},  
         {"className", FT_STRING, offsetof(Self, className)},  
         {"function", FT_STRING, offsetof(Self, function)},  
         {"instance", FT_INSTANCE, offsetof(Self, instance)},  
         {"instanceParams", FT_INSTANCE, offsetof(Self, instanceParams)},  
         {NULL, 0, 0},  
     };  
     _Message_Print(msg, os, "InvokeReq", fields);  
 }  
   
 void AssociatorsOfReq_Print(const AssociatorsOfReq* msg, FILE* os)  
 {  
     typedef AssociatorsOfReq Self;  
     static const Field fields[] =  
     {  
         {"tag", FT_UINT32, offsetof(Self, base.tag)},  
         {"msgID", FT_UINT64, offsetof(Self, base.msgID)},  
         {"clientID", FT_UINT64, offsetof(Self, base.clientID)},  
         {"nameSpace", FT_STRING, offsetof(Self, nameSpace)},  
         {"assocClass", FT_STRING, offsetof(Self, assocClass)},  
         {"resultClass", FT_STRING, offsetof(Self, resultClass)},  
         {"role", FT_STRING, offsetof(Self, role)},  
         {"resultRole", FT_STRING, offsetof(Self, resultRole)},  
         {"instance", FT_INSTANCE, offsetof(Self, instance)},  
         {NULL, 0, 0},  
     };  
     _Message_Print(msg, os, "AssociatorsOfReq", fields);  
 }  
   
 void ReferencesOfReq_Print(const ReferencesOfReq* msg, FILE* os)  
 {  
     typedef ReferencesOfReq Self;  
     static const Field fields[] =  
     {  
         {"tag", FT_UINT32, offsetof(Self, base.tag)},  
         {"msgID", FT_UINT64, offsetof(Self, base.msgID)},  
         {"clientID", FT_UINT64, offsetof(Self, base.clientID)},  
         {"nameSpace", FT_STRING, offsetof(Self, nameSpace)},  
         {"assocClass", FT_STRING, offsetof(Self, assocClass)},  
         {"role", FT_STRING, offsetof(Self, role)},  
         {"instance", FT_INSTANCE, offsetof(Self, instance)},  
         {NULL, 0, 0},  
     };  
     _Message_Print(msg, os, "ReferencesOfReq", fields);  
 }  
   
 void PostInstanceMsg_Print(const PostInstanceMsg* msg, FILE* os)  
 {  
     typedef PostInstanceMsg Self;  
     static const Field fields[] =  
     {  
         {"tag", FT_UINT32, offsetof(Self, base.tag)},  
         {"msgID", FT_UINT64, offsetof(Self, base.msgID)},  
         {"clientID", FT_UINT64, offsetof(Self, base.clientID)},  
         {"instance", FT_INSTANCE, offsetof(Self, instance)},  
         {NULL, 0, 0},  
     };  
     _Message_Print(msg, os, "PostInstanceMsg", fields);  
 }  
   
 void PostResultMsg_Print(const PostResultMsg* msg, FILE* os)  
 {  
     typedef PostResultMsg Self;  
     static const Field fields[] =  
     {  
         {"tag", FT_UINT32, offsetof(Self, base.tag)},  
         {"msgID", FT_UINT64, offsetof(Self, base.msgID)},  
         {"clientID", FT_UINT64, offsetof(Self, base.clientID)},  
         {"result", FT_RESULT, offsetof(Self, result)},  
         {NULL, 0, 0},  
     };  
     _Message_Print(msg, os, "PostResultMsg", fields);  
 }  
   
 void DispResultMsg_Print(const DispResultMsg* msg, FILE* os)  
 {  
     typedef DispResultMsg Self;  
     static const Field fields[] =  
     {     {
         {"tag", FT_UINT32, offsetof(Self, base.tag)},              (*self->dtor)(self, self->dtorData);
         {"msgID", FT_UINT64, offsetof(Self, base.msgID)},  
         {"clientID", FT_UINT64, offsetof(Self, base.clientID)},  
         {"result", FT_RESULT, offsetof(Self, result)},  
         {"requestCounter", FT_ATOMIC, offsetof(Self, requestCounter)},  
         {NULL, 0, 0},  
     };  
     _Message_Print(msg, os, "DispResultMsg", fields);  
 }  
   
 void EnumerateInstancesReq_Print(  
     const EnumerateInstancesReq* msg,  
     FILE* os)  
 {  
     typedef EnumerateInstancesReq Self;  
     static const Field fields[] =  
     {  
         {"tag", FT_UINT32, offsetof(Self, base.tag)},  
         {"msgID", FT_UINT64, offsetof(Self, base.msgID)},  
         {"clientID", FT_UINT64, offsetof(Self, base.clientID)},  
         {"nameSpace", FT_STRING, offsetof(Self, nameSpace)},  
         {"className", FT_STRING, offsetof(Self, className)},  
         {"requestClassName", FT_STRING, offsetof(Self, requestClassName)},  
         {"deepInheritance", FT_BOOLEAN, offsetof(Self, deepInheritance)},  
         {"includeClassOrigin", FT_BOOLEAN, offsetof(Self, includeClassOrigin)},  
         {"propertySet", FT_STRINGA, offsetof(Self, propertySet)},  
         {"queryLanguage", FT_STRING, offsetof(Self, queryLanguage)},  
         {"queryExpression", FT_STRING, offsetof(Self, queryExpression)},  
         {NULL, 0, 0},  
     };  
     _Message_Print(msg, os, "EnumerateInstancesReq", fields);  
 } }
  
 void SubscribeReq_Print(const SubscribeReq* msg, FILE* os)          Batch_Destroy(self->batch);
 {  
     typedef SubscribeReq Self;  
     static const Field fields[] =  
     {  
         {"tag", FT_UINT32, offsetof(Self, base.tag)},  
         {"msgID", FT_UINT64, offsetof(Self, base.msgID)},  
         {"clientID", FT_UINT64, offsetof(Self, base.clientID)},  
         {"nameSpace", FT_STRING, offsetof(Self, nameSpace)},  
         {"className", FT_STRING, offsetof(Self, className)},  
         {"filter", FT_STRING, offsetof(Self, filter)},  
         {"language", FT_STRING, offsetof(Self, language)},  
         {NULL, 0, 0},  
     };  
     _Message_Print(msg, os, "SubscribeReq", fields);  
 } }
       else
 void SubscribeRes_Print(const SubscribeRes* msg, FILE* os)  
 {  
     typedef SubscribeRes Self;  
     static const Field fields[] =  
     {     {
         {"tag", FT_UINT32, offsetof(Self, base.tag)},          refs = self->refCounter;
         {"msgID", FT_UINT64, offsetof(Self, base.msgID)},  
         {"clientID", FT_UINT64, offsetof(Self, base.clientID)},  
         {"subscriptionID", FT_STRING, offsetof(Self, subscriptionID)},  
         {NULL, 0, 0},  
     };  
     _Message_Print(msg, os, "SubscribeRes", fields);  
 } }
  
 void NoOpReq_Print(const NoOpReq* msg, FILE* os)      (void)refs;
 {      (void)cs;
     typedef NoOpReq Self;      (void)tag;
     static const Field fields[] =  #if defined(CONFIG_ENABLE_DEBUG)
     {     {
         {"tag", FT_UINT32, offsetof(Self, base.tag)},          const char* file = "";
         {"msgID", FT_UINT64, offsetof(Self, base.msgID)},          size_t line = 0;
         {"clientID", FT_UINT64, offsetof(Self, base.clientID)},          const PAL_Char* name = MessageName(tag);
         {NULL, 0, 0},  
     };  
     _Message_Print(msg, os, "NoOpReq", fields);  
 }  
  
 void NoOpRsp_Print(const NoOpRsp* msg, FILE* os)          file = cs.file;
 {          line = cs.line;
     typedef NoOpRsp Self;          trace_Message_Release(file, (MI_Uint32)line, name, self, (unsigned int)(refs));
     static const Field fields[] =  
     {  
         {"tag", FT_UINT32, offsetof(Self, base.tag)},  
         {"msgID", FT_UINT64, offsetof(Self, base.msgID)},  
         {"clientID", FT_UINT64, offsetof(Self, base.clientID)},  
         {NULL, 0, 0},  
     };  
     _Message_Print(msg, os, "NoOpRsp", fields);  
 } }
   #endif /* defined(CONFIG_ENABLE_DEBUG) */
 void BinProtocolNotification_Print(const BinProtocolNotification* msg, FILE* os)  
 {  
     typedef BinProtocolNotification Self;  
     static const Field fields[] =  
     {  
         {"tag", FT_UINT32, offsetof(Self, base.tag)},  
         {"msgID", FT_UINT64, offsetof(Self, base.msgID)},  
         {"clientID", FT_UINT64, offsetof(Self, base.clientID)},  
         {NULL, 0, 0},  
     };  
     _Message_Print(msg, os, "BinProtocolNotification", fields);  
 } }
  
 static MI_Boolean _UnpackInstance( static MI_Boolean _UnpackInstance(
Line 869 
Line 420 
                     ptrAdjustmentInfo,                     ptrAdjustmentInfo,
                     ptrAdjustmentInfoCount,                     ptrAdjustmentInfoCount,
                     ptr))                     ptr))
                   {
                       trace_RestoreMsgFailed_PointersForMstPointer();
                         return MI_RESULT_INVALID_PARAMETER;                         return MI_RESULT_INVALID_PARAMETER;
             }             }
               }
             else if (messageFields->type == MFT_POINTER)             else if (messageFields->type == MFT_POINTER)
               {
                   trace_RestoreMsgFailed_PointerIsNull();
                 return MI_RESULT_INVALID_PARAMETER;                 return MI_RESULT_INVALID_PARAMETER;
               }
  
             break;             break;
  
Line 891 
Line 448 
                         ptrAdjustmentInfo,                         ptrAdjustmentInfo,
                         ptrAdjustmentInfoCount,                         ptrAdjustmentInfoCount,
                         ptrPacked))                         ptrPacked))
                       {
                           trace_RestoreMsgFailed_PointersForMstInstance();
                         return MI_RESULT_INVALID_PARAMETER;                         return MI_RESULT_INVALID_PARAMETER;
                       }
  
                     if (!skipInstanceUnpack && !_UnpackInstance(                     if (!skipInstanceUnpack && !_UnpackInstance(
                         batch,                         batch,
                         *ptrPacked,                         *ptrPacked,
                         packedSize,                         packedSize,
                         (MI_Instance**)ptr))                         (MI_Instance**)ptr))
                       {
                           trace_RestoreMsgFailed_UnpackingInstance();
                         return MI_RESULT_INVALID_PARAMETER;                         return MI_RESULT_INVALID_PARAMETER;
                 }                 }
                   }
                 else if (messageFields->type == MFT_INSTANCE)                 else if (messageFields->type == MFT_INSTANCE)
                   {
                       trace_RestoreMsgFailed_PtrPackedMissing();
                     return MI_RESULT_INVALID_PARAMETER;                     return MI_RESULT_INVALID_PARAMETER;
                   }
             }             }
  
             break;             break;
Line 917 
Line 482 
     return MI_RESULT_OK;     return MI_RESULT_OK;
 } }
  
 static MI_Result _Clone(  static MI_Result _CloneMessageFields(
     const Message* msgSrc,      _In_        const Message*      msgSrc,
     Message* msg,      _Inout_     Message*            msg,
     const MessageField* messageFields,      _In_        const MessageField* messageFields )
     size_t size)  
 { {
     char* chunk = (char*)msg;     char* chunk = (char*)msg;
     Batch* batch = msg->batch;     Batch* batch = msg->batch;
     const char* chunkSrc = (const char*)msgSrc;     const char* chunkSrc = (const char*)msgSrc;
  
     /* copy all primitve data first */  
     memcpy(chunk + sizeof(Message), chunkSrc + sizeof(Message), size - sizeof(Message));  
   
     while (messageFields->type != MFT_END_OF_LIST)     while (messageFields->type != MFT_END_OF_LIST)
     {     {
         void** ptr = (void**)(chunk + messageFields->off);         void** ptr = (void**)(chunk + messageFields->off);
Line 939 
Line 500 
         {         {
         case MFT_POINTER_SET_NULL:         case MFT_POINTER_SET_NULL:
         default:         default:
               {
             break;             break;
               }
  
         case MFT_POINTER_OPT:         case MFT_POINTER_OPT:
         case MFT_POINTER:         case MFT_POINTER:
               {
             if (*ptrSrc)             if (*ptrSrc)
             {             {
                 *ptr = Batch_Strdup2(batch, (const char*)*ptrSrc);                      *ptr = Batch_Tcsdup(batch, (const ZChar*)*ptrSrc);
  
                 if (!*ptr)                 if (!*ptr)
                     return MI_RESULT_FAILED;                     return MI_RESULT_FAILED;
Line 954 
Line 518 
                 return MI_RESULT_INVALID_PARAMETER;                 return MI_RESULT_INVALID_PARAMETER;
  
             break;             break;
               }
  
         case MFT_INSTANCE:         case MFT_INSTANCE:
         case MFT_INSTANCE_OPT:         case MFT_INSTANCE_OPT:
             {             {
                 void** ptrPacked = (void**)(chunk + messageFields->offPackedPtr);                  void** ptrPacked =
                 MI_Uint32* packedSize =  (MI_Uint32*)(chunk + messageFields->offPackedSize);                      (void**)(chunk + messageFields->offPackedPtr);
                 const void* ptrPackedSrc = *(void**)(chunkSrc + messageFields->offPackedPtr);  
                 MI_Uint32 packedSizeSrc =  *(MI_Uint32*)(chunkSrc + messageFields->offPackedSize);                  MI_Uint32* packedSize =
                       (MI_Uint32*)(chunk + messageFields->offPackedSize);
   
                   const void* ptrPackedSrc =
                       *(void**)(chunkSrc + messageFields->offPackedPtr);
   
                   MI_Uint32 packedSizeSrc =
                       *(MI_Uint32*)(chunkSrc + messageFields->offPackedSize);
  
                 *ptr = 0;                 *ptr = 0;
  
                 if (ptrPackedSrc)                 if (ptrPackedSrc)
                 {                 {
                     /* Take existing packed instance if exist (received from binary protocol */                      /* Take existing packed instance if exist (received from
                        * binary protocol
                        */
                     *packedSize = packedSizeSrc;                     *packedSize = packedSizeSrc;
                     *ptrPacked = Batch_Get(batch, packedSizeSrc);                     *ptrPacked = Batch_Get(batch, packedSizeSrc);
  
Line 1000 
Line 574 
  
     return MI_RESULT_OK;     return MI_RESULT_OK;
 } }
 MI_Result MessageFromBatch(  
   static MI_Result _CloneMessage(
       _In_        const Message*      msgSrc,
       _Inout_     Message*            msg,
                   MI_Uint32           messageTag )
   {
       char* chunk = (char*)msg;
       const char* chunkSrc = (const char*)msgSrc;
       MI_Uint32 messageIndex = MessageTagIndex( messageTag );
       MI_Result result = MI_RESULT_OK;
   
       if (messageIndex >= MI_COUNT(allMessages))
       {
           trace_RestoreMsgFailed_InvalidTag( msg->tag );
           return MI_RESULT_INVALID_PARAMETER;
       }
   
       /* copy all primitive data first */
       memcpy(chunk + sizeof(Message), chunkSrc + sizeof(Message), allMessages[messageIndex].size - sizeof(Message));
   
       if( MessageTag_IsRequest( messageTag ) )
       {
           result = _CloneMessageFields(msgSrc, msg, requestMessageFields);
       }
       if( MI_RESULT_OK == result )
       {
           result = _CloneMessageFields(msgSrc, msg, allMessages[messageIndex].fields);
       }
   
       return result;
   }
   
   MI_Result __MessageFromBatch(
     Batch* batch,     Batch* batch,
     void* originalMsgPtr,     void* originalMsgPtr,
     const Header_BatchInfoItem* ptrAdjustmentInfo,     const Header_BatchInfoItem* ptrAdjustmentInfo,
     size_t ptrAdjustmentInfoCount,     size_t ptrAdjustmentInfoCount,
     MI_Boolean skipInstanceUnpack,     MI_Boolean skipInstanceUnpack,
     Message** msgOut)      Message** msgOut,
       CallSite cs)
 { {
     Message* msg = originalMsgPtr;     Message* msg = originalMsgPtr;
     MI_Uint32 index;     MI_Uint32 index;
Line 1016 
Line 623 
         ptrAdjustmentInfo,         ptrAdjustmentInfo,
         ptrAdjustmentInfoCount,         ptrAdjustmentInfoCount,
         (void*)&msg))         (void*)&msg))
       {
           trace_BatchFixPointerFailed();
         return MI_RESULT_INVALID_PARAMETER;         return MI_RESULT_INVALID_PARAMETER;
       }
  
     /* fix base part of message */     /* fix base part of message */
     msg->batch = batch;     msg->batch = batch;
Line 1028 
Line 638 
         ptrAdjustmentInfoCount,         ptrAdjustmentInfoCount,
         skipInstanceUnpack,         skipInstanceUnpack,
         baseMessageFields))         baseMessageFields))
       {
           trace_RestoreMsgFailed_FirstTime();
         return MI_RESULT_INVALID_PARAMETER;         return MI_RESULT_INVALID_PARAMETER;
       }
   
       index = MessageTagIndex( msg->tag );
  
     index = (MI_Uint32)msg->tag;      trace_MessageFromBatch(msg->tag, index);
  
     if (index >= MI_COUNT(allMessages))     if (index >= MI_COUNT(allMessages))
       {
           trace_RestoreMsgFailed_InvalidTag( msg->tag );
         return MI_RESULT_INVALID_PARAMETER;         return MI_RESULT_INVALID_PARAMETER;
       }
   
       if( MessageTag_IsRequest( msg->tag ) )
       {
           if (MI_RESULT_OK != _RestoreMessage(
               msg,
               ptrAdjustmentInfo,
               ptrAdjustmentInfoCount,
               skipInstanceUnpack,
               requestMessageFields))
           {
               trace_RestoreMsgFailed_SecondTime(msg->tag);
               return MI_RESULT_INVALID_PARAMETER;
           }
       }
  
     if (MI_RESULT_OK != _RestoreMessage(     if (MI_RESULT_OK != _RestoreMessage(
         msg,         msg,
Line 1041 
Line 673 
         ptrAdjustmentInfoCount,         ptrAdjustmentInfoCount,
         skipInstanceUnpack,         skipInstanceUnpack,
         allMessages[index].fields))         allMessages[index].fields))
       {
           trace_RestoreMsgFailed_ThirdTime(msg->tag);
         return MI_RESULT_INVALID_PARAMETER;         return MI_RESULT_INVALID_PARAMETER;
       }
  
     *msgOut = msg;     *msgOut = msg;
   
       (void)cs;
   #if defined(CONFIG_ENABLE_DEBUG)
       {
           const char* file = "";
           size_t line = 0;
           const PAL_Char* name = MessageName(msg->tag);
           file = cs.file;
           line = cs.line;
           trace_MessageFromBatch_Complete(file, (MI_Uint32)line, name, msg, (unsigned int)msg->refCounter);
       }
   #endif /* defined(CONFIG_ENABLE_DEBUG) */
   
     return MI_RESULT_OK;     return MI_RESULT_OK;
 } }
  
Line 1053 
Line 701 
 { {
     Message* msg = msgSrc;     Message* msg = msgSrc;
     MI_Uint32 index;     MI_Uint32 index;
       MI_Result result;
  
     index = (MI_Uint32)msg->tag;      index = MessageTagIndex( msg->tag );
  
     if (index >= MI_COUNT(allMessages))     if (index >= MI_COUNT(allMessages))
         return MI_RESULT_INVALID_PARAMETER;         return MI_RESULT_INVALID_PARAMETER;
Line 1067 
Line 716 
     }     }
  
     /* create a copy */     /* create a copy */
     msg = __Message_New(msgSrc->tag, allMessages[index].size, msgSrc->msgID, msgSrc->flags);      msg = __Message_New((MessageTag)msgSrc->tag, allMessages[index].size, msgSrc->operationId, msgSrc->flags, CALLSITE);
  
     if (!msg)     if (!msg)
       {
           trace_MessagePackCloneForBinarySending_AllocFailed(msgSrc->tag);
         return MI_RESULT_FAILED;         return MI_RESULT_FAILED;
       }
  
     msg->clientID = msgSrc->clientID;      result = _CloneMessage( msgSrc, msg, msg->tag );
       if( MI_RESULT_OK != result )
     if (MI_RESULT_OK != _Clone(msgSrc, msg, allMessages[index].fields, allMessages[index].size))  
     {     {
           trace_MessagePackCloneForBinarySending_CloneFailed(msg->tag, result);
         Message_Release(msg);         Message_Release(msg);
         return MI_RESULT_FAILED;          return result;
     }     }
  
     *msgOut = msg;     *msgOut = msg;
     return MI_RESULT_OK;     return MI_RESULT_OK;
 } }
   
   /*
   **==============================================================================
   **
   ** MessageName
   **
   **     Get message name on tag
   **
   **==============================================================================
   */
   #define UNKNOWN_MSG PAL_T("UNKNOWN Message")
   
   const PAL_Char* _MsgNames[] = {
       UNKNOWN_MSG,
       PAL_T("GetInstanceReq"),
       PAL_T("PostInstanceMsg"),
       PAL_T("EnumerateInstancesReq"),
       PAL_T("PostResultMsg"),
       PAL_T("NoOpReq"),
       PAL_T("NoOpRsp"),
       PAL_T("InvokeReq"),
       PAL_T("AssociatorsOfReq"),
       PAL_T("ReferencesOfReq"),
       PAL_T("SubscribeReq"),
       PAL_T("UnsubscribeReq"),
       PAL_T("DeleteInstanceReq"),
       PAL_T("CreateInstanceReq"),
       PAL_T("ModifyInstanceReq"),
       PAL_T("BinProtocolNotification"),
       PAL_T("GetClassReq"),
       PAL_T("PostSchemaMsg"),
       PAL_T("HttpRequestMsg"),
       PAL_T("HttpResponseMsg"),
       PAL_T("PostIndicationMsg"),
       PAL_T("SubscribeRes"),
       PAL_T("CancelMsg"),
       PAL_T("ProtocolEventConnect"),
   };
   
   const PAL_Char* MessageName(MI_Uint32 tag)
   {
       tag = MessageTagIndex(tag);
       if( tag < (MI_Uint32)(sizeof(_MsgNames)/sizeof(PAL_Char*)) )
       {
           return _MsgNames[tag];
       }
       return UNKNOWN_MSG;
   }
   
   _Use_decl_annotations_
   HttpHeaders* HttpHeaders_Clone(
       Batch* batch,
       HttpHeaders* headers)
   {
       HttpHeaders* newheaders;
       if ( !batch || !headers )
           return NULL;
   
       newheaders = (HttpHeaders*) Batch_GetClear(batch, sizeof(HttpHeaders));
       if (!newheaders)
           return NULL;
       if (headers->contentType)
       {
           newheaders->contentType = Batch_Strdup(batch, headers->contentType);
           if (!newheaders->contentType)
               return NULL;
       }
       if (headers->charset)
       {
           newheaders->charset = Batch_Strdup(batch, headers->charset);
           if (!newheaders->charset)
               return NULL;
       }
       if (headers->username)
       {
           newheaders->username = Batch_Strdup(batch, headers->username);
           if (!newheaders->username)
               return NULL;
       }
       if (headers->password)
       {
           newheaders->password = Batch_Strdup(batch, headers->password);
           if (!newheaders->password)
               return NULL;
       }
       if (headers->authorization)
       {
           newheaders->authorization = Batch_Strdup(batch, headers->authorization);
           if (!newheaders->authorization)
               return NULL;
       }
       newheaders->contentLength = headers->contentLength;
       if (headers->userAgent)
       {
           newheaders->userAgent = Batch_Strdup(batch, headers->userAgent);
           if (!newheaders->userAgent)
               return NULL;
       }
   #if defined(CONFIG_ENABLE_HTTPHEADERS)
       {
           size_t i;
           newheaders->headersSize = headers->headersSize;
           for ( i = 0; i < newheaders->headersSize; i++ )
           {
               if (headers->headers[i].name)
               {
                   newheaders->headers[i].name = Batch_Strdup(batch, headers->headers[i].name);
                   if (!newheaders->headers[i].name)
                       return NULL;
               }
               if (headers->headers[i].value)
               {
                   newheaders->headers[i].value = Batch_Strdup(batch, headers->headers[i].value);
                   if (!newheaders->headers[i].value)
                       return NULL;
               }
           }
       }
   #endif
       return newheaders;
   }
   


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

ViewCVS 0.9.2