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" |
9 | #include "uulib/uuint.h" |
|
|
10 | |
|
|
11 | static int released; |
|
|
12 | |
|
|
13 | #define RELEASE do { released = 1; perlinterp_release (); } while (0) |
|
|
14 | #define ACQUIRE do { perlinterp_acquire (); released = 0; } while (0) |
|
|
15 | |
|
|
16 | #define TEMP_ACQUIRE if (released) perlinterp_acquire (); |
|
|
17 | #define TEMP_RELEASE if (released) perlinterp_release (); |
8 | |
18 | |
9 | static int |
19 | static int |
10 | not_here (char *s) |
20 | not_here (char *s) |
11 | { |
21 | { |
12 | croak("%s not implemented", s); |
22 | croak("%s not implemented", s); |
… | |
… | |
98 | } |
108 | } |
99 | |
109 | |
100 | static void |
110 | static void |
101 | uu_msg_callback (void *cb, char *msg, int level) |
111 | uu_msg_callback (void *cb, char *msg, int level) |
102 | { |
112 | { |
|
|
113 | TEMP_ACQUIRE { |
|
|
114 | |
103 | dSP; |
115 | dSP; |
104 | |
116 | |
105 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); |
117 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); |
106 | |
118 | |
107 | PUSHs (sv_2mortal (newSVpv (msg, 0))); |
119 | PUSHs (sv_2mortal (newSVpv (msg, 0))); |
108 | PUSHs (sv_2mortal (newSViv (level))); |
120 | PUSHs (sv_2mortal (newSViv (level))); |
109 | |
121 | |
110 | PUTBACK; (void) perl_call_sv ((SV *)cb, G_VOID|G_DISCARD); SPAGAIN; |
122 | PUTBACK; (void) perl_call_sv ((SV *)cb, G_VOID|G_DISCARD); SPAGAIN; |
111 | PUTBACK; FREETMPS; LEAVE; |
123 | PUTBACK; FREETMPS; LEAVE; |
|
|
124 | |
|
|
125 | } TEMP_RELEASE; |
112 | } |
126 | } |
113 | |
127 | |
114 | static int |
128 | static int |
115 | uu_busy_callback (void *cb, uuprogress *uup) |
129 | uu_busy_callback (void *cb, uuprogress *uup) |
116 | { |
130 | { |
|
|
131 | int retval; |
|
|
132 | |
|
|
133 | TEMP_ACQUIRE { |
|
|
134 | |
117 | dSP; |
135 | dSP; |
118 | int count; |
136 | int count; |
119 | int retval; |
137 | |
120 | |
|
|
121 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 6); |
138 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 6); |
122 | |
139 | |
123 | PUSHs (sv_2mortal (newSViv (uup->action))); |
140 | PUSHs (sv_2mortal (newSViv (uup->action))); |
124 | PUSHs (sv_2mortal (newSVpv (uup->curfile, 0))); |
141 | PUSHs (sv_2mortal (newSVpv (uup->curfile, 0))); |
125 | PUSHs (sv_2mortal (newSViv (uup->partno))); |
142 | PUSHs (sv_2mortal (newSViv (uup->partno))); |
… | |
… | |
134 | |
151 | |
135 | retval = POPi; |
152 | retval = POPi; |
136 | |
153 | |
137 | PUTBACK; FREETMPS; LEAVE; |
154 | PUTBACK; FREETMPS; LEAVE; |
138 | |
155 | |
|
|
156 | } TEMP_RELEASE; |
|
|
157 | |
139 | return retval; |
158 | return retval; |
140 | } |
159 | } |
141 | |
160 | |
142 | static char * |
161 | static char * |
143 | uu_fnamefilter_callback (void *cb, char *fname) |
162 | uu_fnamefilter_callback (void *cb, char *fname) |
144 | { |
163 | { |
|
|
164 | static char *str; |
|
|
165 | |
|
|
166 | TEMP_ACQUIRE { |
|
|
167 | |
145 | dSP; |
168 | dSP; |
146 | int count; |
169 | int count; |
147 | static char *str; |
170 | |
148 | |
|
|
149 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 1); |
171 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 1); |
150 | |
172 | |
151 | PUSHs (sv_2mortal (newSVpv (fname, 0))); |
173 | PUSHs (sv_2mortal (newSVpv (fname, 0))); |
152 | |
174 | |
153 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
175 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
… | |
… | |
157 | |
179 | |
158 | _FP_free (str); str = _FP_strdup (SvPV_nolen (TOPs)); |
180 | _FP_free (str); str = _FP_strdup (SvPV_nolen (TOPs)); |
159 | |
181 | |
160 | PUTBACK; FREETMPS; LEAVE; |
182 | PUTBACK; FREETMPS; LEAVE; |
161 | |
183 | |
|
|
184 | } TEMP_RELEASE; |
|
|
185 | |
162 | return str; |
186 | return str; |
163 | } |
187 | } |
164 | |
188 | |
165 | static int |
189 | static int |
166 | uu_file_callback (void *cb, char *id, char *fname, int retrieve) |
190 | uu_file_callback (void *cb, char *id, char *fname, int retrieve) |
167 | { |
191 | { |
|
|
192 | int retval; |
|
|
193 | |
|
|
194 | TEMP_ACQUIRE { |
|
|
195 | |
168 | dSP; |
196 | dSP; |
169 | int count; |
197 | int count; |
170 | int retval; |
|
|
171 | SV *xfname = newSVpv ("", 0); |
198 | SV *xfname = newSVpv ("", 0); |
172 | |
199 | |
173 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 3); |
200 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 3); |
174 | |
201 | |
175 | PUSHs (sv_2mortal (newSVpv (id, 0))); |
202 | PUSHs (sv_2mortal (newSVpv (id, 0))); |
176 | PUSHs (sv_2mortal (xfname)); |
203 | PUSHs (sv_2mortal (xfname)); |
177 | PUSHs (sv_2mortal (newSViv (retrieve))); |
204 | PUSHs (sv_2mortal (newSViv (retrieve))); |
… | |
… | |
184 | strcpy (fname, SvPV_nolen (xfname)); |
211 | strcpy (fname, SvPV_nolen (xfname)); |
185 | retval = POPi; |
212 | retval = POPi; |
186 | |
213 | |
187 | PUTBACK; FREETMPS; LEAVE; |
214 | PUTBACK; FREETMPS; LEAVE; |
188 | |
215 | |
|
|
216 | } TEMP_RELEASE; |
|
|
217 | |
189 | return retval; |
218 | return retval; |
190 | } |
219 | } |
191 | |
220 | |
192 | static char * |
221 | static char * |
193 | uu_filename_callback (void *cb, char *subject, char *filename) |
222 | uu_filename_callback (void *cb, char *subject, char *filename) |
194 | { |
223 | { |
|
|
224 | TEMP_ACQUIRE { |
|
|
225 | |
195 | dSP; |
226 | dSP; |
196 | int count; |
227 | int count; |
197 | |
228 | |
198 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); |
229 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); |
199 | |
230 | |
200 | PUSHs (sv_2mortal(newSVpv(subject, 0))); |
231 | PUSHs (sv_2mortal(newSVpv(subject, 0))); |
201 | PUSHs (filename ? sv_2mortal(newSVpv(filename, 0)) : &PL_sv_undef); |
232 | PUSHs (filename ? sv_2mortal(newSVpv(filename, 0)) : &PL_sv_undef); |
202 | |
233 | |
… | |
… | |
214 | : 0; |
245 | : 0; |
215 | } |
246 | } |
216 | |
247 | |
217 | PUTBACK; FREETMPS; LEAVE; |
248 | PUTBACK; FREETMPS; LEAVE; |
218 | |
249 | |
|
|
250 | } TEMP_RELEASE; |
|
|
251 | |
219 | return filename; |
252 | return filename; |
220 | } |
253 | } |
221 | |
254 | |
222 | static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv, *uu_filename_sv; |
255 | static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv, *uu_filename_sv; |
223 | |
256 | |
224 | #define FUNC_CB(cb) (void *)(sv_setsv (cb ## _sv, func), cb ## _sv), func ? cb ## _callback : NULL |
257 | #define FUNC_CB(cb) (void *)(sv_setsv (cb ## _sv, func), cb ## _sv), func ? cb ## _callback : NULL |
225 | |
258 | |
226 | static int |
259 | static int |
227 | uu_info_file (void *cb, char *info) |
260 | uu_info_file (void *cb, char *info) |
228 | { |
261 | { |
|
|
262 | int retval; |
|
|
263 | |
|
|
264 | TEMP_ACQUIRE { |
|
|
265 | |
229 | dSP; |
266 | dSP; |
230 | int count; |
267 | int count; |
231 | int retval; |
268 | |
232 | |
|
|
233 | ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,1); |
269 | ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,1); |
234 | |
270 | |
235 | PUSHs(sv_2mortal(newSVpv(info,0))); |
271 | PUSHs(sv_2mortal(newSVpv(info,0))); |
236 | |
272 | |
237 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
273 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
… | |
… | |
240 | croak ("info_file perl callback returned more than one argument"); |
276 | croak ("info_file perl callback returned more than one argument"); |
241 | |
277 | |
242 | retval = POPi; |
278 | retval = POPi; |
243 | |
279 | |
244 | PUTBACK; FREETMPS; LEAVE; |
280 | PUTBACK; FREETMPS; LEAVE; |
|
|
281 | |
|
|
282 | } TEMP_RELEASE; |
245 | |
283 | |
246 | return retval; |
284 | return retval; |
247 | } |
285 | } |
248 | |
286 | |
249 | static int |
287 | static int |
… | |
… | |
275 | UUInitialize () |
313 | UUInitialize () |
276 | CODE: |
314 | CODE: |
277 | if (!uu_initialized) |
315 | if (!uu_initialized) |
278 | { |
316 | { |
279 | int retval; |
317 | int retval; |
280 | |
318 | |
281 | if ((retval = UUInitialize ()) != UURET_OK) |
319 | if ((retval = UUInitialize ()) != UURET_OK) |
282 | croak ("unable to initialize uudeview library (%s)", UUstrerror (retval)); |
320 | croak ("unable to initialize uudeview library (%s)", UUstrerror (retval)); |
283 | |
321 | |
284 | uu_initialized = 1; |
322 | uu_initialized = 1; |
285 | } |
323 | } |
286 | |
324 | |
287 | void |
325 | void |
288 | UUCleanUp () |
326 | UUCleanUp () |
289 | CODE: |
327 | CODE: |
290 | if (uu_initialized) |
328 | if (uu_initialized) |
291 | UUCleanUp (); |
329 | UUCleanUp (); |
292 | |
330 | |
293 | uu_initialized = 0; |
331 | uu_initialized = 0; |
294 | |
332 | |
295 | SV * |
333 | SV * |
296 | UUGetOption (opt) |
334 | UUGetOption (opt) |
297 | int opt |
335 | int opt |
298 | CODE: |
336 | CODE: |
299 | { |
337 | { |
300 | if (opt == UUOPT_PROGRESS) |
338 | if (opt == UUOPT_PROGRESS) |
301 | croak ("GetOption(UUOPT_PROGRESS) is not yet implemented"); |
339 | croak ("GetOption(UUOPT_PROGRESS) is not yet implemented"); |
302 | else if (uu_opt_isstring (opt)) |
340 | else if (uu_opt_isstring (opt)) |
303 | { |
341 | { |
304 | char cval[8192]; |
342 | char cval[8192]; |
305 | |
343 | |
306 | UUGetOption (opt, 0, cval, sizeof cval); |
344 | UUGetOption (opt, 0, cval, sizeof cval); |
307 | RETVAL = newSVpv (cval, 0); |
345 | RETVAL = newSVpv (cval, 0); |
308 | } |
346 | } |
309 | else |
347 | else |
310 | { |
348 | { |
311 | RETVAL = newSViv (UUGetOption (opt, 0, 0, 0)); |
349 | RETVAL = newSViv (UUGetOption (opt, 0, 0, 0)); |
312 | } |
350 | } |
313 | } |
351 | } |
314 | OUTPUT: |
352 | OUTPUT: |
315 | RETVAL |
353 | RETVAL |
316 | |
354 | |
317 | int |
355 | int |
318 | UUSetOption (opt, val) |
356 | UUSetOption (opt, val) |
319 | int opt |
357 | int opt |
320 | SV * val |
358 | SV * val |
321 | CODE: |
359 | CODE: |
322 | { |
360 | { |
323 | STRLEN dc; |
361 | STRLEN dc; |
324 | |
362 | |
325 | if (uu_opt_isstring (opt)) |
363 | if (uu_opt_isstring (opt)) |
326 | RETVAL = UUSetOption (opt, 0, SvPV (val, dc)); |
364 | RETVAL = UUSetOption (opt, 0, SvPV (val, dc)); |
327 | else |
365 | else |
328 | RETVAL = UUSetOption (opt, SvIV (val), (void *)0); |
366 | RETVAL = UUSetOption (opt, SvIV (val), (void *)0); |
329 | } |
367 | } |
330 | OUTPUT: |
368 | OUTPUT: |
331 | RETVAL |
369 | RETVAL |
332 | |
370 | |
333 | char * |
371 | char * |
334 | UUstrerror (errcode) |
372 | UUstrerror (errcode) |
… | |
… | |
374 | char * fname |
412 | char * fname |
375 | char * id |
413 | char * id |
376 | int delflag |
414 | int delflag |
377 | int partno |
415 | int partno |
378 | PPCODE: |
416 | PPCODE: |
379 | { |
417 | { |
380 | int count; |
418 | int count; |
381 | |
419 | IV ret; |
382 | XPUSHs (sv_2mortal (newSViv (UULoadFileWithPartNo (fname, id, delflag, partno, &count)))); |
420 | |
|
|
421 | RELEASE; |
|
|
422 | ret = UULoadFileWithPartNo (fname, id, delflag, partno, &count); |
|
|
423 | ACQUIRE; |
|
|
424 | |
|
|
425 | XPUSHs (sv_2mortal (newSViv (ret))); |
383 | if (GIMME_V == G_ARRAY) |
426 | if (GIMME_V == G_ARRAY) |
384 | XPUSHs (sv_2mortal (newSViv (count))); |
427 | XPUSHs (sv_2mortal (newSViv (count))); |
385 | } |
428 | } |
386 | |
|
|
387 | void |
|
|
388 | UUCheckGlobalList () |
|
|
389 | |
429 | |
390 | int |
430 | int |
391 | UUSmerge (pass) |
431 | UUSmerge (pass) |
392 | int pass |
432 | int pass |
393 | |
433 | |
… | |
… | |
484 | |
524 | |
485 | int |
525 | int |
486 | decode_temp (item) |
526 | decode_temp (item) |
487 | uulist *item |
527 | uulist *item |
488 | CODE: |
528 | CODE: |
|
|
529 | RELEASE; |
489 | RETVAL = UUDecodeToTemp (item); |
530 | RETVAL = UUDecodeToTemp (item); |
|
|
531 | ACQUIRE; |
490 | OUTPUT: |
532 | OUTPUT: |
491 | RETVAL |
533 | RETVAL |
492 | |
534 | |
493 | int |
535 | int |
494 | remove_temp (item) |
536 | remove_temp (item) |
495 | uulist *item |
537 | uulist *item |
496 | CODE: |
538 | CODE: |
|
|
539 | RELEASE; |
497 | RETVAL = UURemoveTemp (item); |
540 | RETVAL = UURemoveTemp (item); |
|
|
541 | ACQUIRE; |
498 | OUTPUT: |
542 | OUTPUT: |
499 | RETVAL |
543 | RETVAL |
500 | |
544 | |
501 | int |
545 | int |
502 | decode (item, target = 0) |
546 | decode (item, target = 0) |
503 | uulist *item |
547 | uulist *item |
504 | char * target |
548 | char * target |
505 | CODE: |
549 | CODE: |
|
|
550 | RELEASE; |
506 | RETVAL = UUDecodeFile (item, target); |
551 | RETVAL = UUDecodeFile (item, target); |
|
|
552 | ACQUIRE; |
507 | OUTPUT: |
553 | OUTPUT: |
508 | RETVAL |
554 | RETVAL |
509 | |
555 | |
510 | void |
556 | void |
511 | info (item, func) |
557 | info (item, func) |
512 | uulist *item |
558 | uulist *item |
513 | SV * func |
559 | SV * func |
514 | CODE: |
560 | CODE: |
|
|
561 | RELEASE; |
515 | UUInfoFile (item,(void *)func, uu_info_file); |
562 | UUInfoFile (item, (void *)func, uu_info_file); |
|
|
563 | ACQUIRE; |
516 | |
564 | |
517 | short |
565 | short |
518 | state(li) |
566 | state(li) |
519 | uulist *li |
567 | uulist *li |
520 | CODE: |
568 | CODE: |
… | |
… | |
599 | |
647 | |
600 | void |
648 | void |
601 | parts (li) |
649 | parts (li) |
602 | uulist *li |
650 | uulist *li |
603 | PPCODE: |
651 | PPCODE: |
604 | { |
652 | { |
605 | struct _uufile *p = li->thisfile; |
653 | struct _uufile *p = li->thisfile; |
606 | |
654 | |
607 | while (p) |
655 | while (p) |
608 | { |
656 | { |
609 | HV *pi = newHV (); |
657 | HV *pi = newHV (); |
610 | |
658 | |
611 | hv_store (pi, "partno" , 6, newSViv (p->partno) , 0); |
659 | hv_store (pi, "partno" , 6, newSViv (p->partno) , 0); |
612 | |
660 | |
613 | if (p->filename) |
661 | if (p->filename) |
614 | hv_store (pi, "filename", 8, newSVpv (p->filename, 0) , 0); |
662 | hv_store (pi, "filename", 8, newSVpv (p->filename, 0) , 0); |
615 | if(p->subfname) |
663 | if(p->subfname) |
616 | hv_store (pi, "subfname", 8, newSVpv (p->subfname, 0) , 0); |
664 | hv_store (pi, "subfname", 8, newSVpv (p->subfname, 0) , 0); |
617 | if(p->mimeid) |
665 | if(p->mimeid) |
618 | hv_store (pi, "mimeid" , 6, newSVpv (p->mimeid , 0) , 0); |
666 | hv_store (pi, "mimeid" , 6, newSVpv (p->mimeid , 0) , 0); |
619 | if(p->mimetype) |
667 | if(p->mimetype) |
620 | hv_store (pi, "mimetype", 8, newSVpv (p->mimetype, 0) , 0); |
668 | hv_store (pi, "mimetype", 8, newSVpv (p->mimetype, 0) , 0); |
621 | if (p->data->subject) |
669 | if (p->data->subject) |
622 | hv_store (pi, "subject" , 7, newSVpv (p->data->subject,0), 0); |
670 | hv_store (pi, "subject" , 7, newSVpv (p->data->subject,0), 0); |
623 | if (p->data->origin) |
671 | if (p->data->origin) |
624 | hv_store (pi, "origin" , 6, newSVpv (p->data->origin ,0), 0); |
672 | hv_store (pi, "origin" , 6, newSVpv (p->data->origin ,0), 0); |
625 | if (p->data->sfname) |
673 | if (p->data->sfname) |
626 | hv_store (pi, "sfname" , 6, newSVpv (p->data->sfname ,0), 0); |
674 | hv_store (pi, "sfname" , 6, newSVpv (p->data->sfname ,0), 0); |
627 | |
675 | |
628 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)pi))); |
676 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)pi))); |
629 | |
677 | |
630 | p = p->NEXT; |
678 | p = p->NEXT; |
631 | } |
|
|
632 | } |
679 | } |
|
|
680 | } |
633 | |
681 | |
634 | BOOT: |
682 | BOOT: |
635 | uu_msg_sv = newSVsv (&PL_sv_undef); |
683 | uu_msg_sv = newSVsv (&PL_sv_undef); |
636 | uu_busy_sv = newSVsv (&PL_sv_undef); |
684 | uu_busy_sv = newSVsv (&PL_sv_undef); |
637 | uu_file_sv = newSVsv (&PL_sv_undef); |
685 | uu_file_sv = newSVsv (&PL_sv_undef); |