VirtualBox

Changeset 55592 in vbox for trunk/src


Ignore:
Timestamp:
May 2, 2015 2:36:57 AM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
99965
Message:

Sketched out how the base environment would be received by the guest session code.

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h

    r55591 r55592  
    241241        return RTEnvFreeUtf8Block(pszzBlock);
    242242    }
     243
     244    /**
     245     * Applies a block on the format returned by queryUtf8Block.
     246     *
     247     * @returns IPRT status code.
     248     * @param   pszzBlock           Pointer to the block.
     249     * @param   cbBlock             The size of the block.
     250     * @param   fNoEqualMeansUnset  Whether the lack of a '=' (equal) sign in a
     251     *                              string means it should be unset (@c true), or if
     252     *                              it means the variable should be defined with an
     253     *                              empty value (@c false, the default).
     254     * @todo move this to RTEnv!
     255     */
     256    int copyUtf8Block(const char *pszzBlock, size_t cbBlock, bool fNoEqualMeansUnset = false)
     257    {
     258        int rc = VINF_SUCCESS;
     259        while (cbBlock > 0 && *pszzBlock != '\0')
     260        {
     261            const char *pszEnd = (const char *)memchr(pszzBlock, '\0', cbBlock);
     262            if (!pszEnd)
     263                return VERR_BUFFER_UNDERFLOW;
     264            int rc2;
     265            if (fNoEqualMeansUnset || strchr(pszzBlock, '='))
     266                rc2 = RTEnvPutEx(m_hEnv, pszzBlock);
     267            else
     268                rc2 = RTEnvSetEx(m_hEnv, pszzBlock, "");
     269            if (RT_FAILURE(rc2) && RT_SUCCESS(rc))
     270                rc = rc2;
     271
     272            /* Advance. */
     273            cbBlock -= pszEnd - pszzBlock;
     274            if (cbBlock < 2)
     275                return VERR_BUFFER_UNDERFLOW;
     276            cbBlock--;
     277            pszzBlock = pszEnd + 1;
     278        }
     279
     280        /* The remainder must be zero padded. */
     281        if (RT_SUCCESS(rc))
     282        {
     283            if (ASMMemIsAll8(pszzBlock, cbBlock, 0))
     284                return VINF_SUCCESS;
     285            return VERR_TOO_MUCH_DATA;
     286        }
     287        return rc;
     288    }
     289
    243290
    244291    /**
  • trunk/src/VBox/Main/include/GuestSessionImpl.h

    r55591 r55592  
    515515            , mRC(rThat.mRC)
    516516        { }
     517        ~Data(void)
     518        {
     519            if (mpBaseEnvironment)
     520            {
     521                mpBaseEnvironment->releaseConst();
     522                mpBaseEnvironment = NULL;
     523            }
     524        }
    517525    } mData;
    518526};
  • trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp

    r55591 r55592  
    325325    if (mData.mpBaseEnvironment)
    326326    {
    327         GuestEnvironment *pBaseEnv = unconst(mData.mpBaseEnvironment);
     327        mData.mpBaseEnvironment->releaseConst();
    328328        mData.mpBaseEnvironment = NULL;
    329         pBaseEnv->release();
    330329    }
    331330
     
    15711570        case GUEST_SESSION_NOTIFYTYPE_STARTED:
    15721571            sessionStatus = GuestSessionStatus_Started;
     1572#if 0 /** @todo If we get some environment stuff along with this kind notification: */
     1573            const char *pszzEnvBlock = ...;
     1574            uint32_t    cbEnvBlock   = ...;
     1575            if (!mData.mpBaseEnvironment)
     1576            {
     1577                GuestEnvironment *pBaseEnv;
     1578                try { pBaseEnv = new GuestEnvironment(); } catch (std::bad_alloc &) { pBaseEnv = NULL; }
     1579                if (pBaseEnv)
     1580                {
     1581                    int vrc = pBaseEnv->initNormal();
     1582                    if (RT_SUCCESS(vrc))
     1583                        vrc = pBaseEnv->copyUtf8Block(pszzEnvBlock, cbEnvBlock);
     1584                    if (RT_SUCCESS(vrc))
     1585                        mData.mpBaseEnvironment = pBaseEnv;
     1586                    else
     1587                        pBaseEnv->release();
     1588                }
     1589            }
     1590#endif
    15731591            break;
    15741592
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