3 #include <winpr/print.h>
4 #include <winpr/stream.h>
5 #include <winpr/bitstream.h>
7 static void BitStrGen(
void)
11 for (DWORD i = 0; i < 256;)
15 for (DWORD j = 0; j < 4; j++)
20 str[0] = (i & (1 << 7)) ?
'1' :
'0';
21 str[1] = (i & (1 << 6)) ?
'1' :
'0';
22 str[2] = (i & (1 << 5)) ?
'1' :
'0';
23 str[3] = (i & (1 << 4)) ?
'1' :
'0';
24 str[4] = (i & (1 << 3)) ?
'1' :
'0';
25 str[5] = (i & (1 << 2)) ?
'1' :
'0';
26 str[6] = (i & (1 << 1)) ?
'1' :
'0';
27 str[7] = (i & (1 << 0)) ?
'1' :
'0';
33 str[7] = (i & (1 << 7)) ?
'1' :
'0';
34 str[6] = (i & (1 << 6)) ?
'1' :
'0';
35 str[5] = (i & (1 << 5)) ?
'1' :
'0';
36 str[4] = (i & (1 << 4)) ?
'1' :
'0';
37 str[3] = (i & (1 << 3)) ?
'1' :
'0';
38 str[2] = (i & (1 << 2)) ?
'1' :
'0';
39 str[1] = (i & (1 << 1)) ?
'1' :
'0';
40 str[0] = (i & (1 << 0)) ?
'1' :
'0';
44 printf(
"\"%s\",%s", str, j == 3 ?
"" :
" ");
52 int TestBitStream(
int argc,
char* argv[])
55 BYTE buffer[1024] = { 0 };
63 BitStream_Attach(bs, buffer,
sizeof(buffer));
64 BitStream_Write_Bits(bs, 0xAF, 8);
65 BitStream_Write_Bits(bs, 0xF, 4);
66 BitStream_Write_Bits(bs, 0xA, 4);
68 BitDump(__func__, WLOG_INFO, buffer, bs->position, BITDUMP_MSB_FIRST);
69 BitStream_Write_Bits(bs, 3, 2);
70 BitStream_Write_Bits(bs, 0, 3);
71 BitStream_Write_Bits(bs, 0x2D, 6);
72 BitStream_Write_Bits(bs, 0x19, 5);
74 BitDump(__func__, WLOG_INFO, buffer, bs->position, BITDUMP_MSB_FIRST);
75 BitStream_Write_Bits(bs, 3, 2);
77 BitDump(__func__, WLOG_INFO, buffer, bs->position, BITDUMP_MSB_FIRST);
78 BitStream_Write_Bits(bs, 00, 2);
79 BitStream_Write_Bits(bs, 0xF, 4);
80 BitStream_Write_Bits(bs, 0, 20);
81 BitStream_Write_Bits(bs, 0xAFF, 12);
83 BitDump(__func__, WLOG_INFO, buffer, bs->position, BITDUMP_MSB_FIRST);