当前位置: 首页>>代码示例>>C++>>正文


C++ Marshal函数代码示例

本文整理汇总了C++中Marshal函数的典型用法代码示例。如果您正苦于以下问题:C++ Marshal函数的具体用法?C++ Marshal怎么用?C++ Marshal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Marshal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Marshal

long SDMmessage::SendTCP(long ip_addr,long port)
{
	int sock;
	long i;
	long result;
	char buf[3*BUFSIZE];
	char ack[16];
	short error = 0;

	//fill buffer
	i = Marshal(buf);
	if(i < 0)
		return SDM_MESSAGE_SEND_ERROR;
	//send message
	sock = TCPconnect(ip_addr,port);
  if (sock != IP_SOCK_INVALID)
  {
	  result = TCPsend(sock,buf,i);
	  if(buf[0] == SDM_xTEDS || buf[0] == SDM_CancelxTEDS)
	  {
		  TCPrecv(sock,ack,13);
		  error = GET_SHORT(&ack[HEADER_SIZE]);
		  if(error < 0)
      {
			  result = error;
      }
	  }
	  TCPclose (sock);
#ifdef BUILD_WITH_MESSAGE_LOGGING
	  Logger.MessageSent(*this);
#endif
  }
	return result;
}
开发者ID:NKSG,项目名称:vn-sdm,代码行数:34,代码来源:SDMmessage.cpp

示例2: unchanged

/*
    Forward a previously received message unchanged (i.e. without changing the timestamp).

    Implementation notes:  Currently, only messages of maximum size BUFSIZE can be forwarded.
    The only message that won't send as expected is SDMxTEDS.  The reason for this is that
    the DM is the only application that should ever receive SDMxTEDS, and it will never use
    this function.

    Params:
    	destination - The component id to which to forward the message
    Returns:
    	long - The length of the message sent or -1 to indicate failure
*/
long SDMmessage::Forward(const SDMComponent_ID& destination)
{
	char buf[BUFSIZE];

	if (MsgName == SDM_xTEDS)
		return -1;

	// Save the old timestamp
	long OldSeconds = sec;
	long OldSubSeconds = subsec;

	// Marshal the message, this call will assign a new timestamp
	const long MessageLength = Marshal(buf);
	if (MessageLength < 0)
		return MessageLength;

	// Reset the old timestamp
	sec = OldSeconds;
	subsec = OldSubSeconds;

	// Remarshal the header, overwriting previous data, body of message is still intact
	MarshalHeaderOldTimeStamp(buf);

	// Now send the message to the destination component id
	int sock = UDPconnect(destination.getAddress(), destination.getPort());
	if (sock < 0)
		return -1;
	long SendResult = UDPsend(sock, buf, MessageLength);
	UDPclose(sock);

#ifdef BUILD_WITH_MESSAGE_LOGGING
	Logger.MessageSent(*this);
#endif
	return SendResult;
}
开发者ID:NKSG,项目名称:vn-sdm,代码行数:48,代码来源:SDMmessage.cpp

示例3: main

int
main( int argc, char *argv[] )
{
  tUint8         value[4]  = { 0x42, 0X43, 0X44, 0X45 };
  tUint8         result[4] = { 0x11, 0x12, 0x13, 0x14 };
  unsigned char  buffer[256];

  unsigned int s1 = Marshal( &UserDefinedType, value, buffer );

  if ( s1 != 3 )
       return 1;

  unsigned int s2 = Demarshal( MarshalByteOrder(),
                               &UserDefinedType, result, buffer );

  if ( s2 != 3 )
       return 1;

  if ( value[0] != result[0] )
       return 1;

  if ( value[1] != result[1] )
       return 1;

  if ( value[2] != result[2] )
       return 1;

  if ( result[3] != 0x14 )
       return 1;

  return 0;
}
开发者ID:openhpi1,项目名称:testrepo,代码行数:32,代码来源:marshal_027.c

示例4: AJ_MarshalArg

AJ_Status AJ_MarshalArg(AJ_Message* msg, AJ_Arg* arg)
{
    AJ_Status status;
    AJ_IOBuffer* ioBuf = &msg->bus->sock.tx;
    uint8_t* argStart = ioBuf->writePtr;

    if (msg->varOffset) {
        /*
         * Marshaling a variant - get the signature from the I/O buffer
         */
        const char* sig = (const char*)(argStart - msg->varOffset);
        msg->varOffset = 0;
        status = Marshal(msg, &sig, arg);
    } else if (msg->outer) {
        /*
         * Marshaling a component of a container use the container's signature
         */
        const char* sig = msg->outer->sigPtr;
        if (!*sig) {
            return AJ_ERR_END_OF_DATA;
        }
        status = Marshal(msg, &sig, arg);
        /*
         * Only advance the signature for struct elements
         */
        if (msg->outer->typeId != AJ_ARG_ARRAY) {
            msg->outer->sigPtr = sig;
        }
    } else {
        const char* sig = msg->signature + msg->sigOffset;
        /*
         * Marshalling anything else use the message signature
         */
        if (!*sig) {
            return AJ_ERR_END_OF_DATA;
        }
        status = Marshal(msg, &sig, arg);
        msg->sigOffset = (uint8_t)(sig - msg->signature);
    }
    if (status == AJ_OK) {
        msg->bodyBytes += (uint16_t)(ioBuf->writePtr - argStart);
    } else {
        AJ_ReleaseReplyContext(msg);
    }
    return status;
}
开发者ID:reignme,项目名称:ajtcl,代码行数:46,代码来源:aj_msg.c

示例5: HpiMarshalReply

int
HpiMarshalReply( cHpiMarshal *m, void *buffer, const void **params )
{
  // the first value is the result.
  SaErrorT err = *(const SaErrorT *)params[0];

  if ( err == SA_OK )
       return MarshalArray( m->m_reply, params, buffer );

  return Marshal( &SaErrorType, &err, buffer );
}
开发者ID:openhpi1,项目名称:testrepo,代码行数:11,代码来源:marshal_hpi.c

示例6: Start

/*
 * Manual page at process.def
 */
INT32 CGEN_PUBLIC CProcess::Start()
{
  const SMic* pMic    = NULL;                                                   // Method invocation context of Start()
  CFunction*  iCaller = NULL;                                                   // Function calling Start()
  CFunction*  iFnc    = NULL;                                                   // Process function
  StkItm*     pStkItm = NULL;                                                   // Stack item
  INT32       nArgs   = 0;                                                      // Number of process function arguments

  // Validate and initialize                                                    // ------------------------------------
  if (m_nState!=0)                                                              // Not virginal
    return IERROR(this,PRC_CANTSTART,"multiple starts not allowed",0,0);        //   Forget it!
  if (!(pMic = CDlpObject_MicGet(_this))) return -1;                            // Get method invocation context
  iCaller = (CFunction*)CDlpObject_OfKind("function",pMic->iCaller);            // Get calling CFunction
  if (!iCaller) return -1;                                                      // Must be a function!

  // Initialize process                                                         // ------------------------------------
  sprintf(m_psTmpFile,"%s%ld",dlp_tempnam(NULL,"~dLabPro#process#"),(long)dlp_time());// Initialize temp. file name prefix

  // Marshal arguments                                                          // ------------------------------------
  if (!(pStkItm=iCaller->StackGet(0))) return IERROR(this,PRC_TOOFEWARGS,0,0,0);// Get stack top
  if (pStkItm->nType==T_INSTANCE)                                               // Stack top is an instance
    iFnc = (CFunction*)CDlpObject_OfKind("function",pStkItm->val.i);            //   Get function to be called
  if (iFnc)                                                                     // This process is a function call
  {                                                                             // >>
    IFIELD_RESET(CDlpObject,"dto");                                             //   Create data transfer object
    nArgs = CData_GetNRecs(iFnc->m_idArg);                                      //   Get number of function arguments
    Marshal(m_iDto,iCaller,nArgs);                                              //   Marshal arguments for transfer
  }                                                                             // <<
  else                                                                          // This process is a program call
    dlp_strcpy(m_psCmdLine,iCaller->PopString(0));                              //   Get program command line

#ifdef USE_FORK
  if (iFnc)                                                                     // This process is a function call
  {                                                                             // >>
    m_hPid=fork();                                                              //   Fork the process
    if(m_hPid>0){                                                               //   Parent process >>
      m_nState |= PRC_DATASENT;                                                 //     Remember data have been sent
      m_nState |= PRC_RUNNING;                                                  //     Set running flag
      m_hThread = 0;                                                            //     Clear thread handle
      return O_K;                                                               //     Everything is fine
    }                                                                           //   <<
    if(m_hPid==0) return DoJobFork(iCaller,iFnc);                               //   The child process runs the function
    return IERROR(this,PRC_CANTSTART,"fork() failed",0,0);                      //   On error (fid<0) we return
  }                                                                             // <<
#endif
  // Start job in watcher thread                                                // ------------------------------------
  m_hPid = 0;                                                                   // Reset process id
  SendData();                                                                   // Send transfer data
  m_hThread = dlp_create_thread(DoJob,this);                                    // Do the job and watch it

  return O_K;                                                                   // Yo!
}
开发者ID:gitgun,项目名称:dLabPro,代码行数:55,代码来源:prc_impl.cpp

示例7: Marshal

void CachedObjectMgr::GetCacheFileName(PyRep *key, std::string &into)
{
    Buffer data;
    Marshal( key, data );

    Base64::encode( &data[0], data.size(), into, false );

    std::string::size_type epos = into.find('=');
    if(epos != std::string::npos)
        into.resize(epos);

    into += ".cache";
}
开发者ID:Bes666,项目名称:Evemu,代码行数:13,代码来源:CachedObjectMgr.cpp

示例8: Marshal

int CMarshalled::Send(DPNID idTo, DWORD flags)
{
	CDarkMarshalBuffer buff;

	buff.UseDefaultBuffer();
	Marshal(buff);

	int bytes = buff.GetBytesWritten();

	if (g_pDarkNet)
		g_pDarkNet->Send(idTo, buff.GetStartBuffer(), bytes, NULL, flags);

	return bytes;
}
开发者ID:adrikim,项目名称:thiefmp,代码行数:14,代码来源:Marshal.cpp

示例9: RunThreadedConsole

void RunThreadedConsole(HWND excel)
{
	if (hWndConsole)
	{
		::ShowWindow(hWndConsole, SW_SHOWDEFAULT);
		::SetWindowPos(hWndConsole, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
	}
	else
	{
		DWORD dwID;

		Marshal(); // FIXME: do this elsewhere, and once
		UpdateWordList();
		::CreateThread(0, 0, ThreadProc, excel, 0, &dwID);
	}

}
开发者ID:wck01,项目名称:Basic-Excel-R-Toolkit,代码行数:17,代码来源:Console.cpp

示例10: Marshal

Error SNMPVarbindList::Marshal(std::vector
																	 <Byte> &to) {
	to.push_back(type());

	// get the length of the elements
	int len = 0;
	for (auto it = varbinds_.begin(); it != varbinds_.end(); it++) {
		len += it->length();
	}
	to.push_back(len);

	for (auto it = varbinds_.begin(); it != varbinds_.end(); it++) {
		it->Marshal(to);
	}

	return Error::None;
}
开发者ID:gelidus,项目名称:isasnmp,代码行数:17,代码来源:SNMPPacket.cpp

示例11: MarshalArray

int
MarshalArray( const cMarshalType **types, 
	      const void **data, void *b )
{
  int            i;
  int            size = 0;
  unsigned char *buffer = b;

  for( i = 0; types[i]; i++ )
     {
       int s = Marshal( types[i], data[i], buffer );

       if ( s < 0 )
	    return -1;

       size   += s;
       buffer += s;
     }

  return size;
}
开发者ID:openhpi1,项目名称:testrepo,代码行数:21,代码来源:marshal.c

示例12: main

int
main( int argc, char *argv[] )
{
  tInt8         value = 0xfa;
  tInt8         result;
  unsigned char buffer[256];

  unsigned int s1 = Marshal( &Marshal_Int8Type, &value, buffer );

  if ( s1 != sizeof( tInt8 ) )
       return 1;

  unsigned int s2 = Demarshal( G_BYTE_ORDER, &Marshal_Int8Type, &result, buffer );

  if ( s2 != sizeof( tInt8 ) )
       return 1;

  if ( value != result )
       return 1;

  return 0;
}
开发者ID:openhpi1,项目名称:openhpitest,代码行数:22,代码来源:marshal_004.c

示例13: main

int
main( int argc, char *argv[] )
{
  tUint64       value = 0xfedc12345678abcdLL;
  tUint64       result;
  unsigned char buffer[256];

  unsigned int s1 = Marshal( &Marshal_Uint64Type, &value, buffer );

  if ( s1 != sizeof( tUint64 ) )
       return 1;

  unsigned int s2 = Demarshal( MarshalByteOrder(), &Marshal_Uint64Type, &result, buffer );

  if ( s2 != sizeof( tUint64 ) )
       return 1;

  if ( value != result )
       return 1;

  return 0;
}
开发者ID:openhpi1,项目名称:testrepo,代码行数:22,代码来源:marshal_003.c

示例14: main

int
main( int argc, char *argv[] )
{
  tFloat64      value = -47.345566;
  tFloat64      result;
  unsigned char buffer[256];

  unsigned int s1 = Marshal( &Marshal_Float64Type, &value, buffer );

  if ( s1 != sizeof( tFloat64 ) )
       return 1;

  unsigned int s2 = Demarshal( MarshalByteOrder(), &Marshal_Float64Type, &result, buffer );

  if ( s2 != sizeof( tFloat64 ) )
       return 1;

  if ( value != result )
       return 1;

  return 0;
}
开发者ID:openhpi1,项目名称:testrepo,代码行数:22,代码来源:marshal_009.c

示例15: MarshalArray

int
MarshalArray( const cMarshalType **types, const void **data, void *b )
{
  int            size = 0;
  unsigned char *buffer = b;

  int i;
  for( i = 0; types[i]; i++ )
     {
       int cc = Marshal( types[i], data[i], buffer );
       if ( cc < 0 )
	  {
	    CRIT( "MarshalArray[%d]: %s: failure, cc = %d!", i, types[i]->m_name, cc );
	    return cc;
	  }

       size   += cc;
       buffer += cc;
     }

  return size;
}
开发者ID:openhpi1,项目名称:testrepo,代码行数:22,代码来源:marshal.c


注:本文中的Marshal函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。