void DB_process_UDP(unsigned char* udp_BUF){ int stat_status,i; unsigned char c = udp_BUF[1]; c <<= 1; c >>= 5; if(c == 0x00){ /* If data frame */ //printf("\nData frame reveived\n"); if (cfgInProcess == 0) { stat_status = dataparser(udp_BUF); } //printf("Return from Data Parser\n"); } else if(c == 0x03) { /* If configuration frame */ printf("\nConfiguration frame reveived\n"); cfgInProcess = 1; // A flag to capture that DB is engaged in prosessing the CFG data. cfgparser(udp_BUF); cfgInProcess = 0; // A flag to capture that DB is engaged in prosessing the CFG data. printf("Return from CFG\n"); } else { printf("Erroneous frame\n"); } fflush(stdout); }
void CSubAction::DoMisc() { if (m_nMisc==ExecuteCommandMisc) { if (m_szCommand!=NULL) CLocateDlg::ExecuteCommand(m_szCommand); return; } else if (m_nMisc==InsertAsterisks) { CLocateDlg* pLocateDlg=GetLocateDlg(); if (pLocateDlg==NULL) return; CStringW Text; pLocateDlg->m_NameDlg.m_Name.GetText(Text); DWORD dwSelStart=pLocateDlg->m_NameDlg.m_Name.GetEditSel(); WORD wSelEnd=HIWORD(dwSelStart); dwSelStart&=0xFFFF; // If asterisks are already at the beginning and the end, replace spaces if (Text[0]==L'*' && Text.LastChar()==L'*') Text.ReplaceChars(L' ',L'*'); else { if (Text[0]!=L'*') { Text.InsChar(0,L'*'); // Update selection if (dwSelStart==wSelEnd) { dwSelStart++; wSelEnd++; } else { if (dwSelStart>0) dwSelStart++; wSelEnd++; } } if (Text.LastChar()!=L'*') { // Update selection first if (wSelEnd==Text.GetLength()) { if (dwSelStart==wSelEnd) dwSelStart++; wSelEnd++; } Text.Append(L'*'); } } pLocateDlg->m_NameDlg.m_Name.SetText(Text); pLocateDlg->m_NameDlg.m_Name.SetEditSel(dwSelStart,wSelEnd); pLocateDlg->OnFieldChange(CLocateDlg::isNameChanged); return; } // Send/Post Message BOOL bFreeWParam=FALSE,bFreeLParam=FALSE; HWND hWnd=NULL; WPARAM wParam=NULL,lParam=NULL; if (m_pSendMessage->szWindow[0]=='0') { if (m_pSendMessage->szWindow[1]=='x' || m_pSendMessage->szWindow[1]=='X') { // Hex value LPWSTR szTemp; hWnd=(HWND)wcstoul(m_pSendMessage->szWindow+2,&szTemp,16); } } else if (strcasecmp(m_pSendMessage->szWindow,L"HWND_BROADCAST")==0) hWnd=HWND_BROADCAST; else if (GetLocateDlg()!=NULL && strcasecmp(m_pSendMessage->szWindow,L"LOCATEDLG")==0) hWnd=*GetLocateDlg(); else if (strcasecmp(m_pSendMessage->szWindow,L"LOCATEST")==0) hWnd=*GetTrayIconWnd(); else if (wcsncmp(m_pSendMessage->szWindow,L"Find",4)==0) { int nIndex=(int)FirstCharIndex(m_pSendMessage->szWindow,L'('); if (nIndex!=-1) { LPCWSTR pText=m_pSendMessage->szWindow+nIndex+1; LPWSTR pClassAndWindow[3]={NULL,NULL,NULL}; nIndex=(int)FirstCharIndex(pText,L','); if (nIndex==-1) { nIndex=(int)FirstCharIndex(pText,L')'); if (nIndex==-1) pClassAndWindow[0]=alloccopy(pText); else pClassAndWindow[0]=alloccopy(pText,nIndex); } else { pClassAndWindow[0]=alloccopy(pText,nIndex); pText+=nIndex+1; nIndex=(int)FirstCharIndex(pText,L')'); pClassAndWindow[1]=alloccopy(pText,nIndex); } EnumWindows(WindowEnumProc,LPARAM(pClassAndWindow)); // Third cell is handle to window hWnd=(HWND)pClassAndWindow[2]; delete[] pClassAndWindow[0]; if (pClassAndWindow[1]) delete[] pClassAndWindow[1]; } } // Parse wParam if (m_pSendMessage->szWParam!=NULL) { if (m_pSendMessage->szWParam[0]=='0') { if (m_pSendMessage->szWParam[1]=='x' || m_pSendMessage->szWParam[1]=='X') { // Hex value LPWSTR szTemp; wParam=(WPARAM)wcstoul(m_pSendMessage->szWParam+2,&szTemp,16); } else if (m_pSendMessage->szWParam[1]!='\0') { DWORD dwLength; wParam=(WPARAM)dataparser(m_pSendMessage->szWParam,istrlen(m_pSendMessage->szWParam),gmalloc,&dwLength); *((BYTE*)wParam+dwLength)=0; bFreeWParam=TRUE; } } else if ((wParam=_wtoi(m_pSendMessage->szWParam))==0) { DWORD dwLength; wParam=(WPARAM)dataparser(m_pSendMessage->szWParam,istrlen(m_pSendMessage->szWParam),gmalloc,&dwLength); *((BYTE*)wParam+dwLength)=0; bFreeWParam=TRUE; } } // Parse lParam if (m_pSendMessage->szLParam!=NULL) { if (m_pSendMessage->szLParam[0]=='0') { if (m_pSendMessage->szLParam[1]=='x' || m_pSendMessage->szLParam[1]=='X') { // Hex value LPWSTR szTemp; lParam=(WPARAM)wcstoul(m_pSendMessage->szLParam+2,&szTemp,16); } else if (m_pSendMessage->szLParam[1]!='\0') { DWORD dwLength; lParam=(WPARAM)dataparser(m_pSendMessage->szLParam,istrlen(m_pSendMessage->szLParam),gmalloc,&dwLength); *((BYTE*)lParam+dwLength)=0; bFreeLParam=TRUE; } } else if ((lParam=_wtoi(m_pSendMessage->szLParam))==0) { DWORD dwLength; lParam=(WPARAM)dataparser(m_pSendMessage->szLParam,istrlen(m_pSendMessage->szLParam),gmalloc,&dwLength); *((BYTE*)lParam+dwLength)=0; bFreeLParam=TRUE; } } if (hWnd!=NULL) { if (m_nMisc==PostMessage) ::PostMessage(hWnd,m_pSendMessage->nMessage,wParam,lParam); else ::SendMessage(hWnd,m_pSendMessage->nMessage,wParam,lParam); } if (bFreeWParam) GlobalFree((HANDLE)wParam); if (bFreeLParam) GlobalFree((HANDLE)lParam); }