本文整理汇总了C++中RT_ZERO函数的典型用法代码示例。如果您正苦于以下问题:C++ RT_ZERO函数的具体用法?C++ RT_ZERO怎么用?C++ RT_ZERO使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RT_ZERO函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prepareReplyPacket4Client
/**
* Network manager creates DHCPACK
*/
int NetworkManager::ack(const Client& client, uint32_t u32Xid,
uint8_t *pu8ReqList, int cReqList)
{
RTNETADDRIPV4 address;
prepareReplyPacket4Client(client, u32Xid);
Lease l = client.lease();
address = l.getAddress();
m->BootPReplyMsg.BootPHeader.bp_ciaddr = address;
/* rfc2131 4.3.1 is about DHCPDISCOVER and this value is equal to ciaddr from
* DHCPREQUEST or 0 ...
* XXX: Using addressHint is not correct way to initialize [cy]iaddress...
*/
m->BootPReplyMsg.BootPHeader.bp_ciaddr = address;
m->BootPReplyMsg.BootPHeader.bp_yiaddr = address;
Assert(m->BootPReplyMsg.BootPHeader.bp_yiaddr.u);
/* options:
* - IP address lease time (if DHCPREQUEST)
* - message type
* - server identifier
*/
RawOption opt;
RT_ZERO(opt);
std::vector<RawOption> extra;
opt.u8OptId = RTNET_DHCP_OPT_MSG_TYPE;
opt.au8RawOpt[0] = RTNET_DHCP_MT_ACK;
opt.cbRawOpt = 1;
extra.push_back(opt);
/*
* XXX: lease time should be conditional. If on dhcprequest then tim should be provided,
* else on dhcpinform it mustn't.
*/
opt.u8OptId = RTNET_DHCP_OPT_LEASE_TIME;
*(uint32_t *)opt.au8RawOpt = RT_H2N_U32(l.getExpiration());
opt.cbRawOpt = sizeof(RTNETADDRIPV4);
extra.push_back(opt);
processParameterReqList(client, pu8ReqList, cReqList, extra);
return doReply(client, extra);
}
示例2: vbglR3DnDHGProcessSendFileMessage
static int vbglR3DnDHGProcessSendFileMessage(uint32_t uClientId,
char *pszFilename,
uint32_t cbFilename,
uint32_t *pcbFilenameRecv,
void *pvData,
uint32_t cbData,
uint32_t *pcbDataRecv,
uint32_t *pfMode)
{
/* Validate input */
AssertPtrReturn(pszFilename, VERR_INVALID_POINTER);
AssertReturn(cbFilename, VERR_INVALID_PARAMETER);
AssertPtrReturn(pcbFilenameRecv, VERR_INVALID_POINTER);
AssertPtrReturn(pvData, VERR_INVALID_POINTER);
AssertReturn(cbData, VERR_INVALID_PARAMETER);
AssertPtrReturn(pcbDataRecv, VERR_INVALID_POINTER);
AssertPtrReturn(pfMode, VERR_INVALID_POINTER);
/* Initialize header */
DragAndDropSvc::VBOXDNDHGSENDFILEMSG Msg;
RT_ZERO(Msg);
Msg.hdr.u32ClientID = uClientId;
Msg.hdr.u32Function = DragAndDropSvc::HOST_DND_HG_SND_FILE;
Msg.hdr.cParms = 5;
/* Initialize parameter */
Msg.pvName.SetPtr(pszFilename, cbFilename);
Msg.cName.SetUInt32(0);
Msg.pvData.SetPtr(pvData, cbData);
Msg.cData.SetUInt32(0);
Msg.fMode.SetUInt32(0);
/* Do request */
int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
if (RT_SUCCESS(rc))
{
rc = Msg.hdr.result;
if (RT_SUCCESS(rc))
{
/* Fetch results */
rc = Msg.cName.GetUInt32(pcbFilenameRecv); AssertRC(rc);
rc = Msg.cData.GetUInt32(pcbDataRecv); AssertRC(rc);
rc = Msg.fMode.GetUInt32(pfMode); AssertRC(rc);
/* A little bit paranoia */
AssertReturn(cbFilename >= *pcbFilenameRecv, VERR_TOO_MUCH_DATA);
AssertReturn(cbData >= *pcbDataRecv, VERR_TOO_MUCH_DATA);
}
}
return rc;
}
示例3: rtLocalIpcWinCreateSession
/**
* Create a session instance.
*
* @returns IPRT status code.
*
* @param phClientSession Where to store the session handle on success.
* @param hNmPipeSession The named pipe handle. This will be consumed by this session, meaning on failure
* to create the session it will be closed.
*/
static int rtLocalIpcWinCreateSession(PRTLOCALIPCSESSION phClientSession, HANDLE hNmPipeSession)
{
AssertPtrReturn(phClientSession, VERR_INVALID_POINTER);
AssertReturn(hNmPipeSession != INVALID_HANDLE_VALUE, VERR_INVALID_HANDLE);
int rc;
/*
* Allocate and initialize the session instance data.
*/
PRTLOCALIPCSESSIONINT pThis = (PRTLOCALIPCSESSIONINT)RTMemAlloc(sizeof(*pThis));
if (pThis)
{
pThis->u32Magic = RTLOCALIPCSESSION_MAGIC;
pThis->cRefs = 1; /* our ref */
pThis->fCancelled = false;
pThis->fIOPending = false;
pThis->fZeroByteRead = false;
pThis->hNmPipe = hNmPipeSession;
rc = RTCritSectInit(&pThis->CritSect);
if (RT_SUCCESS(rc))
{
pThis->hEvent = CreateEvent(NULL /*lpEventAttributes*/, TRUE /*bManualReset*/,
FALSE /*bInitialState*/, NULL /*lpName*/);
if (pThis->hEvent != NULL)
{
RT_ZERO(pThis->OverlappedIO);
pThis->OverlappedIO.Internal = STATUS_PENDING;
pThis->OverlappedIO.hEvent = pThis->hEvent;
*phClientSession = pThis;
return VINF_SUCCESS;
}
/* bail out */
rc = RTErrConvertFromWin32(GetLastError());
RTCritSectDelete(&pThis->CritSect);
}
RTMemFree(pThis);
}
else
rc = VERR_NO_MEMORY;
BOOL fRc = CloseHandle(hNmPipeSession);
AssertMsg(fRc, ("%d\n", GetLastError())); NOREF(fRc);
return rc;
}
示例4: vboxTrayRemoveTrayIcon
static void vboxTrayRemoveTrayIcon()
{
if (gNotifyIconData.cbSize > 0)
{
/* Remove the system tray icon and refresh system tray. */
Shell_NotifyIcon(NIM_DELETE, &gNotifyIconData);
HWND hTrayWnd = FindWindow("Shell_TrayWnd", NULL); /* We assume we only have one tray atm. */
if (hTrayWnd)
{
HWND hTrayNotifyWnd = FindWindowEx(hTrayWnd, 0, "TrayNotifyWnd", NULL);
if (hTrayNotifyWnd)
SendMessage(hTrayNotifyWnd, WM_PAINT, 0, NULL);
}
RT_ZERO(gNotifyIconData);
}
}
示例5: sobindto
/*
* Worker for sobind() below.
*/
static int
sobindto(struct socket *so, uint32_t addr, uint16_t port)
{
struct sockaddr_in self;
int status;
if (addr == INADDR_ANY && port == 0 && so->so_type != IPPROTO_UDP)
{
/* TCP sockets without constraints don't need to be bound */
Log2(("NAT: sobind: %s guest %RTnaipv4:%d - nothing to do\n",
so->so_type == IPPROTO_UDP ? "udp" : "tcp",
so->so_laddr.s_addr, ntohs(so->so_lport)));
return 0;
}
RT_ZERO(self);
#ifdef RT_OS_DARWIN
self.sin_len = sizeof(self);
#endif
self.sin_family = AF_INET;
self.sin_addr.s_addr = addr;
self.sin_port = port;
status = bind(so->s, (struct sockaddr *)&self, sizeof(self));
if (status == 0)
{
Log2(("NAT: sobind: %s guest %RTnaipv4:%d to host %RTnaipv4:%d\n",
so->so_type == IPPROTO_UDP ? "udp" : "tcp",
so->so_laddr.s_addr, ntohs(so->so_lport), addr, ntohs(port)));
return 0;
}
Log2(("NAT: sobind: %s guest %RTnaipv4:%d to host %RTnaipv4:%d error %d%s\n",
so->so_type == IPPROTO_UDP ? "udp" : "tcp",
so->so_laddr.s_addr, ntohs(so->so_lport),
addr, ntohs(port),
errno, port ? " (will retry with random port)" : ""));
if (port) /* retry without */
status = sobindto(so, addr, 0);
if (addr)
return status;
else
return 0;
}
示例6: DECLCALLBACK
/**
* @interface_method_impl{RTVFSOBJOPS,pfnQueryInfo}
*/
static DECLCALLBACK(int) rtZipTarFssBaseObj_QueryInfo(void *pvThis, PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr)
{
PRTZIPTARBASEOBJ pThis = (PRTZIPTARBASEOBJ)pvThis;
/*
* Copy the desired data.
*/
switch (enmAddAttr)
{
case RTFSOBJATTRADD_NOTHING:
case RTFSOBJATTRADD_UNIX:
*pObjInfo = pThis->ObjInfo;
break;
case RTFSOBJATTRADD_UNIX_OWNER:
*pObjInfo = pThis->ObjInfo;
pObjInfo->Attr.enmAdditional = RTFSOBJATTRADD_UNIX_OWNER;
pObjInfo->Attr.u.UnixOwner.uid = pThis->ObjInfo.Attr.u.Unix.uid;
pObjInfo->Attr.u.UnixOwner.szName[0] = '\0';
if (rtZipTarReaderHasUserName(pThis->pTarReader))
RTStrCopy(pObjInfo->Attr.u.UnixOwner.szName, sizeof(pObjInfo->Attr.u.UnixOwner.szName),
pThis->pTarReader->Hdr.Common.uname);
break;
case RTFSOBJATTRADD_UNIX_GROUP:
*pObjInfo = pThis->ObjInfo;
pObjInfo->Attr.enmAdditional = RTFSOBJATTRADD_UNIX_GROUP;
pObjInfo->Attr.u.UnixGroup.gid = pThis->ObjInfo.Attr.u.Unix.gid;
pObjInfo->Attr.u.UnixGroup.szName[0] = '\0';
if (rtZipTarReaderHasGroupName(pThis->pTarReader))
RTStrCopy(pObjInfo->Attr.u.UnixGroup.szName, sizeof(pObjInfo->Attr.u.UnixGroup.szName),
pThis->pTarReader->Hdr.Common.gname);
break;
case RTFSOBJATTRADD_EASIZE:
*pObjInfo = pThis->ObjInfo;
pObjInfo->Attr.enmAdditional = RTFSOBJATTRADD_EASIZE;
RT_ZERO(pObjInfo->Attr.u);
break;
default:
return VERR_NOT_SUPPORTED;
}
return VINF_SUCCESS;
}
示例7: VBGLR3DECL
/**
* Reports the Guest Additions status of a certain facility to the host.
*
* @returns IPRT status value
* @param enmFacility The facility to report the status on.
* @param enmStatus The new status of the facility.
* @param fReserved Reserved for future use (what?).
*/
VBGLR3DECL(int) VbglR3ReportAdditionsStatus(VBoxGuestFacilityType enmFacility,
VBoxGuestFacilityStatus enmStatusCurrent,
uint32_t fReserved)
{
VMMDevReportGuestStatus Report;
RT_ZERO(Report);
int rc = vmmdevInitRequest((VMMDevRequestHeader*)&Report, VMMDevReq_ReportGuestStatus);
if (RT_SUCCESS(rc))
{
Report.guestStatus.facility = enmFacility;
Report.guestStatus.status = enmStatusCurrent;
Report.guestStatus.flags = fReserved;
rc = vbglR3GRPerform(&Report.header);
}
return rc;
}
示例8: AssertPtrReturn
err_t VBoxNetLwipNAT::netifLinkoutput(netif *pNetif, pbuf *pPBuf)
{
AssertPtrReturn(pNetif, ERR_ARG);
AssertPtrReturn(pPBuf, ERR_ARG);
VBoxNetLwipNAT *self = static_cast<VBoxNetLwipNAT *>(pNetif->state);
AssertPtrReturn(self, ERR_IF);
AssertReturn(self == g_pLwipNat, ERR_ARG);
LogFlowFunc(("ENTER: pNetif[%c%c%d], pPbuf:%p\n",
pNetif->name[0],
pNetif->name[1],
pNetif->num,
pPBuf));
RT_ZERO(VBoxNetLwipNAT::aXmitSeg);
size_t idx = 0;
for (struct pbuf *q = pPBuf; q != NULL; q = q->next, ++idx)
{
AssertReturn(idx < RT_ELEMENTS(VBoxNetLwipNAT::aXmitSeg), ERR_MEM);
#if ETH_PAD_SIZE
if (q == pPBuf)
{
VBoxNetLwipNAT::aXmitSeg[idx].pv = (uint8_t *)q->payload + ETH_PAD_SIZE;
VBoxNetLwipNAT::aXmitSeg[idx].cb = q->len - ETH_PAD_SIZE;
}
else
#endif
{
VBoxNetLwipNAT::aXmitSeg[idx].pv = q->payload;
VBoxNetLwipNAT::aXmitSeg[idx].cb = q->len;
}
}
int rc = self->sendBufferOnWire(VBoxNetLwipNAT::aXmitSeg, idx,
pPBuf->tot_len - ETH_PAD_SIZE);
AssertRCReturn(rc, ERR_IF);
self->flushWire();
LogFlowFunc(("LEAVE: %d\n", ERR_OK));
return ERR_OK;
}
示例9: RTDECL
RTDECL(void) RTSha1Final(PRTSHA1CONTEXT pCtx, uint8_t pabDigest[RTSHA1_HASH_SIZE])
{
Assert(pCtx->AltPrivate.cbMessage < UINT64_MAX / 2);
/*
* Complete the message by adding a single bit (0x80), padding till
* the next 448-bit boundrary, the add the message length.
*/
uint64_t const cMessageBits = pCtx->AltPrivate.cbMessage * 8;
unsigned cbMissing = RTSHA1_BLOCK_SIZE - ((unsigned)pCtx->AltPrivate.cbMessage & (RTSHA1_BLOCK_SIZE - 1U));
static uint8_t const s_abSingleBitAndSomePadding[12] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, };
if (cbMissing < 1U + 8U)
/* Less than 64+8 bits left in the current block, force a new block. */
RTSha1Update(pCtx, &s_abSingleBitAndSomePadding, sizeof(s_abSingleBitAndSomePadding));
else
RTSha1Update(pCtx, &s_abSingleBitAndSomePadding, 1);
unsigned cbBuffered = (unsigned)pCtx->AltPrivate.cbMessage & (RTSHA1_BLOCK_SIZE - 1U);
cbMissing = RTSHA1_BLOCK_SIZE - cbBuffered;
Assert(cbMissing >= 8);
memset((uint8_t *)&pCtx->AltPrivate.auW[0] + cbBuffered, 0, cbMissing - 8);
*(uint64_t *)&pCtx->AltPrivate.auW[14] = RT_H2BE_U64(cMessageBits);
/*
* Process the last buffered block constructed/completed above.
*/
rtSha1BlockInitBuffered(pCtx);
rtSha1BlockProcess(pCtx);
/*
* Convert the byte order of the hash words and we're done.
*/
pCtx->AltPrivate.auH[0] = RT_H2BE_U32(pCtx->AltPrivate.auH[0]);
pCtx->AltPrivate.auH[1] = RT_H2BE_U32(pCtx->AltPrivate.auH[1]);
pCtx->AltPrivate.auH[2] = RT_H2BE_U32(pCtx->AltPrivate.auH[2]);
pCtx->AltPrivate.auH[3] = RT_H2BE_U32(pCtx->AltPrivate.auH[3]);
pCtx->AltPrivate.auH[4] = RT_H2BE_U32(pCtx->AltPrivate.auH[4]);
memcpy(pabDigest, &pCtx->AltPrivate.auH[0], RTSHA1_HASH_SIZE);
RT_ZERO(pCtx->AltPrivate);
pCtx->AltPrivate.cbMessage = UINT64_MAX;
}
示例10: RTR3DECL
RTR3DECL(int) RTTarClose(RTTAR hTar)
{
if (hTar == NIL_RTTAR)
return VINF_SUCCESS;
PRTTARINTERNAL pInt = hTar;
RTTAR_VALID_RETURN(pInt);
int rc = VINF_SUCCESS;
/* gtar gives a warning, but the documentation says EOF is indicated by a
* zero block. Disabled for now. */
#if 0
{
/* Append the EOF record which is filled all by zeros */
RTTARRECORD record;
RT_ZERO(record);
rc = RTFileWrite(pInt->hTarFile, &record, sizeof(record), NULL);
}
#endif
if (pInt->hVfsFss != NIL_RTVFSFSSTREAM)
{
uint32_t cRefs = RTVfsFsStrmRelease(pInt->hVfsFss); Assert(cRefs != UINT32_MAX);
pInt->hVfsFss = NIL_RTVFSFSSTREAM;
}
if (pInt->hVfsFile != NIL_RTVFSFILE)
{
uint32_t cRefs = RTVfsFileRelease(pInt->hVfsFile); Assert(cRefs != UINT32_MAX);
pInt->hVfsFile = NIL_RTVFSFILE;
}
if (pInt->hTarFile != NIL_RTFILE)
{
rc = RTFileClose(pInt->hTarFile);
pInt->hTarFile = NIL_RTFILE;
}
pInt->u32Magic = RTTAR_MAGIC_DEAD;
RTMemFree(pInt);
return rc;
}
示例11: NetIfGetState
/**
* Obtain the current state of the interface.
*
* @returns VBox status code.
*
* @param pcszIfName Interface name.
* @param penmState Where to store the retrieved state.
*/
int NetIfGetState(const char *pcszIfName, NETIFSTATUS *penmState)
{
int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
if (sock < 0)
return VERR_OUT_OF_RESOURCES;
struct ifreq Req;
RT_ZERO(Req);
RTStrCopy(Req.ifr_name, sizeof(Req.ifr_name), pcszIfName);
if (ioctl(sock, SIOCGIFFLAGS, &Req) < 0)
{
Log(("NetIfGetState: ioctl(SIOCGIFFLAGS) -> %d\n", errno));
*penmState = NETIF_S_UNKNOWN;
}
else
*penmState = (Req.ifr_flags & IFF_UP) ? NETIF_S_UP : NETIF_S_DOWN;
close(sock);
return VINF_SUCCESS;
}
示例12: VBGLR3DECL
VBGLR3DECL(int) VbglR3VrdpGetChangeRequest(bool *pfActive, uint32_t *puExperienceLevel)
{
VMMDevVRDPChangeRequest Req;
RT_ZERO(Req); /* implicit padding */
vmmdevInitRequest(&Req.header, VMMDevReq_GetVRDPChangeRequest); //VMMDEV_REQ_HDR_INIT(&Req.header, sizeof(Req), VMMDevReq_GetVRDPChangeRequest);
int rc = vbglR3GRPerform(&Req.header);
if (RT_SUCCESS(rc))
{
*pfActive = Req.u8VRDPActive != 0;
*puExperienceLevel = Req.u32VRDPExperienceLevel;
}
else
{
*pfActive = false;
*puExperienceLevel = 0;
}
return rc;
}
示例13: RTDECL
RTDECL(int) RTAsn1Time_Clone(PRTASN1TIME pThis, PCRTASN1TIME pSrc, PCRTASN1ALLOCATORVTABLE pAllocator)
{
AssertPtr(pSrc); AssertPtr(pThis); AssertPtr(pAllocator);
RT_ZERO(*pThis);
if (RTAsn1Time_IsPresent(pSrc))
{
AssertReturn(pSrc->Asn1Core.pOps == &g_RTAsn1Time_Vtable, VERR_INTERNAL_ERROR_3);
int rc = RTAsn1Core_CloneContent(&pThis->Asn1Core, &pSrc->Asn1Core, pAllocator);
if (RT_SUCCESS(rc))
{
pThis->Time = pSrc->Time;
return VINF_SUCCESS;
}
return rc;
}
return VINF_SUCCESS;
}
示例14: VBGLR3DECL
VBGLR3DECL(int) VbglR3DnDHGAcknowledgeOperation(uint32_t uAction)
{
DO(("ACK: %u\n", uAction));
/* Initialize header */
DragAndDropSvc::VBOXDNDHGACKOPMSG Msg;
RT_ZERO(Msg);
Msg.hdr.result = VERR_WRONG_ORDER;
Msg.hdr.u32ClientID = g_clientId;
Msg.hdr.u32Function = DragAndDropSvc::GUEST_DND_HG_ACK_OP;
Msg.hdr.cParms = 1;
/* Initialize parameter */
Msg.uAction.SetUInt32(uAction);
/* Do request */
int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
if (RT_SUCCESS(rc))
rc = Msg.hdr.result;
return rc;
}
示例15: testRTFileSetTimes
extern int testRTFileSetTimes(RTFILE File, PCRTTIMESPEC pAccessTime,
PCRTTIMESPEC pModificationTime,
PCRTTIMESPEC pChangeTime,
PCRTTIMESPEC pBirthTime)
{
/* RTPrintf("%s: pFile=%p, *pAccessTime=%lli, *pModificationTime=%lli, *pChangeTime=%lli, *pBirthTime=%lli\n",
__PRETTY_FUNCTION__,
pAccessTime ? (long long)RTTimeSpecGetNano(pAccessTime) : -1,
pModificationTime
? (long long)RTTimeSpecGetNano(pModificationTime) : -1,
pChangeTime ? (long long)RTTimeSpecGetNano(pChangeTime) : -1,
pBirthTime ? (long long)RTTimeSpecGetNano(pBirthTime) : -1); */
if (pAccessTime)
testRTFileSetTimesATime = *pAccessTime;
else
RT_ZERO(testRTFileSetTimesATime);
return VINF_SUCCESS;
}