VirtualBox

Changeset 34450 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Nov 29, 2010 11:00:13 AM (14 years ago)
Author:
vboxsync
Message:

RTManifestWriteStandard: Initial implementation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/checksum/manifest2.cpp

    r34449 r34450  
    105105#define RTMANIFEST_MAGIC    UINT32_C(0x99998866)
    106106
     107/**
     108 * Argument package passed to rtManifestWriteStdAttr by rtManifestWriteStdEntry
     109 * and RTManifestWriteStandard.
     110 */
     111typedef struct RTMANIFESTWRITESTDATTR
     112{
     113    /** The entry name. */
     114    const char     *pszEntry;
     115    /** The output I/O stream. */
     116    RTVFSIOSTREAM   hVfsIos;
     117} RTMANIFESTWRITESTDATTR;
     118
    107119
    108120/**
     
    742754RTDECL(int) RTManifestReadStandardEx(RTMANIFEST hManifest, RTVFSIOSTREAM hVfsIos, char *pszErr, size_t cbErr)
    743755{
     756    /*
     757     * Validate input.
     758     */
     759    AssertPtrNull(pszErr);
    744760    if (pszErr && cbErr)
    745761        *pszErr = '\0';
    746 
     762    RTMANIFESTINT *pThis = hManifest;
     763    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     764    AssertReturn(pThis->u32Magic == RTMANIFEST_MAGIC, VERR_INVALID_HANDLE);
     765
     766    /*
     767     * Process the stream line by line.
     768     */
    747769    uint32_t iLine = 0;
    748770    for (;;)
     
    901923
    902924
     925/**
     926 * @callback_method_impl{FNRTSTRSPACECALLBACK, Writes RTMANIFESTATTR.}
     927 */
     928static DECLCALLBACK(int) rtManifestWriteStdAttr(PRTSTRSPACECORE pStr, void *pvUser)
     929{
     930    PRTMANIFESTATTR         pAttr = RT_FROM_MEMBER(pStr, RTMANIFESTATTR, StrCore);
     931    RTMANIFESTWRITESTDATTR *pArgs = (RTMANIFESTWRITESTDATTR *)pvUser;
     932    char    szLine[RTPATH_MAX + RTSHA512_DIGEST_LEN + 32];
     933    size_t  cchLine = RTStrPrintf(szLine, sizeof(szLine), "%s (%s) = %s\n", pAttr->szName, pArgs->pszEntry, pAttr->pszValue);
     934    if (cchLine >= sizeof(szLine) - 1)
     935        return VERR_BUFFER_OVERFLOW;
     936    return RTVfsIoStrmWrite(pArgs->hVfsIos, szLine, cchLine, true /*fBlocking*/, NULL);
     937}
     938
     939
     940/**
     941 * @callback_method_impl{FNRTSTRSPACECALLBACK, Writes RTMANIFESTENTRY.}
     942 */
     943static DECLCALLBACK(int) rtManifestWriteStdEntry(PRTSTRSPACECORE pStr, void *pvUser)
     944{
     945    PRTMANIFESTENTRY pEntry = RT_FROM_MEMBER(pStr, RTMANIFESTENTRY, StrCore);
     946
     947    RTMANIFESTWRITESTDATTR Args;
     948    Args.hVfsIos  = (RTVFSIOSTREAM)pvUser;
     949    Args.pszEntry = pStr->pszString;
     950    return RTStrSpaceEnumerate(&pEntry->Attributes, rtManifestWriteStdAttr, &Args);
     951}
     952
     953
    903954RTDECL(int) RTManifestWriteStandard(RTMANIFEST hManifest, RTVFSIOSTREAM hVfsIos)
    904955{
    905     return VERR_NOT_IMPLEMENTED;
    906 }
    907 
     956    RTMANIFESTINT *pThis = hManifest;
     957    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     958    AssertReturn(pThis->u32Magic == RTMANIFEST_MAGIC, VERR_INVALID_HANDLE);
     959
     960    RTMANIFESTWRITESTDATTR Args;
     961    Args.hVfsIos  = hVfsIos;
     962    Args.pszEntry = "main";
     963    int rc = RTStrSpaceEnumerate(&pThis->Attributes, rtManifestWriteStdAttr, &Args);
     964    if (RT_SUCCESS(rc))
     965        rc = RTStrSpaceEnumerate(&pThis->Entries, rtManifestWriteStdEntry, hVfsIos);
     966    return rc;
     967}
     968
Note: See TracChangeset for help on using the changeset viewer.

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