Пример #1
0
sLine *GetCommand(LPSTR Param)
{
	for(int x = 0; x < aCommand.GetSize(); x++)
		if(!_strcmpi(aCommand[x]->Param,Param))
			return aCommand[x];

	return 0;
}
Пример #2
0
GENERIC_PACKET *CPacketConn::Read(UINT Message, int Cookie, DWORD Timeout)
{
	CArrayEx<MSG, MSG&>	Reject;
	GENERIC_PACKET	*pPacket = NULL;
	DWORD	Start = GetTickCount();	// milliseconds since system started
	DWORD	Elapsed = 0;
	while (Elapsed < Timeout) {
		DWORD	Remaining = Timeout - Elapsed;
		DWORD	retc = MsgWaitForMultipleObjects(0, NULL, FALSE, 
			Remaining, QS_POSTMESSAGE);	// wait for posted message
		if (retc == WAIT_OBJECT_0) {	// if we have a posted message
			MSG	msg;	// if message is a received packet, dequeue it
			if (PeekMessage(&msg, m_hWnd, UWM_RCVPACKET, UWM_RCVPACKET, PM_REMOVE)) {
				GENERIC_PACKET	*pp = (GENERIC_PACKET *)msg.wParam;
				// if dequeued packet matches caller's specifications
				if (pp->Message == Message && Cookie == msg.lParam) {
					pPacket = pp;	// success
					break;	// end loop
				} else	// caller doesn't want this packet
					Reject.Add(msg);	// store it and repost it later
			}
		} else	// wait timeout or error
			break;	// abort loop
		DWORD	Now = GetTickCount();
		if (Now >= Start)	// usual case
			Elapsed = Now - Start;
		else	// assume tick count wrapped around to zero
			Elapsed = Now + (UINT_MAX - Start);
	}
	// repost any packets that were dequeued and rejected
	for (int i = 0; i < Reject.GetSize(); i++) {
		MSG&	rm = Reject[i];
		PostMessage(m_hWnd, rm.message, rm.wParam, rm.lParam);
	}
	return(pPacket);	// caller is responsible for deleting packet
}
Пример #3
0
VOID ParseCommandLine(LPSTR Command)
{
	for(int x = 0; x < ArraySize(CLine); x++)
	{
		DWORD id = ParseStringForText(Command,CLine[x].Param);
		if(id == -1)
			continue;

		CHAR szText[100];
		BOOL bStart = false;

		memset(szText,0x00,100);

		if(!CLine[x].isBool)
		{
			for(unsigned int y = (id+(strlen(CLine[x].Param))); y < strlen(Command); y++)
			{
				if(Command[y] == '"')
					if(bStart){
						bStart = false;
						break;
					}
					else{
						bStart = true;
						y++;
					}

					int byt = Command[y];

				if(bStart)
					memcpy(szText+strlen(szText),(LPSTR)&byt,sizeof(byt));
			}
		}
		sLine *sl = new sLine;
		sl->isBool = CLine[x].isBool;
		strcpy_s(sl->Param,sizeof(sl->Param),CLine[x].Param);
		if(!sl->isBool)
			strcpy_s(sl->szText,sizeof(sl->szText),szText);

		aCommand.Add(sl);
	}
}