Exemple #1
0
HRESULT Table::Update2(BYTE * bookmarkBuf, uint32_t & bookmarkBufSize)
{
    try
    {
        if (nullptr == bookmarkBuf)
        {
            throw HrError("bookmarkBuf is NULL", E_INVALIDARG, __FUNCTION__);
        }
        JET_ERR jetErr = JET_errSuccess;
        unsigned long actualBookmarkSize = 0;
        jetErr = JetUpdate(sesId_, tableId_, bookmarkBuf, bookmarkBufSize, &actualBookmarkSize);
        if (JET_errBufferTooSmall == jetErr)
        {
            bookmarkBufSize = actualBookmarkSize;
        }
        if (jetErr != JET_errSuccess)
        {
            throw Error("JetUpdate", jetErr, __FUNCTION__);
        }        
        return S_OK;
    }
    catch (const std::exception & e)
    {
        SetLastErrorDesc(e);
    }
    return E_FAIL;
}
Exemple #2
0
HRESULT Table::Update()
{
    const JET_ERR jetErr = JetUpdate(sesId_, tableId_, nullptr, 0, nullptr);
    if (jetErr != JET_errSuccess)
    {
        SetLastErrorDesc(Error("JetUpdate", jetErr, __FUNCTION__));
        return E_FAIL;
    }
    return S_OK;
}
Exemple #3
0
NET_API_STATUS NET_API_FUNCTION
NetrRplVendorAdd(
    IN      RPL_HANDLE                  ServerHandle,
    IN      DWORD                       Level,
    OUT     LPRPL_VENDOR_INFO_STRUCT    VendorInfoStruct,
    OUT     LPDWORD                     pErrorParameter      OPTIONAL
    )
{
    LPRPL_VENDOR_INFO_1     Info;
    LPVOID                  Buffer;
    DWORD                   Error;
    DWORD                   ErrorParameter;
    PRPL_SESSION            pSession = &RG_ApiSession;

    ErrorParameter = INVALID_ERROR_PARAMETER;
    Buffer = Info = VendorInfoStruct->VendorInfo1;

    switch( Level) {
    case 1:
        if ( Info->Flags != 0) {
            ErrorParameter = VENDOR_Flags;
            break;
        }
        if ( RPL_STRING_TOO_LONG( Info->VendorComment)) {
            ErrorParameter = VENDOR_VendorComment;
            break;
        }
        if ( !ValidHexName( Info->VendorName, RPL_VENDOR_NAME_LENGTH, TRUE)) {
            ErrorParameter = VENDOR_VendorName;
            break;
        }
        _wcsupr( Info->VendorName);
        break;
    default:
        return( ERROR_INVALID_LEVEL);
        break;
    }

    if ( ErrorParameter != INVALID_ERROR_PARAMETER) {
        if ( ARGUMENT_PRESENT( pErrorParameter)) {
            *pErrorParameter = ErrorParameter;
        }
        return( ERROR_INVALID_PARAMETER);
    }

    EnterCriticalSection( &RG_ProtectDatabase);
    Call( JetBeginTransaction( pSession->SesId));

    //
    //  Verify that VendorName is available in the database.
    //
    if ( RplFind( pSession, VENDOR_TABLE_TAG, Info->VendorName)) {
        Error = NERR_RplVendorNameUnavailable;
        goto cleanup;
    }

    CallJ( JetPrepareUpdate( pSession->SesId, pSession->VendorTableId, JET_prepInsert));

    Error = VendorSetInfo( pSession, Level, Buffer, &ErrorParameter);
    if ( Error == ERROR_SUCCESS) {
        ErrorParameter = 0;
        CallJ( JetUpdate( pSession->SesId, pSession->VendorTableId, NULL, 0, NULL));
    }

cleanup:
    if ( Error == NO_ERROR) {
        Call( JetCommitTransaction( pSession->SesId, JET_bitCommitFlush));
    } else {
        Call( JetRollback( pSession->SesId, JET_bitRollbackAll));
    }
    LeaveCriticalSection( &RG_ProtectDatabase);

    if ( Error != ERROR_SUCCESS) {
         if ( ARGUMENT_PRESENT( pErrorParameter)) {
             *pErrorParameter = ErrorParameter;
         }
    }
    return( Error);
}
Exemple #4
0
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);
}