本文整理汇总了C++中RTMsgError函数的典型用法代码示例。如果您正苦于以下问题:C++ RTMsgError函数的具体用法?C++ RTMsgError怎么用?C++ RTMsgError使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTMsgError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rtCmdChModOne
/**
* Changes the file mode of one file system object.
*
* @returns exit code
* @param pOpts The chmod options.
* @param pszPath The path to the file system object to change the
* file mode of.
*/
static RTEXITCODE rtCmdChModOne(RTCMDCHMODOPTS const *pOpts, const char *pszPath)
{
int rc;
RTFSOBJINFO ObjInfo;
bool fChanges = false;
if (!pOpts->fAlwaysUseChainApi && !RTVfsChainIsSpec(pszPath) )
{
rc = RTPathQueryInfoEx(pszPath, &ObjInfo, RTFSOBJATTRADD_NOTHING, RTPATH_F_FOLLOW_LINK);
if (RT_SUCCESS(rc))
{
RTFMODE fNewMode = rtCmdMkModCalcNewMode(pOpts, ObjInfo.Attr.fMode);
fChanges = fNewMode != ObjInfo.Attr.fMode;
if (fChanges)
{
rc = RTPathSetMode(pszPath, fNewMode);
if (RT_FAILURE(rc))
RTMsgError("RTPathSetMode failed on '%s' with fNewMode=%#x: %Rrc", pszPath, fNewMode, rc);
}
}
else
RTMsgError("RTPathQueryInfoEx failed on '%s': %Rrc", pszPath, rc);
}
else
{
RTVFSOBJ hVfsObj;
uint32_t offError;
RTERRINFOSTATIC ErrInfo;
rc = RTVfsChainOpenObj(pszPath, RTFILE_O_ACCESS_ATTR_READWRITE | RTFILE_O_DENY_NONE | RTFILE_O_OPEN,
RTVFSOBJ_F_OPEN_ANY | RTVFSOBJ_F_CREATE_NOTHING | RTPATH_F_FOLLOW_LINK,
&hVfsObj, &offError, RTErrInfoInitStatic(&ErrInfo));
if (RT_SUCCESS(rc))
{
rc = RTVfsObjQueryInfo(hVfsObj, &ObjInfo, RTFSOBJATTRADD_NOTHING);
if (RT_SUCCESS(rc))
{
RTFMODE fNewMode = rtCmdMkModCalcNewMode(pOpts, ObjInfo.Attr.fMode);
fChanges = fNewMode != ObjInfo.Attr.fMode;
if (fChanges)
{
rc = RTVfsObjSetMode(hVfsObj, fNewMode, RTCHMOD_SET_ALL_MASK);
if (RT_FAILURE(rc))
RTMsgError("RTVfsObjSetMode failed on '%s' with fNewMode=%#x: %Rrc", pszPath, fNewMode, rc);
}
}
else
RTVfsChainMsgError("RTVfsObjQueryInfo", pszPath, rc, offError, &ErrInfo.Core);
RTVfsObjRelease(hVfsObj);
}
else
RTVfsChainMsgError("RTVfsChainOpenObject", pszPath, rc, offError, &ErrInfo.Core);
}
if (RT_SUCCESS(rc))
{
if (pOpts->enmNoiseLevel >= (fChanges ? kRTCmdChModNoise_Changes : kRTCmdChModNoise_Verbose))
RTPrintf("%s\n", pszPath);
return RTEXITCODE_SUCCESS;
}
return RTEXITCODE_FAILURE;
}
示例2: scmSvnRun
/**
* Executes SVN.
*
* Standard error and standard output is suppressed.
*
* @returns VINF_SUCCESS if the command executed successfully.
* @param pState The rewrite state to work on.
* @param papszArgs The SVN argument.
* @param fNormalFailureOk Whether normal failure is ok.
*/
static int scmSvnRun(PSCMRWSTATE pState, const char **papszArgs, bool fNormalFailureOk)
{
char *pszCmdLine = NULL;
int rc = RTGetOptArgvToString(&pszCmdLine, papszArgs, RTGETOPTARGV_CNV_QUOTE_BOURNE_SH);
if (RT_FAILURE(rc))
return rc;
ScmVerbose(pState, 2, "executing: %s\n", pszCmdLine);
/* Lazy bird uses RTProcExecToString. */
RTPROCSTATUS Status;
rc = RTProcExec(g_szSvnPath, papszArgs, RTENV_DEFAULT, RTPROCEXEC_FLAGS_STD_NULL, &Status);
if ( RT_SUCCESS(rc)
&& ( Status.enmReason != RTPROCEXITREASON_NORMAL
|| Status.iStatus != 0) )
{
if (fNormalFailureOk || Status.enmReason != RTPROCEXITREASON_NORMAL)
RTMsgError("%s: %s -> %s %u\n",
pState->pszFilename,
pszCmdLine,
Status.enmReason == RTPROCEXITREASON_NORMAL ? "exit code"
: Status.enmReason == RTPROCEXITREASON_SIGNAL ? "signal"
: Status.enmReason == RTPROCEXITREASON_ABEND ? "abnormal end"
: "abducted by alien",
Status.iStatus);
rc = VERR_GENERAL_FAILURE;
}
else if (RT_FAILURE(rc))
RTMsgError("%s: %s -> %Rrc\n", pState->pszFilename, pszCmdLine, rc);
RTStrFree(pszCmdLine);
return rc;
}
示例3: GetKeyByName
static int GetKeyByName(uint32_t uKey, SMCPARAM *pKeyData)
{
SMCPARAM In;
RT_ZERO(In);
In.uKey.u = uKey;
int rc = CallSmc(kSMCGetKeyInfo, &In, pKeyData);
if (RT_SUCCESS(rc) && pKeyData->uResult == kSMCSuccess)
{
SMCPARAM Tmp = *pKeyData;
/* Get the key value. */
RT_ZERO(In);
In.uKey.u = uKey;
In.KeyInfo = Tmp.KeyInfo;
rc = CallSmc(kSMCReadKey, &In, pKeyData);
if (RT_SUCCESS(rc) && (pKeyData->uResult == kSMCSuccess || pKeyData->uResult == 0x85 /* not readable */))
{
pKeyData->uKey.u = uKey;
pKeyData->KeyInfo = Tmp.KeyInfo;
rc = VINF_SUCCESS;
}
else if (RT_SUCCESS(rc))
{
RTMsgError("kSMCReadKey failed on %.4s: %#x\n", &uKey, pKeyData->uResult);
rc = VERR_IO_GEN_FAILURE;
}
}
else if (RT_SUCCESS(rc))
{
RTMsgError("kSMCGetKeyInfo failed on %.4s: %#x\n", &uKey, pKeyData->uResult);
rc = VERR_IO_GEN_FAILURE;
}
return rc;
}
示例4: drvdiskintIoReqFree
/**
* Free a async I/O request.
*
* @returns nothing.
* @param pThis Disk driver.
* @param pIoReq The I/O request to free.
*/
static void drvdiskintIoReqFree(PDRVDISKINTEGRITY pThis, PDRVDISKAIOREQ pIoReq)
{
if (pThis->fCheckDoubleCompletion)
{
/* Search if the I/O request completed already. */
for (unsigned i = 0; i < pThis->cEntries; i++)
{
if (RT_UNLIKELY(pThis->papIoReq[i] == pIoReq))
{
RTMsgError("Request %#p completed already!\n", pIoReq);
RTMsgError("Start timestamp %llu Completion timestamp %llu (completed after %llu ms)\n",
pIoReq->tsStart, pIoReq->tsComplete, pIoReq->tsComplete - pIoReq->tsStart);
RTAssertDebugBreak();
}
}
pIoReq->tsComplete = RTTimeSystemMilliTS();
Assert(!pThis->papIoReq[pThis->iEntry]);
pThis->papIoReq[pThis->iEntry] = pIoReq;
pThis->iEntry = (pThis->iEntry+1) % pThis->cEntries;
if (pThis->papIoReq[pThis->iEntry])
{
RTMemFree(pThis->papIoReq[pThis->iEntry]);
pThis->papIoReq[pThis->iEntry] = NULL;
}
}
else
RTMemFree(pIoReq);
}
示例5: readCertFile
/**
* Reads a certificate from a file, returning a context or a the handle to a
* temporary memory store.
*
* @returns true on success, false on failure (error message written).
* @param pszCertFile The name of the file containing the
* certificates.
* @param ppOutCtx Where to return the certificate context.
* @param phSrcStore Where to return the handle to the temporary
* memory store.
*/
static bool readCertFile(const char *pszCertFile, PCCERT_CONTEXT *ppOutCtx, HCERTSTORE *phSrcStore)
{
*ppOutCtx = NULL;
*phSrcStore = NULL;
bool fRc = false;
void *pvFile;
size_t cbFile;
int rc = RTFileReadAll(pszCertFile, &pvFile, &cbFile);
if (RT_SUCCESS(rc))
{
*ppOutCtx = CertCreateCertificateContext(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
(PBYTE)pvFile, (DWORD)cbFile);
if (*ppOutCtx)
fRc = true;
else
{
/** @todo figure out if it's some other format... */
RTMsgError("CertCreateCertificateContext returned %s parsing the content of '%s'",
errorToString(GetLastError()), pszCertFile);
}
}
else
RTMsgError("RTFileReadAll failed on '%s': %Rrc", pszCertFile, rc);
RTFileReadAllFree(pvFile, cbFile);
return fRc;
}
示例6: GetKeyByIndex
static int GetKeyByIndex(uint32_t iKey, SMCPARAM *pKeyData)
{
SMCPARAM In;
RT_ZERO(In);
In.u32Data = iKey;
int rc = CallSmc(kSMCGetKeyFromIndex, &In, pKeyData);
if (RT_SUCCESS(rc))
{
if (pKeyData->uResult == kSMCSuccess)
{
SMCPARAM Tmp = *pKeyData;
/* Get the key info. */
RT_ZERO(In);
In.uKey.u = Tmp.uKey.u;
rc = CallSmc(kSMCGetKeyInfo, &In, pKeyData);
if (RT_SUCCESS(rc) && pKeyData->uResult == kSMCSuccess)
{
Tmp.KeyInfo = pKeyData->KeyInfo;
/* Get the key value. */
RT_ZERO(In);
In.uKey = Tmp.uKey;
In.KeyInfo = Tmp.KeyInfo;
rc = CallSmc(kSMCReadKey, &In, pKeyData);
if (RT_SUCCESS(rc) && (pKeyData->uResult == kSMCSuccess || pKeyData->uResult == 0x85 /* not readable */))
{
pKeyData->uKey = Tmp.uKey;
pKeyData->KeyInfo = Tmp.KeyInfo;
rc = VINF_SUCCESS;
}
else if (RT_SUCCESS(rc))
{
RTMsgError("kSMCReadKey failed on #%x/%.4s: %#x\n", iKey, Tmp.uKey.au8, pKeyData->uResult);
rc = VERR_IO_GEN_FAILURE;
}
}
else if (RT_SUCCESS(rc))
{
RTMsgError("kSMCGetKeyInfo failed on #%x/%.4s: %#x\n", iKey, Tmp.uKey.au8, pKeyData->uResult);
rc = VERR_IO_GEN_FAILURE;
}
}
else
{
RTMsgError("kSMCGetKeyFromIndex failed on #%x: %#x\n", iKey, pKeyData->uResult);
rc = VERR_IO_GEN_FAILURE;
}
}
return rc;
}
示例7: VBoxSVCLogRelCreate
int VBoxSVCLogRelCreate(const char *pszLogFile, uint32_t cHistory,
uint32_t uHistoryFileTime, uint64_t uHistoryFileSize)
{
/* create release logger */
PRTLOGGER pLoggerReleaseFile;
static const char * const s_apszGroups[] = VBOX_LOGGROUP_NAMES;
RTUINT fFlags = RTLOGFLAGS_PREFIX_THREAD | RTLOGFLAGS_PREFIX_TIME_PROG;
#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
fFlags |= RTLOGFLAGS_USECRLF;
#endif
char szError[RTPATH_MAX + 128] = "";
int vrc = RTLogCreateEx(&pLoggerReleaseFile, fFlags, "all",
"VBOXSVC_RELEASE_LOG", RT_ELEMENTS(s_apszGroups), s_apszGroups, 0 /* fDestFlags */,
vboxsvcHeaderFooter, cHistory, uHistoryFileSize, uHistoryFileTime,
szError, sizeof(szError), pszLogFile);
if (RT_SUCCESS(vrc))
{
/* register this logger as the release logger */
RTLogRelSetDefaultInstance(pLoggerReleaseFile);
/* Explicitly flush the log in case of VBOXWEBSRV_RELEASE_LOG=buffered. */
RTLogFlush(pLoggerReleaseFile);
}
else
{
/* print a message, but do not fail */
RTMsgError("failed to open release log (%s, %Rrc)", szError, vrc);
}
return vrc;
}
示例8: GluePrintRCMessage
void GluePrintRCMessage(HRESULT rc)
{
Utf8Str str = Utf8StrFmt("Code %Rhra (extended info not available)\n", rc);
// print and log
RTMsgError("%s", str.c_str());
Log(("ERROR: %s", str.c_str()));
}
示例9: glueHandleComErrorInternal
static void glueHandleComErrorInternal(com::ErrorInfo &info,
const char *pcszContext,
HRESULT rc,
const char *pcszSourceFile,
uint32_t ulLine)
{
const com::ErrorInfo *pInfo = &info;
do
{
if (pInfo->isFullAvailable() || pInfo->isBasicAvailable())
GluePrintErrorInfo(*pInfo);
else
#if defined (RT_OS_WIN)
GluePrintRCMessage(rc);
#else /* defined (RT_OS_WIN) */
GluePrintRCMessage(pInfo->getResultCode());
#endif
pInfo = pInfo->getNext();
/* If there is more than one error, separate them visually. */
if (pInfo)
RTMsgError("--------\n");
}
while(pInfo);
GluePrintErrorContext(pcszContext, pcszSourceFile, ulLine);
}
示例10: rtCmdChModRecursive
/**
* Recursively changes the file mode.
*
* @returns exit code
* @param pOpts The mkdir option.
* @param pszPath The path to start changing the mode of.
*/
static int rtCmdChModRecursive(RTCMDCHMODOPTS const *pOpts, const char *pszPath)
{
/*
* Check if it's a directory first. If not, join the non-recursive code.
*/
int rc;
uint32_t offError;
RTFSOBJINFO ObjInfo;
RTERRINFOSTATIC ErrInfo;
bool const fUseChainApi = pOpts->fAlwaysUseChainApi || RTVfsChainIsSpec(pszPath);
if (!fUseChainApi)
{
rc = RTPathQueryInfoEx(pszPath, &ObjInfo, RTFSOBJATTRADD_NOTHING, RTPATH_F_FOLLOW_LINK);
if (RT_FAILURE(rc))
return RTMsgErrorExitFailure("RTPathQueryInfoEx failed on '%s': %Rrc", pszPath, rc);
}
else
{
rc = RTVfsChainQueryInfo(pszPath, &ObjInfo, RTFSOBJATTRADD_NOTHING, RTPATH_F_FOLLOW_LINK,
&offError, RTErrInfoInitStatic(&ErrInfo));
if (RT_FAILURE(rc))
return RTVfsChainMsgErrorExitFailure("RTVfsChainQueryInfo", pszPath, rc, offError, &ErrInfo.Core);
}
if (!RTFS_IS_DIRECTORY(ObjInfo.Attr.fMode))
{
/*
* Don't bother redoing the above work if its not necessary.
*/
RTFMODE fNewMode = rtCmdMkModCalcNewMode(pOpts, ObjInfo.Attr.fMode);
if (fNewMode != ObjInfo.Attr.fMode)
return rtCmdChModOne(pOpts, pszPath);
if (pOpts->enmNoiseLevel >= kRTCmdChModNoise_Verbose)
RTPrintf("%s\n", pszPath);
return RTEXITCODE_SUCCESS;
}
/*
* For recursion we always use the VFS layer.
*/
RTVFSDIR hVfsDir;
if (!fUseChainApi)
{
rc = RTVfsDirOpenNormal(pszPath, 0 /** @todo write attrib flag*/, &hVfsDir);
if (RT_FAILURE(rc))
return RTMsgErrorExitFailure("RTVfsDirOpenNormal failed on '%s': %Rrc", pszPath, rc);
}
else
{
rc = RTVfsChainOpenDir(pszPath, 0 /** @todo write attrib flag*/, &hVfsDir, &offError, RTErrInfoInitStatic(&ErrInfo));
if (RT_FAILURE(rc))
return RTVfsChainMsgErrorExitFailure("RTVfsChainQueryInfo", pszPath, rc, offError, &ErrInfo.Core);
}
RTMsgError("Recursion is not yet implemented\n");
RTVfsDirRelease(hVfsDir);
rc = VERR_NOT_IMPLEMENTED;
return RT_SUCCESS(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
}
示例11: openCertStore
/**
* Opens a certificate store.
*
* @returns true on success, false on failure (error message written).
* @param dwDst The destination, like
* CERT_SYSTEM_STORE_LOCAL_MACHINE or
* CERT_SYSTEM_STORE_CURRENT_USER.
* @param pszStoreNm The store name.
*/
static HCERTSTORE openCertStore(DWORD dwDst, const char *pszStoreNm)
{
HCERTSTORE hStore = NULL;
PRTUTF16 pwszStoreNm;
int rc = RTStrToUtf16(pszStoreNm, &pwszStoreNm);
if (RT_SUCCESS(rc))
{
if (g_cVerbosityLevel > 1)
RTMsgInfo("Opening store %#x:'%s'", dwDst, pszStoreNm);
/*
* Make sure CERT_STORE_OPEN_EXISTING_FLAG is not set. This causes Windows XP
* to return ACCESS_DENIED when installing TrustedPublisher certificates via
* CertAddCertificateContextToStore() if the TrustedPublisher store never has
* been used (through certmgr.exe and friends) yet.
*
* According to MSDN, if neither CERT_STORE_OPEN_EXISTING_FLAG nor
* CERT_STORE_CREATE_NEW_FLAG is set, the store will be either opened or
* created accordingly.
*/
dwDst &= ~CERT_STORE_OPEN_EXISTING_FLAG;
hStore = CertOpenStore(CERT_STORE_PROV_SYSTEM_W,
PKCS_7_ASN_ENCODING | X509_ASN_ENCODING,
NULL /* hCryptProv = default */,
dwDst,
pwszStoreNm);
if (hStore == NULL)
RTMsgError("CertOpenStore failed opening %#x:'%s': %s",
dwDst, pszStoreNm, errorToString(GetLastError()));
RTUtf16Free(pwszStoreNm);
}
return hStore;
}
示例12: DECLCALLBACK
/**
* @interface_method_impl{TXSTRANSPORT,pfnInit}
*/
static DECLCALLBACK(int) txsTcpInit(void)
{
int rc = RTCritSectInit(&g_TcpCritSect);
if (RT_SUCCESS(rc) && g_enmTcpMode != TXSTCPMODE_CLIENT)
{
rc = RTTcpServerCreateEx(g_szTcpBindAddr[0] ? g_szTcpBindAddr : NULL, g_uTcpBindPort, &g_pTcpServer);
if (RT_FAILURE(rc))
{
if (rc == VERR_NET_DOWN)
{
RTMsgInfo("RTTcpServerCreateEx(%s, %u,) failed: %Rrc, retrying for 20 seconds...\n",
g_szTcpBindAddr[0] ? g_szTcpBindAddr : NULL, g_uTcpBindPort, rc);
uint64_t StartMs = RTTimeMilliTS();
do
{
RTThreadSleep(1000);
rc = RTTcpServerCreateEx(g_szTcpBindAddr[0] ? g_szTcpBindAddr : NULL, g_uTcpBindPort, &g_pTcpServer);
} while ( rc == VERR_NET_DOWN
&& RTTimeMilliTS() - StartMs < 20000);
if (RT_SUCCESS(rc))
RTMsgInfo("RTTcpServerCreateEx succceeded.\n");
}
if (RT_FAILURE(rc))
{
g_pTcpServer = NULL;
RTCritSectDelete(&g_TcpCritSect);
RTMsgError("RTTcpServerCreateEx(%s, %u,) failed: %Rrc\n",
g_szTcpBindAddr[0] ? g_szTcpBindAddr : NULL, g_uTcpBindPort, rc);
}
}
}
return rc;
}
示例13: autostartConfigTokenizerMsgUnexpectedToken
static void autostartConfigTokenizerMsgUnexpectedToken(PCFGTOKEN pToken, const char *pszExpected)
{
RTMsgError("Unexpected token '%s' at %d:%d.%d, expected '%s'",
autostartConfigTokenToString(pToken),
pToken->iLine, pToken->cchStart,
pToken->cchStart + autostartConfigTokenGetLength(pToken) - 1, pszExpected);
}
示例14: drvdiskIntIoReqExpiredCheck
/**
* Thread checking for expired requests.
*
* @returns IPRT status code.
* @param pThread Thread handle.
* @param pvUser Opaque user data.
*/
static int drvdiskIntIoReqExpiredCheck(RTTHREAD pThread, void *pvUser)
{
PDRVDISKINTEGRITY pThis = (PDRVDISKINTEGRITY)pvUser;
while (pThis->fRunning)
{
int rc = RTSemEventWait(pThis->SemEvent, pThis->uCheckIntervalMs);
if (!pThis->fRunning)
break;
Assert(rc == VERR_TIMEOUT);
/* Get current timestamp for comparison. */
uint64_t tsCurr = RTTimeSystemMilliTS();
/* Go through the array and check for expired requests. */
for (unsigned i = 0; i < RT_ELEMENTS(pThis->apReqActive); i++)
{
PDRVDISKAIOREQACTIVE pReqActive = &pThis->apReqActive[i];
PDRVDISKAIOREQ pIoReq = ASMAtomicReadPtrT(&pReqActive->pIoReq, PDRVDISKAIOREQ);
if ( pIoReq
&& (tsCurr > pReqActive->tsStart)
&& (tsCurr - pReqActive->tsStart) >= pThis->uExpireIntervalMs)
{
RTMsgError("Request %#p expired (active for %llu ms already)\n",
pIoReq, tsCurr - pReqActive->tsStart);
RTAssertDebugBreak();
}
}
}
return VINF_SUCCESS;
}
示例15: main
int main(int argc, char **argv)
{
int rc = RTR3InitExe(argc, &argv, 0);
if (RT_FAILURE(rc))
return RTMsgInitFailure(rc);
/*
* Switch on the command.
*/
RTEXITCODE rcExit = RTEXITCODE_SYNTAX;
if (argc < 2)
rtDbgSymCacheUsage(argv[0], NULL);
else if (!strcmp(argv[1], "add"))
rcExit = rtDbgSymCacheCmdAdd(argv[0], argc - 2, argv + 2);
else if ( !strcmp(argv[1], "-h")
|| !strcmp(argv[1], "-?")
|| !strcmp(argv[1], "--help"))
rcExit = rtDbgSymCacheUsage(argv[0], NULL);
else if ( !strcmp(argv[1], "-V")
|| !strcmp(argv[1], "--version"))
rcExit = rtDbgSymCacheVersion();
else
RTMsgError("Unknown command: '%s'", argv[1]);
return rcExit;
}