Faster.xs

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