コード例 #1
0
ファイル: service.cpp プロジェクト: ljr/mm1k
void Service::Display ()
  {
  int srvr_i;
  for (srvr_i = 0; srvr_i < num_srvrs; srvr_i++)
     cout << '(' << setw(2) << srvr_i << ')'
          << " TK " << setw(3) << GetTokenID (srvr_i)
          << " PR " << setw(2) << GetPri     (srvr_i) << ' ';
  }
コード例 #2
0
ファイル: mpIOprt.cpp プロジェクト: QAndot/muparser
//------------------------------------------------------------------------------
string_type IOprtBin::AsciiDump() const
{
    stringstream_type ss;

    ss << g_sCmdCode[ GetCode() ];
    ss << _T(" [addr=0x") << std::hex << this << std::dec;
    ss << _T("; ident=\"") << GetIdent() << _T("\"");
    ss << _T("; prec=") << GetPri();
    ss << _T("; argc=") << GetArgc();
    ss << _T("]");

    return ss.str();
}
コード例 #3
0
char  * CQ931Pdu::ComposeJoyitApi(UINT16& len)
{
	char * pPdu = NULL;
	char pdu[MAX_MSGLEN] = { 0 };
	UINT8 pos = 0;
	UINT16 l;
	int i;
	UINT16 msgType = GetMessageType( );
	UINT8 noIe = 2; //  = NoIe( );

	// Make up API header.
	memcpy(pdu, Header, sizeof(SInterApiHead));
	pos += sizeof(SInterApiHead);

	// #### Add 2005-10-30, by Wujianjin. ###
	// Construct the FIX information element first.
	// UINT8 pt = GetProtocolType( );
	// if ((MOD_TUPAPI == pt)
	//	|| (MOD_ISUPAPI == pt)
	//	|| (MOD_Q931API == pt))
	// { // Construct the fix ie first.
		// Message index.
		CIeBase  * pIe;

		pIe = GetIE(PSG_IE_MSGTYPE);
		if ((pIe != NULL)
			&& (pIe->id != IE_NOT_EXIST))
		{
			pdu[pos++] = pIe->id;
			pdu[pos++] = pIe->len;
			memcpy(pdu+pos, pIe->GetIeData(l), pIe->len);
			pos += pIe->len;
		}
		else
		{ // Not exist, I will get it from mType.
			pdu[pos++] = PSG_IE_MSGTYPE;
			pdu[pos++] = 2;
			// memcpy(pdu+pos, &mType, 2);
			memcpy(pdu+pos, &msgType, 2);
			pos += 2;
		}

		if (pIe != NULL)
		{
			DelIE(PSG_IE_MSGTYPE);
		}

		// Circuit structure.
		pIe = GetIE(PSG_IE_CIR_STRUCT);
		if ((pIe != NULL)
			&& (pIe->id != IE_NOT_EXIST))
		{
			pdu[pos++] = pIe->id;
			pdu[pos++] = pIe->len;
			memcpy(pdu+pos, pIe->GetIeData(l), pIe->len);
			pos += pIe->len;

		}
		else
		{ // Exception handle.
			// return pPdu;
			pdu[pos ++] = PSG_IE_CIR_STRUCT;
			pdu[pos ++] = sizeof(SCircuitStructIE);
			SCircuitStructIE chn;
			chn.pcmId = GetPri( );
			chn.tsId = GetTs( );
			memcpy(pdu+pos, &chn, sizeof(SCircuitStructIE));
			pos += sizeof(SCircuitStructIE);
		}

		if (pIe != NULL)
		{
			DelIE(PSG_IE_CIR_STRUCT);
		}

		// Circuit group indicator.
		pIe = GetIE(PSG_IE_CG_IND);
		if ((pIe != NULL)
			&& (pIe->id != IE_NOT_EXIST))
		{
			pdu[pos++] = pIe->id;
			pdu[pos++] = pIe->len;
			memcpy(pdu+pos, pIe->GetIeData(l), pIe->len);
			pos += pIe->len;
			++ noIe;
		}

		if (pIe != NULL)
		{
			DelIE(PSG_IE_CG_IND);
		}
	// }
	// ### End 2005-10-30 ###

	// Make up all other IEs.
	for (i=0; i<NoIe( ); ++i)
	{
		if ((PSG_IE_L3_SGM == IE[i].id)
			// || (PSG_IE_L3_SNDCMP == IE[i].id) // Delete 2005-11-21, by Wujianjin.
			|| (PSG_IE_L3_MOREDATA == IE[i].id)
			|| (PSG_IE_L3_CR == IE[i].id)
			|| (PSG_IE_L3_PTLDCM == IE[i].id)
			|| (PSG_IE_L3_CHNID == IE[i].id))
		{
			// noIe --;
			continue;
		}

		pdu[pos++] = IE[i].id;
		pdu[pos++] = IE[i].len;
		noIe ++;

		if ((pos + IE[i].len) >= MAX_MSGLEN)
		{ // Message too long.
			printf("Joyit API too long. mType:0x%04X\n", msgType);
			break;
		}

		memcpy(pdu+pos, IE[i].GetIeData(l), IE[i].len);
		pos += IE[i].len;
	}

	// Allocate memory for this PDU.
	// if (i == IeCounter)
	// {
		pPdu = new char[pos];

		if (pPdu != NULL)
		{
			((SInterApiHead *)pdu)->primType = GetPrimitiveType( ); // Modify 2005-10-27, by Wujianjin.
			((SInterApiHead *)pdu)->noie = noIe;;
			// ((SJoyitApiHead *)pdu)->PktLength = pos;

			memcpy(pPdu, pdu, pos);
			len = pos;
		}
		else
		{ // Out of memory.
			printf("Make up Joyit API out of memory. mType:0x%04X\n", msgType);
		}
	// }

	return pPdu;
}