BOOL ResumeKeyGet( IN PRPL_SESSION pSession, IN DWORD ResumeHandle, OUT PVOID ResumeValue, IN OUT PDWORD pResumeSize ) { DWORD DataSize; #ifdef RPL_DEBUG_NEVER if ( RG_DebugLevel == (DWORD)(-1)) { ResumeList( pSession, "++ResumeKeyGet"); } #endif // RPL_DEBUG_NEVER CallB( JetSetCurrentIndex( pSession->SesId, pSession->ResumeTableId, RESUME_INDEX_ResumeHandle)); CallB( JetMakeKey( pSession->SesId, pSession->ResumeTableId, &ResumeHandle, sizeof( ResumeHandle), JET_bitNewKey)); CallB( JetSeek( pSession->SesId, pSession->ResumeTableId, JET_bitSeekEQ)); CallB( JetRetrieveColumn( pSession->SesId, pSession->ResumeTableId, ResumeTable[ RESUME_ResumeValue].ColumnId, ResumeValue, *pResumeSize, &DataSize, 0, NULL)); if ( DataSize > *pResumeSize) { RplDump( ++RG_Assert, ( "DataSize=%d", DataSize)); return( FALSE); } *pResumeSize = DataSize; return( TRUE); }
HRESULT Table::SetCurrentIndex(const wchar_t * indexName) { const JET_ERR jetErr = JetSetCurrentIndex(sesId_, tableId_, indexName); if (jetErr != JET_errSuccess) { SetLastErrorDesc(Error("JetSetCurrentIndex", jetErr, __FUNCTION__)); return E_FAIL; } return S_OK; }
VOID ResumePrune( IN PRPL_SESSION pSession, IN DWORD ServerHandle ) /*++ This function returns no errors, since failure to delete old resume handles is not considered fatal (and there is very little we can do about this). --*/ { JET_ERR JetError; #ifdef RPL_DEBUG if ( RG_DebugLevel == (DWORD)(-1)) { ResumeList( pSession, "++ResumePrune"); } #endif // RPL_DEBUG CallR( JetSetCurrentIndex( pSession->SesId, pSession->ResumeTableId, RESUME_INDEX_ServerHandle)); CallR( JetMakeKey( pSession->SesId, pSession->ResumeTableId, &ServerHandle, sizeof( ServerHandle), JET_bitNewKey)); #ifdef NOT_YET JetError = JetSeek( pSession->SesId, pSession->ResumeTableId, JET_bitSeekEQ); #else JetError = JetSeek( pSession->SesId, pSession->ResumeTableId, JET_bitSeekEQ | JET_bitSetIndexRange); #endif if ( JetError == JET_errSuccess) { #ifdef NOT_YET CallR( JetMakeKey( pSession->SesId, pSession->ResumeTableId, &ServerHandle, sizeof( ServerHandle), JET_bitNewKey)); CallR( JetSetIndexRange( pSession->SesId, pSession->ResumeTableId, JET_bitRangeInclusive | JET_bitRangeUpperLimit)); #endif do { Call( JetDelete( pSession->SesId, pSession->ResumeTableId)); JetError = JetMove( pSession->SesId, pSession->ResumeTableId, JET_MoveNext, 0); } while ( JetError == JET_errSuccess); } #ifdef RPL_DEBUG if ( RG_DebugLevel == (DWORD)(-1)) { ResumeList( pSession, "--ResumePrune"); } #endif // RPL_DEBUG }
VOID Enum( IN JET_TABLEID TableId, IN JET_COLUMNID ColumnId, IN PCHAR IndexName) { WCHAR Name[ 20]; DWORD NameSize; JET_ERR ForJetError; JET_ERR JetError; Call( JetSetCurrentIndex( SesId, TableId, IndexName)); for ( ForJetError = JetMove( SesId, TableId, JET_MoveFirst, 0); ForJetError == JET_errSuccess; ForJetError = JetMove( SesId, TableId, JET_MoveNext, 0)) { JetError = JetRetrieveColumn( SesId, TableId, ColumnId, Name, sizeof( Name), &NameSize, 0, NULL); if ( JetError != JET_errSuccess) { RplAssert( TRUE, ("RetriveColumn failed err=%d", JetError)); continue; } RplDbgPrint(( "%ws\n", Name)); } }
VOID ResumeList( IN PRPL_SESSION pSession, IN PCHAR String ) { WCHAR ResumeValue[ 20]; DWORD NameSize; JET_ERR ForJetError; DWORD ResumeHandle; DWORD ServerHandle; Call( JetSetCurrentIndex( pSession->SesId, pSession->ResumeTableId, RESUME_INDEX_ResumeHandle)); // // We could skip JetMove, but if we do so, we need to modify error // testing for the first JetRetrieveColumn() call (it would return // JET_errNoCurrentRecord for the empty table). // for ( ForJetError = JetMove( pSession->SesId, pSession->ResumeTableId, JET_MoveFirst, 0); ForJetError == JET_errSuccess; ForJetError = JetMove( pSession->SesId, pSession->ResumeTableId, JET_MoveNext, 0)) { Call( JetRetrieveColumn( pSession->SesId, pSession->ResumeTableId, ResumeTable[ RESUME_ResumeHandle].ColumnId, &ResumeHandle, sizeof( ResumeHandle), &NameSize, 0, NULL)); Call( JetRetrieveColumn( pSession->SesId, pSession->ResumeTableId, ResumeTable[ RESUME_ResumeValue].ColumnId, ResumeValue, sizeof( ResumeValue), &NameSize, 0, NULL)); Call( JetRetrieveColumn( pSession->SesId, pSession->ResumeTableId, ResumeTable[ RESUME_ServerHandle].ColumnId, &ServerHandle, sizeof( ServerHandle), &NameSize, 0, NULL)); RplDump( RG_DebugLevel & RPL_DEBUG_RESUME, ( "%s ResumeH=0x%x,Value=%ws,ServerH=0x%x", String, ResumeHandle, ResumeValue, ServerHandle)); } }
BOOL ResumeKeySet( IN PRPL_SESSION pSession, IN DWORD ServerHandle, IN PVOID ResumeValue, IN DWORD ResumeSize, OUT PDWORD pResumeHandle ) { DWORD DataSize; *pResumeHandle = 0; // just in case we fail below #ifdef RPL_DEBUG if ( RG_DebugLevel == (DWORD)(-1)) { ResumeList( pSession, "++ResumeKeySet"); } #endif // RPL_DEBUG CallB( JetSetCurrentIndex( pSession->SesId, pSession->ResumeTableId, RESUME_INDEX_ResumeHandle)); #if 0 // // We do NOT call JetMove() here, because in the case of an empty table // it returns error JET_errNoCurrentRecord. Also, if JetMove() is used // here, then ordering of elements in the table is such that ResumePrune() // function deletes only the OLDEST record for a given server handle. // CallB( JetMove( pSession->SesId, pSession->ResumeTableId, JET_MoveLast, 0)); #endif CallB( JetPrepareUpdate( pSession->SesId, pSession->ResumeTableId, JET_prepInsert)); CallB( JetRetrieveColumn( pSession->SesId, pSession->ResumeTableId, ResumeTable[ RESUME_ResumeHandle].ColumnId, pResumeHandle, sizeof( *pResumeHandle), &DataSize, JET_bitRetrieveCopy, NULL)); if ( DataSize != sizeof( *pResumeHandle) || *pResumeHandle == 0) { RplDump( ++RG_Assert, ( "DataSize=%d", DataSize)); return( FALSE); } CallB( JetSetColumn( pSession->SesId, pSession->ResumeTableId, ResumeTable[ RESUME_ResumeValue].ColumnId, ResumeValue, ResumeSize, 0, NULL)); CallB( JetSetColumn( pSession->SesId, pSession->ResumeTableId, ResumeTable[ RESUME_ServerHandle].ColumnId, &ServerHandle, sizeof( ServerHandle), 0, NULL)); CallB( JetUpdate( pSession->SesId, pSession->ResumeTableId, NULL, 0, NULL)); #ifdef RPL_DEBUG if ( RG_DebugLevel & RPL_DEBUG_RESUME) { WCHAR ValueBuffer[ 32]; DWORD Length; PWCHAR Value; Length = wcslen( (PWCHAR)ResumeValue); if ( (Length + 1) * sizeof(WCHAR) < ResumeSize) { wcscpy( ValueBuffer, (PWCHAR)ResumeValue); wcscat( ValueBuffer, L"!"); wcscat( ValueBuffer, (PWCHAR)ResumeValue + Length + 1); Value = ValueBuffer; } else { Value = (PWCHAR)ResumeValue; } RplDump( RG_DebugLevel & RPL_DEBUG_RESUME, ( "ResumeKeySet: Handle=0x%x, Value=%.20ws", *pResumeHandle, Value)); } #endif // RPL_DEBUG return( TRUE); }