本文整理汇总了C++中decode_uint32函数的典型用法代码示例。如果您正苦于以下问题:C++ decode_uint32函数的具体用法?C++ decode_uint32怎么用?C++ decode_uint32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了decode_uint32函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _size
Variant PackedDataContainer::_iter_get_ofs(const Variant &p_iter, uint32_t p_offset) {
int size = _size(p_offset);
int pos = p_iter;
if (pos < 0 || pos >= size)
return Variant();
PoolVector<uint8_t>::Read rd = data.read();
const uint8_t *r = &rd[p_offset];
uint32_t type = decode_uint32(r);
bool err = false;
if (type == TYPE_ARRAY) {
uint32_t vpos = decode_uint32(rd.ptr() + p_offset + 8 + pos * 4);
return _get_at_ofs(vpos, rd.ptr(), err);
} else if (type == TYPE_DICT) {
uint32_t vpos = decode_uint32(rd.ptr() + p_offset + 8 + pos * 12 + 4);
return _get_at_ofs(vpos, rd.ptr(), err);
} else {
ERR_FAIL_V(Variant());
}
}
示例2: decode_recur
void
decode_recur(DBusMessageIter *iter, int *err, alarm_recur_t *rec)
{
decode_uint64 (iter, err, &rec->mask_min);
decode_uint32 (iter, err, &rec->mask_hour);
decode_uint32 (iter, err, &rec->mask_mday);
decode_uint32 (iter, err, &rec->mask_wday);
decode_uint32 (iter, err, &rec->mask_mon);
decode_uint32 (iter, err, &rec->special);
}
示例3: decode_uint32
Variant PackedDataContainer::_get_at_ofs(uint32_t p_ofs, const uint8_t *p_buf, bool &err) const {
uint32_t type = decode_uint32(p_buf + p_ofs);
if (type == TYPE_ARRAY || type == TYPE_DICT) {
Ref<PackedDataContainerRef> pdcr = memnew(PackedDataContainerRef);
Ref<PackedDataContainer> pdc = Ref<PackedDataContainer>((PackedDataContainer *)this);
pdcr->from = pdc;
pdcr->offset = p_ofs;
return pdcr;
} else {
Variant v;
Error rerr = decode_variant(v, p_buf + p_ofs, datalen - p_ofs, NULL);
if (rerr != OK) {
err = true;
ERR_FAIL_COND_V(err != OK, Variant());
}
return v;
}
}
示例4: _decode_string
static Error _decode_string(const uint8_t *&buf, int &len, int *r_len, String &r_string) {
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
uint32_t strlen = decode_uint32(buf);
buf += 4;
len -= 4;
ERR_FAIL_COND_V((int)strlen > len, ERR_FILE_EOF);
String str;
str.parse_utf8((const char *)buf, strlen);
r_string = str;
//handle padding
if (strlen % 4) {
strlen += 4 - strlen % 4;
}
buf += strlen;
len -= strlen;
if (r_len) {
(*r_len) += 4 + strlen;
}
return OK;
}
示例5: ERR_EXPLAIN
void MultiplayerAPI::_process_simplify_path(int p_from, const uint8_t *p_packet, int p_packet_len) {
ERR_EXPLAIN("Invalid packet received. Size too small.");
ERR_FAIL_COND(p_packet_len < 5);
int id = decode_uint32(&p_packet[1]);
String paths;
paths.parse_utf8((const char *)&p_packet[5], p_packet_len - 5);
NodePath path = paths;
if (!path_get_cache.has(p_from)) {
path_get_cache[p_from] = PathGetCache();
}
PathGetCache::NodeInfo ni;
ni.path = path;
ni.instance = 0;
path_get_cache[p_from].nodes[id] = ni;
// Encode path to send ack.
CharString pname = String(path).utf8();
int len = encode_cstring(pname.get_data(), NULL);
Vector<uint8_t> packet;
packet.resize(1 + len);
packet.write[0] = NETWORK_COMMAND_CONFIRM_PATH;
encode_cstring(pname.get_data(), &packet.write[1]);
network_peer->set_transfer_mode(NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE);
network_peer->set_target_peer(p_from);
network_peer->put_packet(packet.ptr(), packet.size());
}
示例6: _poll_buffer
int PacketPeerStream::get_available_packet_count() const {
_poll_buffer();
uint32_t remaining = ring_buffer.data_left();
int ofs=0;
int count=0;
while(remaining>=4) {
uint8_t lbuf[4];
ring_buffer.copy(lbuf,ofs,4);
uint32_t len = decode_uint32(lbuf);
remaining-=4;
ofs+=4;
if (len>remaining)
break;
remaining-=len;
ofs+=len;
count++;
}
return count;
}
示例7: SWAP
void TileMap::_set_tile_data(const DVector<int>& p_data) {
int c=p_data.size();
DVector<int>::Read r = p_data.read();
for(int i=0;i<c;i+=2) {
const uint8_t *ptr=(const uint8_t*)&r[i];
uint8_t local[8];
for(int j=0;j<8;j++)
local[j]=ptr[j];
#ifdef BIG_ENDIAN_ENABLED
SWAP(local[0],local[3]);
SWAP(local[1],local[2]);
SWAP(local[4],local[7]);
SWAP(local[5],local[6]);
#endif
int x = decode_uint16(&local[0]);
int y = decode_uint16(&local[2]);
uint32_t v = decode_uint32(&local[4]);
bool flip_h = v&(1<<29);
bool flip_v = v&(1<<30);
v&=(1<<29)-1;
// if (x<-20 || y <-20 || x>4000 || y>4000)
// continue;
set_cell(x,y,v,flip_h,flip_v);
}
}
示例8: decode_uint32
int FileAccessNetworkClient::get_32() {
uint8_t buf[4];
client->get_data(buf,4);
return decode_uint32(buf);
}
示例9: transop_decode_twofish
/** The twofish packet format consists of:
*
* - a 8-bit twofish encoding version in clear text
* - a 32-bit SA number in clear text
* - ciphertext encrypted from a 32-bit nonce followed by the payload.
*
* [V|SSSS|nnnnDDDDDDDDDDDDDDDDDDDDD]
* |<------ encrypted ------>|
*/
static int transop_decode_twofish( ntvl_trans_op_t * arg,
uint8_t * outbuf,
size_t out_len,
const uint8_t * inbuf,
size_t in_len ) {
int len=0;
transop_tf_t * priv = (transop_tf_t *)arg->priv;
uint8_t assembly[NTVL_PKT_BUF_SIZE];
if ( ( (in_len - (TRANSOP_TF_VER_SIZE + TRANSOP_TF_SA_SIZE)) <= NTVL_PKT_BUF_SIZE ) /* Cipher text fits in assembly */
&& (in_len >= (TRANSOP_TF_VER_SIZE + TRANSOP_TF_SA_SIZE + TRANSOP_TF_NONCE_SIZE) ) ) { /* Has at least version, SA and nonce */
ntvl_sa_t sa_rx;
ssize_t sa_idx=-1;
size_t rem=in_len;
size_t idx=0;
uint8_t tf_enc_ver=0;
/* Get the encoding version to make sure it is supported */
decode_uint8( &tf_enc_ver, inbuf, &rem, &idx );
if ( NTVL_TWOFISH_TRANSFORM_VERSION == tf_enc_ver ) {
/* Get the SA number and make sure we are decrypting with the right one. */
decode_uint32( &sa_rx, inbuf, &rem, &idx );
sa_idx = twofish_find_sa(priv, sa_rx);
if ( sa_idx >= 0 ) {
sa_twofish_t * sa = &(priv->sa[sa_idx]);
traceEvent( TRACE_DEBUG, "decode_twofish %lu with SA %lu.", in_len, sa_rx, sa->sa_id );
len = TwoFishDecryptRaw( (void *)(inbuf + TRANSOP_TF_VER_SIZE + TRANSOP_TF_SA_SIZE),
assembly, /* destination */
(in_len - (TRANSOP_TF_VER_SIZE + TRANSOP_TF_SA_SIZE)),
sa->dec_tf);
if ( len > 0 ) {
/* Step over 4-byte random nonce value */
len -= TRANSOP_TF_NONCE_SIZE; /* size of ethernet packet */
memcpy( outbuf,
assembly + TRANSOP_TF_NONCE_SIZE,
len );
} else traceEvent( TRACE_ERROR, "decode_twofish decryption failed." );
} else {
/* Wrong security association; drop the packet as it is undecodable. */
traceEvent( TRACE_ERROR, "decode_twofish SA number %lu not found.", sa_rx );
/* REVISIT: should be able to load a new SA at this point to complete the decoding. */
}
} else {
/* Wrong security association; drop the packet as it is undecodable. */
traceEvent( TRACE_ERROR, "decode_twofish unsupported twofish version %u.", tf_enc_ver );
/* REVISIT: should be able to load a new SA at this point to complete the decoding. */
}
} else traceEvent( TRACE_ERROR, "decode_twofish inbuf wrong size (%ul) to decrypt.", in_len );
return len;
}
示例10: decode_uint32
Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs,const Variant& p_key,bool &err) const {
DVector<uint8_t>::Read rd=data.read();
const uint8_t *r=&rd[p_ofs];
uint32_t type = decode_uint32(r);
if (type==TYPE_ARRAY) {
if (p_key.is_num()) {
int idx=p_key;
uint32_t len = decode_uint32(r+4);
if (idx<0 || idx>=len) {
err=true;
return Variant();
}
uint32_t ofs = decode_uint32(r+8+4*idx);
return _get_at_ofs(ofs,rd.ptr(),err);
} else {
err=true;
return Variant();
}
} else if (type==TYPE_DICT) {
uint32_t hash=p_key.hash();
uint32_t len = decode_uint32(r+4);
bool found=false;
for(int i=0;i<len;i++) {
uint32_t khash=decode_uint32(r+8+i*12+0);
if (khash==hash) {
Variant key = _get_at_ofs(decode_uint32(r+8+i*12+4),rd.ptr(),err);
if (err)
return Variant();
if (key==p_key) {
//key matches, return value
return _get_at_ofs(decode_uint32(r+8+i*12+8),rd.ptr(),err);
}
found=true;
} else {
if (found)
break;
}
}
err=true;
return Variant();
} else {
err=true;
return Variant();
}
}
示例11: get_data
int32_t StreamPeer::get_32() {
uint8_t buf[4];
get_data(buf, 4);
uint32_t r = decode_uint32(buf);
if (big_endian) {
r = BSWAP32(r);
}
return r;
}
示例12: client_get_hosts
/*
* Have an exchange with the server over TCP/IP and get the IPs of our local
* and the remote host.
*/
static void
client_get_hosts(char *lhost, char *rhost)
{
SS raddr;
socklen_t rlen;
char *service;
uint32_t port;
int fd = -1;
recv_mesg(&port, sizeof(port), "TCP IPv4 server port");
port = decode_uint32(&port);
service = qasprintf("%d", port);
connect_tcp(ServerName, service, &raddr, &rlen, &fd);
free(service);
get_socket_ip((SA *)&raddr, rlen, rhost, NI_MAXHOST);
send_mesg(rhost, NI_MAXHOST, "server IP");
recv_mesg(lhost, NI_MAXHOST, "client IP");
close(fd);
}
示例13: decode_getacl3resok
static inline int decode_getacl3resok(struct xdr_stream *xdr,
struct nfs3_getaclres *result)
{
struct posix_acl **acl;
unsigned int *aclcnt;
size_t hdrlen;
int error;
error = decode_post_op_attr(xdr, result->fattr);
if (unlikely(error))
goto out;
error = decode_uint32(xdr, &result->mask);
if (unlikely(error))
goto out;
error = -EINVAL;
if (result->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT))
goto out;
hdrlen = (u8 *)xdr->p - (u8 *)xdr->iov->iov_base;
acl = NULL;
if (result->mask & NFS_ACL)
acl = &result->acl_access;
aclcnt = NULL;
if (result->mask & NFS_ACLCNT)
aclcnt = &result->acl_access_count;
error = nfsacl_decode(xdr->buf, hdrlen, aclcnt, acl);
if (unlikely(error <= 0))
goto out;
acl = NULL;
if (result->mask & NFS_DFACL)
acl = &result->acl_default;
aclcnt = NULL;
if (result->mask & NFS_DFACLCNT)
aclcnt = &result->acl_default_count;
error = nfsacl_decode(xdr->buf, hdrlen + error, aclcnt, acl);
if (unlikely(error <= 0))
return error;
error = 0;
out:
return error;
}
示例14: decode_uint32
Node *MultiplayerAPI::_process_get_node(int p_from, const uint8_t *p_packet, int p_packet_len) {
uint32_t target = decode_uint32(&p_packet[1]);
Node *node = NULL;
if (target & 0x80000000) {
// Use full path (not cached yet).
int ofs = target & 0x7FFFFFFF;
ERR_EXPLAIN("Invalid packet received. Size smaller than declared.");
ERR_FAIL_COND_V(ofs >= p_packet_len, NULL);
String paths;
paths.parse_utf8((const char *)&p_packet[ofs], p_packet_len - ofs);
NodePath np = paths;
node = root_node->get_node(np);
if (!node)
ERR_PRINTS("Failed to get path from RPC: " + String(np));
} else {
// Use cached path.
int id = target;
Map<int, PathGetCache>::Element *E = path_get_cache.find(p_from);
ERR_EXPLAIN("Invalid packet received. Requests invalid peer cache.");
ERR_FAIL_COND_V(!E, NULL);
Map<int, PathGetCache::NodeInfo>::Element *F = E->get().nodes.find(id);
ERR_EXPLAIN("Invalid packet received. Unabled to find requested cached node.");
ERR_FAIL_COND_V(!F, NULL);
PathGetCache::NodeInfo *ni = &F->get();
// Do proper caching later.
node = root_node->get_node(ni->path);
if (!node)
ERR_PRINTS("Failed to get cached path from RPC: " + String(ni->path));
}
return node;
}
示例15: ERR_FAIL_COND_V
Error PacketPeerStream::get_packet(const uint8_t **r_buffer, int &r_buffer_size) const {
ERR_FAIL_COND_V(peer.is_null(), ERR_UNCONFIGURED);
_poll_buffer();
int remaining = ring_buffer.data_left();
ERR_FAIL_COND_V(remaining < 4, ERR_UNAVAILABLE);
uint8_t lbuf[4];
ring_buffer.copy(lbuf, 0, 4);
remaining -= 4;
uint32_t len = decode_uint32(lbuf);
ERR_FAIL_COND_V(remaining < (int)len, ERR_UNAVAILABLE);
ring_buffer.read(lbuf, 4); //get rid of first 4 bytes
ring_buffer.read(&temp_buffer[0], len); // read packet
*r_buffer = &temp_buffer[0];
r_buffer_size = len;
return OK;
}