⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bitinput.c

📁 这是一个同样来自贝尔实验室的和UNIX有着渊源的操作系统, 其简洁的设计和实现易于我们学习和理解
💻 C
字号:
#include	<u.h>#include	<libc.h>#include	<bio.h>#include	"sky.h"static int hufvals[] = {	 1,  1,  1,  1,  1,  1,  1,  1,	 2,  2,  2,  2,  2,  2,  2,  2,	 4,  4,  4,  4,  4,  4,  4,  4,	 8,  8,  8,  8,  8,  8,  8,  8,	 3,  3,  3,  3,  5,  5,  5,  5,	10, 10, 10, 10, 12, 12, 12, 12,	15, 15, 15, 15,  6,  6,  7,  7,	 9,  9, 11, 11, 13, 13,  0, 14,};static int huflens[] = {	3, 3, 3, 3, 3, 3, 3, 3,	3, 3, 3, 3, 3, 3, 3, 3,	3, 3, 3, 3, 3, 3, 3, 3,	3, 3, 3, 3, 3, 3, 3, 3,	4, 4, 4, 4, 4, 4, 4, 4,	4, 4, 4, 4, 4, 4, 4, 4,	4, 4, 4, 4, 5, 5, 5, 5,	5, 5, 5, 5, 5, 5, 6, 6,};static	int	buffer;static	int	bits_to_go;		/* Number of bits still in buffer */voidstart_inputing_bits(void){	bits_to_go = 0;}intinput_huffman(Biobuf *infile){	int c;	if(bits_to_go < 6) {		c = Bgetc(infile);		if(c < 0) {			fprint(2, "input_huffman: unexpected EOF\n");			exits("format");		}		buffer = (buffer<<8) | c;		bits_to_go += 8;	}	c = (buffer >> (bits_to_go-6)) & 0x3f;	bits_to_go -= huflens[c];	return hufvals[c];}intinput_nybble(Biobuf *infile){	int c;	if(bits_to_go < 4) {		c = Bgetc(infile);		if(c < 0){			fprint(2, "input_nybble: unexpected EOF\n");			exits("format");		}		buffer = (buffer<<8) | c;		bits_to_go += 8;	}	/*	 * pick off the first 4 bits	 */	bits_to_go -= 4;	return (buffer>>bits_to_go) & 0x0f;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -