Lines Matching refs:os
68 zrleOutStream *os; in zrleOutStreamNew() local
70 os = malloc(sizeof(zrleOutStream)); in zrleOutStreamNew()
71 if (os == NULL) in zrleOutStreamNew()
74 if (!zrleBufferAlloc(&os->in, ZRLE_IN_BUFFER_SIZE)) { in zrleOutStreamNew()
75 free(os); in zrleOutStreamNew()
79 if (!zrleBufferAlloc(&os->out, ZRLE_OUT_BUFFER_SIZE)) { in zrleOutStreamNew()
80 zrleBufferFree(&os->in); in zrleOutStreamNew()
81 free(os); in zrleOutStreamNew()
85 os->zs.zalloc = Z_NULL; in zrleOutStreamNew()
86 os->zs.zfree = Z_NULL; in zrleOutStreamNew()
87 os->zs.opaque = Z_NULL; in zrleOutStreamNew()
88 if (deflateInit(&os->zs, Z_DEFAULT_COMPRESSION) != Z_OK) { in zrleOutStreamNew()
89 zrleBufferFree(&os->in); in zrleOutStreamNew()
90 free(os); in zrleOutStreamNew()
94 return os; in zrleOutStreamNew()
97 void zrleOutStreamFree (zrleOutStream *os) in zrleOutStreamFree() argument
99 deflateEnd(&os->zs); in zrleOutStreamFree()
100 zrleBufferFree(&os->in); in zrleOutStreamFree()
101 zrleBufferFree(&os->out); in zrleOutStreamFree()
102 free(os); in zrleOutStreamFree()
105 rfbBool zrleOutStreamFlush(zrleOutStream *os) in zrleOutStreamFlush() argument
107 os->zs.next_in = os->in.start; in zrleOutStreamFlush()
108 os->zs.avail_in = ZRLE_BUFFER_LENGTH (&os->in); in zrleOutStreamFlush()
111 rfbLog("zrleOutStreamFlush: avail_in %d\n", os->zs.avail_in); in zrleOutStreamFlush()
114 while (os->zs.avail_in != 0) { in zrleOutStreamFlush()
118 if (os->out.ptr >= os->out.end && in zrleOutStreamFlush()
119 !zrleBufferGrow(&os->out, os->out.end - os->out.start)) { in zrleOutStreamFlush()
124 os->zs.next_out = os->out.ptr; in zrleOutStreamFlush()
125 os->zs.avail_out = os->out.end - os->out.ptr; in zrleOutStreamFlush()
129 os->zs.avail_in, os->zs.avail_out); in zrleOutStreamFlush()
132 if ((ret = deflate(&os->zs, Z_SYNC_FLUSH)) != Z_OK) { in zrleOutStreamFlush()
139 os->zs.next_out - os->out.ptr); in zrleOutStreamFlush()
142 os->out.ptr = os->zs.next_out; in zrleOutStreamFlush()
143 } while (os->zs.avail_out == 0); in zrleOutStreamFlush()
146 os->in.ptr = os->in.start; in zrleOutStreamFlush()
151 static int zrleOutStreamOverrun(zrleOutStream *os, in zrleOutStreamOverrun() argument
158 while (os->in.end - os->in.ptr < size && os->in.ptr > os->in.start) { in zrleOutStreamOverrun()
159 os->zs.next_in = os->in.start; in zrleOutStreamOverrun()
160 os->zs.avail_in = ZRLE_BUFFER_LENGTH (&os->in); in zrleOutStreamOverrun()
165 if (os->out.ptr >= os->out.end && in zrleOutStreamOverrun()
166 !zrleBufferGrow(&os->out, os->out.end - os->out.start)) { in zrleOutStreamOverrun()
171 os->zs.next_out = os->out.ptr; in zrleOutStreamOverrun()
172 os->zs.avail_out = os->out.end - os->out.ptr; in zrleOutStreamOverrun()
176 os->zs.avail_in, os->zs.avail_out); in zrleOutStreamOverrun()
179 if ((ret = deflate(&os->zs, 0)) != Z_OK) { in zrleOutStreamOverrun()
186 os->zs.next_out - os->out.ptr); in zrleOutStreamOverrun()
189 os->out.ptr = os->zs.next_out; in zrleOutStreamOverrun()
190 } while (os->zs.avail_out == 0); in zrleOutStreamOverrun()
194 if (os->zs.avail_in == 0) { in zrleOutStreamOverrun()
195 os->in.ptr = os->in.start; in zrleOutStreamOverrun()
201 memmove(os->in.start, os->zs.next_in, os->in.ptr - os->zs.next_in); in zrleOutStreamOverrun()
202 os->in.ptr -= os->zs.next_in - os->in.start; in zrleOutStreamOverrun()
206 if (size > os->in.end - os->in.ptr) in zrleOutStreamOverrun()
207 size = os->in.end - os->in.ptr; in zrleOutStreamOverrun()
212 static int zrleOutStreamCheck(zrleOutStream *os, int size) in zrleOutStreamCheck() argument
214 if (os->in.ptr + size > os->in.end) { in zrleOutStreamCheck()
215 return zrleOutStreamOverrun(os, size); in zrleOutStreamCheck()
220 void zrleOutStreamWriteBytes(zrleOutStream *os, in zrleOutStreamWriteBytes() argument
226 int n = zrleOutStreamCheck(os, dataEnd - data); in zrleOutStreamWriteBytes()
227 memcpy(os->in.ptr, data, n); in zrleOutStreamWriteBytes()
228 os->in.ptr += n; in zrleOutStreamWriteBytes()
233 void zrleOutStreamWriteU8(zrleOutStream *os, zrle_U8 u) in zrleOutStreamWriteU8() argument
235 zrleOutStreamCheck(os, 1); in zrleOutStreamWriteU8()
236 *os->in.ptr++ = u; in zrleOutStreamWriteU8()
239 void zrleOutStreamWriteOpaque8(zrleOutStream *os, zrle_U8 u) in zrleOutStreamWriteOpaque8() argument
241 zrleOutStreamCheck(os, 1); in zrleOutStreamWriteOpaque8()
242 *os->in.ptr++ = u; in zrleOutStreamWriteOpaque8()
245 void zrleOutStreamWriteOpaque16 (zrleOutStream *os, zrle_U16 u) in zrleOutStreamWriteOpaque16() argument
247 zrleOutStreamCheck(os, 2); in zrleOutStreamWriteOpaque16()
248 *os->in.ptr++ = ((zrle_U8*)&u)[0]; in zrleOutStreamWriteOpaque16()
249 *os->in.ptr++ = ((zrle_U8*)&u)[1]; in zrleOutStreamWriteOpaque16()
252 void zrleOutStreamWriteOpaque32 (zrleOutStream *os, zrle_U32 u) in zrleOutStreamWriteOpaque32() argument
254 zrleOutStreamCheck(os, 4); in zrleOutStreamWriteOpaque32()
255 *os->in.ptr++ = ((zrle_U8*)&u)[0]; in zrleOutStreamWriteOpaque32()
256 *os->in.ptr++ = ((zrle_U8*)&u)[1]; in zrleOutStreamWriteOpaque32()
257 *os->in.ptr++ = ((zrle_U8*)&u)[2]; in zrleOutStreamWriteOpaque32()
258 *os->in.ptr++ = ((zrle_U8*)&u)[3]; in zrleOutStreamWriteOpaque32()
261 void zrleOutStreamWriteOpaque24A(zrleOutStream *os, zrle_U32 u) in zrleOutStreamWriteOpaque24A() argument
263 zrleOutStreamCheck(os, 3); in zrleOutStreamWriteOpaque24A()
264 *os->in.ptr++ = ((zrle_U8*)&u)[0]; in zrleOutStreamWriteOpaque24A()
265 *os->in.ptr++ = ((zrle_U8*)&u)[1]; in zrleOutStreamWriteOpaque24A()
266 *os->in.ptr++ = ((zrle_U8*)&u)[2]; in zrleOutStreamWriteOpaque24A()
269 void zrleOutStreamWriteOpaque24B(zrleOutStream *os, zrle_U32 u) in zrleOutStreamWriteOpaque24B() argument
271 zrleOutStreamCheck(os, 3); in zrleOutStreamWriteOpaque24B()
272 *os->in.ptr++ = ((zrle_U8*)&u)[1]; in zrleOutStreamWriteOpaque24B()
273 *os->in.ptr++ = ((zrle_U8*)&u)[2]; in zrleOutStreamWriteOpaque24B()
274 *os->in.ptr++ = ((zrle_U8*)&u)[3]; in zrleOutStreamWriteOpaque24B()