VirtualBox

Changeset 51886 in vbox


Ignore:
Timestamp:
Jul 6, 2014 7:33:54 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
94749
Message:

VD: Add API to query information about a filter

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vd.h

    r51751 r51886  
    424424} VDBACKENDINFO, *PVDBACKENDINFO;
    425425
     426/**
     427 * Data structure for returning a list of filter capabilities.
     428 */
     429typedef struct VDFILTERINFO
     430{
     431    /** Name of the filter. Must be unique even with case insensitive comparison. */
     432    const char *pszFilter;
     433    /** Pointer to an array of structs describing each supported config key.
     434     * Terminated by a NULL config key. Note that some filters do not support
     435     * the configuration interface, so this pointer may just contain NULL. */
     436    PCVDCONFIGINFO paConfigInfo;
     437} VDFILTERINFO, *PVDFILTERINFO;
     438
    426439
    427440/**
     
    508521 */
    509522VBOXDDU_DECL(int) VDBackendInfoOne(const char *pszBackend, PVDBACKENDINFO pEntry);
     523
     524/**
     525 * Lists all filters and their capabilities in a caller-provided buffer.
     526 *
     527 * @return  VBox status code.
     528 *          VERR_BUFFER_OVERFLOW if not enough space is passed.
     529 * @param   cEntriesAlloc   Number of list entries available.
     530 * @param   pEntries        Pointer to array for the entries.
     531 * @param   pcEntriesUsed   Number of entries returned.
     532 */
     533VBOXDDU_DECL(int) VDFilterInfo(unsigned cEntriesAlloc, PVDFILTERINFO pEntries,
     534                               unsigned *pcEntriesUsed);
     535
     536/**
     537 * Lists the capabilities of a filter identified by its name.
     538 *
     539 * @return  VBox status code.
     540 * @param   pszFilter       The filter name (case insensitive).
     541 * @param   pEntries        Pointer to an entry.
     542 */
     543VBOXDDU_DECL(int) VDFilterInfoOne(const char *pszFilter, PVDFILTERINFO pEntry);
    510544
    511545/**
  • trunk/src/VBox/Storage/VD.cpp

    r51756 r51886  
    55385538            pEntry->paFileExtensions = g_apBackends[i]->paFileExtensions;
    55395539            pEntry->paConfigInfo = g_apBackends[i]->paConfigInfo;
     5540            return VINF_SUCCESS;
     5541        }
     5542    }
     5543
     5544    return VERR_NOT_FOUND;
     5545}
     5546
     5547/**
     5548 * Lists all filters and their capabilities in a caller-provided buffer.
     5549 *
     5550 * @return  VBox status code.
     5551 *          VERR_BUFFER_OVERFLOW if not enough space is passed.
     5552 * @param   cEntriesAlloc   Number of list entries available.
     5553 * @param   pEntries        Pointer to array for the entries.
     5554 * @param   pcEntriesUsed   Number of entries returned.
     5555 */
     5556VBOXDDU_DECL(int) VDFilterInfo(unsigned cEntriesAlloc, PVDFILTERINFO pEntries,
     5557                               unsigned *pcEntriesUsed)
     5558{
     5559    int rc = VINF_SUCCESS;
     5560    unsigned cEntries = 0;
     5561
     5562    LogFlowFunc(("cEntriesAlloc=%u pEntries=%#p pcEntriesUsed=%#p\n", cEntriesAlloc, pEntries, pcEntriesUsed));
     5563    /* Check arguments. */
     5564    AssertMsgReturn(cEntriesAlloc,
     5565                    ("cEntriesAlloc=%u\n", cEntriesAlloc),
     5566                    VERR_INVALID_PARAMETER);
     5567    AssertMsgReturn(VALID_PTR(pEntries),
     5568                    ("pEntries=%#p\n", pEntries),
     5569                    VERR_INVALID_PARAMETER);
     5570    AssertMsgReturn(VALID_PTR(pcEntriesUsed),
     5571                    ("pcEntriesUsed=%#p\n", pcEntriesUsed),
     5572                    VERR_INVALID_PARAMETER);
     5573    if (!g_apBackends)
     5574        VDInit();
     5575
     5576    if (cEntriesAlloc < g_cFilterBackends)
     5577    {
     5578        *pcEntriesUsed = g_cFilterBackends;
     5579        return VERR_BUFFER_OVERFLOW;
     5580    }
     5581
     5582    for (unsigned i = 0; i < g_cFilterBackends; i++)
     5583    {
     5584        pEntries[i].pszFilter = g_apFilterBackends[i]->pszBackendName;
     5585        pEntries[i].paConfigInfo = g_apFilterBackends[i]->paConfigInfo;
     5586    }
     5587
     5588    LogFlowFunc(("returns %Rrc *pcEntriesUsed=%u\n", rc, cEntries));
     5589    *pcEntriesUsed = g_cFilterBackends;
     5590    return rc;
     5591}
     5592
     5593/**
     5594 * Lists the capabilities of a filter identified by its name.
     5595 *
     5596 * @return  VBox status code.
     5597 * @param   pszFilter       The filter name (case insensitive).
     5598 * @param   pEntries        Pointer to an entry.
     5599 */
     5600VBOXDDU_DECL(int) VDFilterInfoOne(const char *pszFilter, PVDFILTERINFO pEntry)
     5601{
     5602    LogFlowFunc(("pszFilter=%#p pEntry=%#p\n", pszFilter, pEntry));
     5603    /* Check arguments. */
     5604    AssertMsgReturn(VALID_PTR(pszFilter),
     5605                    ("pszFilter=%#p\n", pszFilter),
     5606                    VERR_INVALID_PARAMETER);
     5607    AssertMsgReturn(VALID_PTR(pEntry),
     5608                    ("pEntry=%#p\n", pEntry),
     5609                    VERR_INVALID_PARAMETER);
     5610    if (!g_apBackends)
     5611        VDInit();
     5612
     5613    /* Go through loaded backends. */
     5614    for (unsigned i = 0; i < g_cFilterBackends; i++)
     5615    {
     5616        if (!RTStrICmp(pszFilter, g_apFilterBackends[i]->pszBackendName))
     5617        {
     5618            pEntry->pszFilter = g_apFilterBackends[i]->pszBackendName;
     5619            pEntry->paConfigInfo = g_apFilterBackends[i]->paConfigInfo;
    55405620            return VINF_SUCCESS;
    55415621        }
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