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); |
… | |
… | |
64 | if (strEQ(name, "OPT_REMOVE")) return UUOPT_REMOVE; |
74 | if (strEQ(name, "OPT_REMOVE")) return UUOPT_REMOVE; |
65 | if (strEQ(name, "OPT_MOREMIME")) return UUOPT_MOREMIME; |
75 | if (strEQ(name, "OPT_MOREMIME")) return UUOPT_MOREMIME; |
66 | if (strEQ(name, "OPT_DOTDOT")) return UUOPT_DOTDOT; |
76 | if (strEQ(name, "OPT_DOTDOT")) return UUOPT_DOTDOT; |
67 | if (strEQ(name, "OPT_RBUF")) return UUOPT_RBUF; |
77 | if (strEQ(name, "OPT_RBUF")) return UUOPT_RBUF; |
68 | if (strEQ(name, "OPT_WBUF")) return UUOPT_WBUF; |
78 | if (strEQ(name, "OPT_WBUF")) return UUOPT_WBUF; |
|
|
79 | if (strEQ(name, "OPT_AUTOCHECK")) return UUOPT_AUTOCHECK; |
69 | case 'R': |
80 | case 'R': |
70 | if (strEQ(name, "RET_CANCEL")) return UURET_CANCEL; |
81 | if (strEQ(name, "RET_CANCEL")) return UURET_CANCEL; |
71 | if (strEQ(name, "RET_CONT")) return UURET_CONT; |
82 | if (strEQ(name, "RET_CONT")) return UURET_CONT; |
72 | if (strEQ(name, "RET_EXISTS")) return UURET_EXISTS; |
83 | if (strEQ(name, "RET_EXISTS")) return UURET_EXISTS; |
73 | if (strEQ(name, "RET_ILLVAL")) return UURET_ILLVAL; |
84 | if (strEQ(name, "RET_ILLVAL")) return UURET_ILLVAL; |
… | |
… | |
97 | } |
108 | } |
98 | |
109 | |
99 | static void |
110 | static void |
100 | uu_msg_callback (void *cb, char *msg, int level) |
111 | uu_msg_callback (void *cb, char *msg, int level) |
101 | { |
112 | { |
|
|
113 | TEMP_ACQUIRE { |
|
|
114 | |
102 | dSP; |
115 | dSP; |
103 | |
116 | |
104 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); |
117 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); |
105 | |
118 | |
106 | PUSHs (sv_2mortal (newSVpv (msg, 0))); |
119 | PUSHs (sv_2mortal (newSVpv (msg, 0))); |
107 | PUSHs (sv_2mortal (newSViv (level))); |
120 | PUSHs (sv_2mortal (newSViv (level))); |
108 | |
121 | |
109 | 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; |
110 | PUTBACK; FREETMPS; LEAVE; |
123 | PUTBACK; FREETMPS; LEAVE; |
|
|
124 | |
|
|
125 | } TEMP_RELEASE; |
111 | } |
126 | } |
112 | |
127 | |
113 | static int |
128 | static int |
114 | uu_busy_callback (void *cb, uuprogress *uup) |
129 | uu_busy_callback (void *cb, uuprogress *uup) |
115 | { |
130 | { |
|
|
131 | int retval; |
|
|
132 | |
|
|
133 | TEMP_ACQUIRE { |
|
|
134 | |
116 | dSP; |
135 | dSP; |
117 | int count; |
136 | int count; |
118 | int retval; |
137 | |
119 | |
|
|
120 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 6); |
138 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 6); |
121 | |
139 | |
122 | PUSHs (sv_2mortal (newSViv (uup->action))); |
140 | PUSHs (sv_2mortal (newSViv (uup->action))); |
123 | PUSHs (sv_2mortal (newSVpv (uup->curfile, 0))); |
141 | PUSHs (sv_2mortal (newSVpv (uup->curfile, 0))); |
124 | PUSHs (sv_2mortal (newSViv (uup->partno))); |
142 | PUSHs (sv_2mortal (newSViv (uup->partno))); |
… | |
… | |
133 | |
151 | |
134 | retval = POPi; |
152 | retval = POPi; |
135 | |
153 | |
136 | PUTBACK; FREETMPS; LEAVE; |
154 | PUTBACK; FREETMPS; LEAVE; |
137 | |
155 | |
|
|
156 | } TEMP_RELEASE; |
|
|
157 | |
138 | return retval; |
158 | return retval; |
139 | } |
159 | } |
140 | |
160 | |
141 | static char * |
161 | static char * |
142 | uu_fnamefilter_callback (void *cb, char *fname) |
162 | uu_fnamefilter_callback (void *cb, char *fname) |
143 | { |
163 | { |
|
|
164 | static char *str; |
|
|
165 | |
|
|
166 | TEMP_ACQUIRE { |
|
|
167 | |
144 | dSP; |
168 | dSP; |
145 | int count; |
169 | int count; |
146 | static char *str; |
170 | |
147 | |
|
|
148 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 1); |
171 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 1); |
149 | |
172 | |
150 | PUSHs (sv_2mortal (newSVpv (fname, 0))); |
173 | PUSHs (sv_2mortal (newSVpv (fname, 0))); |
151 | |
174 | |
152 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
175 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
… | |
… | |
156 | |
179 | |
157 | _FP_free (str); str = _FP_strdup (SvPV_nolen (TOPs)); |
180 | _FP_free (str); str = _FP_strdup (SvPV_nolen (TOPs)); |
158 | |
181 | |
159 | PUTBACK; FREETMPS; LEAVE; |
182 | PUTBACK; FREETMPS; LEAVE; |
160 | |
183 | |
|
|
184 | } TEMP_RELEASE; |
|
|
185 | |
161 | return str; |
186 | return str; |
162 | } |
187 | } |
163 | |
188 | |
164 | static int |
189 | static int |
165 | uu_file_callback (void *cb, char *id, char *fname, int retrieve) |
190 | uu_file_callback (void *cb, char *id, char *fname, int retrieve) |
166 | { |
191 | { |
|
|
192 | int retval; |
|
|
193 | |
|
|
194 | TEMP_ACQUIRE { |
|
|
195 | |
167 | dSP; |
196 | dSP; |
168 | int count; |
197 | int count; |
169 | int retval; |
|
|
170 | SV *xfname = newSVpv ("", 0); |
198 | SV *xfname = newSVpv ("", 0); |
171 | |
199 | |
172 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 3); |
200 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 3); |
173 | |
201 | |
174 | PUSHs (sv_2mortal (newSVpv (id, 0))); |
202 | PUSHs (sv_2mortal (newSVpv (id, 0))); |
175 | PUSHs (sv_2mortal (xfname)); |
203 | PUSHs (sv_2mortal (xfname)); |
176 | PUSHs (sv_2mortal (newSViv (retrieve))); |
204 | PUSHs (sv_2mortal (newSViv (retrieve))); |
… | |
… | |
183 | strcpy (fname, SvPV_nolen (xfname)); |
211 | strcpy (fname, SvPV_nolen (xfname)); |
184 | retval = POPi; |
212 | retval = POPi; |
185 | |
213 | |
186 | PUTBACK; FREETMPS; LEAVE; |
214 | PUTBACK; FREETMPS; LEAVE; |
187 | |
215 | |
|
|
216 | } TEMP_RELEASE; |
|
|
217 | |
188 | return retval; |
218 | return retval; |
189 | } |
219 | } |
190 | |
220 | |
191 | static char * |
221 | static char * |
192 | uu_filename_callback (void *cb, char *subject, char *filename) |
222 | uu_filename_callback (void *cb, char *subject, char *filename) |
193 | { |
223 | { |
|
|
224 | TEMP_ACQUIRE { |
|
|
225 | |
194 | dSP; |
226 | dSP; |
195 | int count; |
227 | int count; |
196 | |
228 | |
197 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); |
229 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); |
198 | |
230 | |
199 | PUSHs (sv_2mortal(newSVpv(subject, 0))); |
231 | PUSHs (sv_2mortal(newSVpv(subject, 0))); |
200 | PUSHs (filename ? sv_2mortal(newSVpv(filename, 0)) : &PL_sv_undef); |
232 | PUSHs (filename ? sv_2mortal(newSVpv(filename, 0)) : &PL_sv_undef); |
201 | |
233 | |
… | |
… | |
213 | : 0; |
245 | : 0; |
214 | } |
246 | } |
215 | |
247 | |
216 | PUTBACK; FREETMPS; LEAVE; |
248 | PUTBACK; FREETMPS; LEAVE; |
217 | |
249 | |
|
|
250 | } TEMP_RELEASE; |
|
|
251 | |
218 | return filename; |
252 | return filename; |
219 | } |
253 | } |
220 | |
254 | |
221 | 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; |
222 | |
256 | |
223 | #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 |
224 | |
258 | |
225 | static int |
259 | static int |
226 | uu_info_file (void *cb, char *info) |
260 | uu_info_file (void *cb, char *info) |
227 | { |
261 | { |
|
|
262 | int retval; |
|
|
263 | |
|
|
264 | TEMP_ACQUIRE { |
|
|
265 | |
228 | dSP; |
266 | dSP; |
229 | int count; |
267 | int count; |
230 | int retval; |
268 | |
231 | |
|
|
232 | ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,1); |
269 | ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,1); |
233 | |
270 | |
234 | PUSHs(sv_2mortal(newSVpv(info,0))); |
271 | PUSHs(sv_2mortal(newSVpv(info,0))); |
235 | |
272 | |
236 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
273 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
… | |
… | |
239 | croak ("info_file perl callback returned more than one argument"); |
276 | croak ("info_file perl callback returned more than one argument"); |
240 | |
277 | |
241 | retval = POPi; |
278 | retval = POPi; |
242 | |
279 | |
243 | PUTBACK; FREETMPS; LEAVE; |
280 | PUTBACK; FREETMPS; LEAVE; |
|
|
281 | |
|
|
282 | } TEMP_RELEASE; |
244 | |
283 | |
245 | return retval; |
284 | return retval; |
246 | } |
285 | } |
247 | |
286 | |
248 | static int |
287 | static int |
… | |
… | |
274 | UUInitialize () |
313 | UUInitialize () |
275 | CODE: |
314 | CODE: |
276 | if (!uu_initialized) |
315 | if (!uu_initialized) |
277 | { |
316 | { |
278 | int retval; |
317 | int retval; |
279 | |
318 | |
280 | if ((retval = UUInitialize ()) != UURET_OK) |
319 | if ((retval = UUInitialize ()) != UURET_OK) |
281 | croak ("unable to initialize uudeview library (%s)", UUstrerror (retval)); |
320 | croak ("unable to initialize uudeview library (%s)", UUstrerror (retval)); |
282 | |
321 | |
283 | uu_initialized = 1; |
322 | uu_initialized = 1; |
284 | } |
323 | } |
285 | |
324 | |
286 | void |
325 | void |
287 | UUCleanUp () |
326 | UUCleanUp () |
288 | CODE: |
327 | CODE: |
289 | if (uu_initialized) |
328 | if (uu_initialized) |
290 | UUCleanUp (); |
329 | UUCleanUp (); |
291 | |
330 | |
292 | uu_initialized = 0; |
331 | uu_initialized = 0; |
293 | |
332 | |
294 | SV * |
333 | SV * |
295 | UUGetOption (opt) |
334 | UUGetOption (opt) |
296 | int opt |
335 | int opt |
297 | CODE: |
336 | CODE: |
298 | { |
337 | { |
299 | if (opt == UUOPT_PROGRESS) |
338 | if (opt == UUOPT_PROGRESS) |
300 | croak ("GetOption(UUOPT_PROGRESS) is not yet implemented"); |
339 | croak ("GetOption(UUOPT_PROGRESS) is not yet implemented"); |
301 | else if (uu_opt_isstring (opt)) |
340 | else if (uu_opt_isstring (opt)) |
302 | { |
341 | { |
303 | char cval[8192]; |
342 | char cval[8192]; |
304 | |
343 | |
305 | UUGetOption (opt, 0, cval, sizeof cval); |
344 | UUGetOption (opt, 0, cval, sizeof cval); |
306 | RETVAL = newSVpv (cval, 0); |
345 | RETVAL = newSVpv (cval, 0); |
307 | } |
346 | } |
308 | else |
347 | else |
309 | { |
348 | { |
310 | RETVAL = newSViv (UUGetOption (opt, 0, 0, 0)); |
349 | RETVAL = newSViv (UUGetOption (opt, 0, 0, 0)); |
311 | } |
350 | } |
312 | } |
351 | } |
313 | OUTPUT: |
352 | OUTPUT: |
314 | RETVAL |
353 | RETVAL |
315 | |
354 | |
316 | int |
355 | int |
317 | UUSetOption (opt, val) |
356 | UUSetOption (opt, val) |
318 | int opt |
357 | int opt |
319 | SV * val |
358 | SV * val |
320 | CODE: |
359 | CODE: |
321 | { |
360 | { |
322 | STRLEN dc; |
361 | STRLEN dc; |
323 | |
362 | |
324 | if (uu_opt_isstring (opt)) |
363 | if (uu_opt_isstring (opt)) |
325 | RETVAL = UUSetOption (opt, 0, SvPV (val, dc)); |
364 | RETVAL = UUSetOption (opt, 0, SvPV (val, dc)); |
326 | else |
365 | else |
327 | RETVAL = UUSetOption (opt, SvIV (val), (void *)0); |
366 | RETVAL = UUSetOption (opt, SvIV (val), (void *)0); |
328 | } |
367 | } |
329 | OUTPUT: |
368 | OUTPUT: |
330 | RETVAL |
369 | RETVAL |
331 | |
370 | |
332 | char * |
371 | char * |
333 | UUstrerror (errcode) |
372 | UUstrerror (errcode) |
… | |
… | |
373 | char * fname |
412 | char * fname |
374 | char * id |
413 | char * id |
375 | int delflag |
414 | int delflag |
376 | int partno |
415 | int partno |
377 | PPCODE: |
416 | PPCODE: |
378 | { |
417 | { |
379 | int count; |
418 | int count; |
380 | |
419 | IV ret; |
381 | 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))); |
382 | if (GIMME_V == G_ARRAY) |
426 | if (GIMME_V == G_ARRAY) |
383 | XPUSHs (sv_2mortal (newSViv (count))); |
427 | XPUSHs (sv_2mortal (newSViv (count))); |
384 | } |
428 | } |
385 | |
429 | |
386 | int |
430 | int |
387 | UUSmerge (pass) |
431 | UUSmerge (pass) |
388 | int pass |
432 | int pass |
389 | |
433 | |
… | |
… | |
465 | |
509 | |
466 | uulist * |
510 | uulist * |
467 | UUGetFileListItem (num) |
511 | UUGetFileListItem (num) |
468 | int num |
512 | int num |
469 | |
513 | |
|
|
514 | void |
|
|
515 | GetFileList () |
|
|
516 | PPCODE: |
|
|
517 | for (uulist *iter = UUGlobalFileList; iter; iter = iter->NEXT) |
|
|
518 | XPUSHs (sv_setref_pv (sv_newmortal (), "Convert::UUlib::Item", iter)); |
|
|
519 | |
470 | MODULE = Convert::UUlib PACKAGE = Convert::UUlib::Item |
520 | MODULE = Convert::UUlib PACKAGE = Convert::UUlib::Item |
471 | |
521 | |
472 | int |
522 | int |
473 | rename (item, newname) |
523 | rename (item, newname) |
474 | uulist *item |
524 | uulist *item |
… | |
… | |
480 | |
530 | |
481 | int |
531 | int |
482 | decode_temp (item) |
532 | decode_temp (item) |
483 | uulist *item |
533 | uulist *item |
484 | CODE: |
534 | CODE: |
|
|
535 | RELEASE; |
485 | RETVAL = UUDecodeToTemp (item); |
536 | RETVAL = UUDecodeToTemp (item); |
|
|
537 | ACQUIRE; |
486 | OUTPUT: |
538 | OUTPUT: |
487 | RETVAL |
539 | RETVAL |
488 | |
540 | |
489 | int |
541 | int |
490 | remove_temp (item) |
542 | remove_temp (item) |
491 | uulist *item |
543 | uulist *item |
492 | CODE: |
544 | CODE: |
|
|
545 | RELEASE; |
493 | RETVAL = UURemoveTemp (item); |
546 | RETVAL = UURemoveTemp (item); |
|
|
547 | ACQUIRE; |
494 | OUTPUT: |
548 | OUTPUT: |
495 | RETVAL |
549 | RETVAL |
496 | |
550 | |
497 | int |
551 | int |
498 | decode (item, target = 0) |
552 | decode (item, target = 0) |
499 | uulist *item |
553 | uulist *item |
500 | char * target |
554 | char * target |
501 | CODE: |
555 | CODE: |
|
|
556 | RELEASE; |
502 | RETVAL = UUDecodeFile (item, target); |
557 | RETVAL = UUDecodeFile (item, target); |
|
|
558 | ACQUIRE; |
503 | OUTPUT: |
559 | OUTPUT: |
504 | RETVAL |
560 | RETVAL |
505 | |
561 | |
506 | void |
562 | void |
507 | info (item, func) |
563 | info (item, func) |
508 | uulist *item |
564 | uulist *item |
509 | SV * func |
565 | SV * func |
510 | CODE: |
566 | CODE: |
|
|
567 | RELEASE; |
511 | UUInfoFile (item,(void *)func, uu_info_file); |
568 | UUInfoFile (item, (void *)func, uu_info_file); |
|
|
569 | ACQUIRE; |
512 | |
570 | |
513 | short |
571 | short |
514 | state(li) |
572 | state(li) |
515 | uulist *li |
573 | uulist *li |
516 | CODE: |
574 | CODE: |
… | |
… | |
595 | |
653 | |
596 | void |
654 | void |
597 | parts (li) |
655 | parts (li) |
598 | uulist *li |
656 | uulist *li |
599 | PPCODE: |
657 | PPCODE: |
600 | { |
658 | { |
601 | struct _uufile *p = li->thisfile; |
659 | struct _uufile *p = li->thisfile; |
602 | |
660 | |
603 | while (p) |
661 | while (p) |
604 | { |
662 | { |
605 | HV *pi = newHV (); |
663 | HV *pi = newHV (); |
606 | |
664 | |
607 | hv_store (pi, "partno" , 6, newSViv (p->partno) , 0); |
665 | hv_store (pi, "partno" , 6, newSViv (p->partno) , 0); |
608 | |
666 | |
609 | if (p->filename) |
667 | if (p->filename) |
610 | hv_store (pi, "filename", 8, newSVpv (p->filename, 0) , 0); |
668 | hv_store (pi, "filename", 8, newSVpv (p->filename, 0) , 0); |
611 | if(p->subfname) |
669 | if(p->subfname) |
612 | hv_store (pi, "subfname", 8, newSVpv (p->subfname, 0) , 0); |
670 | hv_store (pi, "subfname", 8, newSVpv (p->subfname, 0) , 0); |
613 | if(p->mimeid) |
671 | if(p->mimeid) |
614 | hv_store (pi, "mimeid" , 6, newSVpv (p->mimeid , 0) , 0); |
672 | hv_store (pi, "mimeid" , 6, newSVpv (p->mimeid , 0) , 0); |
615 | if(p->mimetype) |
673 | if(p->mimetype) |
616 | hv_store (pi, "mimetype", 8, newSVpv (p->mimetype, 0) , 0); |
674 | hv_store (pi, "mimetype", 8, newSVpv (p->mimetype, 0) , 0); |
617 | if (p->data->subject) |
675 | if (p->data->subject) |
618 | hv_store (pi, "subject" , 7, newSVpv (p->data->subject,0), 0); |
676 | hv_store (pi, "subject" , 7, newSVpv (p->data->subject,0), 0); |
619 | if (p->data->origin) |
677 | if (p->data->origin) |
620 | hv_store (pi, "origin" , 6, newSVpv (p->data->origin ,0), 0); |
678 | hv_store (pi, "origin" , 6, newSVpv (p->data->origin ,0), 0); |
621 | if (p->data->sfname) |
679 | if (p->data->sfname) |
622 | hv_store (pi, "sfname" , 6, newSVpv (p->data->sfname ,0), 0); |
680 | hv_store (pi, "sfname" , 6, newSVpv (p->data->sfname ,0), 0); |
623 | |
681 | |
624 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)pi))); |
682 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)pi))); |
625 | |
683 | |
626 | p = p->NEXT; |
684 | p = p->NEXT; |
627 | } |
|
|
628 | } |
685 | } |
|
|
686 | } |
629 | |
687 | |
630 | BOOT: |
688 | BOOT: |
631 | uu_msg_sv = newSVsv (&PL_sv_undef); |
689 | uu_msg_sv = newSVsv (&PL_sv_undef); |
632 | uu_busy_sv = newSVsv (&PL_sv_undef); |
690 | uu_busy_sv = newSVsv (&PL_sv_undef); |
633 | uu_file_sv = newSVsv (&PL_sv_undef); |
691 | uu_file_sv = newSVsv (&PL_sv_undef); |