std::string Isa::GetFullName() const { std::stringstream full_name; full_name << GetVendor() << ":" << GetArchitecture() << ":" << GetMajorVersion() << ":" << GetMinorVersion() << ":" << GetStepping(); return full_name.str(); }
static NvError aos_UartSetBaudRateT30(NvU32 portNumber, NvU32 baud_rate) { NvU32 BaudRateDivisor; NvU32 LineControlReg; volatile void* pUartRegs = 0; pUartRegs = (void*)s_UartBaseAddress[portNumber]; // Compute the baudrate divisor // Prepare the divisor value. #if 0 // jz if (GetMajorVersion() == 0) BaudRateDivisor = (13000 * 1000) / (baud_rate *16); //for emulation else #endif BaudRateDivisor = (AOS_PLLP_FIXED_FREQ_KHZ * 1000) / (baud_rate *16); // Set the divisor latch bit to allow access to divisor registers (DLL/DLM) LineControlReg = NV_UART_REGR(pUartRegs, LCR); LineControlReg |= NV_DRF_NUM(UART, LCR, DLAB, 1); NV_UART_REGW(pUartRegs, LCR, LineControlReg); // First write the LSB of the baud rate divisor NV_UART_REGW(pUartRegs, THR_DLAB_0, BaudRateDivisor & 0xFF); // Now write the MSB of the baud rate divisor NV_UART_REGW(pUartRegs, IER_DLAB_0, (BaudRateDivisor >> 8) & 0xFF); // Now that the baud rate has been set turn off divisor latch // bit to allow access to receive/transmit holding registers // and interrupt enable register. LineControlReg &= ~NV_DRF_NUM(UART, LCR, DLAB, 1); NV_UART_REGW(pUartRegs, LCR, LineControlReg); return NvError_Success; }
bool Handshake::IsValid() const { if (! (memcmp(Magic, Protocol::Magic, sizeof(Protocol::Magic)) == 0)) return false; if (! (Space == ' ')) return false; if (! (Dot == '.')) return false; if (! (Newline == '\n')) return false; if (! (GetMajorVersion() >= 0)) return false; if (! (GetMinorVersion() >= 0)) return false; return true; return memcmp(Magic, Protocol::Magic, sizeof(Protocol::Magic)) == 0 && Space == ' ' && Dot == '.' && Newline == '\n' && GetMajorVersion() >= 0 && GetMinorVersion() >= 0; }
CString CInternetExplorerVersion::GetVersionString(void) { CString csVersion; csVersion.Format("%u.%u.%u.%u", GetMajorVersion(), GetMinorVersion(), GetBuild(), GetSubBuild()); return csVersion; }
IProtocol * ONBinaryProtocol::ConstructIfSuitable(const QByteArray &data, QObject *parent) const { auto handshake = reinterpret_cast<const Protocol::Handshake *>(data.data()); if (handshake->IsValid() && handshake->GetMajorVersion() == MajorVersion && handshake->ProtocolType == Protocol::Type::Binary) { return new ONBinaryProtocol(parent); } return 0; }
BOOL CInternetExplorerVersion::IsVersion4(void) const { BOOL fResult = FALSE; if (IsValid()) { fResult = (GetMajorVersion() == 4) && (GetMinorVersion() >= 71); } return fResult; }
void *RequestProc(void *p) { TRequest request; memset(&request, 0, sizeof(TRequest)); request.nStartByte = REQUEST_START_BYTE; request.nMajorVersion = GetMajorVersion(); request.nMinorVersion = GetMinorVersion(); request.nCustomerID = CUSTOMER_ID; if ( bparam.stIEBaseParam.dwDeviceID[0] != 0 ) strcpy(request.szID, bparam.stIEBaseParam.dwDeviceID); char server_ip[32] = {0}; GetDownloadServerIPAddress(server_ip); while(1) { sleep(REQUEST_FREQUENCY); //ONE HOUR Request Once TiNetUdpSend( server_ip, (Int8 *)&request, sizeof(TRequest)); } }
bool Client::AreServicesSupported() const { return Features::iRemoteServices(GetMajorVersion(), GetMinorVersion()); }
bool Client::IsZoomingSupported() const { return Features::iRemoteZooming(GetMajorVersion(), GetMinorVersion()); }
bool Client::SupportPasswordProtection() const { return Features::iRemotePasswordProtection(GetMajorVersion(), GetMinorVersion()); }
int OGRMySQLDataSource::FetchSRSId( OGRSpatialReference * poSRS ) { if( poSRS == nullptr ) return GetUnknownSRID(); OGRSpatialReference oSRS(*poSRS); // cppcheck-suppress uselessAssignmentPtrArg poSRS = nullptr; const char* pszAuthorityName = oSRS.GetAuthorityName(nullptr); if( pszAuthorityName == nullptr || strlen(pszAuthorityName) == 0 ) { /* -------------------------------------------------------------------- */ /* Try to identify an EPSG code */ /* -------------------------------------------------------------------- */ oSRS.AutoIdentifyEPSG(); pszAuthorityName = oSRS.GetAuthorityName(nullptr); if (pszAuthorityName != nullptr && EQUAL(pszAuthorityName, "EPSG")) { const char* pszAuthorityCode = oSRS.GetAuthorityCode(nullptr); if ( pszAuthorityCode != nullptr && strlen(pszAuthorityCode) > 0 ) { /* Import 'clean' SRS */ oSRS.importFromEPSG( atoi(pszAuthorityCode) ); pszAuthorityName = oSRS.GetAuthorityName(nullptr); } } } /* -------------------------------------------------------------------- */ /* Check whether the authority name/code is already mapped to a */ /* SRS ID. */ /* -------------------------------------------------------------------- */ CPLString osCommand; int nAuthorityCode = 0; if( pszAuthorityName != nullptr ) { /* Check that the authority code is integral */ nAuthorityCode = atoi( oSRS.GetAuthorityCode(nullptr) ); if( nAuthorityCode > 0 ) { if( GetMajorVersion() < 8 || IsMariaDB() ) { osCommand.Printf( "SELECT srid FROM spatial_ref_sys WHERE " "auth_name = '%s' AND auth_srid = %d", pszAuthorityName, nAuthorityCode ); } else { osCommand.Printf( "SELECT SRS_ID FROM INFORMATION_SCHEMA.ST_SPATIAL_REFERENCE_SYSTEMS " "WHERE ORGANIZATION = '%s' AND ORGANIZATION_COORDSYS_ID = %d", pszAuthorityName, nAuthorityCode ); } MYSQL_RES *hResult = nullptr; if( !mysql_query( GetConn(), osCommand ) ) hResult = mysql_store_result( GetConn() ); if ( hResult != nullptr && !mysql_num_rows(hResult)) { CPLDebug("MYSQL", "No rows exist currently exist in spatial_ref_sys"); mysql_free_result( hResult ); hResult = nullptr; } char **papszRow = nullptr; if( hResult != nullptr ) papszRow = mysql_fetch_row( hResult ); if( papszRow != nullptr && papszRow[0] != nullptr ) { const int nSRSId = atoi(papszRow[0]); if( hResult != nullptr ) mysql_free_result( hResult ); hResult = nullptr; return nSRSId; } // make sure to attempt to free results of successful queries hResult = mysql_store_result( GetConn() ); if( hResult != nullptr ) mysql_free_result( hResult ); } } /* -------------------------------------------------------------------- */ /* Translate SRS to WKT. */ /* -------------------------------------------------------------------- */ char *pszWKT = nullptr; if( oSRS.exportToWkt( &pszWKT ) != OGRERR_NONE ) return GetUnknownSRID(); /* -------------------------------------------------------------------- */ /* Try to find in the existing record. */ /* -------------------------------------------------------------------- */ if( GetMajorVersion() < 8 || IsMariaDB() ) { osCommand.Printf( "SELECT srid FROM spatial_ref_sys WHERE srtext = '%s'", pszWKT ); } else { osCommand.Printf( "SELECT SRS_ID FROM INFORMATION_SCHEMA.ST_SPATIAL_REFERENCE_SYSTEMS WHERE DEFINITION = '%s'", pszWKT ); } MYSQL_RES *hResult = nullptr; if( !mysql_query( GetConn(), osCommand ) ) hResult = mysql_store_result( GetConn() ); if ( hResult != nullptr && !mysql_num_rows(hResult)) { CPLDebug("MYSQL", "No rows exist currently exist in spatial_ref_sys"); mysql_free_result( hResult ); hResult = nullptr; } char **papszRow = nullptr; if( hResult != nullptr ) papszRow = mysql_fetch_row( hResult ); if( papszRow != nullptr && papszRow[0] != nullptr ) { const int nSRSId = atoi(papszRow[0]); if( hResult != nullptr ) mysql_free_result( hResult ); hResult = nullptr; CPLFree(pszWKT); return nSRSId; } // make sure to attempt to free results of successful queries hResult = mysql_store_result( GetConn() ); if( hResult != nullptr ) mysql_free_result( hResult ); hResult = nullptr; // TODO: try to insert in INFORMATION_SCHEMA.ST_SPATIAL_REFERENCE_SYSTEMS if( GetMajorVersion() >= 8 && !IsMariaDB() ) { CPLFree(pszWKT); return GetUnknownSRID(); } /* -------------------------------------------------------------------- */ /* Get the current maximum srid in the srs table. */ /* -------------------------------------------------------------------- */ osCommand = "SELECT MAX(srid) FROM spatial_ref_sys"; if( !mysql_query( GetConn(), osCommand ) ) { hResult = mysql_store_result( GetConn() ); papszRow = mysql_fetch_row( hResult ); } const int nSRSId = papszRow != nullptr && papszRow[0] != nullptr ? atoi(papszRow[0]) + 1 : 1; if( hResult != nullptr ) mysql_free_result( hResult ); hResult = nullptr; /* -------------------------------------------------------------------- */ /* Try adding the SRS to the SRS table. */ /* -------------------------------------------------------------------- */ osCommand.Printf( "INSERT INTO spatial_ref_sys (srid,srtext) VALUES (%d,'%s')", nSRSId, pszWKT ); if( !mysql_query( GetConn(), osCommand ) ) /*hResult = */ mysql_store_result( GetConn() ); /* FIXME ? */ // make sure to attempt to free results of successful queries hResult = mysql_store_result( GetConn() ); if( hResult != nullptr ) mysql_free_result( hResult ); hResult = nullptr; CPLFree(pszWKT); return nSRSId; }
OGRSpatialReference *OGRMySQLDataSource::FetchSRS( int nId ) { if( nId < 0 ) return nullptr; /* -------------------------------------------------------------------- */ /* First, we look through our SRID cache, is it there? */ /* -------------------------------------------------------------------- */ for( int i = 0; i < nKnownSRID; i++ ) { if( panSRID[i] == nId ) return papoSRS[i]; } OGRSpatialReference *poSRS = nullptr; // make sure to attempt to free any old results MYSQL_RES *hResult = mysql_store_result( GetConn() ); if( hResult != nullptr ) mysql_free_result( hResult ); hResult = nullptr; char szCommand[128] = {}; if( GetMajorVersion() < 8 || IsMariaDB() ) { snprintf( szCommand, sizeof(szCommand), "SELECT srtext FROM spatial_ref_sys WHERE srid = %d", nId ); } else { snprintf( szCommand, sizeof(szCommand), "SELECT DEFINITION FROM INFORMATION_SCHEMA.ST_SPATIAL_REFERENCE_SYSTEMS WHERE SRS_ID = %d", nId ); } if( !mysql_query( GetConn(), szCommand ) ) hResult = mysql_store_result( GetConn() ); char *pszWKT = nullptr; char **papszRow = nullptr; if( hResult != nullptr ) papszRow = mysql_fetch_row( hResult ); if( papszRow != nullptr && papszRow[0] != nullptr ) { pszWKT = CPLStrdup(papszRow[0]); } if( hResult != nullptr ) mysql_free_result( hResult ); hResult = nullptr; poSRS = new OGRSpatialReference(); poSRS->SetAxisMappingStrategy(OAMS_TRADITIONAL_GIS_ORDER); if( pszWKT == nullptr || poSRS->importFromWkt( pszWKT ) != OGRERR_NONE ) { delete poSRS; poSRS = nullptr; } CPLFree(pszWKT); if( poSRS ) { // The WKT found in MySQL 8 ST_SPATIAL_REFERENCE_SYSTEMS is not // compatible of what GDAL understands. const char* pszAuthorityName = poSRS->GetAuthorityName(nullptr); const char* pszAuthorityCode = poSRS->GetAuthorityCode(nullptr); if (pszAuthorityName != nullptr && EQUAL(pszAuthorityName, "EPSG") && pszAuthorityCode != nullptr && strlen(pszAuthorityCode) > 0 ) { /* Import 'clean' SRS */ poSRS->importFromEPSG( atoi(pszAuthorityCode) ); } } /* -------------------------------------------------------------------- */ /* Add to the cache. */ /* -------------------------------------------------------------------- */ panSRID = (int *) CPLRealloc(panSRID,sizeof(int) * (nKnownSRID+1) ); papoSRS = (OGRSpatialReference **) CPLRealloc(papoSRS, sizeof(void*) * (nKnownSRID + 1) ); panSRID[nKnownSRID] = nId; papoSRS[nKnownSRID] = poSRS; nKnownSRID ++; return poSRS; }
OGRErr OGRMySQLDataSource::InitializeMetadataTables() { const char* pszCommand; MYSQL_RES *hResult; OGRErr eErr = OGRERR_NONE; pszCommand = "DESCRIBE geometry_columns"; if( mysql_query(GetConn(), pszCommand ) ) { pszCommand = "CREATE TABLE geometry_columns " "( F_TABLE_CATALOG VARCHAR(256), " "F_TABLE_SCHEMA VARCHAR(256), " "F_TABLE_NAME VARCHAR(256) NOT NULL," "F_GEOMETRY_COLUMN VARCHAR(256) NOT NULL, " "COORD_DIMENSION INT, " "SRID INT," "TYPE VARCHAR(256) NOT NULL)"; if( mysql_query(GetConn(), pszCommand ) ) { ReportError( pszCommand ); eErr = OGRERR_FAILURE; } else CPLDebug("MYSQL","Creating geometry_columns metadata table"); } // make sure to attempt to free results of successful queries hResult = mysql_store_result( GetConn() ); if( hResult != nullptr ) { mysql_free_result( hResult ); hResult = nullptr; } if( GetMajorVersion() < 8 || IsMariaDB() ) { pszCommand = "DESCRIBE spatial_ref_sys"; if( mysql_query(GetConn(), pszCommand ) ) { pszCommand = "CREATE TABLE spatial_ref_sys " "(SRID INT NOT NULL, " "AUTH_NAME VARCHAR(256), " "AUTH_SRID INT, " "SRTEXT VARCHAR(2048))"; if( mysql_query(GetConn(), pszCommand ) ) { ReportError( pszCommand ); eErr = OGRERR_FAILURE; } else CPLDebug("MYSQL","Creating spatial_ref_sys metadata table"); } // make sure to attempt to free results of successful queries hResult = mysql_store_result( GetConn() ); if( hResult != nullptr ) { mysql_free_result( hResult ); hResult = nullptr; } } return eErr; }