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