bool MythConfirmationDialog::Create(void) { if (!CopyWindowFromBase("MythConfirmationDialog", this)) return false; MythUIButton *okButton = NULL; MythUIButton *cancelButton = NULL; bool err = false; UIUtilE::Assign(this, m_messageText, "message", &err); UIUtilE::Assign(this, okButton, "ok", &err); UIUtilE::Assign(this, cancelButton, "cancel", &err); if (err) { LOG(VB_GENERAL, LOG_ERR, "Cannot load screen 'MythConfirmationDialog'"); return false; } if (m_showCancel) { connect(cancelButton, SIGNAL(Clicked()), SLOT(Cancel())); } else cancelButton->SetVisible(false); connect(okButton, SIGNAL(Clicked()), SLOT(Confirm())); m_messageText->SetText(m_message); BuildFocusList(); SetFocusWidget(okButton); return true; }
BOOL ProcessCardAtr(SCARDCONTEXT hContext, BYTE atr[], DWORD atrlen) { LONG lReturn = NO_ERROR; DWORD dwActiveProtocol = 0; DWORD cbAtr = MAX_ATR_LEN; DWORD dwIndex = 0; DWORD cchCards; char *pmszCards = NULL; BYTE name[MAX_PATH]; LONG rc; BOOL success = TRUE; /* Determine if the ATR is already in the Smart Card Database */ cchCards = SCARD_AUTOALLOCATE; rc = SCardListCards(hContext, atr, NULL, 0, (char *) &pmszCards, &cchCards); if (rc != SCARD_S_SUCCESS) { printf("SCardListCards error 0x%08lX (%lu).\n", rc, rc); return FALSE; } if ((pmszCards == NULL) || (*pmszCards == 0)) { /* Card not found. We need to add it. */ printf("\tThis card is currently not recognized by the system.\n"); if (!Confirm("Do you want to add this card to the 'no driver' list ?")) return TRUE; printf("\tAdding card's ATR...\n"); sprintf(name, "%s-", name_prefix); if (!ComputeCardNameFromAtr(&name[strlen(name)], atr, NULL, atrlen)) { printf("Failed to compute a name for the card.\n"); return FALSE; } success = IntroduceCardAtr(hContext, atr, NULL, atrlen, name); if (success) printf("\tOK!\n"); } else { printf("\tThis card is already known by the system.\n"); printf("\t(%s)\n", pmszCards); } // Free resources if (pmszCards != NULL) { SCardFreeMemory(hContext, pmszCards); } return success; }
signed Identity1 (struct plc * plc) { struct channel * channel = (struct channel *)(plc->channel); struct message * message = (struct message *)(plc->message); #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_rd_mod_request { struct ethernet_hdr ethernet; struct qualcomm_hdr qualcomm; uint8_t MODULEID; uint8_t MACCESS; uint16_t MLENGTH; uint32_t MOFFSET; uint8_t MSECRET [16]; } * request = (struct vs_rd_mod_request *) (message); struct __packed vs_rd_mod_confirm { struct ethernet_hdr ethernet; struct qualcomm_hdr qualcomm; uint8_t MSTATUS; uint8_t RES [3]; uint8_t MODULEID; uint8_t RESERVED; uint16_t MLENGTH; uint32_t MOFFSET; uint32_t MCHKSUM; uint8_t BUFFER [PLC_RECORD_SIZE]; } * confirm = (struct vs_rd_mod_confirm *) (message); #ifndef __GNUC__ #pragma pack (pop) #endif Request (plc, "Device Identity"); memset (message, 0, sizeof (* message)); EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type); QualcommHeader (&request->qualcomm, 0, (VS_RD_MOD | MMTYPE_REQ)); plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN); request->MODULEID = VS_MODULE_PIB; request->MLENGTH = HTOLE16 (sizeof (confirm->BUFFER)); request->MOFFSET = HTOLE32 (0); if (SendMME (plc) <= 0) { error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND); return (-1); } while (ReadMME (plc, 0, (VS_RD_MOD | MMTYPE_CNF)) > 0) { if (confirm->MSTATUS) { Failure (plc, PLC_WONTDOIT); continue; } Confirm (plc, "-------"); pibpeek1 (confirm->BUFFER); } return (0); }
static signed con_info (struct plc * plc, uint8_t TYPE, uint16_t CID, uint16_t TOT_BW_USED) { struct channel * channel = (struct channel *)(plc->channel); struct message * message = (struct message *)(plc->message); #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_con_info_req { struct ethernet_hdr ethernet; struct qualcomm_hdr qualcomm; uint8_t REQ_TYPE; uint32_t RSVD; uint16_t CSPEC_VER; uint16_t CID; uint16_t TOT_BW_USED; } * request = (struct vs_con_info_req *)(message); struct __packed vs_con_info_cnf { struct ethernet_hdr ethernet; struct qualcomm_hdr qualcomm; uint8_t REQ_TYPE; uint8_t MSTATUS; uint16_t ERR_REC_CODE; uint32_t RSVD; uint8_t NUM_CONN; struct conn_info CONN_INFO [64]; } * confirm = (struct vs_con_info_cnf *)(message); struct conn_info * conn_info = (struct conn_info*)(confirm->CONN_INFO); struct vs_con_info_cnf * indicate = (struct vs_con_info_cnf *)(message); #ifndef __GNUC__ #pragma pack (pop) #endif int i; Request (plc, "COQOS connection information"); memset (message, 0, sizeof (* message)); EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type); QualcommHeader (&request->qualcomm, 0, (VS_CONN_INFO | MMTYPE_REQ)); plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN); request->REQ_TYPE = TYPE; request->CID = CID; request->TOT_BW_USED = TOT_BW_USED; request->CSPEC_VER = 0x01; if (SendMME (plc) <= 0) { error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND); return (-1); } while (ReadMME (plc, 0, (VS_CONN_INFO | MMTYPE_CNF)) <= 0); if (confirm->MSTATUS) { Failure (plc, "Error requesting information."); return (-1); } /* BW exceeded request and "cancel all requests" do not send indicate */ if ((TYPE == CONTROL_BW) || (TYPE == CONTROL_BWC)) { Confirm (plc, "Success"); return (0); } Confirm (plc, "Received confirm, waiting for indicate..."); while (ReadMME (plc, 0, (VS_CONN_INFO | MMTYPE_IND)) <= 0); if (indicate->MSTATUS) { Failure (plc, "Error requesting information."); return (-1); } printf ("Number of Connections: %d\n", (int)indicate->NUM_CONN); conn_info = (struct conn_info *)(indicate->CONN_INFO); for (i = 0; i < indicate->NUM_CONN; i++) { printf ("SNID: %02X ", conn_info->SNID); printf ("CID: %04X ", conn_info->CID); printf ("STEI: %02X ", conn_info->STEI); printf ("DTEI: %02X ", conn_info->DTEI); printf ("LLID: %02X ", conn_info->LLID); printf ("CSPEC_VERSION: %04X ", conn_info->CSPECVERSION); printf ("CONN_CAP: %02d ", conn_info->CONN_CAP); printf ("CONN_COQOS_PRIO: %02d ", conn_info->CONN_COQOS_PRIO); printf ("CONN_RATE: %d ", conn_info->CONN_RATE); printf ("CONN_TTL: %d ", conn_info->CONN_TTL); printf ("BW_USED: %d \n", conn_info->BW_USED); conn_info++; } return (0); }
int HexDoc::FindHex(const wxByte *hex, size_t count, /*IN_OUT*/THSIZE &startpos, /*IN_OUT*/THSIZE &endpos, bool caseSensitive /*= true*/) { if ((startpos <= endpos && startpos + count > endpos) || (startpos >= endpos && endpos + count > startpos) || count == 0) return false; //THSIZE startbase, endbase; //Segment *startseg = GetSegment(startpos, &startbase), *endseg; //if (endpos == GetSize()) // endseg = GetSegment(endpos - 1, &endbase); //else // endseg = GetSegment(endpos, &endbase); //if (startseg == NULL || endseg == NULL) // return false; //ByteIterator start(startpos, startseg, startpos - startbase); //ByteIterator end(endpos, endseg, endpos - endbase); ByteIterator2 start(startpos, this); ByteIterator2 end(endpos, this); uint32 blockSize = MEGA; THSIZE foundPos; uint8 *pData, *psrc; LowerCaseConverter lc; int result = false; if (caseSensitive) psrc = (uint8*)hex; else { pData = new uint8[blockSize]; psrc = new uint8[count]; memcpy(psrc, hex, count); lc.convert(psrc, count); } THSIZE findSize; if (startpos > endpos) findSize = startpos - endpos; else findSize = endpos - startpos; thProgressDialog *progress = NULL; if (findSize > MEGA) progress = new thProgressDialog(findSize, hw, _T("Searching...")); THSIZE pos = startpos, lastStart = startpos; if (startpos > endpos) { //if (::SearchReverse(start, end, hex, count, true)) //{ // startpos = start.pos; // endpos = end.pos; // return true; //} for (pos = startpos; pos > endpos; ) { if (pos - endpos < MEGA) blockSize = pos - endpos; if (pos < startpos && pos - blockSize > endpos) pos += count - 1; // Go back and see if the end of the previous block matches. pos -= blockSize; if (caseSensitive) { pData = (uint8*)Load(pos, blockSize); if (!pData) // compiler says "warning C4701: potentially uninitialized local variable 'pData' used." WTF!? goto done; } else { if (!Read(pos, blockSize, pData)) goto done; lc.convert(pData, blockSize); } if (::Find(false, psrc, count, pData, blockSize, foundPos)) { startpos = pos + foundPos + count; endpos = startpos - count; result = true; goto done; } if (progress && !progress->Update(startpos - pos) && Confirm(_T("Are you sure you want to abort?"))) goto abort; } } //else if(::Search(start, end, hex, count, true)) //{ // startpos = start.pos; // endpos = end.pos; // return true; //} else { for (pos = startpos; pos < endpos; pos += blockSize) { if (pos > startpos && pos + blockSize >= endpos) pos -= count - 1; // Go back and see if the end of the previous block matches. if (endpos - pos < MEGA) blockSize = endpos - pos; if (caseSensitive) { pData = (uint8*)Load(pos, blockSize); if (!pData) goto done; } else { if (!Read(pos, blockSize, pData)) // aligned read is better than cache-bypassing DoRead(). goto done; lc.convert(pData, blockSize); } if (::Find(true, psrc, count, pData, blockSize, foundPos)) { startpos = pos + foundPos; endpos = startpos + count; result = true; goto done; } if (progress && !progress->Update(pos - startpos) && Confirm(_T("Are you sure you want to abort?"))) goto abort; } } done: if (!caseSensitive) { delete [] pData; delete [] psrc; } delete progress; return result; abort: hw->ScrollToRange(pos, pos, J_AUTO); result = -1; // aborted goto done; }
std::string SolicitedConfirm(uint8_t seq) { return Confirm(seq, false); }
signed ResetAndWait (struct plc * plc) { struct channel * channel = (struct channel *)(plc->channel); struct message * message = (struct message *)(plc->message); struct timeval ts; struct timeval tc; unsigned timer = 0; #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_rs_dev_request { struct ethernet_std ethernet; struct qualcomm_std qualcomm; } * request = (struct vs_rs_dev_request *) (message); struct __packed vs_rs_dev_confirm { struct ethernet_std ethernet; struct qualcomm_std qualcomm; uint8_t MSTATUS; } * confirm = (struct vs_rs_dev_confirm *) (message); #ifndef __GNUC__ #pragma pack (pop) #endif Request (plc, "Reset when Ready"); if (gettimeofday (&ts, NULL) == -1) { error (1, errno, CANT_START_TIMER); } for (timer = 0; timer < plc->timer; timer = SECONDS (ts, tc)) { memset (message, 0, sizeof (* message)); EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type); QualcommHeader (&request->qualcomm, 0, (VS_RS_DEV | MMTYPE_REQ)); plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN); if (SendMME (plc) <= 0) { error ((plc->flags & PLC_BAILOUT), errno, CHANNEL_CANTSEND); return (-1); } if (ReadMME (plc, 0, (VS_RS_DEV | MMTYPE_CNF)) < 0) { error ((plc->flags & PLC_BAILOUT), errno, CHANNEL_CANTREAD); return (-1); } if (gettimeofday (&tc, NULL) == -1) { error (1, errno, CANT_RESET_TIMER); } if (plc->packetsize) { if (!confirm->MSTATUS) { Confirm (plc, "Resetting ..."); return (0); } } } return (-1); }
void CDuffDlg::Exit() { if ( g_DupeFileFind.m_DuffStatus.Status == DUFFSTATUS_STOPPED || ( (g_DupeFileFind.m_DuffStatus.Status != DUFFSTATUS_STOPPED) && Confirm()) ) { g_DupeFileFind.m_DuffStatus.Status = DUFFSTATUS_STOPPED; CResizableDialog::OnOK(); } }
void startBackup(COptions options) { GUID snapshotSetId = GUID_NULL; bool bSnapshotCreated = false; bool bAbnormalAbort = true; CComPtr<IVssBackupComponents> pBackupComponents; int fileCount = 0; LONGLONG byteCount = 0; int directoryCount = 0; int skipCount = 0; SYSTEMTIME startTime; try { OutputWriter::SetVerbosityLevel((VERBOSITY_LEVEL)options.get_VerbosityLevel()); //for (int i = 0; i < argc; ++i) //{ // CString message; // message.AppendFormat(TEXT("Argument %d: %s"), i, argv[i]); // OutputWriter::WriteLine(message, VERBOSITY_THRESHOLD_IF_VERBOSE); //} OutputWriter::WriteLine(TEXT("Calling CoInitialize")); CHECK_HRESULT(::CoInitialize(NULL)); CHECK_HRESULT( ::CoInitializeSecurity( NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_PKT_PRIVACY, RPC_C_IMP_LEVEL_IDENTIFY, NULL, EOAC_NONE, NULL)); ::GetSystemTime(&startTime); CString startTimeString; Utilities::FormatDateTime(&startTime, TEXT(" "), false, startTimeString); CString message; message.AppendFormat(TEXT("Starting a %s copy from %s to %s"), options.get_BackupType() == VSS_BT_FULL ? TEXT("full") : TEXT("incremental"), options.get_Source(), options.get_Destination()); OutputWriter::WriteLine(message, VERBOSITY_THRESHOLD_NORMAL); if (options.get_ClearDestination()) { if (!Utilities::DirectoryExists(options.get_Destination())) { CString message; message.AppendFormat(TEXT("Skipping recursive delete of destination directory %s because it appears not to exist."), options.get_Destination()); OutputWriter::WriteLine(message, VERBOSITY_THRESHOLD_NORMAL); } else { CString message; message.AppendFormat(TEXT("Recursively deleting destination directory %s."), options.get_Destination()); OutputWriter::WriteLine(message, VERBOSITY_THRESHOLD_NORMAL); bool doDelete = options.get_AcceptAll(); if (!doDelete) { if (Confirm(message)) { doDelete = true; } else { OutputWriter::WriteLine(TEXT("Aborting backup."), VERBOSITY_THRESHOLD_NORMAL); return; } } if (doDelete) { DeleteRecursive(options.get_Destination(), options.get_IgnorePattern()); } } } CBackupState backupState; LPSYSTEMTIME lastBackupTime; if (options.get_BackupType() == VSS_BT_INCREMENTAL) { backupState.Load(options.get_StateFile()); LPSYSTEMTIME lastFullBackupTime = backupState.get_LastFullBackupTime(); LPSYSTEMTIME lastIncrementalBackupTime = backupState.get_LastIncrementalBackupTime(); if (lastIncrementalBackupTime != NULL) { lastBackupTime = lastIncrementalBackupTime; } else { lastBackupTime = lastFullBackupTime; } } OutputWriter::WriteLine(TEXT("Calling CreateVssBackupComponents")); CHECK_HRESULT(::CreateVssBackupComponents(&pBackupComponents)); OutputWriter::WriteLine(TEXT("Calling InitializeForBackup")); CHECK_HRESULT(pBackupComponents->InitializeForBackup()); CComPtr<IVssAsync> pWriterMetadataStatus; OutputWriter::WriteLine(TEXT("Calling GatherWriterMetadata")); CHECK_HRESULT(pBackupComponents->GatherWriterMetadata(&pWriterMetadataStatus)); OutputWriter::WriteLine(TEXT("Waiting for call to GatherWriterMetadata to finish...")); CHECK_HRESULT(pWriterMetadataStatus->Wait()); HRESULT hrGatherStatus; OutputWriter::WriteLine(TEXT("Calling QueryStatus for GatherWriterMetadata")); CHECK_HRESULT(pWriterMetadataStatus->QueryStatus(&hrGatherStatus, NULL)); if (hrGatherStatus == VSS_S_ASYNC_CANCELLED) { throw new CVSSCopyException(L"GatherWriterMetadata was cancelled."); } OutputWriter::WriteLine(TEXT("Call to GatherWriterMetadata finished.")); OutputWriter::WriteLine(TEXT("Calling GetWriterMetadataCount")); vector<CWriter> writers; UINT cWriters; CHECK_HRESULT(pBackupComponents->GetWriterMetadataCount(&cWriters)); for (UINT iWriter = 0; iWriter < cWriters; ++iWriter) { CWriter writer; CComPtr<IVssExamineWriterMetadata> pExamineWriterMetadata; GUID id; OutputWriter::WriteLine(TEXT("Calling GetWriterMetadata")); CHECK_HRESULT(pBackupComponents->GetWriterMetadata(iWriter, &id, &pExamineWriterMetadata)); GUID idInstance; GUID idWriter; BSTR bstrWriterName; VSS_USAGE_TYPE usage; VSS_SOURCE_TYPE source; CHECK_HRESULT(pExamineWriterMetadata->GetIdentity(&idInstance, &idWriter, &bstrWriterName, &usage, &source)); writer.set_InstanceId(idInstance); writer.set_Name(bstrWriterName); writer.set_WriterId(idWriter); CComBSTR writerName(bstrWriterName); CString message; message.AppendFormat(TEXT("Writer %d named %s"), iWriter, (LPCTSTR)writerName); OutputWriter::WriteLine(message); UINT cIncludeFiles; UINT cExcludeFiles; UINT cComponents; CHECK_HRESULT(pExamineWriterMetadata->GetFileCounts(&cIncludeFiles, &cExcludeFiles, &cComponents)); message.Empty(); message.AppendFormat(TEXT("Writer has %d components"), cComponents); OutputWriter::WriteLine(message); for (UINT iComponent = 0; iComponent < cComponents; ++iComponent) { CWriterComponent component; CComPtr<IVssWMComponent> pComponent; CHECK_HRESULT(pExamineWriterMetadata->GetComponent(iComponent, &pComponent)); PVSSCOMPONENTINFO pComponentInfo; CHECK_HRESULT(pComponent->GetComponentInfo(&pComponentInfo)); CString message; message.AppendFormat(TEXT("Component %d is named %s, has a path of %s, and is %sselectable for backup. %d files, %d databases, %d log files."), iComponent, pComponentInfo->bstrComponentName, pComponentInfo->bstrLogicalPath, pComponentInfo->bSelectable ? TEXT("") : TEXT("not "), pComponentInfo->cFileCount, pComponentInfo->cDatabases, pComponentInfo->cLogFiles); OutputWriter::WriteLine(message); component.set_LogicalPath(pComponentInfo->bstrLogicalPath); component.set_SelectableForBackup(pComponentInfo->bSelectable); component.set_Writer(iWriter); component.set_Name(pComponentInfo->bstrComponentName); component.set_Type(pComponentInfo->type); for (UINT iFile = 0; iFile < pComponentInfo->cFileCount; ++iFile) { CComPtr<IVssWMFiledesc> pFileDesc; CHECK_HRESULT(pComponent->GetFile(iFile, &pFileDesc)); CComBSTR bstrPath; CHECK_HRESULT(pFileDesc->GetPath(&bstrPath)); CComBSTR bstrFileSpec; CHECK_HRESULT(pFileDesc->GetFilespec(&bstrFileSpec)); CString message; message.AppendFormat(TEXT("File %d has path %s\\%s"), iFile, bstrPath, bstrFileSpec); OutputWriter::WriteLine(message); } for (UINT iDatabase = 0; iDatabase < pComponentInfo->cDatabases; ++iDatabase) { CComPtr<IVssWMFiledesc> pFileDesc; CHECK_HRESULT(pComponent->GetDatabaseFile(iDatabase, &pFileDesc)); CComBSTR bstrPath; CHECK_HRESULT(pFileDesc->GetPath(&bstrPath)); CComBSTR bstrFileSpec; CHECK_HRESULT(pFileDesc->GetFilespec(&bstrFileSpec)); CString message; message.AppendFormat(TEXT("Database file %d has path %s\\%s"), iDatabase, bstrPath, bstrFileSpec); OutputWriter::WriteLine(message); } for (UINT iDatabaseLogFile = 0; iDatabaseLogFile < pComponentInfo->cLogFiles; ++iDatabaseLogFile) { CComPtr<IVssWMFiledesc> pFileDesc; CHECK_HRESULT(pComponent->GetDatabaseLogFile(iDatabaseLogFile, &pFileDesc)); CComBSTR bstrPath; CHECK_HRESULT(pFileDesc->GetPath(&bstrPath)); CComBSTR bstrFileSpec; CHECK_HRESULT(pFileDesc->GetFilespec(&bstrFileSpec)); CString message; message.AppendFormat(TEXT("Database log file %d has path %s\\%s"), iDatabaseLogFile, bstrPath, bstrFileSpec); OutputWriter::WriteLine(message); } CHECK_HRESULT(pComponent->FreeComponentInfo(pComponentInfo)); writer.get_Components().push_back(component); } writer.ComputeComponentTree(); for (unsigned int iComponent = 0; iComponent < writer.get_Components().size(); ++iComponent) { CWriterComponent& component = writer.get_Components()[iComponent]; CString message; message.AppendFormat(TEXT("Component %d has name %s, path %s, is %sselectable for backup, and has parent %s"), iComponent, component.get_Name(), component.get_LogicalPath(), component.get_SelectableForBackup() ? TEXT("") : TEXT("not "), component.get_Parent() == NULL ? TEXT("(no parent)") : component.get_Parent()->get_Name()); OutputWriter::WriteLine(message); } writers.push_back(writer); } OutputWriter::WriteLine(TEXT("Calling StartSnapshotSet")); CHECK_HRESULT(pBackupComponents->StartSnapshotSet(&snapshotSetId)); OutputWriter::WriteLine(TEXT("Calling GetVolumePathName")); WCHAR wszVolumePathName[MAX_PATH]; BOOL bWorked = ::GetVolumePathName(options.get_Source(), wszVolumePathName, MAX_PATH); if (!bWorked) { DWORD error = ::GetLastError(); CString errorMessage; Utilities::FormatErrorMessage(error, errorMessage); CString message; message.AppendFormat(TEXT("There was an error retrieving the volume name from the path. Path: %s Error: %s"), options.get_Source(), errorMessage); throw new CVSSCopyException(message.GetString()); } OutputWriter::WriteLine(TEXT("Calling AddToSnapshotSet")); GUID snapshotId; CHECK_HRESULT(pBackupComponents->AddToSnapshotSet(wszVolumePathName, GUID_NULL, &snapshotId)); for (unsigned int iWriter = 0; iWriter < writers.size(); ++iWriter) { CWriter writer = writers[iWriter]; CString message; message.AppendFormat(TEXT("Adding components to snapshot set for writer %s"), writer.get_Name()); OutputWriter::WriteLine(message); for (unsigned int iComponent = 0; iComponent < writer.get_Components().size(); ++iComponent) { CWriterComponent component = writer.get_Components()[iComponent]; if (ShouldAddComponent(component)) { CString message; message.AppendFormat(TEXT("Adding component %s (%s) from writer %s"), component.get_Name(), component.get_LogicalPath(), writer.get_Name()); OutputWriter::WriteLine(message); CHECK_HRESULT(pBackupComponents->AddComponent( writer.get_InstanceId(), writer.get_WriterId(), component.get_Type(), component.get_LogicalPath(), component.get_Name() )); } else { CString message; message.AppendFormat(TEXT("Not adding component %s from writer %s."), component.get_Name(), writer.get_Name()); OutputWriter::WriteLine(message); } } } OutputWriter::WriteLine(TEXT("Calling SetBackupState")); // Issue #29: trying to figure out if using VSS_BT_INCREMENTAL causes a problem CHECK_HRESULT(pBackupComponents->SetBackupState(TRUE, FALSE, VSS_BT_FULL, FALSE)); OutputWriter::WriteLine(TEXT("Calling PrepareForBackup")); CComPtr<IVssAsync> pPrepareForBackupResults; CHECK_HRESULT(pBackupComponents->PrepareForBackup(&pPrepareForBackupResults)); OutputWriter::WriteLine(TEXT("Waiting for call to PrepareForBackup to finish...")); CHECK_HRESULT(pPrepareForBackupResults->Wait()); HRESULT hrPrepareForBackupResults; CHECK_HRESULT(pPrepareForBackupResults->QueryStatus(&hrPrepareForBackupResults, NULL)); if (hrPrepareForBackupResults != VSS_S_ASYNC_FINISHED) { throw new CVSSCopyException(TEXT("Prepare for backup failed.")); } OutputWriter::WriteLine(TEXT("Call to PrepareForBackup finished.")); SYSTEMTIME snapshotTime; ::GetSystemTime(&snapshotTime); bWorked = ::SetConsoleCtrlHandler(CtrlHandler, TRUE); if (!bWorked) { OutputWriter::WriteLine(TEXT("Unable to set control handler. Ctrl-C and Ctrl-Break may have undesirable results."), VERBOSITY_THRESHOLD_NORMAL); } if (!options.get_Simulate()) { OutputWriter::WriteLine(TEXT("Calling DoSnapshotSet")); CComPtr<IVssAsync> pDoSnapshotSetResults; CHECK_HRESULT(pBackupComponents->DoSnapshotSet(&pDoSnapshotSetResults)); OutputWriter::WriteLine(TEXT("Waiting for call to DoSnapshotSet to finish...")); CHECK_HRESULT(pDoSnapshotSetResults->Wait()); bSnapshotCreated = true; if (s_cancel) { throw new CVSSCopyException(TEXT("Processing was cancelled by control-c, control-break, or a shutdown event. Terminating.")); } bWorked = ::SetConsoleCtrlHandler(CtrlHandler, FALSE); if (!bWorked) { OutputWriter::WriteLine(TEXT("Unable to reset control handler. Ctrl-C and Ctrl-Break may have undesirable results."), VERBOSITY_THRESHOLD_NORMAL); } HRESULT hrDoSnapshotSetResults; CHECK_HRESULT(pDoSnapshotSetResults->QueryStatus(&hrDoSnapshotSetResults, NULL)); if (hrDoSnapshotSetResults != VSS_S_ASYNC_FINISHED) { throw new CVSSCopyException(L"DoSnapshotSet failed."); } OutputWriter::WriteLine(TEXT("Call to DoSnapshotSet finished.")); OutputWriter::WriteLine(TEXT("Calling GetSnapshotProperties")); VSS_SNAPSHOT_PROP snapshotProperties; CHECK_HRESULT(pBackupComponents->GetSnapshotProperties(snapshotId, &snapshotProperties)); OutputWriter::WriteLine(TEXT("Calling CalculateSourcePath")); // TODO: We'll eventually have to deal with mount points CString wszSource; CalculateSourcePath( snapshotProperties.m_pwszSnapshotDeviceObject, options.get_Source(), wszVolumePathName, wszSource ); message.Empty(); message.AppendFormat(TEXT("Recursively creating destination directory %s."), options.get_Destination()); OutputWriter::WriteLine(message); Utilities::CreateDirectory(options.get_Destination()); OutputWriter::WriteLine(TEXT("Calling CopyRecursive")); vector<CCopyFilter*> filters; if (options.get_BackupType() == VSS_BT_FULL) { filters.push_back(new CIncludeAllCopyFilter()); } else if (options.get_BackupType() == VSS_BT_INCREMENTAL) { filters.push_back(new CModifiedSinceCopyFilter(lastBackupTime, options.get_SkipDenied())); } filters.push_back(new CFilespecCopyFilter(options.get_Filespecs())); CCopyAction copyAction(wszSource, options.get_Destination(), options.get_SkipDenied(), filters); ProcessDirectory(wszSource, copyAction, TEXT(""), options.get_Recursive(), options.get_IgnorePattern()); for (unsigned int iFilter = 0; iFilter < filters.size(); ++iFilter) { delete filters[iFilter]; } fileCount = copyAction.get_FileCount(); directoryCount = copyAction.get_DirectoryCount(); skipCount = copyAction.get_SkipCount(); byteCount = copyAction.get_ByteCount(); OutputWriter::WriteLine(TEXT("Calling BackupComplete")); CComPtr<IVssAsync> pBackupCompleteResults; CHECK_HRESULT(pBackupComponents->BackupComplete(&pBackupCompleteResults)); OutputWriter::WriteLine(TEXT("Waiting for call to BackupComplete to finish...")); CHECK_HRESULT(pBackupCompleteResults->Wait()); HRESULT hrBackupCompleteResults; CHECK_HRESULT(pBackupCompleteResults->QueryStatus(&hrBackupCompleteResults, NULL)); if (hrBackupCompleteResults != VSS_S_ASYNC_FINISHED) { throw new CVSSCopyException(TEXT("Completion of backup failed.")); } OutputWriter::WriteLine(TEXT("Call to BackupComplete finished.")); bAbnormalAbort = false; if (options.get_StateFile() != NULL) { OutputWriter::WriteLine(TEXT("Calling SaveAsXML")); CComBSTR bstrBackupDocument; CHECK_HRESULT(pBackupComponents->SaveAsXML(&bstrBackupDocument)); if (options.get_BackupType() == VSS_BT_FULL) { backupState.set_LastFullBackupTime(&snapshotTime); } else if (options.get_BackupType() == VSS_BT_INCREMENTAL) { backupState.set_LastIncrementalBackupTime(&snapshotTime); } else { throw new CVSSCopyException(TEXT("Unsupported backup type.")); } backupState.Save(options.get_StateFile(), bstrBackupDocument); } } } catch (CComException* e) { Cleanup(bAbnormalAbort, bSnapshotCreated, pBackupComponents, snapshotSetId); CString message; CString file; e->get_File(file); message.Format(TEXT("There was a COM failure 0x%x - %s (%d)"), e->get_Hresult(), file, e->get_Line()); OutputWriter::WriteLine(message, VERBOSITY_THRESHOLD_UNLESS_SILENT); return; } catch (CVSSCopyException* e) { Cleanup(bAbnormalAbort, bSnapshotCreated, pBackupComponents, snapshotSetId); OutputWriter::WriteLine(e->get_Message(), VERBOSITY_THRESHOLD_UNLESS_SILENT); return; } catch (CParseOptionsException* e) { Cleanup(bAbnormalAbort, bSnapshotCreated, pBackupComponents, snapshotSetId); CString message; message.AppendFormat(TEXT("Error: %s\n"), e->get_Message()); OutputWriter::WriteLine(message, VERBOSITY_THRESHOLD_UNLESS_SILENT); OutputWriter::WriteLine(COptions::get_Usage(), VERBOSITY_THRESHOLD_UNLESS_SILENT); return; } Cleanup(false, bSnapshotCreated, pBackupComponents, snapshotSetId); OutputWriter::WriteLine(TEXT("Backup successfully completed."), VERBOSITY_THRESHOLD_UNLESS_SILENT); CString message; CString startTimeStringLocal; Utilities::FormatDateTime(&startTime, TEXT(" "), true, startTimeStringLocal); CString finishTimeString; SYSTEMTIME finishTime; ::GetSystemTime(&finishTime); Utilities::FormatDateTime(&finishTime, TEXT(" "), true, finishTimeString); message.AppendFormat(TEXT("Backup started at %s, completed at %s."), startTimeStringLocal, finishTimeString); OutputWriter::WriteLine(message, VERBOSITY_THRESHOLD_NORMAL); message.Empty(); float unitCount = (float)byteCount; LPCTSTR units = TEXT("bytes"); if (unitCount > 1024) { unitCount = unitCount / 1024.0F; units = TEXT("KB"); } if (unitCount > 1024) { unitCount = unitCount / 1024.0F; units = TEXT("MB"); } if (unitCount > 1024) { unitCount = unitCount / 1024.0F; units = TEXT("GB"); } message.AppendFormat(TEXT("%d files (%.2f %s, %d directories) copied, %d files skipped"), fileCount, unitCount, units, directoryCount, skipCount); OutputWriter::WriteLine(message, VERBOSITY_THRESHOLD_NORMAL); OutputWriter::SetVerbosityLevel((VERBOSITY_LEVEL)options.get_VerbosityLevel()); //for (int i = 0; i < argc; ++i) //{ // CString message; // message.AppendFormat(TEXT("Argument %d: %s"), i, argv[i]); // OutputWriter::WriteLine(message, VERBOSITY_THRESHOLD_IF_VERBOSE); //} }
// To confirm the modifications made HRESULT CFrameProcessor_CAN::FPC_Confirm(void) { return Confirm(); }
int WriteCFG (struct plc * plc) { struct channel * channel = (struct channel *)(plc->channel); struct message * message = (struct message *)(plc->message); #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_set_sdram_request { struct ethernet_hdr ethernet; struct qualcomm_hdr qualcomm; struct config_ram config_ram; uint32_t CHECKSUM; } * request = (struct vs_set_sdram_request *) (message); struct __packed vs_set_sdram_confirm { struct ethernet_hdr ethernet; struct qualcomm_hdr qualcomm; uint8_t MSTATUS; } * confirm = (struct vs_set_sdram_confirm *) (message); #ifndef __GNUC__ #pragma pack (pop) #endif Request (plc, "Write Configuration Applet from %s", plc->CFG.name); memset (message, 0, sizeof (* message)); EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type); QualcommHeader (&request->qualcomm, 0, (VS_SET_SDRAM | MMTYPE_REQ)); plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN); if (lseek (plc->CFG.file, 0, SEEK_SET)) { error (PLC_EXIT (plc), errno, FILE_CANTHOME, plc->CFG.name); return (-1); } if (read (plc->CFG.file, &request->config_ram, sizeof (struct config_ram)) != sizeof (struct config_ram)) { error (PLC_EXIT (plc), errno, FILE_CANTREAD, plc->CFG.name); return (-1); } if (read (plc->CFG.file, &request->CHECKSUM, sizeof (request->CHECKSUM)) != sizeof (request->CHECKSUM)) { error (PLC_EXIT (plc), errno, "can't read %s checksum", plc->CFG.name); return (-1); } if (SendMME (plc) <= 0) { error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND); return (-1); } if (ReadMME (plc, 0, (VS_SET_SDRAM | MMTYPE_CNF)) <= 0) { error (PLC_EXIT (plc), errno, CHANNEL_CANTREAD); return (-1); } if (confirm->MSTATUS) { Failure (plc, PLC_WONTDOIT); return (-1); } Confirm (plc, "Written"); return (0); }
ConfirmAnswer Reporting::Confirm(const std::wstring &text, bool showCancel, bool defaultNo, const CWnd *parent) //------------------------------------------------------------------------------------------------------------- { return Confirm(text, MAINFRAME_TITLEW L" - Confirmation", showCancel, defaultNo, parent); }
void MyMessageBox::rightButtonClicked() { emit Confirm(true); }
void MyMessageBox::leftButtonClicked() { emit Confirm(false); }
BOOL ProcessCommandLineAtr(SCARDCONTEXT hContext, char *p_atr, char *p_name, BOOL forget_not_introduce) { BYTE atr[MAX_ATR_LEN]; BYTE mask[MAX_ATR_LEN]; char name[MAX_PATH]; BYTE atrlen = 0; unsigned int i, j; j = 0; for (i=0; i<strlen(p_atr); i++) { BYTE c_atr, c_mask = 0x0F; if (atrlen >= MAX_ATR_LEN) { printf("The ATR is too long.\n"); return FALSE; } if ((p_atr[i] == ' ') || (p_atr[i] == ':')) continue; if ((p_atr[i] >= '0') && (p_atr[i] <= '9')) { c_atr = p_atr[i] - '0'; } else if ((p_atr[i] >= 'A') && (p_atr[i] <= 'F')) { c_atr = p_atr[i] - 'A' + 10; } else if ((p_atr[i] >= 'a') && (p_atr[i] <= 'f')) { c_atr = p_atr[i] - 'a' + 10; } else if ((p_atr[i] == 'x') || (p_atr[i] == 'X') || (p_atr[i] == '?') || (p_atr[i] == '.')) { c_atr = 0; c_mask = 0; } else { printf("Invalid character '%c' in the ATR.\n", p_atr[i]); return FALSE; } if (j) { atr[atrlen] <<= 4; atr[atrlen] |= c_atr; mask[atrlen] <<= 4; mask[atrlen] |= c_mask; atrlen++; j = 0; } else { atr[atrlen] = c_atr; mask[atrlen] = c_mask; j = 1; } } if (j) { printf("Odd number of characters in the ATR.\n"); return FALSE; } if (p_name != NULL) { sprintf(name, "%s-%s", name_prefix, p_name); } else { sprintf(name, "%s-", name_prefix); if (!ComputeCardNameFromAtr(&name[strlen(name)], atr, mask, atrlen)) { printf("Failed to compute a name for the card.\n"); return FALSE; } } if (forget_not_introduce) { if (!Confirm("Do you want to remove this card from the 'no driver' list ?")) return TRUE; return ForgetCardAtr(hContext, name); } else { if (!Confirm("Do you want to add this card to the 'no driver' list ?")) return TRUE; return IntroduceCardAtr(hContext, atr, mask, atrlen, name); } }
signed ResetAndWait (struct int6k * int6k) { struct channel * channel = (struct channel *)(int6k->channel); struct message * message = (struct message *)(int6k->message); #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_rs_dev_confirm { struct header_eth ethernet; struct header_int intellon; uint8_t MSTATUS; } * confirm = (struct vs_rs_dev_confirm *) (message); #ifndef __GNUC__ #pragma pack (pop) #endif char string [INT6K_VERSTRING]; Request (int6k, "Reset Device"); memset (message, 0, sizeof (struct message)); EthernetHeader (&message->ethernet, channel->peer, channel->host); IntellonHeader (&message->intellon, (VS_RS_DEV | MMTYPE_REQ)); int6k->packetsize = ETHER_MIN_LEN; if (SendMME (int6k) <= 0) { error ((int6k->flags & INT6K_BAILOUT), ECANCELED, INT6K_CANTSEND); return (-1); } #if 0 if (ReadMME (int6k, (VS_RS_DEV | MMTYPE_CNF)) <= 0) { error ((int6k->flags & INT6K_BAILOUT), ECANCELED, INT6K_CANTREAD); return (-1); } if (confirm->MSTATUS) { Failure (int6k, INT6K_WONTDOIT); return (-1); } Confirm (int6k, "Resetting ..."); if (WaitForReset (int6k)) { return (-1); } if (WaitForStart (int6k, string, sizeof (string))) { return (-1); } #else while (ReadMME (int6k, (VS_RS_DEV | MMTYPE_CNF)) > 0) { if (confirm->MSTATUS) { continue; } Confirm (int6k, "Start %s", string); return (0); } #endif return (-1); }
void CDuffDlg::OnCancel() { if ( g_DupeFileFind.m_DuffStatus.Status != DUFFSTATUS_RUNNING || ( (g_DupeFileFind.m_DuffStatus.Status == DUFFSTATUS_RUNNING) && Confirm()) ) { g_DupeFileFind.m_DuffStatus.Status = DUFFSTATUS_STOPPED; Exit(); } // TODO: Add extra cleanup here //CResizableDialog::OnCancel(); }
signed ReadParameters1 (struct plc * plc) { struct channel * channel = (struct channel *)(plc->channel); struct message * message = (struct message *)(plc->message); #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_rd_mod_request { struct ethernet_std ethernet; struct qualcomm_std qualcomm; uint8_t MODULEID; uint8_t MACCESS; uint16_t MLENGTH; uint32_t MOFFSET; uint8_t MSECRET [16]; } * request = (struct vs_rd_mod_request *) (message); struct __packed vs_rd_mod_confirm { struct ethernet_std ethernet; struct qualcomm_std qualcomm; uint8_t MSTATUS; uint8_t RESERVED1 [3]; uint8_t MODULEID; uint8_t RESERVED; uint16_t MLENGTH; uint32_t MOFFSET; uint32_t CHKSUM; uint8_t BUFFER [PLC_RECORD_SIZE]; } * confirm = (struct vs_rd_mod_confirm *) (message); #ifndef __GNUC__ #pragma pack (pop) #endif uint32_t extent = 0; uint32_t offset = 0; uint16_t length = PLC_RECORD_SIZE; Request (plc, "Read Parameters from Device"); if (lseek (plc->pib.file, 0, SEEK_SET)) { error ((plc->flags & PLC_BAILOUT), errno, FILE_CANTHOME, plc->pib.name); return (1); } do { memset (message, 0, sizeof (* message)); EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type); QualcommHeader (&request->qualcomm, 0, (VS_RD_MOD | MMTYPE_REQ)); plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN); request->MODULEID = VS_MODULE_PIB; request->MLENGTH = HTOLE16 (length); request->MOFFSET = HTOLE32 (offset); if (SendMME (plc) <= 0) { error ((plc->flags & PLC_BAILOUT), errno, CHANNEL_CANTSEND); return (-1); } if (ReadMME (plc, 0, (VS_RD_MOD | MMTYPE_CNF)) <= 0) { error ((plc->flags & PLC_BAILOUT), errno, CHANNEL_CANTREAD); return (-1); } if (confirm->MSTATUS) { Failure (plc, PLC_WONTDOIT); return (-1); } if (LE16TOH (confirm->MLENGTH) != length) { error ((plc->flags & PLC_BAILOUT), 0, PLC_ERR_LENGTH); return (-1); } if (LE32TOH (confirm->MOFFSET) != offset) { error ((plc->flags & PLC_BAILOUT), 0, PLC_ERR_OFFSET); return (-1); } length = LE16TOH (confirm->MLENGTH); offset = LE32TOH (confirm->MOFFSET); if (checksum32 (confirm->BUFFER, length, confirm->CHKSUM)) { error ((plc->flags & PLC_BAILOUT), ECANCELED, "Bad Packet Checksum"); return (-1); } if (offset == extent) { struct pib_header * pib_header = (struct pib_header *) (confirm->BUFFER); extent = LE16TOH (pib_header->PIBLENGTH); } if ((offset + length) > extent) { length = extent - offset; } if (lseek (plc->pib.file, offset, SEEK_SET) != (signed)(offset)) { error ((plc->flags & PLC_BAILOUT), errno, FILE_CANTSEEK, plc->pib.name); return (-1); } if (write (plc->pib.file, confirm->BUFFER, length) != (signed)(length)) { error ((plc->flags & PLC_BAILOUT), errno, FILE_CANTSAVE, plc->pib.name); return (-1); } offset += length; } while (offset < extent); Confirm (plc, "Read %s", plc->pib.name); return (0); }
void MdiEditor::createMenuBar() { pro_menu=menuBar()->addMenu("Project"); new_pro=new QAction("&New Project", this); save_pro=new QAction("&Save Project", this); pro_menu->addAction(new_pro); pro_menu->addAction(save_pro); setting_menu=menuBar()->addMenu("Settings"); mod_para=new QAction("&Parameters", this); setting_menu->addAction(mod_para); mod_mask=new QAction("&Masks", this); setting_menu->addAction(mod_mask); mod_layer=new QAction("&Layers", this); setting_menu->addAction(mod_layer); view_menu=menuBar()->addMenu("View"); mask_view=view_menu->addMenu("Mask"); show_mask=new QAction("&Show", this); mask_view->addAction(show_mask); hide_mask=new QAction("&Hide", this); mask_view->addAction(hide_mask); result_view=view_menu->addMenu("Results"); show_halfway=new QAction("&Halfway Image", this); result_view->addAction(show_halfway); show_error=new QAction("&Error Image", this); result_view->addAction(show_error); color_view=view_menu->addMenu("Color from"); show_image1=new QAction("&Image1", this); color_view->addAction(show_image1); show_image12=new QAction("&Both image1 & image2", this); color_view->addAction(show_image12); show_image2=new QAction("&Image2", this); color_view->addAction(show_image2); layer_view=view_menu->addMenu("Layer"); show_multilayer=new QAction("&Multilayer", this); layer_view->addAction(show_multilayer); alg_menu=menuBar()->addMenu("Algorithm"); cpu_alg=new QAction("&CPU", this); gpu_alg=new QAction("&GPU", this); alg_menu->addAction(cpu_alg); alg_menu->addAction(gpu_alg); show_mask->setCheckable(true); hide_mask->setCheckable(true); show_halfway->setCheckable(true); show_error->setCheckable(true); show_image1->setCheckable(true); show_image12->setCheckable(true); show_image2->setCheckable(true); show_multilayer->setCheckable(true); cpu_alg->setCheckable(true); gpu_alg->setCheckable(true); //right menu confirm=new QAction("&confirm",this); cancel=new QAction("&cancel",this); //signal connect(new_pro,SIGNAL(triggered()),this,SLOT(NewProject())); connect(save_pro,SIGNAL(triggered()),this,SLOT(SaveProject())); connect(mod_para,SIGNAL(triggered()),this,SLOT(ModifyPara())); connect(mod_mask,SIGNAL(triggered()),this,SLOT(ModifyMask())); connect(show_mask,SIGNAL(triggered()),this,SLOT(ShowMask())); connect(hide_mask,SIGNAL(triggered()),this,SLOT(HideMask())); connect(show_halfway,SIGNAL(triggered()),this,SLOT(ShowHalfway())); connect(show_error,SIGNAL(triggered()),this,SLOT(ShowError())); connect(show_image1,SIGNAL(triggered()),this,SLOT(ColorFromImage1())); connect(show_image12,SIGNAL(triggered()),this,SLOT(ColorFromImage12())); connect(show_image2,SIGNAL(triggered()),this,SLOT(ColorFromImage2())); connect(confirm,SIGNAL(triggered()),this,SLOT(Confirm())); connect(cancel,SIGNAL(triggered()),this,SLOT(Cancel())); connect(mod_layer,SIGNAL(triggered()),this,SLOT(ModifyLayer())); connect(show_multilayer,SIGNAL(triggered()),this,SLOT(MultyLayer())); connect(cpu_alg,SIGNAL(triggered()),this,SLOT(CPU_Alg())); connect(gpu_alg,SIGNAL(triggered()),this,SLOT(GPU_Alg())); }
signed ResetAndWait (struct plc * plc) { struct channel * channel = (struct channel *)(plc->channel); struct message * message = (struct message *)(plc->message); #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_rs_dev_request { struct ethernet_hdr ethernet; struct qualcomm_hdr qualcomm; uint8_t MSTATUS; } * request = (struct vs_rs_dev_request *) (message); struct __packed vs_rs_dev_confirm { struct ethernet_hdr ethernet; struct qualcomm_hdr qualcomm; uint8_t MSTATUS; uint8_t MDEVICEID; uint8_t MVERLENGTH; char MVERSION [PLC_VERSION_STRING]; } * confirm = (struct vs_rs_dev_confirm *) (message); #ifndef __GNUC__ #pragma pack (pop) #endif char firmware [PLC_VERSION_STRING]; Request (plc, "Reset Device"); memset (message, 0, sizeof (* message)); EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type); QualcommHeader (&request->qualcomm, 0, (VS_RS_DEV | MMTYPE_REQ)); plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN); if (SendMME (plc) <= 0) { error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND); return (-1); } memset (firmware, 0, sizeof (firmware)); #if 0 if (ReadMME (plc, (VS_RS_DEV | MMTYPE_CNF)) <= 0) { error (PLC_EXIT (plc), errno, CHANNEL_CANTREAD); return (-1); } if (confirm->MSTATUS) { Failure (plc, PLC_WONTDOIT); return (-1); } Confirm (plc, "Resetting ..."); if (WaitForReset (plc)) { Failure (plc, "Device did not Reset"); return (-1); } if (WaitForStart (plc, firmware, sizeof (firmware))) { Failure (plc, "Device did not Start"); return (-1); } #else while (ReadMME (plc, 0, (VS_RS_DEV | MMTYPE_CNF)) > 0) { if (confirm->MSTATUS) { continue; } return (0); } #endif return (-1); }
signed WaitForStart (struct plc * plc, char string [], size_t length) { struct channel * channel = (struct channel *)(plc->channel); struct message * message = (struct message *)(plc->message); struct timeval ts; struct timeval tc; unsigned timer = 0; #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_sw_ver_request { struct ethernet_std ethernet; struct qualcomm_std qualcomm; uint8_t MSTATUS; uint8_t MDEVICEID; uint8_t MVERLENGTH; char MVERSION [PLC_VERSION_STRING]; } * request = (struct vs_sw_ver_request *) (message); struct __packed vs_sw_ver_confirm { struct ethernet_std ethernet; struct qualcomm_std qualcomm; uint8_t MSTATUS; uint8_t MDEVICEID; uint8_t MVERLENGTH; char MVERSION [PLC_VERSION_STRING]; } * confirm = (struct vs_sw_ver_confirm *) (message); #ifndef __GNUC__ #pragma pack (pop) #endif Request (plc, "Allow %d seconds for Start", plc->timer); if (gettimeofday (&ts, NULL) == -1) { error (1, errno, CANT_START_TIMER); } for (timer = 0; timer < plc->timer; timer = SECONDS (ts, tc)) { memset (message, 0, sizeof (* message)); EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type); QualcommHeader (&request->qualcomm, 0, (VS_SW_VER | MMTYPE_REQ)); plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN); if (SendMME (plc) <= 0) { error ((plc->flags & PLC_BAILOUT), errno, CHANNEL_CANTSEND); return (-1); } if (ReadMME (plc, 0, (VS_SW_VER | MMTYPE_CNF)) < 0) { error ((plc->flags & PLC_BAILOUT), errno, CHANNEL_CANTREAD); return (-1); } if (gettimeofday (&tc, NULL) == -1) { error (1, errno, CANT_RESET_TIMER); } if (plc->packetsize) { if (confirm->MSTATUS) { Failure (plc, PLC_WONTDOIT); return (-1); } if (_allset (plc->flags, (PLC_WAITFORSTART | PLC_ANALYSE))) { Confirm (plc, "Waited %d seconds for Start", timer); } strncpy (string, confirm->MVERSION, length); return (0); } } if (_allset (plc->flags, (PLC_WAITFORSTART | PLC_ANALYSE))) { Confirm (plc, "Waited %d seconds for Start", timer); } return (-1); }
// To confirm the modifications made HRESULT CFrameProcessor_J1939::FPJ1_Confirm(void) { return Confirm(); }
std::string UnsolConfirm(uint8_t seq) { return Confirm(seq, true); }
signed function (struct plc * plc) { struct channel * channel = (struct channel *)(plc->channel); struct message * message = (struct message *)(plc->message); static char const * actions [] = { "start device", "store firmware", "store parameters", "update host", "config memory", "restore defaults", "unknown" }; #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_host_action_ind { struct ethernet_hdr ethernet; struct qualcomm_hdr qualcomm; uint8_t MACTION; uint8_t MAJOR_VERSION; uint8_t MINOR_VERSION; } * indicate = (struct vs_host_action_ind *) (message); #ifndef __GNUC__ #pragma pack (pop) #endif char const * FactoryNVM = plc->NVM.name; char const * FactoryPIB = plc->PIB.name; signed status; signed action; Request (plc, "Waiting for Host Action"); while (1) { status = ReadMME (plc, 0, (VS_HOST_ACTION | MMTYPE_IND)); if (status < 0) { break; } if (status > 0) { printf ("\n"); if (indicate->MACTION < SIZEOF (actions)) { Confirm (plc, "Host Action Request is (%d) %s.", indicate->MACTION, actions [indicate->MACTION]); } else { error (0, ENOTSUP, "Host Action 0x%0X", indicate->MACTION); continue; } action = indicate->MACTION; memcpy (channel->peer, indicate->ethernet.OSA, sizeof (channel->peer)); if (HostActionResponse (plc)) { return (-1); } if (action == 0x00) { if (BootDevice1 (plc)) { return (-1); } if (_anyset (plc->flags, PLC_FLASH_DEVICE)) { FlashDevice1 (plc); } continue; } if (action == 0x01) { close (plc->NVM.file); if (ReadFirmware1 (plc)) { return (-1); } if ((plc->NVM.file = open (plc->NVM.name = plc->nvm.name, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->NVM.name); } if (ResetDevice (plc)) { return (-1); } continue; } if (action == 0x02) { close (plc->PIB.file); if (ReadParameters1 (plc)) { return (-1); } if ((plc->PIB.file = open (plc->PIB.name = plc->pib.name, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->PIB.name); } if (ResetDevice (plc)) { return (-1); } continue; } if (action == 0x03) { close (plc->PIB.file); if (ReadParameters1 (plc)) { return (-1); } if ((plc->PIB.file = open (plc->PIB.name = plc->pib.name, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->PIB.name); } close (plc->NVM.file); if (ReadFirmware1 (plc)) { return (-1); } if ((plc->NVM.file = open (plc->NVM.name = plc->nvm.name, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->NVM.name); } if (ResetDevice (plc)) { return (-1); } continue; } if (action == 0x04) { if (InitDevice1 (plc)) { return (-1); } continue; } if (action == 0x05) { close (plc->PIB.file); if ((plc->PIB.file = open (plc->PIB.name = FactoryPIB, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->PIB.name); } close (plc->NVM.file); if ((plc->NVM.file = open (plc->NVM.name = FactoryNVM, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->NVM.name); } if (ResetDevice (plc)) { return (-1); } continue; } if (action == 0x06) { close (plc->PIB.file); if (ReadParameters1 (plc)) { return (-1); } if ((plc->PIB.file = open (plc->PIB.name = plc->pib.name, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->PIB.name); } continue; } error (0, ENOSYS, "Host Action 0x%02X", action); } } return (0); }
signed ReadFirmware1 (struct plc * plc) { struct channel * channel = (struct channel *)(plc->channel); struct message * message = (struct message *)(plc->message); #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_rd_mod_request { struct ethernet_hdr ethernet; struct qualcomm_hdr qualcomm; uint8_t MODULEID; uint8_t MACCESS; uint16_t MLENGTH; uint32_t MOFFSET; uint8_t MSECRET [16]; } * request = (struct vs_rd_mod_request *) (message); struct __packed vs_rd_mod_confirm { struct ethernet_hdr ethernet; struct qualcomm_hdr qualcomm; uint8_t MSTATUS; uint8_t RES [3]; uint8_t MODULEID; uint8_t RESERVED; uint16_t MLENGTH; uint32_t MOFFSET; uint32_t CHKSUM; uint8_t BUFFER [PLC_RECORD_SIZE]; } * confirm = (struct vs_rd_mod_confirm *) (message); #ifndef __GNUC__ #pragma pack (pop) #endif uint32_t header = 0; uint32_t extent = 0; uint32_t offset = 0; uint16_t length = PLC_RECORD_SIZE; Request (plc, "Read Firmware from Device"); if (lseek (plc->nvm.file, 0, SEEK_SET)) { error (PLC_EXIT (plc), errno, FILE_CANTHOME, plc->nvm.name); return (1); } do { memset (message, 0, sizeof (* message)); EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type); QualcommHeader (&request->qualcomm, 0, (VS_RD_MOD | MMTYPE_REQ)); plc->packetsize = (ETHER_MIN_LEN - ETHER_CRC_LEN); request->MODULEID = VS_MODULE_MAC; request->MLENGTH = HTOLE16 (length); request->MOFFSET = HTOLE32 (offset); if (SendMME (plc) <= 0) { error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND); return (-1); } if (ReadMME (plc, 0, (VS_RD_MOD | MMTYPE_CNF)) <= 0) { error (PLC_EXIT (plc), errno, CHANNEL_CANTREAD); return (-1); } if (confirm->MSTATUS) { Failure (plc, PLC_WONTDOIT); return (-1); } if (LE16TOH (confirm->MLENGTH) != length) { error (PLC_EXIT (plc), 0, PLC_ERR_LENGTH); return (-1); } if (LE32TOH (confirm->MOFFSET) != offset) { error (PLC_EXIT (plc), 0, PLC_ERR_OFFSET); return (-1); } length = LE16TOH (confirm->MLENGTH); offset = LE32TOH (confirm->MOFFSET); if (checksum32 (confirm->BUFFER, length, confirm->CHKSUM)) { error (PLC_EXIT (plc), ECANCELED, "Bad Packet Checksum"); return (-1); } if (offset == extent) { struct nvm_header1 * nvm_header = (struct nvm_header1 *)(confirm->BUFFER); if (checksum32 (nvm_header, sizeof (* nvm_header), 0)) { error (PLC_EXIT (plc), ECANCELED, "Bad Header Checksum"); return (-1); } if (LE32TOH (nvm_header->HEADERVERSION) != 0x60000000) { error (PLC_EXIT (plc), ECANCELED, "Bad Header Version"); return (-1); } extent += sizeof (* nvm_header); extent += LE32TOH (nvm_header->IMAGELENGTH); header = LE32TOH (nvm_header->NEXTHEADER); } if ((offset + length) > extent) { length = extent - offset; } if (lseek (plc->nvm.file, offset, SEEK_SET) != (off_t)(offset)) { error (PLC_EXIT (plc), errno, FILE_CANTSEEK, plc->nvm.name); return (-1); } if (write (plc->nvm.file, confirm->BUFFER, length) != (signed)(length)) { error (PLC_EXIT (plc), errno, FILE_CANTSEEK, plc->nvm.name); return (-1); } offset += length; length = 1024; } while ((header) || (offset < extent)); Confirm (plc, "Read %s", plc->nvm.name); return (0); }
///////////////////////////////////////////////////////////////////// // TPreferencesDialog // ------------------ // void TPreferencesDialog::CmOk () { char str[MAX_BITMAPNAME + 1]; if ( !CanClose() ) return; // Get MAX UNDO int max_undo; pMaxUndoEdit->GetText(str, MAX_BITMAPNAME + 1); max_undo = atoi(str); if ( max_undo != MaxUndo ) { if ( (GetUndoName() == NULL && GetRedoName() == NULL) || Confirm("WARNING: Changing the maximum number of UNDO/REDO " "will free up current UNDO/REDO structure(s).\n" "Are you sure you want to do this ?") ) { CleanupUndo(); MaxUndo = max_undo; InitUndo(); } else { wsprintf(str, "%d", MaxUndo); pMaxUndoEdit->SetText(str); return; } } // Floor/Ceiling Texture pAboveText->GetText (str, MAX_BITMAPNAME + 1); FreeMemory (DefaultUpperTexture); DefaultUpperTexture = (char *)GetMemory (strlen(str)+1); strcpy (DefaultUpperTexture, str); pNormalText->GetText (str, MAX_BITMAPNAME + 1); FreeMemory (DefaultWallTexture); DefaultWallTexture = (char *)GetMemory (strlen(str)+1); strcpy (DefaultWallTexture, str); pBelowText->GetText (str, MAX_BITMAPNAME + 1); FreeMemory (DefaultLowerTexture); DefaultLowerTexture = (char *)GetMemory (strlen(str)+1); strcpy (DefaultLowerTexture, str); pFloorText->GetText (str, MAX_BITMAPNAME + 1); FreeMemory (DefaultFloorTexture); DefaultFloorTexture = (char *)GetMemory (strlen(str)+1); strcpy (DefaultFloorTexture, str); pCeilingText->GetText (str, MAX_BITMAPNAME + 1); FreeMemory (DefaultCeilingTexture); DefaultCeilingTexture = (char *)GetMemory (strlen(str)+1); strcpy (DefaultCeilingTexture, str); // Floor/Ceiling height pFloorHeight->GetText (str, 6); DefaultFloorHeight = (SHORT)atoi(str); pCeilingHeight->GetText (str, 6); DefaultCeilingHeight = (SHORT)atoi(str); #if (COOPERATION_VERSION == 1) BuildCoopExecTab(); #endif // COOPERATION_VERSION // Check grid size value /* if ( GridScale >= 256 ) GridScale = 256; else if ( GridScale >= 128 ) GridScale = 128; else if ( GridScale >= 64 ) GridScale = 64; else if ( GridScale >= 32 ) GridScale = 32; else if ( GridScale >= 16 ) GridScale = 16; else if ( GridScale >= 8 ) GridScale = 8; else GridScale = 0; */ // Misc boolean options AdditiveSelBox = (pAddSelBoxCheck->GetCheck() == BF_CHECKED); Debug = (pDebugCheck->GetCheck() == BF_CHECKED); DrawLineDefsLen = (pDrawLengthCheck->GetCheck() == BF_CHECKED); Expert = (pExpertCheck->GetCheck() == BF_CHECKED); Quiet = (pQuietCheck->GetCheck() == BF_CHECKED); Quieter = (pQuiterCheck->GetCheck() == BF_CHECKED); Select0 = (pSelect0Check->GetCheck() == BF_CHECKED); AutoScroll = (pAutoScrollCheck->GetCheck() == BF_CHECKED); // Toggle status bar if if ( InfoShown != (pInfoBarCheck->GetCheck() == BF_CHECKED) ) TYPESAFE_DOWNCAST(GetApplication()->GetMainWindow(), TMainFrame)->ToggleStatusBar(); InfoShown = (pInfoBarCheck->GetCheck() == BF_CHECKED); // Close Dialog box TDialog::CmOk(); }
signed EmulateHost (struct plc * plc) { struct channel * channel = (struct channel *)(plc->channel); struct message * message = (struct message *)(plc->message); static char const * actions [] = { "start device", "store firmware", "store parameters", "update host", "config memory", "restore defaults", "unknown" }; #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_host_action_ind { struct ethernet_hdr ethernet; struct qualcomm_hdr qualcomm; uint8_t MACTION; uint8_t MAJOR_VERSION; uint8_t MINOR_VERSION; } * indicate = (struct vs_host_action_ind *) (message); #if 0 struct __packed vs_host_action_rsp { struct ethernet_hdr ethernet; struct qualcomm_hdr qualcomm; uint8_t MSTATUS; } * response = (struct vs_host_action_rsp *) (message); #endif #ifndef __GNUC__ #pragma pack (pop) #endif struct nvm_header1 nvm_header; struct pib_header pib_header; uint32_t offset; char const * PIB = plc->PIB.name; char const * NVM = plc->NVM.name; signed timer = channel->timeout; signed status = 0; Request (plc, "Waiting for Host Action"); while (1) { channel->timeout = plc->timer; status = ReadMME (plc, 0, (VS_HOST_ACTION | MMTYPE_IND)); channel->timeout = timer; if (status < 0) { break; } if (status > 0) { printf ("\n"); if (indicate->MACTION < (sizeof (actions) / sizeof (char const *))) { Confirm (plc, "Host Action Request is (%d) %s.", indicate->MACTION, actions [indicate->MACTION]); } else { error (0, ENOTSUP, "Host Action 0x%0X", indicate->MACTION); continue; } memcpy (channel->peer, indicate->ethernet.OSA, sizeof (channel->peer)); channel->timeout = timer; if (indicate->MACTION == 0x00) { unsigned module = 0; char firmware [PLC_VERSION_STRING]; if (HostActionResponse (plc)) { return (-1); } if (lseek (plc->PIB.file, 0, SEEK_SET)) { error (1, errno, FILE_CANTHOME, plc->PIB.name); } if (read (plc->PIB.file, &pib_header, sizeof (pib_header)) != sizeof (pib_header)) { error (1, errno, FILE_CANTREAD, plc->PIB.name); } if (lseek (plc->PIB.file, 0, SEEK_SET)) { error (1, errno, FILE_CANTHOME, plc->PIB.name); } if (BE16TOH (*(uint16_t *)(&pib_header)) < 0x0305) { offset = LEGACY_PIBOFFSET; } else if (BE16TOH (*(uint16_t *)(&pib_header)) < 0x0500) { offset = INT6x00_PIBOFFSET; } else { offset = AR7x00_PIBOFFSET; } if (WriteMEM (plc, &plc->PIB, 0, offset, LE16TOH (pib_header.PIBLENGTH))) { return (-1); } if (lseek (plc->NVM.file, 0, SEEK_SET)) { error (1, errno, FILE_CANTHOME, plc->NVM.name); } if (read (plc->NVM.file, &nvm_header, sizeof (nvm_header)) != sizeof (nvm_header)) { error (1, errno, FILE_CANTREAD, plc->NVM.name); } while (nvm_header.NEXTHEADER) { lseek (plc->NVM.file, LE32TOH (nvm_header.NEXTHEADER), SEEK_SET); if (read (plc->NVM.file, &nvm_header, sizeof (nvm_header)) != sizeof (nvm_header)) { error (1, errno, FILE_CANTREAD, plc->NVM.name); } module++; } if (WriteFirmware1 (plc, module, &nvm_header)) { return (-1); } if (StartFirmware1 (plc, module, &nvm_header)) { return (-1); } if (WaitForStart (plc, firmware, sizeof (firmware))) { return (-1); } if (_anyset (plc->flags, PLC_FLASH_DEVICE)) { if (WriteNVM (plc)) { return (-1); } if (WritePIB (plc)) { return (-1); } if (FlashNVM (plc)) { return (-1); } } continue; } if (indicate->MACTION == 0x01) { if (HostActionResponse (plc)) { return (-1); } close (plc->NVM.file); if (ReadFirmware1 (plc)) { return (-1); } if ((plc->NVM.file = open (plc->NVM.name = plc->nvm.name, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->NVM.name); } if (ResetDevice (plc)) { return (-1); } continue; } if (indicate->MACTION == 0x02) { if (HostActionResponse (plc)) { return (-1); } close (plc->PIB.file); if (ReadParameters1 (plc)) { return (-1); } if ((plc->PIB.file = open (plc->PIB.name = plc->pib.name, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->PIB.name); } if (ResetDevice (plc)) { return (-1); } continue; } if (indicate->MACTION == 0x03) { if (HostActionResponse (plc)) { return (-1); } close (plc->NVM.file); if (ReadFirmware1 (plc)) { return (-1); } if ((plc->NVM.file = open (plc->NVM.name = plc->nvm.name, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->NVM.name); } close (plc->PIB.file); if (ReadParameters1 (plc)) { return (-1); } if ((plc->PIB.file = open (plc->PIB.name = plc->pib.name, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->PIB.name); } if (ResetDevice (plc)) { return (-1); } continue; } if (indicate->MACTION == 0x04) { #if 0 /* * Due to an omission in the INT6300 BootLoader, responding to this VS_HOST_ACTION * indication will suppress subsequent VS_HOST_ACTION messages and the device will * not request firmware and parameters; this may be corrected on the INT6400; */ if (HostActionResponse (plc)) { return (-1); } #endif if (WriteCFG (plc)) { return (-1); } /* * At this point, one could download firmware and parameters without waiting for * further requests from the device; however, we elect to wait for them since it * is 'good form'; a device should send code 0x00 within 10 seconds of this one; */ continue; } if (indicate->MACTION == 0x05) { if (HostActionResponse (plc)) { return (-1); } close (plc->NVM.file); if ((plc->NVM.file = open (plc->NVM.name = NVM, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->NVM.name); } close (plc->PIB.file); if ((plc->PIB.file = open (plc->PIB.name = PIB, O_BINARY|O_RDONLY)) == -1) { error (1, errno, "%s", plc->PIB.name); } if (ResetDevice (plc)) { return (-1); } continue; } error (0, ENOSYS, "Host Action 0x%0X", indicate->MACTION); } } return (0); }
static signed add_conn (struct plc * plc, struct connection * connection) { struct channel * channel = (struct channel *)(plc->channel); struct message * message = (struct message *)(plc->message); #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_add_conn_req { struct ethernet_std ethernet; struct qualcomm_std qualcomm; struct connection connection; } * request = (struct vs_add_conn_req *)(message); struct __packed vs_add_conn_cnf { struct ethernet_std ethernet; struct qualcomm_std qualcomm; uint32_t REQ_ID; uint8_t MSTATUS; uint16_t ERR_REC_CODE; uint32_t RSVD; uint16_t CID; uint8_t REJECT_MAC [ETHER_ADDR_LEN]; uint16_t CSPEC_VERSION; uint8_t CONN_CAP; uint8_t CONN_COQOS_PRIO; uint16_t CONN_RATE; uint32_t CONN_TTL; } * confirm = (struct vs_add_conn_cnf *)(message); #ifndef __GNUC__ #pragma pack (pop) #endif Request (plc, "Add COQOS connection"); memset (message, 0, sizeof (* message)); EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type); QualcommHeader (&request->qualcomm, 0, (VS_CONN_ADD | MMTYPE_REQ)); memcpy (&request->connection, connection, sizeof (struct connection)); memcpy (&request->connection.rule.CLASSIFIERS [request->connection.rule.NUM_CLASSIFIERS], &request->connection.cspec, sizeof (request->connection.cspec)); plc->packetsize = sizeof (struct vs_add_conn_req); if (SendMME (plc) <= 0) { error ((plc->flags & PLC_BAILOUT), errno, CHANNEL_CANTSEND); return (-1); } while (ReadMME (plc, 0, (VS_CONN_ADD | MMTYPE_CNF)) <= 0) { if (confirm->MSTATUS) { Failure (plc, "Device won't add connection"); return (-1); } Confirm (plc, "Setting ..."); } return (0); }
signed SetNMK (struct plc * plc) { struct channel * channel = (struct channel *)(plc->channel); struct message * message = (struct message *)(plc->message); #ifndef __GNUC__ #pragma pack (push,1) #endif struct __packed vs_set_key_request { struct ethernet_hdr ethernet; struct qualcomm_hdr qualcomm; uint8_t EKS; uint8_t NMK [HPAVKEY_NMK_LEN]; uint8_t PEKS; uint8_t RDA [ETHER_ADDR_LEN]; uint8_t DAK [HPAVKEY_DAK_LEN]; } * request = (struct vs_set_key_request *) (message); struct __packed vs_set_key_confirm { struct ethernet_hdr ethernet; struct qualcomm_hdr qualcomm; uint8_t MSTATUS; } * confirm = (struct vs_set_key_confirm *) (message); #ifndef __GNUC__ #pragma pack (pop) #endif memset (message, 0, sizeof (* message)); EthernetHeader (&request->ethernet, channel->peer, channel->host, channel->type); QualcommHeader (&request->qualcomm, 0, (VS_SET_KEY | MMTYPE_REQ)); plc->packetsize = sizeof (struct vs_set_key_request); request->EKS = 0x01; memcpy (request->NMK, plc->NMK, sizeof (request->NMK)); if (_anyset (plc->flags, PLC_SETREMOTEKEY)) { Request (plc, "Set Remote Network Membership Key"); memcpy (request->RDA, plc->RDA, sizeof (request->RDA)); memcpy (request->DAK, plc->DAK, sizeof (request->DAK)); request->PEKS = 0x00; } else { Request (plc, "Set Local Network Membership Key"); memset (request->RDA, 0, sizeof (request->RDA)); memset (request->DAK, 0, sizeof (request->DAK)); request->PEKS = 0x0F; } if (SendMME (plc) <= 0) { error (PLC_EXIT (plc), errno, CHANNEL_CANTSEND); return (-1); } if (ReadMME (plc, 0, (VS_SET_KEY | MMTYPE_CNF)) <= 0) { error (PLC_EXIT (plc), errno, CHANNEL_CANTREAD); return (-1); } if (confirm->MSTATUS) { Failure (plc, PLC_WONTDOIT); return (-1); } Confirm (plc, "Setting ..."); return (0); }
bool Interrupt(){ if( kbhit() && Confirm()) return true; return false; }