本文整理汇总了C++中RTStrDup函数的典型用法代码示例。如果您正苦于以下问题:C++ RTStrDup函数的具体用法?C++ RTStrDup怎么用?C++ RTStrDup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RTStrDup函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: RTR3DECL
RTR3DECL(int) RTS3Create(PRTS3 ppS3, const char* pszAccessKey, const char* pszSecretKey, const char* pszBaseUrl, const char* pszUserAgent /* = NULL */)
{
AssertPtrReturn(ppS3, VERR_INVALID_POINTER);
/* We need at least an URL to connect with */
if (pszBaseUrl == NULL ||
pszBaseUrl[0] == 0)
return VERR_INVALID_PARAMETER;
/* In windows, this will init the winsock stuff */
if (curl_global_init(CURL_GLOBAL_ALL) != 0)
return VERR_INTERNAL_ERROR;
CURL* pCurl = curl_easy_init();
if (!pCurl)
return VERR_INTERNAL_ERROR;
PRTS3INTERNAL pS3Int = (PRTS3INTERNAL)RTMemAllocZ(sizeof(RTS3INTERNAL));
if (pS3Int == NULL)
return VERR_NO_MEMORY;
pS3Int->u32Magic = RTS3_MAGIC;
pS3Int->pCurl = pCurl;
pS3Int->pszAccessKey = RTStrDup(pszAccessKey);
pS3Int->pszSecretKey = RTStrDup(pszSecretKey);
pS3Int->pszBaseUrl = RTStrDup(pszBaseUrl);
if (pszUserAgent)
pS3Int->pszUserAgent = RTStrDup(pszUserAgent);
*ppS3 = (RTS3)pS3Int;
return VINF_SUCCESS;
}
开发者ID:mcenirm,项目名称:vbox,代码行数:33,代码来源:s3.cpp
示例2: ScmSvnSetProperty
/**
* Schedules the setting of a property.
*
* @returns IPRT status code.
* @retval VERR_INVALID_STATE if not a SVN WC file.
* @param pState The rewrite state to work on.
* @param pszName The name of the property to set.
* @param pszValue The value. NULL means deleting it.
*/
int ScmSvnSetProperty(PSCMRWSTATE pState, const char *pszName, const char *pszValue)
{
/*
* Update any existing entry first.
*/
size_t i = pState->cSvnPropChanges;
while (i-- > 0)
if (!strcmp(pState->paSvnPropChanges[i].pszName, pszName))
{
if (!pszValue)
{
RTStrFree(pState->paSvnPropChanges[i].pszValue);
pState->paSvnPropChanges[i].pszValue = NULL;
}
else
{
char *pszCopy;
int rc = RTStrDupEx(&pszCopy, pszValue);
if (RT_FAILURE(rc))
return rc;
pState->paSvnPropChanges[i].pszValue = pszCopy;
}
return VINF_SUCCESS;
}
/*
* Insert a new entry.
*/
i = pState->cSvnPropChanges;
if ((i % 32) == 0)
{
void *pvNew = RTMemRealloc(pState->paSvnPropChanges, (i + 32) * sizeof(SCMSVNPROP));
if (!pvNew)
return VERR_NO_MEMORY;
pState->paSvnPropChanges = (PSCMSVNPROP)pvNew;
}
pState->paSvnPropChanges[i].pszName = RTStrDup(pszName);
pState->paSvnPropChanges[i].pszValue = pszValue ? RTStrDup(pszValue) : NULL;
if ( pState->paSvnPropChanges[i].pszName
&& (pState->paSvnPropChanges[i].pszValue || !pszValue) )
pState->cSvnPropChanges = i + 1;
else
{
RTStrFree(pState->paSvnPropChanges[i].pszName);
pState->paSvnPropChanges[i].pszName = NULL;
RTStrFree(pState->paSvnPropChanges[i].pszValue);
pState->paSvnPropChanges[i].pszValue = NULL;
return VERR_NO_MEMORY;
}
return VINF_SUCCESS;
}
开发者ID:bringhurst,项目名称:vbox,代码行数:61,代码来源:scmsubversion.cpp
示例3: AssertPtrReturn
int DnDURIList::AppendNativePath(const char *pszPath, uint32_t fFlags)
{
AssertPtrReturn(pszPath, VERR_INVALID_POINTER);
int rc;
char *pszPathNative = RTStrDup(pszPath);
if (pszPathNative)
{
RTPathChangeToUnixSlashes(pszPathNative, true /* fForce */);
char *pszPathURI = RTUriCreate("file" /* pszScheme */, "/" /* pszAuthority */,
pszPathNative, NULL /* pszQuery */, NULL /* pszFragment */);
if (pszPathURI)
{
rc = AppendURIPath(pszPathURI, fFlags);
RTStrFree(pszPathURI);
}
else
rc = VERR_INVALID_PARAMETER;
RTStrFree(pszPathNative);
}
else
rc = VERR_NO_MEMORY;
return rc;
}
开发者ID:mcenirm,项目名称:vbox,代码行数:27,代码来源:DnDURIList.cpp
示例4: RTSemFastMutexRequest
PUSBDEVICE USBProxyBackendUsbIp::getDevices(void)
{
PUSBDEVICE pFirst = NULL;
PUSBDEVICE *ppNext = &pFirst;
/* Create a deep copy of the device list. */
RTSemFastMutexRequest(m->hMtxDevices);
PUSBDEVICE pCur = m->pUsbDevicesCur;
while (pCur)
{
PUSBDEVICE pNew = (PUSBDEVICE)RTMemAllocZ(sizeof(USBDEVICE));
if (pNew)
{
pNew->pszManufacturer = RTStrDup(pCur->pszManufacturer);
pNew->pszProduct = RTStrDup(pCur->pszProduct);
if (pCur->pszSerialNumber)
pNew->pszSerialNumber = RTStrDup(pCur->pszSerialNumber);
pNew->pszBackend = RTStrDup(pCur->pszBackend);
pNew->pszAddress = RTStrDup(pCur->pszAddress);
pNew->idVendor = pCur->idVendor;
pNew->idProduct = pCur->idProduct;
pNew->bcdDevice = pCur->bcdDevice;
pNew->bcdUSB = pCur->bcdUSB;
pNew->bDeviceClass = pCur->bDeviceClass;
pNew->bDeviceSubClass = pCur->bDeviceSubClass;
pNew->bDeviceProtocol = pCur->bDeviceProtocol;
pNew->bNumConfigurations = pCur->bNumConfigurations;
pNew->enmState = pCur->enmState;
pNew->u64SerialHash = pCur->u64SerialHash;
pNew->bBus = pCur->bBus;
pNew->bPort = pCur->bPort;
pNew->enmSpeed = pCur->enmSpeed;
/* link it */
pNew->pNext = NULL;
pNew->pPrev = *ppNext;
*ppNext = pNew;
ppNext = &pNew->pNext;
}
pCur = pCur->pNext;
}
RTSemFastMutexRelease(m->hMtxDevices);
return pFirst;
}
开发者ID:jeppeter,项目名称:vbox,代码行数:47,代码来源:USBProxyBackendUsbIp.cpp
示例5: rtS3ExtractAllKeys
static void rtS3ExtractAllKeys(xmlDocPtr pDoc, xmlNodePtr pNode, PCRTS3KEYENTRY *ppKeys)
{
if (pNode != NULL)
{
PRTS3KEYENTRY pPrevKey = NULL;
xmlNodePtr pCurKey = pNode->xmlChildrenNode;
while (pCurKey != NULL)
{
if ((!xmlStrcmp(pCurKey->name, (const xmlChar *)"Contents")))
{
PRTS3KEYENTRY pKey = (PRTS3KEYENTRY)RTMemAllocZ(sizeof(RTS3KEYENTRY));
pKey->pPrev = pPrevKey;
if (pPrevKey)
pPrevKey->pNext = pKey;
else
(*ppKeys) = pKey;
pPrevKey = pKey;
xmlNodePtr pCurCont = pCurKey->xmlChildrenNode;
while (pCurCont != NULL)
{
if ((!xmlStrcmp(pCurCont->name, (const xmlChar *)"Key")))
{
xmlChar *pszKey = xmlNodeListGetString(pDoc, pCurCont->xmlChildrenNode, 1);
pKey->pszName = RTStrDup((const char*)pszKey);
xmlFree(pszKey);
}
if ((!xmlStrcmp(pCurCont->name, (const xmlChar*)"LastModified")))
{
xmlChar *pszKey = xmlNodeListGetString(pDoc, pCurCont->xmlChildrenNode, 1);
pKey->pszLastModified = RTStrDup((const char*)pszKey);
xmlFree(pszKey);
}
if ((!xmlStrcmp(pCurCont->name, (const xmlChar*)"Size")))
{
xmlChar *pszKey = xmlNodeListGetString(pDoc, pCurCont->xmlChildrenNode, 1);
pKey->cbFile = RTStrToUInt64((const char*)pszKey);
xmlFree(pszKey);
}
pCurCont = pCurCont->next;
}
}
pCurKey = pCurKey->next;
}
}
}
开发者ID:mcenirm,项目名称:vbox,代码行数:45,代码来源:s3.cpp
示例6: RT_ZERO
/**
* Search for a USB test device and return the device path.
*
* @returns Path to the USB test device or NULL if none was found.
*/
static char *usbTestFindDevice(void)
{
/*
* Very crude and quick way to search for the correct test device.
* Assumption is that the path looks like /dev/bus/usb/%3d/%3d.
*/
uint8_t uBus = 1;
bool fBusExists = false;
char aszDevPath[64];
RT_ZERO(aszDevPath);
do
{
RTStrPrintf(aszDevPath, sizeof(aszDevPath), "/dev/bus/usb/%03d", uBus);
fBusExists = RTPathExists(aszDevPath);
if (fBusExists)
{
/* Check every device. */
bool fDevExists = false;
uint8_t uDev = 1;
do
{
RTStrPrintf(aszDevPath, sizeof(aszDevPath), "/dev/bus/usb/%03d/%03d", uBus, uDev);
fDevExists = RTPathExists(aszDevPath);
if (fDevExists)
{
RTFILE hFileDev;
int rc = RTFileOpen(&hFileDev, aszDevPath, RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_NONE);
if (RT_SUCCESS(rc))
{
USBDEVDESC DevDesc;
rc = RTFileRead(hFileDev, &DevDesc, sizeof(DevDesc), NULL);
RTFileClose(hFileDev);
if ( RT_SUCCESS(rc)
&& DevDesc.idVendor == 0x0525
&& DevDesc.idProduct == 0xa4a0)
return RTStrDup(aszDevPath);
}
}
uDev++;
} while (fDevExists);
}
uBus++;
} while (fBusExists);
return NULL;
}
开发者ID:mcenirm,项目名称:vbox,代码行数:62,代码来源:UsbTest.cpp
示例7: m
MemoryBuf::MemoryBuf (const char *aBuf, size_t aLen, const char *aURI /* = NULL */)
: m (new Data())
{
if (aBuf == NULL)
throw EInvalidArg (RT_SRC_POS);
m->buf = aBuf;
m->len = aLen;
m->uri = RTStrDup (aURI);
}
开发者ID:marktsai0316,项目名称:VirtualMonitor,代码行数:10,代码来源:xml.cpp
示例8: tst1
static void tst1(size_t cTest, size_t cchDigits, char chSep)
{
RTTestISubF("tst #%u (digits: %u; sep: %c)", cTest, cchDigits, chSep ? chSep : ' ');
/* We try to create max possible + one. */
size_t cTimes = 1;
for (size_t i = 0; i < cchDigits; ++i)
cTimes *= 10;
/* Allocate the result array. */
char **papszNames = (char **)RTMemTmpAllocZ(cTimes * sizeof(char *));
RTTESTI_CHECK_RETV(papszNames != NULL);
int rc = VERR_INTERNAL_ERROR;
/* The test loop. */
size_t i;
for (i = 0; i < cTimes; i++)
{
char szName[RTPATH_MAX];
RTTESTI_CHECK_RC(rc = RTPathAppend(strcpy(szName, g_szTempPath), sizeof(szName), "RTDirCreateUniqueNumbered"), VINF_SUCCESS);
if (RT_FAILURE(rc))
break;
RTTESTI_CHECK_RC(rc = RTDirCreateUniqueNumbered(szName, sizeof(szName), 0700, cchDigits, chSep), VINF_SUCCESS);
if (RT_FAILURE(rc))
{
RTTestIFailed("RTDirCreateUniqueNumbered(%s) call #%u -> %Rrc\n", szName, i, rc);
break;
}
RTTESTI_CHECK(papszNames[i] = RTStrDup(szName));
if (!papszNames[i])
break;
RTTestIPrintf(RTTESTLVL_DEBUG, "%s\n", papszNames[i]);
}
/* Try to create one more, which shouldn't be possible. */
if (RT_SUCCESS(rc))
{
char szName[RTPATH_MAX];
RTTESTI_CHECK_RC(rc = RTPathAppend(strcpy(szName, g_szTempPath), sizeof(szName), "RTDirCreateUniqueNumbered"), VINF_SUCCESS);
if (RT_SUCCESS(rc))
RTTESTI_CHECK_RC(rc = RTDirCreateUniqueNumbered(szName, sizeof(szName), 0700, cchDigits, chSep), VERR_ALREADY_EXISTS);
}
/* cleanup */
while (i-- > 0)
{
RTTESTI_CHECK_RC(RTDirRemove(papszNames[i]), VINF_SUCCESS);
RTStrFree(papszNames[i]);
}
RTMemTmpFree(papszNames);
}
开发者ID:miguelinux,项目名称:vbox,代码行数:54,代码来源:tstRTDirCreateUniqueNumbered.cpp
示例9: RTR3DECL
RTR3DECL(int) RTHttpGetRedirLocation(RTHTTP hHttp, char **ppszRedirLocation)
{
PRTHTTPINTERNAL pHttpInt = hHttp;
RTHTTP_VALID_RETURN(pHttpInt);
if (!pHttpInt->pszRedirLocation)
return VERR_HTTP_NOT_FOUND;
*ppszRedirLocation = RTStrDup(pHttpInt->pszRedirLocation);
return VINF_SUCCESS;
}
开发者ID:Klanly,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:11,代码来源:http.cpp
示例10: RTUriFilePath
/* static */
int DnDURIObject::RebaseURIPath(RTCString &strPathAbs,
const RTCString &strBaseOld /* = "" */,
const RTCString &strBaseNew /* = "" */)
{
char *pszPath = RTUriFilePath(strPathAbs.c_str());
if (!pszPath) /* No URI? */
pszPath = RTStrDup(strPathAbs.c_str());
int rc;
if (pszPath)
{
const char *pszPathStart = pszPath;
const char *pszBaseOld = strBaseOld.c_str();
if ( pszBaseOld
&& RTPathStartsWith(pszPath, pszBaseOld))
{
pszPathStart += strlen(pszBaseOld);
}
rc = VINF_SUCCESS;
if (RT_SUCCESS(rc))
{
char *pszPathNew = RTPathJoinA(strBaseNew.c_str(), pszPathStart);
if (pszPathNew)
{
char *pszPathURI = RTUriCreate("file" /* pszScheme */, "/" /* pszAuthority */,
pszPathNew /* pszPath */,
NULL /* pszQuery */, NULL /* pszFragment */);
if (pszPathURI)
{
LogFlowFunc(("Rebasing \"%s\" to \"%s\"\n", strPathAbs.c_str(), pszPathURI));
strPathAbs = RTCString(pszPathURI) + "\r\n";
RTStrFree(pszPathURI);
}
else
rc = VERR_INVALID_PARAMETER;
RTStrFree(pszPathNew);
}
else
rc = VERR_NO_MEMORY;
}
RTStrFree(pszPath);
}
else
rc = VERR_NO_MEMORY;
return rc;
}
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:54,代码来源:DnDURIObject.cpp
示例11: rtS3ExtractAllBuckets
static void rtS3ExtractAllBuckets(xmlDocPtr pDoc, xmlNodePtr pNode, PCRTS3BUCKETENTRY *ppBuckets)
{
pNode = rtS3FindNode(pNode, "Buckets");
if (pNode != NULL)
{
PRTS3BUCKETENTRY pPrevBucket = NULL;
xmlNodePtr pCurBucket = pNode->xmlChildrenNode;
while (pCurBucket != NULL)
{
if ((!xmlStrcmp(pCurBucket->name, (const xmlChar *)"Bucket")))
{
PRTS3BUCKETENTRY pBucket = (PRTS3BUCKETENTRY)RTMemAllocZ(sizeof(RTS3BUCKETENTRY));
pBucket->pPrev = pPrevBucket;
if (pPrevBucket)
pPrevBucket->pNext = pBucket;
else
(*ppBuckets) = pBucket;
pPrevBucket = pBucket;
xmlNodePtr pCurCont = pCurBucket->xmlChildrenNode;
while (pCurCont != NULL)
{
if ((!xmlStrcmp(pCurCont->name, (const xmlChar *)"Name")))
{
xmlChar *pszKey = xmlNodeListGetString(pDoc, pCurCont->xmlChildrenNode, 1);
pBucket->pszName = RTStrDup((const char*)pszKey);
xmlFree(pszKey);
}
if ((!xmlStrcmp(pCurCont->name, (const xmlChar*)"CreationDate")))
{
xmlChar *pszKey = xmlNodeListGetString(pDoc, pCurCont->xmlChildrenNode, 1);
pBucket->pszCreationDate = RTStrDup((const char*)pszKey);
xmlFree(pszKey);
}
pCurCont = pCurCont->next;
}
}
pCurBucket = pCurBucket->next;
}
}
}
开发者ID:mcenirm,项目名称:vbox,代码行数:40,代码来源:s3.cpp
示例12: alock
HRESULT VFSExplorer::cdUp(ComPtr<IProgress> &aProgress)
{
Utf8Str strUpPath;
{
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
/* Remove lowest dir entry in a platform neutral way. */
char *pszNewPath = RTStrDup(m->strPath.c_str());
RTPathStripTrailingSlash(pszNewPath);
RTPathStripFilename(pszNewPath);
strUpPath = pszNewPath;
RTStrFree(pszNewPath);
}
return cd(strUpPath, aProgress);
}
开发者ID:mcenirm,项目名称:vbox,代码行数:15,代码来源:VFSExplorerImpl.cpp
示例13: rtR0DbgKrnlInfoModRetainEx
/**
* Helper for opening the specified kernel module.
*
* @param pszModule The name of the module.
* @param ppMod Where to store the module handle.
* @param ppCtf Where to store the module's CTF handle.
*
* @returns Pointer to the CTF structure for the module.
*/
static int rtR0DbgKrnlInfoModRetainEx(const char *pszModule, modctl_t **ppMod, ctf_file_t **ppCtf)
{
char *pszMod = RTStrDup(pszModule);
if (RT_LIKELY(pszMod))
{
int rc = rtR0DbgKrnlInfoModRetain(pszMod, ppMod, ppCtf);
RTStrFree(pszMod);
if (RT_SUCCESS(rc))
{
AssertPtrReturn(*ppMod, VERR_INTERNAL_ERROR_2);
AssertPtrReturn(*ppCtf, VERR_INTERNAL_ERROR_3);
}
return rc;
}
return VERR_NO_MEMORY;
}
开发者ID:svn2github,项目名称:virtualbox,代码行数:25,代码来源:dbgkrnlinfo-r0drv-solaris.c
示例14: autoCaller
STDMETHODIMP VFSExplorer::CdUp(IProgress **aProgress)
{
AutoCaller autoCaller(this);
if (FAILED(autoCaller.rc())) return autoCaller.rc();
Utf8Str strUpPath;
{
AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
/* Remove lowest dir entry in a platform neutral way. */
char *pszNewPath = RTStrDup(m->strPath.c_str());
RTPathStripTrailingSlash(pszNewPath);
RTPathStripFilename(pszNewPath);
strUpPath = pszNewPath;
RTStrFree(pszNewPath);
}
return Cd(Bstr(strUpPath).raw(), aProgress);
}
开发者ID:MadHacker217,项目名称:VirtualBox-OSE,代码行数:18,代码来源:VFSExplorerImpl.cpp
示例15: rtTarFileCreateForWrite
/* Only used for write handles. */
static PRTTARFILEINTERNAL rtTarFileCreateForWrite(PRTTARINTERNAL pInt, const char *pszFilename, uint32_t fOpen)
{
PRTTARFILEINTERNAL pFileInt = (PRTTARFILEINTERNAL)RTMemAllocZ(sizeof(RTTARFILEINTERNAL));
if (!pFileInt)
return NULL;
pFileInt->u32Magic = RTTARFILE_MAGIC;
pFileInt->pTar = pInt;
pFileInt->fOpenMode = fOpen;
pFileInt->pszFilename = RTStrDup(pszFilename);
pFileInt->hVfsIos = NIL_RTVFSIOSTREAM;
if (pFileInt->pszFilename)
return pFileInt;
RTMemFree(pFileInt);
return NULL;
}
开发者ID:mcenirm,项目名称:vbox,代码行数:19,代码来源:tar.cpp
示例16: tstDirCreateTemp
static void tstDirCreateTemp(const char *pszSubTest, const char *pszTemplate, unsigned cTimes, bool fSkipXCheck)
{
RTTestISub(pszSubTest);
/* Allocate the result array. */
char **papszNames = (char **)RTMemTmpAllocZ(cTimes * sizeof(char *));
RTTESTI_CHECK_RETV(papszNames != NULL);
/* The test loop. */
unsigned i;
for (i = 0; i < cTimes; i++)
{
int rc;
char szName[RTPATH_MAX];
RTTESTI_CHECK_RC(rc = RTPathAppend(strcpy(szName, g_szTempPath), sizeof(szName), pszTemplate), VINF_SUCCESS);
if (RT_FAILURE(rc))
break;
RTTESTI_CHECK(papszNames[i] = RTStrDup(szName));
if (!papszNames[i])
break;
rc = RTDirCreateTemp(papszNames[i]);
if (rc != VINF_SUCCESS)
{
RTTestIFailed("RTDirCreateTemp(%s) call #%u -> %Rrc\n", szName, i, rc);
RTStrFree(papszNames[i]);
papszNames[i] = NULL;
break;
}
RTTestIPrintf(RTTESTLVL_DEBUG, "%s\n", papszNames[i]);
RTTESTI_CHECK_MSG(strlen(szName) == strlen(papszNames[i]), ("szName %s\nReturned %s\n", szName, papszNames[i]));
if (!fSkipXCheck)
RTTESTI_CHECK_MSG(strchr(RTPathFilename(papszNames[i]), 'X') == NULL, ("szName %s\nReturned %s\n", szName, papszNames[i]));
}
/* cleanup */
while (i-- > 0)
{
RTTESTI_CHECK_RC(RTDirRemove(papszNames[i]), VINF_SUCCESS);
RTStrFree(papszNames[i]);
}
RTMemTmpFree(papszNames);
}
开发者ID:virendramishra,项目名称:VirtualBox4.1.18,代码行数:44,代码来源:tstRTTemp.cpp
示例17: RTDECL
/**
* Add an entry for an I/O stream using a passthru stream.
*
* The passthru I/O stream will hash all the data read from or written to the
* stream and automatically add an entry to the manifest with the desired
* attributes when it is released. Alternatively one can call
* RTManifestPtIosAddEntryNow() to have more control over exactly when this
* action is performed and which status it yields.
*
* @returns IPRT status code.
* @param hManifest The manifest to add the entry to.
* @param hVfsIos The I/O stream to pass thru to/from.
* @param pszEntry The entry name.
* @param fAttrs The attributes to create for this stream.
* @param fReadOrWrite Whether it's a read or write I/O stream.
* @param phVfsIosPassthru Where to return the new handle.
*/
RTDECL(int) RTManifestEntryAddPassthruIoStream(RTMANIFEST hManifest, RTVFSIOSTREAM hVfsIos, const char *pszEntry,
uint32_t fAttrs, bool fReadOrWrite, PRTVFSIOSTREAM phVfsIosPassthru)
{
/*
* Validate input.
*/
AssertReturn(fAttrs < RTMANIFEST_ATTR_END, VERR_INVALID_PARAMETER);
AssertPtr(pszEntry);
AssertPtr(phVfsIosPassthru);
uint32_t cRefs = RTManifestRetain(hManifest);
AssertReturn(cRefs != UINT32_MAX, VERR_INVALID_HANDLE);
cRefs = RTVfsIoStrmRetain(hVfsIos);
AssertReturnStmt(cRefs != UINT32_MAX, RTManifestRelease(hManifest), VERR_INVALID_HANDLE);
/*
* Create an instace of the passthru I/O stream.
*/
PRTMANIFESTPTIOS pThis;
RTVFSIOSTREAM hVfsPtIos;
int rc = RTVfsNewIoStream(&g_rtManifestPassthruIosOps, sizeof(*pThis), fReadOrWrite ? RTFILE_O_READ : RTFILE_O_WRITE,
NIL_RTVFS, NIL_RTVFSLOCK, &hVfsPtIos, (void **)&pThis);
if (RT_SUCCESS(rc))
{
pThis->hVfsIos = hVfsIos;
pThis->pHashes = rtManifestHashesCreate(fAttrs);
pThis->hManifest = hManifest;
pThis->fReadOrWrite = fReadOrWrite;
pThis->fAddedEntry = false;
pThis->pszEntry = RTStrDup(pszEntry);
if (pThis->pszEntry && pThis->pHashes)
{
*phVfsIosPassthru = hVfsPtIos;
return VINF_SUCCESS;
}
RTVfsIoStrmRelease(hVfsPtIos);
}
else
{
RTVfsIoStrmRelease(hVfsIos);
RTManifestRelease(hManifest);
}
return rc;
}
开发者ID:stefano-garzarella,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:61,代码来源:manifest3.cpp
示例18: IsTestcaseIncluded
/**
* Checks if a testcase is include or should be skipped.
*
* @param pszTestcase The testcase (filename).
*
* @return true if the testcase is included.
* false if the testcase should be skipped.
*/
static bool IsTestcaseIncluded(const char *pszTestcase)
{
/* exclude special modules based on extension. */
const char *pszExt = RTPathExt(pszTestcase);
if ( !RTStrICmp(pszExt, ".r0")
|| !RTStrICmp(pszExt, ".gc")
|| !RTStrICmp(pszExt, ".sys")
|| !RTStrICmp(pszExt, ".ko")
|| !RTStrICmp(pszExt, ".o")
|| !RTStrICmp(pszExt, ".obj")
|| !RTStrICmp(pszExt, ".lib")
|| !RTStrICmp(pszExt, ".a")
|| !RTStrICmp(pszExt, ".so")
|| !RTStrICmp(pszExt, ".dll")
|| !RTStrICmp(pszExt, ".dylib")
|| !RTStrICmp(pszExt, ".tmp")
|| !RTStrICmp(pszExt, ".log")
)
return false;
/* check by name */
char *pszDup = RTStrDup(pszTestcase);
if (pszDup)
{
RTPathStripExt(pszDup);
for (unsigned i = 0; i < RT_ELEMENTS(g_apszExclude); i++)
{
if (!strcmp(g_apszExclude[i], pszDup))
{
RTStrFree(pszDup);
return false;
}
}
RTStrFree(pszDup);
return true;
}
RTPrintf("tstRunTestcases: Out of memory!\n");
return false;
}
开发者ID:leopucci,项目名称:VirtualMonitor,代码行数:48,代码来源:tstRunTestcases.cpp
示例19: defined
int AutostartDb::setAutostartDbPath(const char *pszAutostartDbPathNew)
{
#if defined(RT_OS_LINUX)
char *pszAutostartDbPathTmp = NULL;
if (pszAutostartDbPathNew)
{
pszAutostartDbPathTmp = RTStrDup(pszAutostartDbPathNew);
if (!pszAutostartDbPathTmp)
return VERR_NO_MEMORY;
}
RTCritSectEnter(&this->CritSect);
if (m_pszAutostartDbPath)
RTStrFree(m_pszAutostartDbPath);
m_pszAutostartDbPath = pszAutostartDbPathTmp;
RTCritSectLeave(&this->CritSect);
return VINF_SUCCESS;
#else
NOREF(pszAutostartDbPathNew);
return VERR_NOT_SUPPORTED;
#endif
}
开发者ID:gvsurenderreddy,项目名称:virtualbox,代码行数:24,代码来源:AutostartDb-generic.cpp
示例20: autostartConfigParseValue
/**
* Parse a key value node and returns the AST.
*
* @returns VBox status code.
* @param pCfgTokenizer The tokenizer for the config stream.
* @param pszKey The key for the pair.
* @param ppCfgAst Where to store the resulting AST on success.
*/
static int autostartConfigParseValue(PCFGTOKENIZER pCfgTokenizer, const char *pszKey,
PCFGAST *ppCfgAst)
{
int rc = VINF_SUCCESS;
PCFGTOKEN pToken = NULL;
rc = autostartConfigTokenizerGetNextToken(pCfgTokenizer, &pToken);
if ( RT_SUCCESS(rc)
&& pToken->enmType == CFGTOKENTYPE_ID)
{
PCFGAST pCfgAst = NULL;
pCfgAst = (PCFGAST)RTMemAllocZ(RT_OFFSETOF(CFGAST, u.KeyValue.aszValue[pToken->u.Id.cchToken + 1]));
if (!pCfgAst)
return VERR_NO_MEMORY;
pCfgAst->enmType = CFGASTNODETYPE_KEYVALUE;
pCfgAst->pszKey = RTStrDup(pszKey);
if (!pCfgAst->pszKey)
{
RTMemFree(pCfgAst);
return VERR_NO_MEMORY;
}
memcpy(pCfgAst->u.KeyValue.aszValue, pToken->u.Id.achToken, pToken->u.Id.cchToken);
pCfgAst->u.KeyValue.cchValue = pToken->u.Id.cchToken;
*ppCfgAst = pCfgAst;
}
else
{
autostartConfigTokenizerMsgUnexpectedToken(pToken, "non reserved token");
rc = VERR_INVALID_PARAMETER;
}
return rc;
}
开发者ID:VirtualMonitor,项目名称:VirtualMonitor,代码行数:44,代码来源:VBoxAutostartCfg.cpp
注:本文中的RTStrDup函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论