Ignore:
Timestamp:
Dec 5, 2001, 3:16:38 PM (24 years ago)
Author:
sandervl
Message:

preliminary changes for new overlapped io framework

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/hmmailslot.cpp

    r7489 r7549  
    1 /* $Id: hmmailslot.cpp,v 1.5 2001-11-29 13:38:51 sandervl Exp $
     1/* $Id: hmmailslot.cpp,v 1.6 2001-12-05 14:16:01 sandervl Exp $
    22 *
    33 * Win32 mailslot APIs
     
    176176 *****************************************************************************/
    177177
    178 DWORD HMMailslotClass::CreateFile (HANDLE        hHandle,
    179                                    LPCSTR        lpFileName,
     178DWORD HMMailslotClass::CreateFile (LPCSTR        lpFileName,
    180179                                   PHMHANDLEDATA pHMHandleData,
    181180                                   PVOID         lpSecurityAttributes,
     
    361360                               DWORD         nNumberOfBytesToRead,
    362361                               LPDWORD       lpNumberOfBytesRead,
    363                                LPOVERLAPPED  lpOverlapped)
     362                               LPOVERLAPPED  lpOverlapped,
     363                               LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine)
    364364{
    365365    HMMailSlotInfo *mailslot = (HMMailSlotInfo *)pHMHandleData->dwUserData;
     
    380380        return FALSE;
    381381    }
    382     return ::ReadFile(mailslot->hPipe, (LPVOID)lpBuffer, nNumberOfBytesToRead,
    383                       lpNumberOfBytesRead, lpOverlapped);
    384 }
    385 
    386 /*****************************************************************************
    387  * Name      : BOOL ReadFileEx
    388  * Purpose   : The ReadFileEx function reads data from a file asynchronously.
    389  *             It is designed solely for asynchronous operation, unlike the
    390  *             ReadFile function, which is designed for both synchronous and
    391  *             asynchronous operation. ReadFileEx lets an application perform
    392  *             other processing during a file read operation.
    393  *             The ReadFileEx function reports its completion status asynchronously,
    394  *             calling a specified completion routine when reading is completed
    395  *             and the calling thread is in an alertable wait state.
    396  * Parameters: HANDLE       hFile                handle of file to read
    397  *             LPVOID       lpBuffer             address of buffer
    398  *             DWORD        nNumberOfBytesToRead number of bytes to read
    399  *             LPOVERLAPPED lpOverlapped         address of offset
    400  *             LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
    401  * Variables :
    402  * Result    : TRUE / FALSE
    403  * Remark    :
    404  * Status    : UNTESTED STUB
    405  *
    406  * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
    407  *****************************************************************************/
    408 BOOL HMMailslotClass::ReadFileEx(PHMHANDLEDATA pHMHandleData,
    409                            LPVOID       lpBuffer,
    410                            DWORD        nNumberOfBytesToRead,
    411                            LPOVERLAPPED lpOverlapped,
    412                            LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine)
    413 {
    414     HMMailSlotInfo *mailslot = (HMMailSlotInfo *)pHMHandleData->dwUserData;
    415 
    416     dprintf(("HMMailslotClass::ReadFileEx(%08xh,%08xh,%08xh,%08xh,%08xh)",  pHMHandleData->hHMHandle,
    417              lpBuffer, nNumberOfBytesToRead, lpOverlapped, lpCompletionRoutine));
    418 
    419     if(mailslot == NULL) {
    420         DebugInt3();
    421         return FALSE;
    422     }
    423     if(mailslot->fServer == FALSE) {
    424         dprintf(("ReadFile not allowed with client handle"));
    425         SetLastError(ERROR_INVALID_FUNCTION); //TODO: right error?
    426         return FALSE;
    427     }
    428     return ::ReadFileEx(mailslot->hPipe, lpBuffer, nNumberOfBytesToRead, lpOverlapped, lpCompletionRoutine);
    429 }
    430 
     382    if(lpCompletionRoutine) {
     383          return ::ReadFileEx(mailslot->hPipe, (LPVOID)lpBuffer, nNumberOfBytesToRead,
     384                              lpOverlapped, lpCompletionRoutine);
     385    }
     386    else  return ::ReadFile(mailslot->hPipe, (LPVOID)lpBuffer, nNumberOfBytesToRead,
     387                            lpNumberOfBytesRead, lpOverlapped);
     388}
    431389
    432390/*****************************************************************************
     
    447405
    448406BOOL HMMailslotClass::WriteFile(PHMHANDLEDATA pHMHandleData,
    449                                     LPCVOID       lpBuffer,
    450                                     DWORD         nNumberOfBytesToWrite,
    451                                     LPDWORD       lpNumberOfBytesWritten,
    452                                     LPOVERLAPPED  lpOverlapped)
     407                                LPCVOID       lpBuffer,
     408                                DWORD         nNumberOfBytesToWrite,
     409                                LPDWORD       lpNumberOfBytesWritten,
     410                                LPOVERLAPPED  lpOverlapped,
     411                                LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine)
    453412{
    454413    HMMailSlotInfo *mailslot = (HMMailSlotInfo *)pHMHandleData->dwUserData;
     
    471430    }
    472431
    473     return ::WriteFile(mailslot->hPipe, lpBuffer, nNumberOfBytesToWrite,
    474                        lpNumberOfBytesWritten, lpOverlapped);
    475 }
    476 
    477 /*****************************************************************************
    478  * Name      : BOOL WriteFileEx
    479  * Purpose   : The WriteFileEx function writes data to a file. It is designed
    480  *             solely for asynchronous operation, unlike WriteFile, which is
    481  *             designed for both synchronous and asynchronous operation.
    482  *             WriteFileEx reports its completion status asynchronously,
    483  *             calling a specified completion routine when writing is completed
    484  *             and the calling thread is in an alertable wait state.
    485  * Parameters: HANDLE       hFile                handle of file to write
    486  *             LPVOID       lpBuffer             address of buffer
    487  *             DWORD        nNumberOfBytesToRead number of bytes to write
    488  *             LPOVERLAPPED lpOverlapped         address of offset
    489  *             LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
    490  * Variables :
    491  * Result    : TRUE / FALSE
    492  * Remark    :
    493  * Status    : UNTESTED STUB
    494  *
    495  * Author    : Patrick Haller [Mon, 1998/06/15 08:00]
    496  *****************************************************************************/
    497 
    498 BOOL HMMailslotClass::WriteFileEx(PHMHANDLEDATA pHMHandleData,
    499                            LPVOID       lpBuffer,
    500                            DWORD        nNumberOfBytesToWrite,
    501                            LPOVERLAPPED lpOverlapped,
    502                            LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine)
    503 {
    504     HMMailSlotInfo *mailslot = (HMMailSlotInfo *)pHMHandleData->dwUserData;
    505 
    506     dprintf(("HMMailslotClass::WriteFileEx(%08xh,%08xh,%08xh,%08xh,%08xh)",
    507              pHMHandleData->hHMHandle, lpBuffer, nNumberOfBytesToWrite,
    508              lpOverlapped,lpCompletionRoutine));
    509 
    510     if(mailslot == NULL) {
    511         DebugInt3();
    512         return FALSE;
    513     }
    514     if(mailslot->fServer == TRUE) {
    515         dprintf(("ReadFile not allowed with server handle"));
    516         SetLastError(ERROR_INVALID_FUNCTION); //TODO: right error?
    517         return FALSE;
    518     }
    519     return ::WriteFileEx(mailslot->hPipe, lpBuffer, nNumberOfBytesToWrite,lpOverlapped,lpCompletionRoutine);
    520 }
     432    if(lpCompletionRoutine) {
     433          return ::WriteFileEx(mailslot->hPipe, lpBuffer, nNumberOfBytesToWrite,
     434                               lpOverlapped, lpCompletionRoutine);
     435    }
     436    else  return ::WriteFile(mailslot->hPipe, lpBuffer, nNumberOfBytesToWrite,
     437                             lpNumberOfBytesWritten, lpOverlapped);
     438}
     439
Note: See TracChangeset for help on using the changeset viewer.