Deleted Added
full compact
compress.c (57429) compress.c (58582)
1/*
2 *
3 * compress.c
4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved
9 *
10 * Created: Wed Oct 25 22:12:46 1995 ylo
11 *
12 * Interface to packet compression for ssh.
13 *
14 */
15
16#include "includes.h"
1/*
2 *
3 * compress.c
4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved
9 *
10 * Created: Wed Oct 25 22:12:46 1995 ylo
11 *
12 * Interface to packet compression for ssh.
13 *
14 */
15
16#include "includes.h"
17RCSID("$Id: compress.c,v 1.4 1999/11/24 19:53:46 markus Exp $");
17RCSID("$Id: compress.c,v 1.5 2000/03/16 20:56:14 markus Exp $");
18
19#include "ssh.h"
20#include "buffer.h"
21#include "zlib.h"
22
23static z_stream incoming_stream;
24static z_stream outgoing_stream;
25

--- 44 unchanged lines hidden (view full) ---

70 char buf[4096];
71 int status;
72
73 /* This case is not handled below. */
74 if (buffer_len(input_buffer) == 0)
75 return;
76
77 /* Input is the contents of the input buffer. */
18
19#include "ssh.h"
20#include "buffer.h"
21#include "zlib.h"
22
23static z_stream incoming_stream;
24static z_stream outgoing_stream;
25

--- 44 unchanged lines hidden (view full) ---

70 char buf[4096];
71 int status;
72
73 /* This case is not handled below. */
74 if (buffer_len(input_buffer) == 0)
75 return;
76
77 /* Input is the contents of the input buffer. */
78 outgoing_stream.next_in = buffer_ptr(input_buffer);
78 outgoing_stream.next_in = (unsigned char *) buffer_ptr(input_buffer);
79 outgoing_stream.avail_in = buffer_len(input_buffer);
80
81 /* Loop compressing until deflate() returns with avail_out != 0. */
82 do {
83 /* Set up fixed-size output buffer. */
79 outgoing_stream.avail_in = buffer_len(input_buffer);
80
81 /* Loop compressing until deflate() returns with avail_out != 0. */
82 do {
83 /* Set up fixed-size output buffer. */
84 outgoing_stream.next_out = buf;
84 outgoing_stream.next_out = (unsigned char *)buf;
85 outgoing_stream.avail_out = sizeof(buf);
86
87 /* Compress as much data into the buffer as possible. */
88 status = deflate(&outgoing_stream, Z_PARTIAL_FLUSH);
89 switch (status) {
90 case Z_OK:
91 /* Append compressed data to output_buffer. */
92 buffer_append(output_buffer, buf,

--- 26 unchanged lines hidden (view full) ---

119 */
120
121void
122buffer_uncompress(Buffer * input_buffer, Buffer * output_buffer)
123{
124 char buf[4096];
125 int status;
126
85 outgoing_stream.avail_out = sizeof(buf);
86
87 /* Compress as much data into the buffer as possible. */
88 status = deflate(&outgoing_stream, Z_PARTIAL_FLUSH);
89 switch (status) {
90 case Z_OK:
91 /* Append compressed data to output_buffer. */
92 buffer_append(output_buffer, buf,

--- 26 unchanged lines hidden (view full) ---

119 */
120
121void
122buffer_uncompress(Buffer * input_buffer, Buffer * output_buffer)
123{
124 char buf[4096];
125 int status;
126
127 incoming_stream.next_in = buffer_ptr(input_buffer);
127 incoming_stream.next_in = (unsigned char *) buffer_ptr(input_buffer);
128 incoming_stream.avail_in = buffer_len(input_buffer);
129
128 incoming_stream.avail_in = buffer_len(input_buffer);
129
130 incoming_stream.next_out = buf;
130 incoming_stream.next_out = (unsigned char *) buf;
131 incoming_stream.avail_out = sizeof(buf);
132
133 for (;;) {
134 status = inflate(&incoming_stream, Z_PARTIAL_FLUSH);
135 switch (status) {
136 case Z_OK:
137 buffer_append(output_buffer, buf,
138 sizeof(buf) - incoming_stream.avail_out);
131 incoming_stream.avail_out = sizeof(buf);
132
133 for (;;) {
134 status = inflate(&incoming_stream, Z_PARTIAL_FLUSH);
135 switch (status) {
136 case Z_OK:
137 buffer_append(output_buffer, buf,
138 sizeof(buf) - incoming_stream.avail_out);
139 incoming_stream.next_out = buf;
139 incoming_stream.next_out = (unsigned char *) buf;
140 incoming_stream.avail_out = sizeof(buf);
141 break;
142 case Z_STREAM_END:
143 fatal("buffer_uncompress: inflate returned Z_STREAM_END");
144 /* NOTREACHED */
145 case Z_DATA_ERROR:
146 fatal("buffer_uncompress: inflate returned Z_DATA_ERROR");
147 /* NOTREACHED */

--- 18 unchanged lines hidden ---
140 incoming_stream.avail_out = sizeof(buf);
141 break;
142 case Z_STREAM_END:
143 fatal("buffer_uncompress: inflate returned Z_STREAM_END");
144 /* NOTREACHED */
145 case Z_DATA_ERROR:
146 fatal("buffer_uncompress: inflate returned Z_DATA_ERROR");
147 /* NOTREACHED */

--- 18 unchanged lines hidden ---