VirtualBox

Ignore:
Timestamp:
Jan 22, 2010 11:15:43 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56818
Message:

PDMIBASE refactoring; use UUID as interface IDs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Serial/DrvNamedPipe.cpp

    r25893 r25966  
     1/* $Id$ */
    12/** @file
    2  *
    3  * VBox stream devices:
    4  * Named pipe stream
     3 * VBox stream drivers: Named pipe stream
    54 */
    65
    76/*
    8  * Copyright (C) 2006-2007 Sun Microsystems, Inc.
     7 * Copyright (C) 2006-2010 Sun Microsystems, Inc.
    98 *
    109 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3332#include <iprt/string.h>
    3433#include <iprt/semaphore.h>
     34#include <iprt/uuid.h>
    3535
    3636#include "Builtins.h"
    3737
    3838#ifdef RT_OS_WINDOWS
    39 #include <windows.h>
    40 #else /* !RT_OS_WINDOWS */
    41 #include <errno.h>
    42 #include <unistd.h>
    43 #include <sys/types.h>
    44 #include <sys/socket.h>
    45 #include <sys/un.h>
    46 #endif /* !RT_OS_WINDOWS */
     39# include <windows.h>
     40#else /* !RT_OS_WINDOWS */
     41# include <errno.h>
     42# include <unistd.h>
     43# include <sys/types.h>
     44# include <sys/socket.h>
     45# include <sys/un.h>
     46#endif /* !RT_OS_WINDOWS */
     47
    4748
    4849/*******************************************************************************
    4950*   Defined Constants And Macros                                               *
    5051*******************************************************************************/
    51 
    5252/** Converts a pointer to DRVNAMEDPIPE::IMedia to a PDRVNAMEDPIPE. */
    5353#define PDMISTREAM_2_DRVNAMEDPIPE(pInterface) ( (PDRVNAMEDPIPE)((uintptr_t)pInterface - RT_OFFSETOF(DRVNAMEDPIPE, IStream)) )
     
    5555/** Converts a pointer to PDMDRVINS::IBase to a PPDMDRVINS. */
    5656#define PDMIBASE_2_DRVINS(pInterface)   ( (PPDMDRVINS)((uintptr_t)pInterface - RT_OFFSETOF(PDMDRVINS, IBase)) )
     57
    5758
    5859/*******************************************************************************
     
    6162/**
    6263 * Named pipe driver instance data.
     64 *
     65 * @implements PDMISTREAM
    6366 */
    6467typedef struct DRVNAMEDPIPE
     
    278281
    279282/**
    280  * Queries an interface to the driver.
    281  *
    282  * @returns Pointer to interface.
    283  * @returns NULL if the interface was not supported by the driver.
    284  * @param   pInterface          Pointer to this interface structure.
    285  * @param   enmInterface        The requested interface identification.
    286  * @thread  Any thread.
    287  */
    288 static DECLCALLBACK(void *) drvNamedPipeQueryInterface(PPDMIBASE pInterface, PDMINTERFACE enmInterface)
    289 {
    290     PPDMDRVINS pDrvIns = PDMIBASE_2_DRVINS(pInterface);
    291     PDRVNAMEDPIPE pDrv = PDMINS_2_DATA(pDrvIns, PDRVNAMEDPIPE);
    292     switch (enmInterface)
    293     {
    294         case PDMINTERFACE_BASE:
    295             return &pDrvIns->IBase;
    296         case PDMINTERFACE_STREAM:
    297             return &pDrv->IStream;
    298         default:
    299             return NULL;
    300     }
     283 * @interface_method_impl{PDMIBASE,pfnQueryInterface}
     284 */
     285static DECLCALLBACK(void *) drvNamedPipeQueryInterface(PPDMIBASE pInterface, const char *pszIID)
     286{
     287    PPDMDRVINS      pDrvIns = PDMIBASE_2_DRVINS(pInterface);
     288    PDRVNAMEDPIPE   pThis   = PDMINS_2_DATA(pDrvIns, PDRVNAMEDPIPE);
     289    if (RTUuidCompare2Strs(pszIID, PDMIBASE_IID) == 0)
     290        return &pDrvIns->IBase;
     291    if (RTUuidCompare2Strs(pszIID, PDMINTERFACE_STREAM) == 0)
     292        return &pThis->IStream;
     293    return NULL;
    301294}
    302295
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette