71 {
72 z_stream zstream = {0};
73 int ret = inflateInit(&zstream);
74
75 std::string decode_summary_buff;
76 size_t ungzip_buff_size = target.size() * 0x30;
77 std::string current_decode_buff(ungzip_buff_size, 'X');
78
79 while(target.size())
80 {
81
82
83 zstream.next_out = (Bytef*)current_decode_buff.data();
84 zstream.avail_out = (uInt)ungzip_buff_size;
85
86 int flag = Z_SYNC_FLUSH;
87
88 static char dummy_head[2] =
89 {
90 0x8 + 0x7 * 0x10,
91 (((0x8 + 0x7 * 0x10) * 0x100 + 30) / 31 * 31) & 0xFF,
92 };
93 zstream.next_in = (Bytef*) dummy_head;
94 zstream.avail_in = sizeof(dummy_head);
95 ret = inflate(&zstream, Z_NO_FLUSH);
96 if (ret != Z_OK)
97 {
99 return false;
100 }
101
102 zstream.next_in = (Bytef*)target.data();
103 zstream.avail_in = (uInt)target.size();
104
105 ret = inflate(&zstream, Z_SYNC_FLUSH);
106 if (ret != Z_OK && ret != Z_STREAM_END)
107 {
109 return false;
110 }
111
112
113 target.erase(0, target.size()-zstream.avail_in);
114
115
116 if(ungzip_buff_size == zstream.avail_out)
117 {
119 return false;
120 }
121
122
123 current_decode_buff.resize(ungzip_buff_size - zstream.avail_out);
124 if(decode_summary_buff.size())
125 decode_summary_buff += current_decode_buff;
126 else
127 current_decode_buff.swap(decode_summary_buff);
128
129 current_decode_buff.resize(ungzip_buff_size);
130 }
131
132 inflateEnd(&zstream );
133
134 decode_summary_buff.swap(target);
135 return 1;
136 }
#define LOCAL_ASSERT(expr)