tor  0.4.2.0-alpha-dev
compress_none.c
Go to the documentation of this file.
1 /* Copyright (c) 2004, Roger Dingledine.
2  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3  * Copyright (c) 2007-2019, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
5 
17 #include "orconfig.h"
18 
19 #include "lib/log/log.h"
20 #include "lib/compress/compress.h"
22 #include "lib/intmath/cmp.h"
23 
24 #include <string.h>
25 
38 tor_cnone_compress_process(char **out, size_t *out_len,
39  const char **in, size_t *in_len,
40  int finish)
41 {
42  size_t n_to_copy = MIN(*in_len, *out_len);
43 
44  memcpy(*out, *in, n_to_copy);
45  *out += n_to_copy;
46  *in += n_to_copy;
47  *out_len -= n_to_copy;
48  *in_len -= n_to_copy;
49  if (*in_len == 0) {
50  return finish ? TOR_COMPRESS_DONE : TOR_COMPRESS_OK;
51  } else {
52  return TOR_COMPRESS_BUFFER_FULL;
53  }
54 }
Macro definitions for MIN, MAX, and CLAMP.
Headers for compress.c.
Header for compress_none.c.
Headers for log.c.
tor_compress_output_t tor_cnone_compress_process(char **out, size_t *out_len, const char **in, size_t *in_len, int finish)
Definition: compress_none.c:38
tor_compress_output_t
Definition: compress.h:68