1 | #include "EXTERN.h" |
1 | #include "EXTERN.h" |
2 | #include "perl.h" |
2 | #include "perl.h" |
3 | #include "XSUB.h" |
3 | #include "XSUB.h" |
4 | |
4 | |
|
|
5 | #include "perlmulticore.h" |
|
|
6 | |
5 | #include "uulib/fptools.h" |
7 | #include "uulib/fptools.h" |
6 | #include "uulib/uudeview.h" |
8 | #include "uulib/uudeview.h" |
7 | #include "uulib/uuint.h" |
|
|
8 | |
9 | |
9 | static int |
10 | static int perlinterp_released; |
10 | not_here (char *s) |
|
|
11 | { |
|
|
12 | croak("%s not implemented", s); |
|
|
13 | return -1; |
|
|
14 | } |
|
|
15 | |
11 | |
16 | static int |
12 | #define RELEASE do { perlinterp_released = 1; perlinterp_release (); } while (0) |
17 | constant (char *name) |
13 | #define ACQUIRE do { perlinterp_acquire (); perlinterp_released = 0; } while (0) |
18 | { |
14 | |
19 | errno = 0; |
15 | #define TEMP_ACQUIRE if (perlinterp_released) perlinterp_acquire (); |
20 | switch (*name) { |
16 | #define TEMP_RELEASE if (perlinterp_released) perlinterp_release (); |
21 | case 'A': |
|
|
22 | if (strEQ(name, "ACT_COPYING")) return UUACT_COPYING; |
|
|
23 | if (strEQ(name, "ACT_DECODING")) return UUACT_DECODING; |
|
|
24 | if (strEQ(name, "ACT_ENCODING")) return UUACT_ENCODING; |
|
|
25 | if (strEQ(name, "ACT_IDLE")) return UUACT_IDLE; |
|
|
26 | if (strEQ(name, "ACT_SCANNING")) return UUACT_SCANNING; |
|
|
27 | case 'F': |
|
|
28 | if (strEQ(name, "FILE_DECODED")) return UUFILE_DECODED; |
|
|
29 | if (strEQ(name, "FILE_ERROR")) return UUFILE_ERROR; |
|
|
30 | if (strEQ(name, "FILE_MISPART")) return UUFILE_MISPART; |
|
|
31 | if (strEQ(name, "FILE_NOBEGIN")) return UUFILE_NOBEGIN; |
|
|
32 | if (strEQ(name, "FILE_NODATA")) return UUFILE_NODATA; |
|
|
33 | if (strEQ(name, "FILE_NOEND")) return UUFILE_NOEND; |
|
|
34 | if (strEQ(name, "FILE_OK")) return UUFILE_OK; |
|
|
35 | if (strEQ(name, "FILE_READ")) return UUFILE_READ; |
|
|
36 | if (strEQ(name, "FILE_TMPFILE")) return UUFILE_TMPFILE; |
|
|
37 | break; |
|
|
38 | case 'M': |
|
|
39 | if (strEQ(name, "MSG_ERROR")) return UUMSG_ERROR; |
|
|
40 | if (strEQ(name, "MSG_FATAL")) return UUMSG_FATAL; |
|
|
41 | if (strEQ(name, "MSG_MESSAGE")) return UUMSG_MESSAGE; |
|
|
42 | if (strEQ(name, "MSG_NOTE")) return UUMSG_NOTE; |
|
|
43 | if (strEQ(name, "MSG_PANIC")) return UUMSG_PANIC; |
|
|
44 | if (strEQ(name, "MSG_WARNING")) return UUMSG_WARNING; |
|
|
45 | case 'O': |
|
|
46 | if (strEQ(name, "OPT_VERSION")) return UUOPT_VERSION; |
|
|
47 | if (strEQ(name, "OPT_FAST")) return UUOPT_FAST; |
|
|
48 | if (strEQ(name, "OPT_DUMBNESS")) return UUOPT_DUMBNESS; |
|
|
49 | if (strEQ(name, "OPT_BRACKPOL")) return UUOPT_BRACKPOL; |
|
|
50 | if (strEQ(name, "OPT_VERBOSE")) return UUOPT_VERBOSE; |
|
|
51 | if (strEQ(name, "OPT_DESPERATE")) return UUOPT_DESPERATE; |
|
|
52 | if (strEQ(name, "OPT_IGNREPLY")) return UUOPT_IGNREPLY; |
|
|
53 | if (strEQ(name, "OPT_OVERWRITE")) return UUOPT_OVERWRITE; |
|
|
54 | if (strEQ(name, "OPT_SAVEPATH")) return UUOPT_SAVEPATH; |
|
|
55 | if (strEQ(name, "OPT_IGNMODE")) return UUOPT_IGNMODE; |
|
|
56 | if (strEQ(name, "OPT_DEBUG")) return UUOPT_DEBUG; |
|
|
57 | if (strEQ(name, "OPT_ERRNO")) return UUOPT_ERRNO; |
|
|
58 | if (strEQ(name, "OPT_PROGRESS")) return UUOPT_PROGRESS; |
|
|
59 | if (strEQ(name, "OPT_USETEXT")) return UUOPT_USETEXT; |
|
|
60 | if (strEQ(name, "OPT_PREAMB")) return UUOPT_PREAMB; |
|
|
61 | if (strEQ(name, "OPT_TINYB64")) return UUOPT_TINYB64; |
|
|
62 | if (strEQ(name, "OPT_ENCEXT")) return UUOPT_ENCEXT; |
|
|
63 | if (strEQ(name, "OPT_REMOVE")) return UUOPT_REMOVE; |
|
|
64 | if (strEQ(name, "OPT_MOREMIME")) return UUOPT_MOREMIME; |
|
|
65 | if (strEQ(name, "OPT_DOTDOT")) return UUOPT_DOTDOT; |
|
|
66 | case 'R': |
|
|
67 | if (strEQ(name, "RET_CANCEL")) return UURET_CANCEL; |
|
|
68 | if (strEQ(name, "RET_CONT")) return UURET_CONT; |
|
|
69 | if (strEQ(name, "RET_EXISTS")) return UURET_EXISTS; |
|
|
70 | if (strEQ(name, "RET_ILLVAL")) return UURET_ILLVAL; |
|
|
71 | if (strEQ(name, "RET_IOERR")) return UURET_IOERR; |
|
|
72 | if (strEQ(name, "RET_NODATA")) return UURET_NODATA; |
|
|
73 | if (strEQ(name, "RET_NOEND")) return UURET_NOEND; |
|
|
74 | if (strEQ(name, "RET_NOMEM")) return UURET_NOMEM; |
|
|
75 | if (strEQ(name, "RET_OK")) return UURET_OK; |
|
|
76 | if (strEQ(name, "RET_UNSUP")) return UURET_UNSUP; |
|
|
77 | case 'B': |
|
|
78 | if (strEQ(name, "B64_ENCODED")) return B64ENCODED; |
|
|
79 | if (strEQ(name, "BH_ENCODED")) return BH_ENCODED; |
|
|
80 | case 'P': |
|
|
81 | if (strEQ(name, "PT_ENCODED")) return PT_ENCODED; |
|
|
82 | case 'Q': |
|
|
83 | if (strEQ(name, "QP_ENCODED")) return QP_ENCODED; |
|
|
84 | case 'U': |
|
|
85 | if (strEQ(name, "UU_ENCODED")) return UU_ENCODED; |
|
|
86 | case 'X': |
|
|
87 | if (strEQ(name, "XX_ENCODED")) return XX_ENCODED; |
|
|
88 | case 'Y': |
|
|
89 | if (strEQ(name, "YENC_ENCODED")) return YENC_ENCODED; |
|
|
90 | } |
|
|
91 | errno = EINVAL; |
|
|
92 | return 0; |
|
|
93 | } |
|
|
94 | |
17 | |
95 | static void |
18 | static void |
96 | uu_msg_callback (void *cb, char *msg, int level) |
19 | uu_msg_callback (void *cb, char *msg, int level) |
97 | { |
20 | { |
|
|
21 | TEMP_ACQUIRE { |
|
|
22 | |
98 | dSP; |
23 | dSP; |
99 | |
24 | |
100 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); |
25 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); |
101 | |
26 | |
102 | PUSHs (sv_2mortal (newSVpv (msg, 0))); |
27 | PUSHs (sv_2mortal (newSVpv (msg, 0))); |
103 | PUSHs (sv_2mortal (newSViv (level))); |
28 | PUSHs (sv_2mortal (newSViv (level))); |
104 | |
29 | |
105 | PUTBACK; (void) perl_call_sv ((SV *)cb, G_VOID|G_DISCARD); SPAGAIN; |
30 | PUTBACK; (void) perl_call_sv ((SV *)cb, G_VOID|G_DISCARD); SPAGAIN; |
106 | PUTBACK; FREETMPS; LEAVE; |
31 | PUTBACK; FREETMPS; LEAVE; |
|
|
32 | |
|
|
33 | } TEMP_RELEASE; |
107 | } |
34 | } |
108 | |
35 | |
109 | static int |
36 | static int |
110 | uu_busy_callback (void *cb, uuprogress *uup) |
37 | uu_busy_callback (void *cb, uuprogress *uup) |
111 | { |
38 | { |
112 | dSP; |
|
|
113 | int count; |
|
|
114 | int retval; |
39 | int retval; |
|
|
40 | |
|
|
41 | TEMP_ACQUIRE { |
|
|
42 | |
|
|
43 | dSP; |
|
|
44 | int count; |
115 | |
45 | |
116 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 6); |
46 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 6); |
117 | |
47 | |
118 | PUSHs (sv_2mortal (newSViv (uup->action))); |
48 | PUSHs (sv_2mortal (newSViv (uup->action))); |
119 | PUSHs (sv_2mortal (newSVpv (uup->curfile, 0))); |
49 | PUSHs (sv_2mortal (newSVpv (uup->curfile, 0))); |
120 | PUSHs (sv_2mortal (newSViv (uup->partno))); |
50 | PUSHs (sv_2mortal (newSViv (uup->partno))); |
121 | PUSHs (sv_2mortal (newSViv (uup->numparts))); |
51 | PUSHs (sv_2mortal (newSViv (uup->numparts))); |
122 | PUSHs (sv_2mortal (newSViv (uup->fsize))); |
52 | PUSHs (sv_2mortal (newSViv (uup->fsize))); |
123 | PUSHs (sv_2mortal (newSViv (uup->percent))); |
53 | PUSHs (sv_2mortal (newSViv (uup->percent))); |
124 | |
54 | |
125 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
55 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
126 | |
56 | |
127 | if (count != 1) |
57 | if (count != 1) |
128 | croak ("busycallback perl callback returned more than one argument"); |
58 | croak ("busycallback perl callback returned more than one argument"); |
129 | |
59 | |
130 | retval = POPi; |
60 | retval = POPi; |
131 | |
61 | |
132 | PUTBACK; FREETMPS; LEAVE; |
62 | PUTBACK; FREETMPS; LEAVE; |
|
|
63 | |
|
|
64 | } TEMP_RELEASE; |
133 | |
65 | |
134 | return retval; |
66 | return retval; |
135 | } |
67 | } |
136 | |
68 | |
137 | static char * |
69 | static char * |
138 | uu_fnamefilter_callback (void *cb, char *fname) |
70 | uu_fnamefilter_callback (void *cb, char *fname) |
139 | { |
71 | { |
140 | dSP; |
|
|
141 | int count; |
|
|
142 | static char *str; |
72 | static char *str; |
|
|
73 | |
|
|
74 | TEMP_ACQUIRE { |
|
|
75 | |
|
|
76 | dSP; |
|
|
77 | int count; |
143 | |
78 | |
144 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 1); |
79 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 1); |
145 | |
80 | |
146 | PUSHs (sv_2mortal (newSVpv (fname, 0))); |
81 | PUSHs (sv_2mortal (newSVpv (fname, 0))); |
147 | |
82 | |
148 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
83 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
149 | |
84 | |
150 | if (count != 1) |
85 | if (count != 1) |
151 | croak ("fnamefilter perl callback returned more than one argument"); |
86 | croak ("fnamefilter perl callback MUST return a single filename exactly"); |
152 | |
87 | |
153 | _FP_free(str); str = _FP_strdup (POPp); |
88 | FP_free (str); str = FP_strdup (SvPV_nolen (TOPs)); |
154 | |
89 | |
155 | PUTBACK; FREETMPS; LEAVE; |
90 | PUTBACK; FREETMPS; LEAVE; |
|
|
91 | |
|
|
92 | } TEMP_RELEASE; |
156 | |
93 | |
157 | return str; |
94 | return str; |
158 | } |
95 | } |
159 | |
96 | |
160 | static int |
97 | static int |
161 | uu_file_callback (void *cb, char *id, char *fname, int retrieve) |
98 | uu_file_callback (void *cb, char *id, char *fname, int retrieve) |
162 | { |
99 | { |
163 | dSP; |
|
|
164 | int count; |
|
|
165 | int retval; |
100 | int retval; |
|
|
101 | |
|
|
102 | TEMP_ACQUIRE { |
|
|
103 | |
|
|
104 | dSP; |
|
|
105 | int count; |
166 | SV *xfname = newSVpv ("", 0); |
106 | SV *xfname = newSVpv ("", 0); |
167 | STRLEN dc; |
|
|
168 | |
107 | |
169 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 3); |
108 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 3); |
170 | |
109 | |
171 | PUSHs (sv_2mortal (newSVpv (id, 0))); |
110 | PUSHs (sv_2mortal (newSVpv (id, 0))); |
172 | PUSHs (sv_2mortal (xfname)); |
111 | PUSHs (sv_2mortal (xfname)); |
173 | PUSHs (sv_2mortal (newSViv (retrieve))); |
112 | PUSHs (sv_2mortal (newSViv (retrieve))); |
174 | |
113 | |
175 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
114 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
176 | |
115 | |
177 | if (count != 1) |
116 | if (count != 1) |
178 | croak ("filecallback perl callback returned more than one argument"); |
117 | croak ("filecallback perl callback must return a single return status"); |
179 | |
118 | |
180 | strcpy (fname, SvPV (xfname, dc)); |
119 | strcpy (fname, SvPV_nolen (xfname)); |
181 | |
|
|
182 | retval = POPi; |
120 | retval = POPi; |
183 | |
121 | |
184 | PUTBACK; FREETMPS; LEAVE; |
122 | PUTBACK; FREETMPS; LEAVE; |
|
|
123 | |
|
|
124 | } TEMP_RELEASE; |
185 | |
125 | |
186 | return retval; |
126 | return retval; |
187 | } |
127 | } |
188 | |
128 | |
189 | static char * |
129 | static char * |
190 | uu_filename_callback (void *cb, char *subject, char *filename) |
130 | uu_filename_callback (void *cb, char *subject, char *filename) |
191 | { |
131 | { |
|
|
132 | TEMP_ACQUIRE { |
|
|
133 | |
192 | dSP; |
134 | dSP; |
193 | int count; |
135 | int count; |
194 | SV *retval; |
|
|
195 | STRLEN dc; |
|
|
196 | |
136 | |
197 | ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,3); |
137 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); |
198 | |
138 | |
199 | PUSHs(sv_2mortal(newSVpv(subject, 0))); |
139 | PUSHs (sv_2mortal (newSVpv (subject, 0))); |
200 | PUSHs(filename ? sv_2mortal(newSVpv(filename, 0)) : &PL_sv_undef); |
140 | PUSHs (filename ? sv_2mortal (newSVpv (filename, 0)) : &PL_sv_undef); |
201 | |
141 | |
202 | PUTBACK; count = perl_call_sv ((SV *)cb, G_ARRAY); SPAGAIN; |
142 | PUTBACK; count = perl_call_sv ((SV *)cb, G_ARRAY); SPAGAIN; |
203 | |
143 | |
204 | if (count > 1) |
144 | if (count > 1) |
205 | croak ("filenamecallback perl callback returned more than one argument"); |
145 | croak ("filenamecallback perl callback must return nothing or a single filename"); |
206 | |
146 | |
207 | if (count) |
147 | if (count) |
208 | { |
148 | { |
209 | _FP_free (filename); |
149 | FP_free (filename); |
210 | |
150 | |
211 | retval = POPs; |
151 | filename = SvOK (TOPs) |
212 | |
152 | ? FP_strdup (SvPV_nolen (TOPs)) |
213 | if (SvOK (retval)) |
|
|
214 | { |
|
|
215 | STRLEN len; |
|
|
216 | char *fn = SvPV (retval, len); |
|
|
217 | |
|
|
218 | filename = malloc (len + 1); |
|
|
219 | |
|
|
220 | if (filename) |
|
|
221 | { |
153 | : 0; |
222 | memcpy (filename, fn, len); |
|
|
223 | filename[len] = 0; |
|
|
224 | } |
|
|
225 | } |
154 | } |
226 | else |
|
|
227 | filename = 0; |
|
|
228 | } |
|
|
229 | |
155 | |
230 | PUTBACK; FREETMPS; LEAVE; |
156 | PUTBACK; FREETMPS; LEAVE; |
|
|
157 | |
|
|
158 | } TEMP_RELEASE; |
231 | |
159 | |
232 | return filename; |
160 | return filename; |
233 | } |
161 | } |
234 | |
162 | |
235 | static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv, *uu_filename_sv; |
163 | static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv, *uu_filename_sv; |
… | |
… | |
237 | #define FUNC_CB(cb) (void *)(sv_setsv (cb ## _sv, func), cb ## _sv), func ? cb ## _callback : NULL |
165 | #define FUNC_CB(cb) (void *)(sv_setsv (cb ## _sv, func), cb ## _sv), func ? cb ## _callback : NULL |
238 | |
166 | |
239 | static int |
167 | static int |
240 | uu_info_file (void *cb, char *info) |
168 | uu_info_file (void *cb, char *info) |
241 | { |
169 | { |
242 | dSP; |
|
|
243 | int count; |
|
|
244 | int retval; |
170 | int retval; |
|
|
171 | |
|
|
172 | TEMP_ACQUIRE { |
|
|
173 | |
|
|
174 | dSP; |
|
|
175 | int count; |
245 | |
176 | |
246 | ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,1); |
177 | ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,1); |
247 | |
178 | |
248 | PUSHs(sv_2mortal(newSVpv(info,0))); |
179 | PUSHs(sv_2mortal(newSVpv(info,0))); |
249 | |
180 | |
250 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
181 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
251 | |
182 | |
252 | if (count != 1) |
183 | if (count != 1) |
253 | croak ("info_file perl callback returned more than one argument"); |
184 | croak ("info_file perl callback returned more than one argument"); |
254 | |
185 | |
255 | retval = POPi; |
186 | retval = POPi; |
256 | |
187 | |
257 | PUTBACK; FREETMPS; LEAVE; |
188 | PUTBACK; FREETMPS; LEAVE; |
|
|
189 | |
|
|
190 | } TEMP_RELEASE; |
258 | |
191 | |
259 | return retval; |
192 | return retval; |
260 | } |
193 | } |
261 | |
194 | |
262 | static int |
195 | static int |
… | |
… | |
271 | default: |
204 | default: |
272 | return 0; |
205 | return 0; |
273 | } |
206 | } |
274 | } |
207 | } |
275 | |
208 | |
276 | static int uu_initialized; |
209 | static void |
|
|
210 | initialise (void) |
|
|
211 | { |
|
|
212 | int retval = UUInitialize (); |
|
|
213 | |
|
|
214 | if (retval != UURET_OK) |
|
|
215 | croak ("unable to initialize uudeview library (%s)", UUstrerror (retval)); |
|
|
216 | } |
277 | |
217 | |
278 | MODULE = Convert::UUlib PACKAGE = Convert::UUlib PREFIX = UU |
218 | MODULE = Convert::UUlib PACKAGE = Convert::UUlib PREFIX = UU |
279 | |
219 | |
280 | PROTOTYPES: ENABLE |
220 | PROTOTYPES: ENABLE |
281 | |
|
|
282 | int |
|
|
283 | constant (name) |
|
|
284 | char * name |
|
|
285 | |
|
|
286 | |
|
|
287 | void |
|
|
288 | UUInitialize () |
|
|
289 | CODE: |
|
|
290 | if (!uu_initialized) |
|
|
291 | { |
|
|
292 | int retval; |
|
|
293 | |
|
|
294 | if ((retval = UUInitialize ()) != UURET_OK) |
|
|
295 | croak ("unable to initialize uudeview library (%s)", UUstrerror (retval)); |
|
|
296 | |
|
|
297 | uu_initialized = 1; |
|
|
298 | } |
|
|
299 | |
221 | |
300 | void |
222 | void |
301 | UUCleanUp () |
223 | UUCleanUp () |
302 | CODE: |
224 | CODE: |
303 | if (uu_initialized) |
|
|
304 | UUCleanUp (); |
225 | UUCleanUp (); |
305 | |
226 | initialise (); |
306 | uu_initialized = 0; |
|
|
307 | |
227 | |
308 | SV * |
228 | SV * |
309 | UUGetOption (opt) |
229 | UUGetOption (opt) |
310 | int opt |
230 | int opt |
311 | CODE: |
231 | CODE: |
312 | { |
232 | { |
313 | if (opt == UUOPT_PROGRESS) |
233 | if (opt == UUOPT_PROGRESS) |
314 | croak ("GetOption(UUOPT_PROGRESS) is not yet implemented"); |
234 | croak ("GetOption(UUOPT_PROGRESS) is not yet implemented"); |
315 | else if (uu_opt_isstring (opt)) |
235 | else if (uu_opt_isstring (opt)) |
316 | { |
236 | { |
317 | char cval[8192]; |
237 | char cval[8192]; |
318 | |
238 | |
319 | UUGetOption (opt, 0, cval, sizeof cval); |
239 | UUGetOption (opt, 0, cval, sizeof cval); |
320 | RETVAL = newSVpv (cval, 0); |
240 | RETVAL = newSVpv (cval, 0); |
321 | } |
241 | } |
322 | else |
242 | else |
323 | { |
243 | { |
324 | RETVAL = newSViv (UUGetOption (opt, 0, 0, 0)); |
244 | RETVAL = newSViv (UUGetOption (opt, 0, 0, 0)); |
325 | } |
245 | } |
326 | } |
246 | } |
327 | OUTPUT: |
247 | OUTPUT: |
328 | RETVAL |
248 | RETVAL |
329 | |
249 | |
330 | int |
250 | int |
331 | UUSetOption (opt, val) |
251 | UUSetOption (opt, val) |
332 | int opt |
252 | int opt |
333 | SV * val |
253 | SV * val |
334 | CODE: |
254 | CODE: |
335 | { |
255 | { |
336 | STRLEN dc; |
256 | STRLEN dc; |
337 | |
257 | |
338 | if (uu_opt_isstring (opt)) |
258 | if (uu_opt_isstring (opt)) |
339 | RETVAL = UUSetOption (opt, 0, SvPV (val, dc)); |
259 | RETVAL = UUSetOption (opt, 0, SvPV (val, dc)); |
340 | else |
260 | else |
341 | RETVAL = UUSetOption (opt, SvIV (val), (void *)0); |
261 | RETVAL = UUSetOption (opt, SvIV (val), (void *)0); |
342 | } |
262 | } |
343 | OUTPUT: |
263 | OUTPUT: |
344 | RETVAL |
264 | RETVAL |
345 | |
265 | |
346 | char * |
266 | char * |
347 | UUstrerror (errcode) |
267 | UUstrerror (errcode) |
… | |
… | |
349 | |
269 | |
350 | void |
270 | void |
351 | UUSetMsgCallback (func = 0) |
271 | UUSetMsgCallback (func = 0) |
352 | SV * func |
272 | SV * func |
353 | CODE: |
273 | CODE: |
354 | UUSetMsgCallback (FUNC_CB(uu_msg)); |
274 | UUSetMsgCallback (FUNC_CB (uu_msg)); |
355 | |
275 | |
356 | void |
276 | void |
357 | UUSetBusyCallback (func = 0,msecs = 1000) |
277 | UUSetBusyCallback (func = 0,msecs = 1000) |
358 | SV * func |
278 | SV * func |
359 | long msecs |
279 | long msecs |
360 | CODE: |
280 | CODE: |
361 | UUSetBusyCallback (FUNC_CB(uu_busy), msecs); |
281 | UUSetBusyCallback (FUNC_CB (uu_busy), msecs); |
362 | |
282 | |
363 | void |
283 | void |
364 | UUSetFileCallback (func = 0) |
284 | UUSetFileCallback (func = 0) |
365 | SV * func |
285 | SV * func |
366 | CODE: |
286 | CODE: |
367 | UUSetFileCallback (FUNC_CB(uu_file)); |
287 | UUSetFileCallback (FUNC_CB (uu_file)); |
368 | |
288 | |
369 | void |
289 | void |
370 | UUSetFNameFilter (func = 0) |
290 | UUSetFNameFilter (func = 0) |
371 | SV * func |
291 | SV * func |
372 | CODE: |
292 | CODE: |
373 | UUSetFNameFilter (FUNC_CB(uu_fnamefilter)); |
293 | UUSetFNameFilter (FUNC_CB (uu_fnamefilter)); |
374 | |
294 | |
375 | void |
295 | void |
376 | UUSetFileNameCallback (func = 0) |
296 | UUSetFileNameCallback (func = 0) |
377 | SV * func |
297 | SV * func |
378 | CODE: |
298 | CODE: |
379 | UUSetFileNameCallback (FUNC_CB(uu_filename)); |
299 | UUSetFileNameCallback (FUNC_CB (uu_filename)); |
380 | |
300 | |
381 | char * |
301 | char * |
382 | UUFNameFilter (fname) |
302 | UUFNameFilter (fname) |
383 | char * fname |
303 | char * fname |
384 | |
304 | |
385 | void |
305 | void |
386 | UULoadFile (fname, id = 0, delflag = 0, int partno = -1) |
306 | UULoadFile (fname, id = 0, delflag = 0, partno = -1) |
387 | char * fname |
307 | char * fname |
388 | char * id |
308 | char * id |
389 | int delflag |
309 | int delflag |
|
|
310 | int partno |
390 | PPCODE: |
311 | PPCODE: |
391 | { |
312 | { |
392 | int count; |
313 | int count; |
393 | |
314 | IV ret; |
394 | XPUSHs (sv_2mortal (newSViv (UULoadFileWithPartNo (fname, id, delflag, partno, &count)))); |
315 | |
|
|
316 | RELEASE; |
|
|
317 | ret = UULoadFileWithPartNo (fname, id, delflag, partno, &count); |
|
|
318 | ACQUIRE; |
|
|
319 | |
|
|
320 | XPUSHs (sv_2mortal (newSViv (ret))); |
395 | if (GIMME_V == G_ARRAY) |
321 | if (GIMME_V == G_ARRAY) |
396 | XPUSHs (sv_2mortal (newSViv (count))); |
322 | XPUSHs (sv_2mortal (newSViv (count))); |
397 | } |
323 | } |
398 | |
324 | |
399 | int |
325 | int |
400 | UUSmerge (pass) |
326 | UUSmerge (pass) |
401 | int pass |
327 | int pass |
402 | |
328 | |
… | |
… | |
416 | char * outfname |
342 | char * outfname |
417 | char * mimetype |
343 | char * mimetype |
418 | int filemode |
344 | int filemode |
419 | |
345 | |
420 | int |
346 | int |
421 | UUEncodePartial(outfile,infile,infname,encoding,outfname,mimetype,filemode,partno,linperfile) |
347 | UUEncodePartial(outfile,infile,infname,encoding,outfname,mimetype,filemode,partno,linperfile,crc) |
422 | FILE * outfile |
348 | FILE * outfile |
423 | FILE * infile |
349 | FILE * infile |
424 | char * infname |
350 | char * infname |
425 | int encoding |
351 | int encoding |
426 | char * outfname |
352 | char * outfname |
427 | char * mimetype |
353 | char * mimetype |
428 | int filemode |
354 | int filemode |
429 | int partno |
355 | int partno |
430 | long linperfile |
356 | long linperfile |
|
|
357 | U32 &crc |
|
|
358 | OUTPUT: |
|
|
359 | RETVAL |
|
|
360 | crc |
431 | |
361 | |
432 | int |
362 | int |
433 | UUEncodeToStream(outfile,infile,infname,encoding,outfname,filemode) |
363 | UUEncodeToStream(outfile,infile,infname,encoding,outfname,filemode) |
434 | FILE * outfile |
364 | FILE * outfile |
435 | FILE * infile |
365 | FILE * infile |
… | |
… | |
478 | |
408 | |
479 | uulist * |
409 | uulist * |
480 | UUGetFileListItem (num) |
410 | UUGetFileListItem (num) |
481 | int num |
411 | int num |
482 | |
412 | |
|
|
413 | void |
|
|
414 | GetFileList () |
|
|
415 | PPCODE: |
|
|
416 | { |
|
|
417 | uulist *iter; |
|
|
418 | |
|
|
419 | for (iter = UUGlobalFileList; iter; iter = iter->NEXT) |
|
|
420 | XPUSHs (sv_setref_pv (sv_newmortal (), "Convert::UUlib::Item", iter)); |
|
|
421 | } |
|
|
422 | |
483 | MODULE = Convert::UUlib PACKAGE = Convert::UUlib::Item |
423 | MODULE = Convert::UUlib PACKAGE = Convert::UUlib::Item |
484 | |
424 | |
485 | int |
425 | int |
486 | rename (item, newname) |
426 | rename (item, newname) |
487 | uulist *item |
427 | uulist *item |
… | |
… | |
493 | |
433 | |
494 | int |
434 | int |
495 | decode_temp (item) |
435 | decode_temp (item) |
496 | uulist *item |
436 | uulist *item |
497 | CODE: |
437 | CODE: |
|
|
438 | RELEASE; |
498 | RETVAL = UUDecodeToTemp (item); |
439 | RETVAL = UUDecodeToTemp (item); |
|
|
440 | ACQUIRE; |
499 | OUTPUT: |
441 | OUTPUT: |
500 | RETVAL |
442 | RETVAL |
501 | |
443 | |
502 | int |
444 | int |
503 | remove_temp (item) |
445 | remove_temp (item) |
504 | uulist *item |
446 | uulist *item |
505 | CODE: |
447 | CODE: |
|
|
448 | RELEASE; |
506 | RETVAL = UURemoveTemp (item); |
449 | RETVAL = UURemoveTemp (item); |
|
|
450 | ACQUIRE; |
507 | OUTPUT: |
451 | OUTPUT: |
508 | RETVAL |
452 | RETVAL |
509 | |
453 | |
510 | int |
454 | int |
511 | decode (item, target = 0) |
455 | decode (item, target = 0) |
512 | uulist *item |
456 | uulist *item |
513 | char * target |
457 | char * target |
514 | CODE: |
458 | CODE: |
|
|
459 | RELEASE; |
515 | RETVAL = UUDecodeFile (item, target); |
460 | RETVAL = UUDecodeFile (item, target); |
|
|
461 | ACQUIRE; |
516 | OUTPUT: |
462 | OUTPUT: |
517 | RETVAL |
463 | RETVAL |
518 | |
464 | |
519 | void |
465 | void |
520 | info (item, func) |
466 | info (item, func) |
521 | uulist *item |
467 | uulist *item |
522 | SV * func |
468 | SV * func |
523 | CODE: |
469 | CODE: |
|
|
470 | RELEASE; |
524 | UUInfoFile (item,(void *)func, uu_info_file); |
471 | UUInfoFile (item, (void *)func, uu_info_file); |
|
|
472 | ACQUIRE; |
525 | |
473 | |
526 | short |
474 | short |
527 | state(li) |
475 | state(li) |
528 | uulist *li |
476 | uulist *li |
529 | CODE: |
477 | CODE: |
… | |
… | |
563 | uulist *li |
511 | uulist *li |
564 | char * newfilename |
512 | char * newfilename |
565 | CODE: |
513 | CODE: |
566 | if (newfilename) |
514 | if (newfilename) |
567 | { |
515 | { |
568 | _FP_free (li->filename); |
516 | FP_free (li->filename); |
569 | li->filename = _FP_strdup (newfilename); |
517 | li->filename = FP_strdup (newfilename); |
570 | } |
518 | } |
571 | RETVAL = li->filename; |
519 | RETVAL = li->filename; |
572 | OUTPUT: |
520 | OUTPUT: |
573 | RETVAL |
521 | RETVAL |
574 | |
522 | |
… | |
… | |
608 | |
556 | |
609 | void |
557 | void |
610 | parts (li) |
558 | parts (li) |
611 | uulist *li |
559 | uulist *li |
612 | PPCODE: |
560 | PPCODE: |
613 | { |
561 | { |
614 | struct _uufile *p = li->thisfile; |
562 | struct _uufile *p = li->thisfile; |
615 | |
563 | |
616 | while (p) |
564 | while (p) |
617 | { |
565 | { |
618 | HV *pi = newHV (); |
566 | HV *pi = newHV (); |
619 | |
567 | |
620 | hv_store (pi, "partno" , 6, newSViv (p->partno) , 0); |
568 | hv_store (pi, "partno" , 6, newSViv (p->partno) , 0); |
621 | |
|
|
622 | if (p->filename) |
|
|
623 | hv_store (pi, "filename", 8, newSVpv (p->filename, 0) , 0); |
569 | if (p->filename ) hv_store (pi, "filename", 8, newSVpv (p->filename, 0) , 0); |
624 | if(p->subfname) |
|
|
625 | hv_store (pi, "subfname", 8, newSVpv (p->subfname, 0) , 0); |
570 | if (p->subfname ) hv_store (pi, "subfname", 8, newSVpv (p->subfname, 0) , 0); |
626 | if(p->mimeid) |
571 | if (p->mimeid ) hv_store (pi, "mimeid" , 6, newSVpv (p->mimeid , 0) , 0); |
627 | hv_store (pi, "mimeid" , 6, newSVpv (p->mimeid , 0) , 0); |
|
|
628 | if(p->mimetype) |
|
|
629 | hv_store (pi, "mimetype", 8, newSVpv (p->mimetype, 0) , 0); |
572 | if (p->mimetype ) hv_store (pi, "mimetype", 8, newSVpv (p->mimetype, 0) , 0); |
630 | if (p->data->subject) |
|
|
631 | hv_store (pi, "subject" , 7, newSVpv (p->data->subject,0), 0); |
573 | if (p->data->subject) hv_store (pi, "subject" , 7, newSVpv (p->data->subject,0), 0); |
632 | if (p->data->origin) |
574 | if (p->data->origin ) hv_store (pi, "origin" , 6, newSVpv (p->data->origin ,0), 0); |
633 | hv_store (pi, "origin" , 6, newSVpv (p->data->origin ,0), 0); |
575 | if (p->data->sfname ) hv_store (pi, "sfname" , 6, newSVpv (p->data->sfname ,0), 0); |
634 | if (p->data->sfname) |
|
|
635 | hv_store (pi, "sfname" , 6, newSVpv (p->data->sfname ,0), 0); |
|
|
636 | |
576 | |
637 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)pi))); |
577 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)pi))); |
638 | |
578 | |
639 | p = p->NEXT; |
579 | p = p->NEXT; |
640 | } |
|
|
641 | } |
580 | } |
|
|
581 | } |
642 | |
582 | |
643 | BOOT: |
583 | BOOT: |
|
|
584 | { |
|
|
585 | HV *stash = GvSTASH (CvGV (cv)); |
|
|
586 | |
|
|
587 | static const struct { |
|
|
588 | const char *name; |
|
|
589 | IV iv; |
|
|
590 | } *civ, const_iv[] = { |
|
|
591 | # define const_iv(name, value) { # name, (IV) value }, |
|
|
592 | const_iv (ACT_COPYING , UUACT_COPYING) |
|
|
593 | const_iv (ACT_DECODING , UUACT_DECODING) |
|
|
594 | const_iv (ACT_ENCODING , UUACT_ENCODING) |
|
|
595 | const_iv (ACT_IDLE , UUACT_IDLE) |
|
|
596 | const_iv (ACT_SCANNING , UUACT_SCANNING) |
|
|
597 | const_iv (FILE_DECODED , UUFILE_DECODED) |
|
|
598 | const_iv (FILE_ERROR , UUFILE_ERROR) |
|
|
599 | const_iv (FILE_MISPART , UUFILE_MISPART) |
|
|
600 | const_iv (FILE_NOBEGIN , UUFILE_NOBEGIN) |
|
|
601 | const_iv (FILE_NODATA , UUFILE_NODATA) |
|
|
602 | const_iv (FILE_NOEND , UUFILE_NOEND) |
|
|
603 | const_iv (FILE_OK , UUFILE_OK) |
|
|
604 | const_iv (FILE_READ , UUFILE_READ) |
|
|
605 | const_iv (FILE_TMPFILE , UUFILE_TMPFILE) |
|
|
606 | const_iv (MSG_ERROR , UUMSG_ERROR) |
|
|
607 | const_iv (MSG_FATAL , UUMSG_FATAL) |
|
|
608 | const_iv (MSG_MESSAGE , UUMSG_MESSAGE) |
|
|
609 | const_iv (MSG_NOTE , UUMSG_NOTE) |
|
|
610 | const_iv (MSG_PANIC , UUMSG_PANIC) |
|
|
611 | const_iv (MSG_WARNING , UUMSG_WARNING) |
|
|
612 | const_iv (OPT_VERSION , UUOPT_VERSION) |
|
|
613 | const_iv (OPT_FAST , UUOPT_FAST) |
|
|
614 | const_iv (OPT_DUMBNESS , UUOPT_DUMBNESS) |
|
|
615 | const_iv (OPT_BRACKPOL , UUOPT_BRACKPOL) |
|
|
616 | const_iv (OPT_VERBOSE , UUOPT_VERBOSE) |
|
|
617 | const_iv (OPT_DESPERATE, UUOPT_DESPERATE) |
|
|
618 | const_iv (OPT_IGNREPLY , UUOPT_IGNREPLY) |
|
|
619 | const_iv (OPT_OVERWRITE, UUOPT_OVERWRITE) |
|
|
620 | const_iv (OPT_SAVEPATH , UUOPT_SAVEPATH) |
|
|
621 | const_iv (OPT_IGNMODE , UUOPT_IGNMODE) |
|
|
622 | const_iv (OPT_DEBUG , UUOPT_DEBUG) |
|
|
623 | const_iv (OPT_ERRNO , UUOPT_ERRNO) |
|
|
624 | const_iv (OPT_PROGRESS , UUOPT_PROGRESS) |
|
|
625 | const_iv (OPT_USETEXT , UUOPT_USETEXT) |
|
|
626 | const_iv (OPT_PREAMB , UUOPT_PREAMB) |
|
|
627 | const_iv (OPT_TINYB64 , UUOPT_TINYB64) |
|
|
628 | const_iv (OPT_ENCEXT , UUOPT_ENCEXT) |
|
|
629 | const_iv (OPT_REMOVE , UUOPT_REMOVE) |
|
|
630 | const_iv (OPT_MOREMIME , UUOPT_MOREMIME) |
|
|
631 | const_iv (OPT_DOTDOT , UUOPT_DOTDOT) |
|
|
632 | const_iv (OPT_RBUF , UUOPT_RBUF) |
|
|
633 | const_iv (OPT_WBUF , UUOPT_WBUF) |
|
|
634 | const_iv (OPT_AUTOCHECK, UUOPT_AUTOCHECK) |
|
|
635 | const_iv (RET_CANCEL , UURET_CANCEL) |
|
|
636 | const_iv (RET_CONT , UURET_CONT) |
|
|
637 | const_iv (RET_EXISTS , UURET_EXISTS) |
|
|
638 | const_iv (RET_ILLVAL , UURET_ILLVAL) |
|
|
639 | const_iv (RET_IOERR , UURET_IOERR) |
|
|
640 | const_iv (RET_NODATA , UURET_NODATA) |
|
|
641 | const_iv (RET_NOEND , UURET_NOEND) |
|
|
642 | const_iv (RET_NOMEM , UURET_NOMEM) |
|
|
643 | const_iv (RET_OK , UURET_OK) |
|
|
644 | const_iv (RET_UNSUP , UURET_UNSUP) |
|
|
645 | const_iv (B64_ENCODED , B64ENCODED) |
|
|
646 | const_iv (BH_ENCODED , BH_ENCODED) |
|
|
647 | const_iv (PT_ENCODED , PT_ENCODED) |
|
|
648 | const_iv (QP_ENCODED , QP_ENCODED) |
|
|
649 | const_iv (UU_ENCODED , UU_ENCODED) |
|
|
650 | const_iv (XX_ENCODED , XX_ENCODED) |
|
|
651 | const_iv (YENC_ENCODED , YENC_ENCODED) |
|
|
652 | }; |
|
|
653 | |
|
|
654 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
|
|
655 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
|
|
656 | |
644 | uu_msg_sv = newSVsv(&PL_sv_undef); |
657 | uu_msg_sv = newSVsv (&PL_sv_undef); |
645 | uu_busy_sv = newSVsv(&PL_sv_undef); |
658 | uu_busy_sv = newSVsv (&PL_sv_undef); |
646 | uu_file_sv = newSVsv(&PL_sv_undef); |
659 | uu_file_sv = newSVsv (&PL_sv_undef); |
647 | uu_fnamefilter_sv = newSVsv(&PL_sv_undef); |
660 | uu_fnamefilter_sv = newSVsv (&PL_sv_undef); |
648 | uu_filename_sv = newSVsv(&PL_sv_undef); |
661 | uu_filename_sv = newSVsv (&PL_sv_undef); |
649 | |
662 | |
|
|
663 | initialise (); |
|
|
664 | } |
|
|
665 | |