本文整理匯總了C++中AssertPtrNullReturn函數的典型用法代碼示例。如果您正苦於以下問題:C++ AssertPtrNullReturn函數的具體用法?C++ AssertPtrNullReturn怎麽用?C++ AssertPtrNullReturn使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了AssertPtrNullReturn函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: RTDECL
RTDECL(int) RTEnvGetUtf8(const char *pszVar, char *pszValue, size_t cbValue, size_t *pcchActual)
{
AssertPtrReturn(pszVar, VERR_INVALID_POINTER);
AssertPtrNullReturn(pszValue, VERR_INVALID_POINTER);
AssertReturn(pszValue || !cbValue, VERR_INVALID_PARAMETER);
AssertPtrNullReturn(pcchActual, VERR_INVALID_POINTER);
AssertReturn(pcchActual || (pszValue && cbValue), VERR_INVALID_PARAMETER);
AssertReturn(strchr(pszVar, '=') == NULL, VERR_ENV_INVALID_VAR_NAME);
if (pcchActual)
*pcchActual = 0;
PRTUTF16 pwszVar;
int rc = RTStrToUtf16(pszVar, &pwszVar);
AssertRCReturn(rc, rc);
/** @todo Consider _wgetenv_s or GetEnvironmentVariableW here to avoid the
* potential race with a concurrent _wputenv/_putenv. */
PCRTUTF16 pwszValue = _wgetenv(pwszVar);
RTUtf16Free(pwszVar);
if (pwszValue)
{
if (cbValue)
rc = RTUtf16ToUtf8Ex(pwszValue, RTSTR_MAX, &pszValue, cbValue, pcchActual);
else
rc = RTUtf16CalcUtf8LenEx(pwszValue, RTSTR_MAX, pcchActual);
}
else
rc = VERR_ENV_VAR_NOT_FOUND;
return rc;
}
示例2: VMMR3DECL
VMMR3DECL(int) DBGFR3AsLineByAddr(PUVM pUVM, RTDBGAS hDbgAs, PCDBGFADDRESS pAddress,
PRTGCINTPTR poffDisp, PRTDBGLINE pLine, PRTDBGMOD phMod)
{
/*
* Implement the special address space aliases the lazy way.
*/
if (hDbgAs == DBGF_AS_RC_AND_GC_GLOBAL)
{
int rc = DBGFR3AsLineByAddr(pUVM, DBGF_AS_RC, pAddress, poffDisp, pLine, phMod);
if (RT_FAILURE(rc))
rc = DBGFR3AsLineByAddr(pUVM, DBGF_AS_GLOBAL, pAddress, poffDisp, pLine, phMod);
return rc;
}
/*
* Input validation.
*/
UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
AssertReturn(DBGFR3AddrIsValid(pUVM, pAddress), VERR_INVALID_PARAMETER);
AssertPtrNullReturn(poffDisp, VERR_INVALID_POINTER);
AssertPtrReturn(pLine, VERR_INVALID_POINTER);
AssertPtrNullReturn(phMod, VERR_INVALID_POINTER);
if (poffDisp)
*poffDisp = 0;
if (phMod)
*phMod = NIL_RTDBGMOD;
RTDBGAS hRealAS = DBGFR3AsResolveAndRetain(pUVM, hDbgAs);
if (hRealAS == NIL_RTDBGAS)
return VERR_INVALID_HANDLE;
/*
* Do the lookup.
*/
return RTDbgAsLineByAddr(hRealAS, pAddress->FlatPtr, poffDisp, pLine, phMod);
}
示例3: VBGLR3DECL
/**
* Wait for the host to signal one or more events and return which.
*
* The events will only be delivered by the host if they have been enabled
* previously using @a VbglR3CtlFilterMask. If one or several of the events
* have already been signalled but not yet waited for, this function will return
* immediately and return those events.
*
* @returns IPRT status code.
*
* @param fMask The events we want to wait for, or-ed together.
* @param cMillies How long to wait before giving up and returning
* (VERR_TIMEOUT). Use RT_INDEFINITE_WAIT to wait until we
* are interrupted or one of the events is signalled.
* @param pfEvents Where to store the events signalled. Optional.
*/
VBGLR3DECL(int) VbglR3WaitEvent(uint32_t fMask, uint32_t cMillies, uint32_t *pfEvents)
{
LogFlow(("VbglR3WaitEvent: fMask=0x%x, cMillies=%u, pfEvents=%p\n",
fMask, cMillies, pfEvents));
AssertReturn((fMask & ~VMMDEV_EVENT_VALID_EVENT_MASK) == 0, VERR_INVALID_PARAMETER);
AssertPtrNullReturn(pfEvents, VERR_INVALID_POINTER);
VBoxGuestWaitEventInfo waitEvent;
waitEvent.u32TimeoutIn = cMillies;
waitEvent.u32EventMaskIn = fMask;
waitEvent.u32Result = VBOXGUEST_WAITEVENT_ERROR;
waitEvent.u32EventFlagsOut = 0;
int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_WAITEVENT, &waitEvent, sizeof(waitEvent));
if (RT_SUCCESS(rc))
{
/*
* If a guest requests for an event which is not available on the host side
* (because of an older host version, a disabled feature or older Guest Additions),
* don't trigger an assertion here even in debug builds - would be annoying.
*/
#if 0
AssertMsg(waitEvent.u32Result == VBOXGUEST_WAITEVENT_OK, ("%d rc=%Rrc\n", waitEvent.u32Result, rc));
#endif
if (pfEvents)
*pfEvents = waitEvent.u32EventFlagsOut;
}
LogFlow(("VbglR3WaitEvent: rc=%Rrc, u32EventFlagsOut=0x%x. u32Result=%d\n",
rc, waitEvent.u32EventFlagsOut, waitEvent.u32Result));
return rc;
}
示例4: VMMR3DECL
/**
* Registers a guest OS digger.
*
* This will instantiate an instance of the digger and add it
* to the list for us in the next call to DBGFR3OSDetect().
*
* @returns VBox status code.
* @param pVM Pointer to the shared VM structure.
* @param pReg The registration structure.
* @thread Any.
*/
VMMR3DECL(int) DBGFR3OSRegister(PVM pVM, PCDBGFOSREG pReg)
{
/*
* Validate intput.
*/
VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
AssertPtrReturn(pReg, VERR_INVALID_POINTER);
AssertReturn(pReg->u32Magic == DBGFOSREG_MAGIC, VERR_INVALID_MAGIC);
AssertReturn(pReg->u32EndMagic == DBGFOSREG_MAGIC, VERR_INVALID_MAGIC);
AssertReturn(!pReg->fFlags, VERR_INVALID_PARAMETER);
AssertReturn(pReg->cbData < _2G, VERR_INVALID_PARAMETER);
AssertReturn(pReg->szName[0], VERR_INVALID_NAME);
AssertReturn(RTStrEnd(&pReg->szName[0], sizeof(pReg->szName)), VERR_INVALID_NAME);
AssertPtrReturn(pReg->pfnConstruct, VERR_INVALID_POINTER);
AssertPtrNullReturn(pReg->pfnDestruct, VERR_INVALID_POINTER);
AssertPtrReturn(pReg->pfnProbe, VERR_INVALID_POINTER);
AssertPtrReturn(pReg->pfnInit, VERR_INVALID_POINTER);
AssertPtrReturn(pReg->pfnRefresh, VERR_INVALID_POINTER);
AssertPtrReturn(pReg->pfnTerm, VERR_INVALID_POINTER);
AssertPtrReturn(pReg->pfnQueryVersion, VERR_INVALID_POINTER);
AssertPtrReturn(pReg->pfnQueryInterface, VERR_INVALID_POINTER);
/*
* Pass it on to EMT(0).
*/
return VMR3ReqPriorityCallWait(pVM, 0 /*idDstCpu*/, (PFNRT)dbgfR3OSRegister, 2, pVM, pReg);
}
示例5: RTDECL
RTDECL(int) RTPollSetQueryHandle(RTPOLLSET hPollSet, uint32_t id, PRTHANDLE pHandle)
{
/*
* Validate the input.
*/
RTPOLLSETINTERNAL *pThis = hPollSet;
AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
AssertReturn(pThis->u32Magic == RTPOLLSET_MAGIC, VERR_INVALID_HANDLE);
AssertReturn(id != UINT32_MAX, VERR_INVALID_PARAMETER);
AssertPtrNullReturn(pHandle, VERR_INVALID_POINTER);
/*
* Set the busy flag and do the job.
*/
AssertReturn(ASMAtomicCmpXchgBool(&pThis->fBusy, true, false), VERR_CONCURRENT_ACCESS);
int rc = VERR_POLL_HANDLE_ID_NOT_FOUND;
uint32_t i = pThis->cHandles;
while (i-- > 0)
if (pThis->paHandles[i].id == id)
{
if (pHandle)
{
pHandle->enmType = pThis->paHandles[i].enmType;
pHandle->u = pThis->paHandles[i].u;
}
rc = VINF_SUCCESS;
break;
}
ASMAtomicWriteBool(&pThis->fBusy, false);
return rc;
}
示例6: RTR3DECL
RTR3DECL(int) RTSha256Digest(void* pvBuf, size_t cbBuf, char **ppszDigest, PFNRTPROGRESS pfnProgressCallback, void *pvUser)
{
/* Validate input */
AssertPtrReturn(pvBuf, VERR_INVALID_POINTER);
AssertPtrReturn(ppszDigest, VERR_INVALID_POINTER);
AssertPtrNullReturn(pfnProgressCallback, VERR_INVALID_PARAMETER);
int rc = VINF_SUCCESS;
*ppszDigest = NULL;
/* Initialize the hash context. */
RTSHA256CONTEXT Ctx;
RTSha256Init(&Ctx);
/* Buffer size for progress callback */
double rdMulti = 100.0 / (cbBuf ? cbBuf : 1);
/* Working buffer */
char *pvTmp = (char*)pvBuf;
/* Process the memory in blocks */
size_t cbReadTotal = 0;
for (;;)
{
size_t cbRead = RT_MIN(cbBuf - cbReadTotal, _1M);
RTSha256Update(&Ctx, pvTmp, cbRead);
cbReadTotal += cbRead;
pvTmp += cbRead;
/* Call the progress callback if one is defined */
if (pfnProgressCallback)
{
rc = pfnProgressCallback((unsigned)(cbReadTotal * rdMulti), pvUser);
if (RT_FAILURE(rc))
break; /* canceled */
}
/* Finished? */
if (cbReadTotal == cbBuf)
break;
}
if (RT_SUCCESS(rc))
{
/* Finally calculate & format the SHA256 sum */
uint8_t abHash[RTSHA256_HASH_SIZE];
RTSha256Final(&Ctx, abHash);
char *pszDigest;
rc = RTStrAllocEx(&pszDigest, RTSHA256_DIGEST_LEN + 1);
if (RT_SUCCESS(rc))
{
rc = RTSha256ToString(abHash, pszDigest, RTSHA256_DIGEST_LEN + 1);
if (RT_SUCCESS(rc))
*ppszDigest = pszDigest;
else
RTStrFree(pszDigest);
}
}
return rc;
}
示例7: getDriveInfoFromSysfs
/* static */
int getDriveInfoFromSysfs(DriveInfoList *pList, bool isDVD, bool *pfSuccess)
{
AssertPtrReturn(pList, VERR_INVALID_POINTER);
AssertPtrNullReturn(pfSuccess, VERR_INVALID_POINTER); /* Valid or Null */
LogFlowFunc (("pList=%p, isDVD=%u, pfSuccess=%p\n",
pList, (unsigned) isDVD, pfSuccess));
RTDIR hDir;
int rc;
bool fSuccess = false;
unsigned cFound = 0;
if (!RTPathExists("/sys"))
return VINF_SUCCESS;
rc = RTDirOpen(&hDir, "/sys/block");
/* This might mean that sysfs semantics have changed */
AssertReturn(rc != VERR_FILE_NOT_FOUND, VINF_SUCCESS);
fSuccess = true;
if (RT_SUCCESS(rc))
{
for (;;)
{
RTDIRENTRY entry;
rc = RTDirRead(hDir, &entry, NULL);
Assert(rc != VERR_BUFFER_OVERFLOW); /* Should never happen... */
if (RT_FAILURE(rc)) /* Including overflow and no more files */
break;
if (entry.szName[0] == '.')
continue;
sysfsBlockDev dev(entry.szName, isDVD);
/* This might mean that sysfs semantics have changed */
AssertBreakStmt(dev.isConsistent(), fSuccess = false);
if (!dev.isValid())
continue;
try
{
pList->push_back(DriveInfo(dev.getNode(), dev.getUdi(), dev.getDesc()));
}
catch(std::bad_alloc &e)
{
rc = VERR_NO_MEMORY;
break;
}
++cFound;
}
RTDirClose(hDir);
}
if (rc == VERR_NO_MORE_FILES)
rc = VINF_SUCCESS;
if (RT_FAILURE(rc))
/* Clean up again */
for (unsigned i = 0; i < cFound; ++i)
pList->pop_back();
if (pfSuccess)
*pfSuccess = fSuccess;
LogFlow (("rc=%Rrc, fSuccess=%u\n", rc, (unsigned) fSuccess));
return rc;
}
示例8: VMMR3DECL
/**
* Detects the guest OS and try dig out symbols and useful stuff.
*
* When called the 2nd time, symbols will be updated that if the OS
* is the same.
*
* @returns VBox status code.
* @retval VINF_SUCCESS if successfully detected.
* @retval VINF_DBGF_OS_NOT_DETCTED if we cannot figure it out.
*
* @param pUVM The user mode VM handle.
* @param pszName Where to store the OS name. Empty string if not detected.
* @param cchName Size of the buffer.
* @thread Any.
*/
VMMR3DECL(int) DBGFR3OSDetect(PUVM pUVM, char *pszName, size_t cchName)
{
AssertPtrNullReturn(pszName, VERR_INVALID_POINTER);
if (pszName && cchName)
*pszName = '\0';
UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
/*
* Pass it on to EMT(0).
*/
return VMR3ReqPriorityCallWaitU(pUVM, 0 /*idDstCpu*/, (PFNRT)dbgfR3OSDetect, 3, pUVM, pszName, cchName);
}
示例9: VMMR3DECL
/**
* Query a symbol by name.
*
* The symbol can be prefixed by a module name pattern to scope the search. The
* pattern is a simple string pattern with '*' and '?' as wild chars. See
* RTStrSimplePatternMatch().
*
* @returns VBox status code. See RTDbgAsSymbolByAddr.
*
* @param pUVM The user mode VM handle.
* @param hDbgAs The address space handle.
* @param pszSymbol The symbol to search for, maybe prefixed by a
* module pattern.
* @param pSymbol Where to return the symbol information.
* The returned symbol name will be prefixed by
* the module name as far as space allows.
* @param phMod Where to return the module handle. Optional.
*/
VMMR3DECL(int) DBGFR3AsSymbolByName(PUVM pUVM, RTDBGAS hDbgAs, const char *pszSymbol,
PRTDBGSYMBOL pSymbol, PRTDBGMOD phMod)
{
/*
* Implement the special address space aliases the lazy way.
*/
if (hDbgAs == DBGF_AS_RC_AND_GC_GLOBAL)
{
int rc = DBGFR3AsSymbolByName(pUVM, DBGF_AS_RC, pszSymbol, pSymbol, phMod);
if (RT_FAILURE(rc))
rc = DBGFR3AsSymbolByName(pUVM, DBGF_AS_GLOBAL, pszSymbol, pSymbol, phMod);
return rc;
}
/*
* Input validation.
*/
UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
AssertPtrReturn(pSymbol, VERR_INVALID_POINTER);
AssertPtrNullReturn(phMod, VERR_INVALID_POINTER);
if (phMod)
*phMod = NIL_RTDBGMOD;
RTDBGAS hRealAS = DBGFR3AsResolveAndRetain(pUVM, hDbgAs);
if (hRealAS == NIL_RTDBGAS)
return VERR_INVALID_HANDLE;
/*
* Do the lookup.
*/
RTDBGMOD hMod;
int rc = RTDbgAsSymbolByName(hRealAS, pszSymbol, pSymbol, &hMod);
if (RT_SUCCESS(rc))
{
dbgfR3AsSymbolJoinNames(pSymbol, hMod);
if (!phMod)
RTDbgModRelease(hMod);
}
/* Temporary conversion. */
else if (hDbgAs == DBGF_AS_GLOBAL)
{
DBGFSYMBOL DbgfSym;
rc = DBGFR3SymbolByName(pUVM->pVM, pszSymbol, &DbgfSym);
if (RT_SUCCESS(rc))
dbgfR3AsSymbolConvert(pSymbol, &DbgfSym);
}
return rc;
}
示例10: RTR3DECL
RTR3DECL(int) RTManifestVerifyFiles(const char *pszManifestFile, const char * const *papszFiles, size_t cFiles, size_t *piFailed,
PFNRTPROGRESS pfnProgressCallback, void *pvUser)
{
/* Validate input */
AssertPtrReturn(pszManifestFile, VERR_INVALID_POINTER);
AssertPtrReturn(papszFiles, VERR_INVALID_POINTER);
AssertPtrNullReturn(pfnProgressCallback, VERR_INVALID_POINTER);
int rc = VINF_SUCCESS;
/* Create our compare list */
PRTMANIFESTTEST paFiles = (PRTMANIFESTTEST)RTMemTmpAllocZ(sizeof(RTMANIFESTTEST) * cFiles);
if (!paFiles)
return VERR_NO_MEMORY;
RTMANIFESTCALLBACKDATA callback = { pfnProgressCallback, pvUser, cFiles, 0 };
/* Fill our compare list */
for (size_t i = 0; i < cFiles; ++i)
{
char *pszDigest;
if (pfnProgressCallback)
{
callback.cCurrentFile = i;
rc = RTSha1DigestFromFile(papszFiles[i], &pszDigest, rtSHAProgressCallback, &callback);
}
else
rc = RTSha1DigestFromFile(papszFiles[i], &pszDigest, NULL, NULL);
if (RT_FAILURE(rc))
break;
paFiles[i].pszTestFile = (char*)papszFiles[i];
paFiles[i].pszTestDigest = pszDigest;
}
/* Do the verification */
if (RT_SUCCESS(rc))
rc = RTManifestVerify(pszManifestFile, paFiles, cFiles, piFailed);
/* Cleanup */
for (size_t i = 0; i < cFiles; ++i)
{
if (paFiles[i].pszTestDigest)
RTStrFree((char*)paFiles[i].pszTestDigest);
}
RTMemTmpFree(paFiles);
return rc;
}
示例11: AssertPtrReturn
/**
* Convert an (X, Y) value pair in screen co-ordinates (starting from 1) to a
* value from VMMDEV_MOUSE_RANGE_MIN to VMMDEV_MOUSE_RANGE_MAX. Sets the
* optional validity value to false if the pair is not on an active screen and
* to true otherwise.
* @note since guests with recent versions of X.Org use a different method
* to everyone else to map the valuator value to a screen pixel (they
* multiply by the screen dimension, do a floating point divide by
* the valuator maximum and round the result, while everyone else
* does truncating integer operations) we adjust the value we send
* so that it maps to the right pixel both when the result is rounded
* and when it is truncated.
*
* @returns COM status value
*/
HRESULT Mouse::convertDisplayRes(LONG x, LONG y, int32_t *pxAdj, int32_t *pyAdj,
bool *pfValid)
{
AssertPtrReturn(pxAdj, E_POINTER);
AssertPtrReturn(pyAdj, E_POINTER);
AssertPtrNullReturn(pfValid, E_POINTER);
DisplayMouseInterface *pDisplay = mParent->getDisplayMouseInterface();
ComAssertRet(pDisplay, E_FAIL);
/** The amount to add to the result (multiplied by the screen width/height)
* to compensate for differences in guest methods for mapping back to
* pixels */
enum { ADJUST_RANGE = - 3 * VMMDEV_MOUSE_RANGE / 4 };
if (pfValid)
*pfValid = true;
if (!(mfVMMDevGuestCaps & VMMDEV_MOUSE_NEW_PROTOCOL))
{
ULONG displayWidth, displayHeight;
/* Takes the display lock */
HRESULT rc = pDisplay->getScreenResolution(0, &displayWidth,
&displayHeight, NULL);
if (FAILED(rc))
return rc;
*pxAdj = displayWidth ? (x * VMMDEV_MOUSE_RANGE + ADJUST_RANGE)
/ (LONG) displayWidth: 0;
*pyAdj = displayHeight ? (y * VMMDEV_MOUSE_RANGE + ADJUST_RANGE)
/ (LONG) displayHeight: 0;
}
else
{
int32_t x1, y1, x2, y2;
/* Takes the display lock */
pDisplay->getFramebufferDimensions(&x1, &y1, &x2, &y2);
*pxAdj = x1 < x2 ? ((x - x1) * VMMDEV_MOUSE_RANGE + ADJUST_RANGE)
/ (x2 - x1) : 0;
*pyAdj = y1 < y2 ? ((y - y1) * VMMDEV_MOUSE_RANGE + ADJUST_RANGE)
/ (y2 - y1) : 0;
if ( *pxAdj < VMMDEV_MOUSE_RANGE_MIN
|| *pxAdj > VMMDEV_MOUSE_RANGE_MAX
|| *pyAdj < VMMDEV_MOUSE_RANGE_MIN
|| *pyAdj > VMMDEV_MOUSE_RANGE_MAX)
if (pfValid)
*pfValid = false;
}
return S_OK;
}
示例12: RTDECL
RTDECL(int) RTCrDigestFinal(RTCRDIGEST hDigest, void *pvHash, size_t cbHash)
{
PRTCRDIGESTINT pThis = hDigest;
AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
AssertReturn(pThis->u32Magic == RTCRDIGESTINT_MAGIC, VERR_INVALID_HANDLE);
AssertReturn(pThis->uState == RTCRDIGEST_STATE_READY || pThis->uState == RTCRDIGEST_STATE_FINAL, VERR_INVALID_STATE);
AssertPtrNullReturn(pvHash, VERR_INVALID_POINTER);
/*
* Make sure the hash calculation is final.
*/
if (pThis->uState == RTCRDIGEST_STATE_READY)
{
pThis->pDesc->pfnFinal(pThis->pvState, &pThis->abState[pThis->offHash]);
pThis->uState = RTCRDIGEST_STATE_FINAL;
}
else
AssertReturn(pThis->uState == RTCRDIGEST_STATE_FINAL, VERR_INVALID_STATE);
/*
* Copy out the hash if requested.
*/
if (cbHash > 0)
{
uint32_t cbNeeded = pThis->pDesc->cbHash;
if (pThis->pDesc->pfnGetHashSize)
cbNeeded = pThis->pDesc->pfnGetHashSize(pThis->pvState);
Assert(cbNeeded > 0);
if (cbNeeded == cbHash)
memcpy(pvHash, &pThis->abState[pThis->offHash], cbNeeded);
else if (cbNeeded > cbHash)
{
memcpy(pvHash, &pThis->abState[pThis->offHash], cbNeeded);
memset((uint8_t *)pvHash + cbNeeded, 0, cbHash - cbNeeded);
return VINF_BUFFER_UNDERFLOW;
}
else
{
memcpy(pvHash, &pThis->abState[pThis->offHash], cbHash);
return VERR_BUFFER_OVERFLOW;
}
}
return rtCrDigestSuccessWithDigestWarnings(pThis->pDesc);
}
示例13: DECLCALLBACK
/**
* @interface_method_impl{DBGFOSIDMESG,pfnQueryKernelLog, Generic EMT wrapper.}
*/
static DECLCALLBACK(int) dbgfR3OSEmtIDmesg_QueryKernelLog(PDBGFOSIDMESG pThis, PUVM pUVM, uint32_t fFlags, uint32_t cMessages,
char *pszBuf, size_t cbBuf, size_t *pcbActual)
{
PDBGFOSEMTWRAPPER pWrapper = RT_FROM_MEMBER(pThis, DBGFOSEMTWRAPPER, uWrapper.Dmesg);
UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
AssertReturn(pUVM == pWrapper->pUVM, VERR_INVALID_VM_HANDLE);
AssertReturn(!fFlags, VERR_INVALID_FLAGS);
AssertReturn(cMessages > 0, VERR_INVALID_PARAMETER);
if (cbBuf)
AssertPtrReturn(pszBuf, VERR_INVALID_POINTER);
AssertPtrNullReturn(pcbActual, VERR_INVALID_POINTER);
return VMR3ReqPriorityCallWaitU(pWrapper->pUVM, 0 /*idDstCpu*/,
(PFNRT)pWrapper->uDigger.pDmesg->pfnQueryKernelLog, 7,
pWrapper->uDigger.pDmesg, pUVM, fFlags, cMessages, pszBuf, cbBuf, pcbActual);
}
示例14: RTDECL
RTDECL(int) RTEnvGetEx(RTENV Env, const char *pszVar, char *pszValue, size_t cbValue, size_t *pcchActual)
{
AssertPtrReturn(pszVar, VERR_INVALID_POINTER);
AssertPtrNullReturn(pszValue, VERR_INVALID_POINTER);
AssertPtrNullReturn(pcchActual, VERR_INVALID_POINTER);
AssertReturn(pcchActual || (pszValue && cbValue), VERR_INVALID_PARAMETER);
AssertReturn(strchr(pszVar, '=') == NULL, VERR_ENV_INVALID_VAR_NAME);
if (pcchActual)
*pcchActual = 0;
int rc;
if (Env == RTENV_DEFAULT)
{
#ifdef RTENV_IMPLEMENTS_UTF8_DEFAULT_ENV_API
rc = RTEnvGetUtf8(pszVar, pszValue, cbValue, pcchActual);
#else
/*
* Since RTEnvGet isn't UTF-8 clean and actually expects the strings
* to be in the current code page (codeset), we'll do the necessary
* conversions here.
*/
char *pszVarOtherCP;
rc = RTStrUtf8ToCurrentCP(&pszVarOtherCP, pszVar);
if (RT_SUCCESS(rc))
{
const char *pszValueOtherCP = RTEnvGet(pszVarOtherCP);
RTStrFree(pszVarOtherCP);
if (pszValueOtherCP)
{
char *pszValueUtf8;
rc = RTStrCurrentCPToUtf8(&pszValueUtf8, pszValueOtherCP);
if (RT_SUCCESS(rc))
{
rc = VINF_SUCCESS;
size_t cch = strlen(pszValueUtf8);
if (pcchActual)
*pcchActual = cch;
if (pszValue && cbValue)
{
if (cch < cbValue)
memcpy(pszValue, pszValueUtf8, cch + 1);
else
rc = VERR_BUFFER_OVERFLOW;
}
RTStrFree(pszValueUtf8);
}
}
else
rc = VERR_ENV_VAR_NOT_FOUND;
}
#endif
}
else
{
PRTENVINTERNAL pIntEnv = Env;
AssertPtrReturn(pIntEnv, VERR_INVALID_HANDLE);
AssertReturn(pIntEnv->u32Magic == RTENV_MAGIC, VERR_INVALID_HANDLE);
RTENV_LOCK(pIntEnv);
/*
* Locate the first variable and return it to the caller.
*/
rc = VERR_ENV_VAR_NOT_FOUND;
const size_t cchVar = strlen(pszVar);
size_t iVar;
for (iVar = 0; iVar < pIntEnv->cVars; iVar++)
if (!pIntEnv->pfnCompare(pIntEnv->papszEnv[iVar], pszVar, cchVar))
{
if (pIntEnv->papszEnv[iVar][cchVar] == '=')
{
rc = VINF_SUCCESS;
const char *pszValueOrg = pIntEnv->papszEnv[iVar] + cchVar + 1;
size_t cch = strlen(pszValueOrg);
if (pcchActual)
*pcchActual = cch;
if (pszValue && cbValue)
{
if (cch < cbValue)
memcpy(pszValue, pszValueOrg, cch + 1);
else
rc = VERR_BUFFER_OVERFLOW;
}
break;
}
if (pIntEnv->papszEnv[iVar][cchVar] == '\0')
{
Assert(pIntEnv->fPutEnvBlock);
rc = VERR_ENV_VAR_UNSET;
break;
}
}
RTENV_UNLOCK(pIntEnv);
}
return rc;
}
示例15: RTDECL
RTDECL(int) RTManifestEqualsEx(RTMANIFEST hManifest1, RTMANIFEST hManifest2, const char * const *papszIgnoreEntries,
const char * const *papszIgnoreAttr, uint32_t fFlags, char *pszError, size_t cbError)
{
/*
* Validate input.
*/
AssertPtrNullReturn(pszError, VERR_INVALID_POINTER);
if (pszError && cbError)
*pszError = '\0';
RTMANIFESTINT *pThis1 = hManifest1;
RTMANIFESTINT *pThis2 = hManifest2;
if (pThis1 != NIL_RTMANIFEST)
{
AssertPtrReturn(pThis1, VERR_INVALID_HANDLE);
AssertReturn(pThis1->u32Magic == RTMANIFEST_MAGIC, VERR_INVALID_HANDLE);
}
if (pThis2 != NIL_RTMANIFEST)
{
AssertPtrReturn(pThis2, VERR_INVALID_HANDLE);
AssertReturn(pThis2->u32Magic == RTMANIFEST_MAGIC, VERR_INVALID_HANDLE);
}
AssertReturn(!(fFlags & ~(RTMANIFEST_EQUALS_IGN_MISSING_ATTRS)), VERR_INVALID_PARAMETER);
/*
* The simple cases.
*/
if (pThis1 == pThis2)
return VINF_SUCCESS;
if (pThis1 == NIL_RTMANIFEST || pThis2 == NIL_RTMANIFEST)
return VERR_NOT_EQUAL;
/*
* Since we have to use callback style enumeration, we have to mark the
* entries and attributes to make sure we've covered them all.
*/
RTStrSpaceEnumerate(&pThis1->Entries, rtManifestEntryClearVisited, NULL);
RTStrSpaceEnumerate(&pThis2->Entries, rtManifestEntryClearVisited, NULL);
RTStrSpaceEnumerate(&pThis1->SelfEntry.Attributes, rtManifestAttributeClearVisited, NULL);
RTStrSpaceEnumerate(&pThis2->SelfEntry.Attributes, rtManifestAttributeClearVisited, NULL);
RTMANIFESTEQUALS Equals;
Equals.pThis2 = pThis2;
Equals.fFlags = fFlags;
Equals.papszIgnoreEntries = papszIgnoreEntries;
Equals.papszIgnoreAttr = papszIgnoreAttr;
Equals.pszError = pszError;
Equals.cbError = cbError;
Equals.cIgnoredEntries2 = 0;
Equals.cEntries2 = 0;
Equals.cIgnoredAttributes1 = 0;
Equals.cIgnoredAttributes2 = 0;
Equals.cAttributes2 = 0;
Equals.pAttributes2 = NULL;
Equals.pszCurEntry = NULL;
int rc = rtManifestEntryCompare2(&Equals, &pThis1->SelfEntry, &pThis2->SelfEntry);
if (RT_SUCCESS(rc))
rc = RTStrSpaceEnumerate(&pThis1->Entries, rtManifestEntryCompare, &Equals);
if (RT_SUCCESS(rc))
{
/*
* Did we cover all entries of the 2nd manifest?
*/
if (Equals.cEntries2 + Equals.cIgnoredEntries2 != pThis2->cEntries)
rc = RTStrSpaceEnumerate(&pThis1->Entries, rtManifestEntryFindMissing2, &Equals);
}
return rc;
}