• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ decode_uint32函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中decode_uint32函数的典型用法代码示例。如果您正苦于以下问题:C++ decode_uint32函数的具体用法?C++ decode_uint32怎么用?C++ decode_uint32使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了decode_uint32函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
	}
}
开发者ID:Ranakhamis,项目名称:godot,代码行数:25,代码来源:packed_data_container.cpp


示例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);
}
开发者ID:tidatida,项目名称:alarmd,代码行数:10,代码来源:codec.c


示例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;
	}
}
开发者ID:Ranakhamis,项目名称:godot,代码行数:25,代码来源:packed_data_container.cpp


示例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;
}
开发者ID:jejung,项目名称:godot,代码行数:26,代码来源:marshalls.cpp


示例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());
}
开发者ID:Paulloz,项目名称:godot,代码行数:35,代码来源:multiplayer_api.cpp


示例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;
}
开发者ID:3miu,项目名称:godot,代码行数:25,代码来源:packet_peer.cpp


示例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);
	}

}
开发者ID:hbiblia,项目名称:godot,代码行数:34,代码来源:tile_map.cpp


示例8: decode_uint32

int FileAccessNetworkClient::get_32() {

	uint8_t buf[4];
	client->get_data(buf,4);
	return decode_uint32(buf);

}
开发者ID:AwsomeGameEngine,项目名称:godot,代码行数:7,代码来源:file_access_network.cpp


示例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;
}
开发者ID:tempbottle,项目名称:ntvl,代码行数:69,代码来源:transform_tf.c


示例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();
	}
 

}
开发者ID:AMG194,项目名称:godot,代码行数:59,代码来源:packed_data_container.cpp


示例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;
}
开发者ID:allkhor,项目名称:godot,代码行数:10,代码来源:stream_peer.cpp


示例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);
}
开发者ID:aclisp,项目名称:myqperf,代码行数:23,代码来源:rds.c


示例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;
}
开发者ID:Albinoman887,项目名称:pyramid-3.4.10,代码行数:43,代码来源:nfs3xdr.c


示例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;
}
开发者ID:Paulloz,项目名称:godot,代码行数:43,代码来源:multiplayer_api.cpp


示例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;
}
开发者ID:MattUV,项目名称:godot,代码行数:20,代码来源:packet_peer.cpp


示例16: nfs3_xdr_dec_access3res

static int nfs3_xdr_dec_access3res(struct rpc_rqst *req,
				   struct xdr_stream *xdr,
				   struct nfs3_accessres *result)
{
	enum nfs_stat status;
	int error;

	error = decode_nfsstat3(xdr, &status);
	if (unlikely(error))
		goto out;
	error = decode_post_op_attr(xdr, result->fattr);
	if (unlikely(error))
		goto out;
	if (status != NFS3_OK)
		goto out_default;
	error = decode_uint32(xdr, &result->access);
out:
	return error;
out_default:
	return nfs_stat_to_errno(status);
}
开发者ID:Albinoman887,项目名称:pyramid-3.4.10,代码行数:21,代码来源:nfs3xdr.c


示例17: init

/*
 * Initialize and return open socket.
 */
static int
init(void)
{
    int sockfd;
    uint32_t lport;
    uint32_t rport;
    char lhost[NI_MAXHOST];
    char rhost[NI_MAXHOST];

    if (is_client())
        client_get_hosts(lhost, rhost);
    else
        server_get_hosts(lhost, rhost);
    sockfd = rds_socket(lhost, Req.port);
    lport = get_socket_port(sockfd);
    encode_uint32(&lport, lport);
    send_mesg(&lport, sizeof(lport), "RDS port");
    recv_mesg(&rport, sizeof(rport), "RDS port");
    rport = decode_uint32(&rport);
    rds_makeaddr(&RAddr, &RLen, rhost, rport);
    return sockfd;
}
开发者ID:aclisp,项目名称:myqperf,代码行数:25,代码来源:rds.c


示例18: while

  std::shared_ptr<ErrorContext> PrintContentHandler::process_template_set(
      uint16_t set_id,
      uint16_t set_length,
      const uint8_t* buf,
      bool is_options_set) {
    const uint8_t* cur = buf;
    const uint8_t* set_end = buf + set_length;
    const uint16_t header_length 
      = is_options_set ? kOptionsTemplateHeaderLen
                       : kTemplateHeaderLen;

    while (CHECK_POINTER_WITHIN_I(cur + header_length, cur, set_end)) {
      /* Decode template record */
      uint16_t set_id = decode_uint16(cur + 0); 
      uint16_t field_count = decode_uint16(cur + 2);
      uint16_t scope_field_count = is_options_set ? decode_uint16(cur + 4) : 0;
      
      PH_RETURN_CALLBACK_ERROR(start_template_record(set_id, field_count));
      
      cur += header_length;
      
      for (unsigned int field = 0; field < field_count; field++) {
        if (!CHECK_POINTER_WITHIN_I(cur + kFieldSpecifierLen,
                                    cur, set_end)) {
          libfc_RETURN_ERROR(recoverable, long_fieldspec,
                             "Field specifier partly outside template record", 
                             0, 0, 0, 0, cur - buf);
        }
        
        uint16_t ie_id = decode_uint16(cur + 0);
        uint16_t ie_length = decode_uint16(cur + 2);
        bool enterprise = ie_id & 0x8000;
        ie_id &= 0x7fff;
        
        uint32_t enterprise_number = 0;
        if (enterprise) {
          if (!CHECK_POINTER_WITHIN_I(cur + kFieldSpecifierLen
                                      + kEnterpriseLen, cur,
                                      set_end)) {
            libfc_RETURN_ERROR(recoverable, long_fieldspec,
                               "Field specifier partly outside template "
                               "record (enterprise)", 
                               0, 0, 0, 0, cur - buf);
          }
          enterprise_number = decode_uint32(cur + 4);
        }
        
        std::cerr << "        ";
        if (is_options_set && field < scope_field_count)
          std::cerr << "Scope field";
        else if (is_options_set)
          std::cerr << "Options field";
        else /* !is_options_set */
          std::cerr << "Field specifier";
        
        const InfoElement* ie 
          = info_model.lookupIE(enterprise_number, ie_id, ie_length);

        if (ie != 0) 
          std::cerr << ", name=" << ie->name();
        else {
          std::cerr << ( enterprise ? ", enterprise" : "" )
                    << ", ie_id=" << ie_id
                    << ", ie_length=" << ie_length;
          if (enterprise)
            std::cerr << ", enterprise_number=" << enterprise_number;
        }
        std::cerr << std::endl;

        cur += kFieldSpecifierLen + (enterprise ? kEnterpriseLen : 0);
        assert (cur <= set_end);
      }
      
      PH_RETURN_CALLBACK_ERROR(end_template_record());
    }
    libfc_RETURN_OK();
  }
开发者ID:britram,项目名称:libfc,代码行数:77,代码来源:PrintContentHandler.cpp


示例19: ERR_FAIL_COND_V

Error GDTokenizerBuffer::set_code_buffer(const Vector<uint8_t> & p_buffer) {


	const uint8_t *buf=p_buffer.ptr();
	int total_len=p_buffer.size();
	ERR_FAIL_COND_V( p_buffer.size()<24 || p_buffer[0]!='G' || p_buffer[1]!='D' || p_buffer[2]!='S' || p_buffer[3]!='C',ERR_INVALID_DATA);
	
	int version = decode_uint32(&buf[4]);
	if (version>BYTECODE_VERSION) {
		ERR_EXPLAIN("Bytecode is too New! Please use a newer engine version.");
		ERR_FAIL_COND_V(version>BYTECODE_VERSION,ERR_INVALID_DATA);
	}
	int identifier_count = decode_uint32(&buf[8]);
	int constant_count = decode_uint32(&buf[12]);
	int line_count = decode_uint32(&buf[16]);
	int token_count = decode_uint32(&buf[20]);

	const uint8_t *b=buf;
	
	b=&buf[24];
	total_len-=24;
	
	identifiers.resize(identifier_count);
	for(int i=0;i<identifier_count;i++) {
		
		int len = decode_uint32(b);
		ERR_FAIL_COND_V(len>total_len,ERR_INVALID_DATA);
		b+=4;
		Vector<uint8_t> cs;
		cs.resize(len);
		for(int j=0;j<len;j++) {
			cs[j]=b[j]^0xb6;
		}

		cs[cs.size()-1]=0;
		String s;
		s.parse_utf8((const char*)cs.ptr());
		b+=len;
		total_len-=len+4;
		identifiers[i]=s;
	}
	
	constants.resize(constant_count);
	for(int i=0;i<constant_count;i++) {

		Variant v;
		int len;
		Error err = decode_variant(v,b,total_len,&len);
		if (err)
			return err;
		b+=len;
		total_len-=len;
		constants[i]=v;

	}

	ERR_FAIL_COND_V(line_count*8>total_len,ERR_INVALID_DATA);

	for(int i=0;i<line_count;i++) {

		uint32_t token=decode_uint32(b);
		b+=4;
		uint32_t linecol=decode_uint32(b);
		b+=4;

		lines.insert(token,linecol);
		total_len-=8;
	}

	tokens.resize(token_count);

	for(int i=0;i<token_count;i++) {

		ERR_FAIL_COND_V( total_len < 1, ERR_INVALID_DATA);

		if ((*b)&TOKEN_BYTE_MASK) { //little endian always
			ERR_FAIL_COND_V( total_len < 4, ERR_INVALID_DATA);

			tokens[i]=decode_uint32(b)&~TOKEN_BYTE_MASK;
			b+=4;
		} else {
			tokens[i]=*b;
			b+=1;
			total_len--;
		}
	}

	token=0;

	return OK;

}
开发者ID:Martho42,项目名称:godot,代码行数:92,代码来源:gd_tokenizer.cpp


示例20: while

  std::shared_ptr<ErrorContext> PlacementContentHandler::process_template_set(
      uint16_t set_id,
      uint16_t set_length,
      const uint8_t* buf,
      bool is_options_set) {
    const uint8_t* cur = buf;
    const uint8_t* set_end = buf + set_length;
    const uint16_t header_length 
      = is_options_set ? kOptionsTemplateHeaderLen
                       : kTemplateHeaderLen;

    while (CHECK_POINTER_WITHIN_I(cur + header_length, cur, set_end)) {
      /* Decode template record */
      uint16_t set_id = decode_uint16(cur + 0); 
      uint16_t field_count = decode_uint16(cur + 2);
      uint16_t scope_field_count = is_options_set ? decode_uint16(cur + 4) : 0;
      
      CH_REPORT_CALLBACK_ERROR(start_template_record(set_id, field_count));
      
      cur += header_length;
      
      for (unsigned int field = 0; field < field_count; field++) {
        if (!CHECK_POINTER_WITHIN_I(cur + kFieldSpecifierLen,
                                    cur, set_end)) {
          libfc_RETURN_ERROR(recoverable, long_fieldspec,
                             "Field specifier partly outside template record", 
                             0, 0, 0, 0, cur - buf);
        }
        
        uint16_t ie_id = decode_uint16(cur + 0);
        uint16_t ie_length = decode_uint16(cur + 2);
        bool enterprise = ie_id & 0x8000;
        ie_id &= 0x7fff;
        
        uint32_t enterprise_number = 0;
        if (enterprise) {
          if (!CHECK_POINTER_WITHIN_I(cur + kFieldSpecifierLen
                                      + kEnterpriseLen, cur,
                                      set_end)) {
            libfc_RETURN_ERROR(recoverable, long_fieldspec,
                               "Field specifier partly outside template "
                               "record (enterprise)", 
                               0, 0, 0, 0, cur - buf);
          }
          enterprise_number = decode_uint32(cur + 4);
        }
        
        if (is_options_set && field < scope_field_count)
          CH_REPORT_CALLBACK_ERROR(scope_field_specifier(enterprise, ie_id, 
                                                         ie_length,
                                                         enterprise_number));
        else if (is_options_set)
          CH_REPORT_CALLBACK_ERROR(options_field_specifier(enterprise, ie_id,
                                                           ie_length,
                                                           enterprise_number));
        else /* !is_options_set */
          CH_REPORT_CALLBACK_ERROR(field_specifier(enterprise, ie_id,
                                                   ie_length,
                                                   enterprise_number));
        
        cur += kFieldSpecifierLen + (enterprise ? kEnterpriseLen : 0);
        assert (cur <= set_end);
      }
      
      CH_REPORT_CALLBACK_ERROR(end_template_record());
    }
    libfc_RETURN_OK();
  }
开发者ID:britram,项目名称:libfc,代码行数:68,代码来源:PlacementContentHandler.cpp



注:本文中的decode_uint32函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ decoder函数代码示例发布时间:2022-05-30
下一篇:
C++ decode_string函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap