////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////// BOOL CFileWriter::WriteString(char* szString) { int iStrLen; iStrLen = (int)strlen(szString)+1; CheckWrite(&iStrLen, sizeof(int)); CheckWrite(szString, iStrLen); return TRUE; }
void CCeWatchDlg::OnBtnWrite() { if (CheckWrite()) { CString strValue; m_HistoryListCtrl.GetWindowText(strValue); if (m_pBackEnd->WriteVar(m_pWriteVar, strValue)) { m_pWriteVar->AddToHistory(strValue); m_HistoryListCtrl.ResetContent(); for (int ii = 0; ii < m_pWriteVar->GetHistoryCount(); ii++) m_HistoryListCtrl.AddString(m_pWriteVar->GetHistory(ii)); } else { CString strMessage; strMessage.LoadString(IDS_ERROR_WRITE_FAILED); ::AfxMessageBox(strMessage, MB_ICONSTOP); } } }
int JackRequestDecoder::HandleRequest(detail::JackChannelTransactionInterface* socket, int type_aux) { JackRequest::RequestType type = (JackRequest::RequestType)type_aux; // Read data switch (type) { case JackRequest::kClientCheck: { jack_log("JackRequest::ClientCheck"); JackClientCheckRequest req; JackClientCheckResult res; CheckRead(req, socket); res.fResult = fServer->GetEngine()->ClientCheck(req.fName, req.fUUID, res.fName, req.fProtocol, req.fOptions, &res.fStatus); CheckWriteName("JackRequest::ClientCheck", socket); // Atomic ClientCheck followed by ClientOpen on same socket if (req.fOpen) { JackRequest header; header.Read(socket); return HandleRequest(socket, header.fType); } break; } case JackRequest::kClientOpen: { jack_log("JackRequest::ClientOpen"); JackClientOpenRequest req; JackClientOpenResult res; CheckRead(req, socket); fHandler->ClientAdd(socket, &req, &res); CheckWriteName("JackRequest::ClientOpen", socket); break; } case JackRequest::kClientClose: { jack_log("JackRequest::ClientClose"); JackClientCloseRequest req; JackResult res; CheckRead(req, socket); res.fResult = fServer->GetEngine()->ClientExternalClose(req.fRefNum); CheckWriteRefNum("JackRequest::ClientClose", socket); fHandler->ClientRemove(socket, req.fRefNum); // Will cause the wrapping thread to stop return -1; } case JackRequest::kActivateClient: { JackActivateRequest req; JackResult res; jack_log("JackRequest::ActivateClient"); CheckRead(req, socket); res.fResult = fServer->GetEngine()->ClientActivate(req.fRefNum, req.fIsRealTime); CheckWriteRefNum("JackRequest::ActivateClient", socket); break; } case JackRequest::kDeactivateClient: { jack_log("JackRequest::DeactivateClient"); JackDeactivateRequest req; JackResult res; CheckRead(req, socket); res.fResult = fServer->GetEngine()->ClientDeactivate(req.fRefNum); CheckWriteRefNum("JackRequest::DeactivateClient", socket); break; } case JackRequest::kRegisterPort: { jack_log("JackRequest::RegisterPort"); JackPortRegisterRequest req; JackPortRegisterResult res; CheckRead(req, socket); res.fResult = fServer->GetEngine()->PortRegister(req.fRefNum, req.fName, req.fPortType, req.fFlags, req.fBufferSize, &res.fPortIndex); CheckWriteRefNum("JackRequest::RegisterPort", socket); break; } case JackRequest::kUnRegisterPort: { jack_log("JackRequest::UnRegisterPort"); JackPortUnRegisterRequest req; JackResult res; CheckRead(req, socket); res.fResult = fServer->GetEngine()->PortUnRegister(req.fRefNum, req.fPortIndex); CheckWriteRefNum("JackRequest::UnRegisterPort", socket); break; } case JackRequest::kConnectNamePorts: { jack_log("JackRequest::ConnectNamePorts"); JackPortConnectNameRequest req; JackResult res; CheckRead(req, socket); res.fResult = fServer->GetEngine()->PortConnect(req.fRefNum, req.fSrc, req.fDst); CheckWriteRefNum("JackRequest::ConnectNamePorts", socket); break; } case JackRequest::kDisconnectNamePorts: { jack_log("JackRequest::DisconnectNamePorts"); JackPortDisconnectNameRequest req; JackResult res; CheckRead(req, socket); res.fResult = fServer->GetEngine()->PortDisconnect(req.fRefNum, req.fSrc, req.fDst); CheckWriteRefNum("JackRequest::DisconnectNamePorts", socket); break; } case JackRequest::kConnectPorts: { jack_log("JackRequest::ConnectPorts"); JackPortConnectRequest req; JackResult res; CheckRead(req, socket); res.fResult = fServer->GetEngine()->PortConnect(req.fRefNum, req.fSrc, req.fDst); CheckWriteRefNum("JackRequest::ConnectPorts", socket); break; } case JackRequest::kDisconnectPorts: { jack_log("JackRequest::DisconnectPorts"); JackPortDisconnectRequest req; JackResult res; CheckRead(req, socket); res.fResult = fServer->GetEngine()->PortDisconnect(req.fRefNum, req.fSrc, req.fDst); CheckWriteRefNum("JackRequest::DisconnectPorts", socket); break; } case JackRequest::kPortRename: { jack_log("JackRequest::PortRename"); JackPortRenameRequest req; JackResult res; CheckRead(req, socket); res.fResult = fServer->GetEngine()->PortRename(req.fRefNum, req.fPort, req.fName); CheckWriteRefNum("JackRequest::PortRename", socket); break; } case JackRequest::kSetBufferSize: { jack_log("JackRequest::SetBufferSize"); JackSetBufferSizeRequest req; JackResult res; CheckRead(req, socket); res.fResult = fServer->SetBufferSize(req.fBufferSize); CheckWrite("JackRequest::SetBufferSize", socket); break; } case JackRequest::kSetFreeWheel: { jack_log("JackRequest::SetFreeWheel"); JackSetFreeWheelRequest req; JackResult res; CheckRead(req, socket); res.fResult = fServer->SetFreewheel(req.fOnOff); CheckWrite("JackRequest::SetFreeWheel", socket); #ifdef __ANDROID__ #ifdef WORKAROUND_QC_JACK_ALSA /* for supporting qualcomm platform */ if(req.fOnOff == 0) { usleep(300 * 1000); kill(getpid(), SIGUSR2); //switch master driver via SIGUSR2 signal usleep(300 * 1000); kill(getpid(), SIGUSR2); //switch master driver via SIGUSR2 signal usleep(300 * 1000); fServer->GetEngine()->PortConnect(0, "out:__system_playback_1", "system:playback_1"); fServer->GetEngine()->PortConnect(0, "out:__system_playback_2", "system:playback_2"); fServer->GetEngine()->PortConnect(0, "system:capture_1", "in:__system_capture_1"); fServer->GetEngine()->PortConnect(0, "system:capture_2", "in:__system_capture_2"); } #endif #endif break; } case JackRequest::kComputeTotalLatencies: { jack_log("JackRequest::ComputeTotalLatencies"); JackComputeTotalLatenciesRequest req; JackResult res; CheckRead(req, socket); res.fResult = fServer->GetEngine()->ComputeTotalLatencies(); CheckWrite("JackRequest::ComputeTotalLatencies", socket); break; } case JackRequest::kReleaseTimebase: { jack_log("JackRequest::ReleaseTimebase"); JackReleaseTimebaseRequest req; JackResult res; CheckRead(req, socket); res.fResult = fServer->ReleaseTimebase(req.fRefNum); CheckWriteRefNum("JackRequest::ReleaseTimebase", socket); break; } case JackRequest::kSetTimebaseCallback: { jack_log("JackRequest::SetTimebaseCallback"); JackSetTimebaseCallbackRequest req; JackResult res; CheckRead(req, socket); res.fResult = fServer->SetTimebaseCallback(req.fRefNum, req.fConditionnal); CheckWriteRefNum("JackRequest::SetTimebaseCallback", socket); break; } case JackRequest::kGetInternalClientName: { jack_log("JackRequest::GetInternalClientName"); JackGetInternalClientNameRequest req; JackGetInternalClientNameResult res; CheckRead(req, socket); res.fResult = fServer->GetEngine()->GetInternalClientName(req.fIntRefNum, res.fName); CheckWriteRefNum("JackRequest::GetInternalClientName", socket); break; } case JackRequest::kInternalClientHandle: { jack_log("JackRequest::InternalClientHandle"); JackInternalClientHandleRequest req; JackInternalClientHandleResult res; CheckRead(req, socket); res.fResult = fServer->GetEngine()->InternalClientHandle(req.fName, &res.fStatus, &res.fIntRefNum); CheckWriteRefNum("JackRequest::InternalClientHandle", socket); break; } case JackRequest::kInternalClientLoad: { jack_log("JackRequest::InternalClientLoad"); JackInternalClientLoadRequest req; JackInternalClientLoadResult res; CheckRead(req, socket); res.fResult = fServer->InternalClientLoad1(req.fName, req.fDllName, req.fLoadInitName, req.fOptions, &res.fIntRefNum, req.fUUID, &res.fStatus); CheckWriteName("JackRequest::InternalClientLoad", socket); break; } case JackRequest::kInternalClientUnload: { jack_log("JackRequest::InternalClientUnload"); JackInternalClientUnloadRequest req; JackInternalClientUnloadResult res; CheckRead(req, socket); res.fResult = fServer->GetEngine()->InternalClientUnload(req.fIntRefNum, &res.fStatus); CheckWriteRefNum("JackRequest::InternalClientUnload", socket); break; } case JackRequest::kNotification: { jack_log("JackRequest::Notification"); JackClientNotificationRequest req; CheckRead(req, socket); if (req.fNotify == kQUIT) { jack_log("JackRequest::Notification kQUIT"); throw JackQuitException(); } else { fServer->Notify(req.fRefNum, req.fNotify, req.fValue); } break; } case JackRequest::kSessionNotify: { jack_log("JackRequest::SessionNotify"); JackSessionNotifyRequest req; CheckRead(req, socket); fServer->GetEngine()->SessionNotify(req.fRefNum, req.fDst, req.fEventType, req.fPath, socket, NULL); break; } case JackRequest::kSessionReply: { jack_log("JackRequest::SessionReply"); JackSessionReplyRequest req; JackResult res; CheckRead(req, socket); res.fResult = fServer->GetEngine()->SessionReply(req.fRefNum); CheckWrite("JackRequest::SessionReply", socket); break; } case JackRequest::kGetClientByUUID: { jack_log("JackRequest::GetClientByUUID"); JackGetClientNameRequest req; JackClientNameResult res; CheckRead(req, socket); res.fResult = fServer->GetEngine()->GetClientNameForUUID(req.fUUID, res.fName); CheckWrite("JackRequest::GetClientByUUID", socket); break; } case JackRequest::kGetUUIDByClient: { jack_log("JackRequest::GetUUIDByClient"); JackGetUUIDRequest req; JackUUIDResult res; CheckRead(req, socket); res.fResult = fServer->GetEngine()->GetUUIDForClientName(req.fName, res.fUUID); CheckWrite("JackRequest::GetUUIDByClient", socket); break; } case JackRequest::kReserveClientName: { jack_log("JackRequest::ReserveClientName"); JackReserveNameRequest req; JackResult res; CheckRead(req, socket); res.fResult = fServer->GetEngine()->ReserveClientName(req.fName, req.fUUID); CheckWrite("JackRequest::ReserveClientName", socket); break; } case JackRequest::kClientHasSessionCallback: { jack_log("JackRequest::ClientHasSessionCallback"); JackClientHasSessionCallbackRequest req; JackResult res; CheckRead(req, socket); res.fResult = fServer->GetEngine()->ClientHasSessionCallback(req.fName); CheckWrite("JackRequest::ClientHasSessionCallback", socket); break; } default: jack_error("Unknown request %ld", type); return -1; } return 0; }
int TDBCSV::WriteDB(PGLOBAL g) { char sep[2], qot[2]; int i, nlen, oldlen = strlen(To_Line); if (trace > 1) htrc("CSV WriteDB: R%d Mode=%d key=%p link=%p\n", Tdb_No, Mode, To_Key_Col, To_Link); // Before writing the line we must check its length if ((nlen = CheckWrite(g)) < 0) return RC_FX; // Before writing the line we must make it sep[0] = Sep; sep[1] = '\0'; qot[0] = Qot; qot[1] = '\0'; *To_Line = '\0'; for (i = 0; i < Fields; i++) { if (i) strcat(To_Line, sep); if (Field[i]) if (!strlen(Field[i])) { // Generally null fields are not quoted if (Quoted > 2) // Except if explicitely required strcat(strcat(To_Line, qot), qot); } else if (Qot && (strchr(Field[i], Sep) || *Field[i] == Qot || Quoted > 1 || (Quoted == 1 && !Fldtyp[i]))) if (strchr(Field[i], Qot)) { // Field contains quotes that must be doubled int j, k = strlen(To_Line), n = strlen(Field[i]); To_Line[k++] = Qot; for (j = 0; j < n; j++) { if (Field[i][j] == Qot) To_Line[k++] = Qot; To_Line[k++] = Field[i][j]; } // endfor j To_Line[k++] = Qot; To_Line[k] = '\0'; } else strcat(strcat(strcat(To_Line, qot), Field[i]), qot); else strcat(To_Line, Field[i]); } // endfor i #if defined(_DEBUG) assert ((unsigned)nlen == strlen(To_Line)); #endif if (Mode == MODE_UPDATE && nlen < oldlen && !((PDOSFAM)Txfp)->GetUseTemp()) { // In Update mode with no temp file, line length must not change To_Line[nlen] = Sep; for (nlen++; nlen < oldlen; nlen++) To_Line[nlen] = ' '; To_Line[nlen] = '\0'; } // endif if (trace > 1) htrc("Write: line is=%s", To_Line); /*********************************************************************/ /* Now start the writing process. */ /*********************************************************************/ return Txfp->WriteBuffer(g); } // end of WriteDB
void CCeWatchDlg::UpdateWriteButton(LPCTSTR pNewValue/*=NULL*/) { if (IsWindow(m_WriteButton.GetSafeHwnd())) m_WriteButton.EnableWindow(CheckWrite(pNewValue)); }
////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////// BOOL CFileWriter::WriteChar(char c) { CheckWrite(&c, sizeof(char)); return TRUE; }
////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////// BOOL CFileWriter::WriteDouble(double f) { CheckWrite(&f, sizeof(double)); return TRUE; }
////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////// BOOL CFileWriter::WriteFloat(float f) { CheckWrite(&f, sizeof(float)); return TRUE; }
////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////// BOOL CFileWriter::WriteInt(int i) { CheckWrite(&i, sizeof(int)); return TRUE; }
////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////// BOOL CFileWriter::WriteData(void* pvData, filePos iDataSize) { CheckWrite(pvData, iDataSize); return TRUE; }
////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////// BOOL CFileWriter::WriteIntArray(int* pai, int iLength) { CheckWrite(pai, iLength * sizeof(int)); return TRUE; }
////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////// BOOL CFileWriter::WriteBits(void* pvData, int iByteLength) { CheckWrite(pvData, iByteLength); return TRUE; }
////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////// BOOL CFileWriter::WriteLong(long long int i) { CheckWrite(&i, sizeof(long long int)); return TRUE; }
////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////// BOOL CFileWriter::WriteShort(unsigned short int i) { CheckWrite(&i, sizeof(unsigned short int)); return TRUE; }
////////////////////////////////////////////////////////////////////////// // // // // ////////////////////////////////////////////////////////////////////////// BOOL CFileWriter::WriteBool(BOOL b) { CheckWrite(&b, sizeof(BOOL)); return TRUE; }