-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFaster.xs
211 lines (191 loc) · 3.51 KB
/
Faster.xs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
#include <zlib.h>
#include "gzip-faster-perl.c"
typedef gzip_faster_t * Gzip__Faster;
MODULE=Gzip::Faster PACKAGE=Gzip::Faster
PROTOTYPES: DISABLE
SV * gzip (plain)
SV * plain
PREINIT:
gzip_faster_t gz;
CODE:
gz.in = plain;
gz.is_gzip = 1;
gz.is_raw = 0;
gz.user_object = 0;
RETVAL = gzip_faster (& gz);
OUTPUT:
RETVAL
SV * gunzip (zipped)
SV * zipped
PREINIT:
gzip_faster_t gz;
CODE:
gz.in = zipped;
gz.is_gzip = 1;
gz.is_raw = 0;
gz.user_object = 0;
RETVAL = gunzip_faster (& gz);
OUTPUT:
RETVAL
SV * deflate (plain)
SV * plain
PREINIT:
gzip_faster_t gz;
CODE:
gz.in = plain;
gz.is_gzip = 0;
gz.is_raw = 0;
gz.user_object = 0;
RETVAL = gzip_faster (& gz);
OUTPUT:
RETVAL
SV * inflate (deflated)
SV * deflated
PREINIT:
gzip_faster_t gz;
CODE:
gz.in = deflated;
gz.is_gzip = 0;
gz.is_raw = 0;
gz.user_object = 0;
RETVAL = gunzip_faster (& gz);
OUTPUT:
RETVAL
SV * deflate_raw (plain)
SV * plain
PREINIT:
gzip_faster_t gz;
CODE:
gz.in = plain;
gz.is_gzip = 0;
gz.is_raw = 1;
gz.user_object = 0;
RETVAL = gzip_faster (& gz);
OUTPUT:
RETVAL
SV * inflate_raw (deflated)
SV * deflated
PREINIT:
gzip_faster_t gz;
CODE:
gz.is_gzip = 0;
gz.is_raw = 1;
gz.in = deflated;
gz.user_object = 0;
RETVAL = gunzip_faster (& gz);
OUTPUT:
RETVAL
Gzip::Faster
new (class)
const char * class;
CODE:
Newxz (RETVAL, 1, gzip_faster_t);
new_user_object (RETVAL);
if (! class) {
croak ("No class");
}
OUTPUT:
RETVAL
void
DESTROY (gf)
Gzip::Faster gf
CODE:
if (! gf->user_object) {
croak ("%s:%d: THIS IS NOT A USER-VISIBLE OBJECT",
__FILE__, __LINE__);
}
gf_delete_file_name (gf);
gf_delete_mod_time (gf);
Safefree (gf);
void
level (gf, level = Z_DEFAULT_COMPRESSION)
Gzip::Faster gf;
int level;
CODE:
set_compression_level (gf, level);
SV *
zip (gf, plain)
Gzip::Faster gf;
SV * plain;
CODE:
gf->in = plain;
RETVAL = gzip_faster (gf);
OUTPUT:
RETVAL
SV *
unzip (gf, deflated)
Gzip::Faster gf
SV * deflated
CODE:
gf->in = deflated;
RETVAL = gunzip_faster (gf);
OUTPUT:
RETVAL
void
copy_perl_flags (gf, on_off)
Gzip::Faster gf;
SV * on_off;
CODE:
gf->copy_perl_flags = SvTRUE (on_off);
void
raw (gf, on_off)
Gzip::Faster gf;
SV * on_off;
CODE:
gf->is_raw = SvTRUE (on_off);
gf->is_gzip = 0;
void
gzip_format (gf, on_off)
Gzip::Faster gf;
SV * on_off;
CODE:
gf->is_gzip = SvTRUE (on_off);
gf->is_raw = 0;
SV *
file_name (gf, filename = 0)
Gzip::Faster gf;
SV * filename;
CODE:
if (filename) {
gf_set_file_name (gf, filename);
/* We increment the reference count twice, once here
because it returns its own value, and once in
gf_set_file_name. Unless the user captures the
following return value, Perl then decrements it by
one as the return value is discarded, so it has to
be done twice. */
SvREFCNT_inc (filename);
RETVAL = filename;
}
else {
SvREFCNT_inc (gf->file_name);
RETVAL = gf_get_file_name (gf);
}
OUTPUT:
RETVAL
SV *
mod_time (gf, modtime = 0)
Gzip::Faster gf;
SV * modtime;
CODE:
if (modtime) {
gf_set_mod_time (gf, modtime);
/* We increment the reference count twice, once here
because it returns its own value, and once in
gf_set_mod_time. Unless the user captures the
following return value, Perl then decrements it by
one as the return value is discarded, so it has to
be done twice. */
SvREFCNT_inc (modtime);
RETVAL = modtime;
}
else {
SvREFCNT_inc (gf->mod_time);
RETVAL = gf_get_mod_time (gf);
}
OUTPUT:
RETVAL