bin/varnishtest/vtc_h2_hpack.c
static enum hpk_result
huff_encode(struct hpk_iter *iter, const char *str, int len)
{
	uint64_t pack = 0;
	int pl = 0; /* pack length*/
	uint32_t	v;
	uint8_t		s;

	assert(iter->buf < iter->end);

	while (len--) {
		v = coding_table[(uint8_t)*str].val;
		s = coding_table[(uint8_t)*str].size;

		pl += s;
		pack |= (uint64_t)v << (64 - pl);

		while (pl >= 8) {
			if (iter->buf == iter->end)
				return (hpk_done);
			*iter->buf = (char)(pack >> 56);
			iter->buf++;
			pack <<= 8;
			pl -= 8;
		}
		str++;
	}

	/* padding */
	if (pl) {
		assert(pl < 8);
		if (iter->buf == iter->end)
			return (hpk_done);
		pl += 8;
		pack |= (uint64_t)0xff << (64 - pl);
		*iter->buf = (char)(pack >> 56);
		iter->buf++;
	}

	return (hpk_more);
}
/* inspired from Dridi Boukelmoune's cashpack. */
inspired from Dridi Boukelmoune's cashpack.
inspired from Dridi Boukelmoune ' s cashpack .
static enum hpk_result
huff_encode(struct hpk_iter *iter, const char *str, int len)
{
	uint64_t pack = 0;
	int pl = 0; 
	uint32_t	v;
	uint8_t		s;
	assert(iter->buf < iter->end);
	while (len--) {
		v = coding_table[(uint8_t)*str].val;
		s = coding_table[(uint8_t)*str].size;
		pl += s;
		pack |= (uint64_t)v << (64 - pl);
		while (pl >= 8) {
			if (iter->buf == iter->end)
				return (hpk_done);
			*iter->buf = (char)(pack >> 56);
			iter->buf++;
			pack <<= 8;
			pl -= 8;
		}
		str++;
	}
	if (pl) {
		assert(pl < 8);
		if (iter->buf == iter->end)
			return (hpk_done);
		pl += 8;
		pack |= (uint64_t)0xff << (64 - pl);
		*iter->buf = (char)(pack >> 56);
		iter->buf++;
	}
	return (hpk_more);
}
static enum hpk_result huff_encode ( struct hpk_iter * iter , const char * str , int len ) { uint64_t pack = 0 ; int pl = 0 ; uint32_t v ; uint8_t s ; assert ( iter -> buf < iter -> end ) ; while ( len -- ) { v = coding_table [ ( uint8_t ) * str ] . val ; s = coding_table [ ( uint8_t ) * str ] . size ; pl += s ; pack |= ( uint64_t ) v << ( 64 - pl ) ; while ( pl >= 8 ) { if ( iter -> buf == iter -> end ) return ( hpk_done ) ; * iter -> buf = ( char ) ( pack >> 56 ) ; iter -> buf ++ ; pack <<= 8 ; pl -= 8 ; } str ++ ; } if ( pl ) { assert ( pl < 8 ) ; if ( iter -> buf == iter -> end ) return ( hpk_done ) ; pl += 8 ; pack |= ( uint64_t ) 0xff << ( 64 - pl ) ; * iter -> buf = ( char ) ( pack >> 56 ) ; iter -> buf ++ ; } return ( hpk_more ) ; }
inspired from Dridi Boukelmoune's cashpack.
inspired from Dridi Boukelmoune ' s cashpack .
/* pack length*/ /* padding */