Tor
0.4.9.3-alpha-dev
Toggle main menu visibility
Main Page
Related Pages
Topics
Data Structures
Data Structures
Data Structure Index
Data Fields
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Functions
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Enumerator
Files
File List
Globals
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Typedefs
b
c
d
f
g
h
l
m
n
o
p
r
s
v
Enumerations
a
b
c
d
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Enumerator
a
b
c
d
e
g
h
i
m
n
o
p
q
r
s
t
v
w
Macros
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
x
•
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
Loading...
Searching...
No Matches
lib
compress
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-2021, The Tor Project, Inc. */
4
/* See LICENSE for licensing information */
5
6
/**
7
* \file compress_none.c
8
* \brief Compression backend for identity compression.
9
*
10
* We actually define this backend so that we can treat the identity transform
11
* as another case of compression.
12
*
13
* This module should never be invoked directly. Use the compress module
14
* instead.
15
**/
16
17
#include "orconfig.h"
18
19
#include "
lib/log/log.h
"
20
#include "
lib/compress/compress.h
"
21
#include "
lib/compress/compress_none.h
"
22
#include "
lib/intmath/cmp.h
"
23
24
#include <string.h>
25
26
/** Transfer some bytes using the identity transformation. Read up to
27
* *<b>in_len</b> bytes from *<b>in</b>, and write up to *<b>out_len</b> bytes
28
* to *<b>out</b>, adjusting the values as we go. If <b>finish</b> is true,
29
* we've reached the end of the input.
30
*
31
* Return TOR_COMPRESS_DONE if we've finished the entire
32
* compression/decompression.
33
* Return TOR_COMPRESS_OK if we're processed everything from the input.
34
* Return TOR_COMPRESS_BUFFER_FULL if we're out of space on <b>out</b>.
35
* Return TOR_COMPRESS_ERROR if the stream is corrupt.
36
*/
37
tor_compress_output_t
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
}
38
tor_cnone_compress_process
(
char
**out,
size_t
*out_len, {
…
}
cmp.h
Macro definitions for MIN, MAX, and CLAMP.
compress.h
Headers for compress.c.
tor_compress_output_t
tor_compress_output_t
Definition
compress.h:68
tor_cnone_compress_process
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
compress_none.h
Header for compress_none.c.
log.h
Headers for log.c.
Generated by
1.9.8