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 "uulib/fptools.h" |
5 | #include "uulib/fptools.h" |
6 | #include "uulib/uulib.h" |
6 | #include "uulib/uudeview.h" |
7 | #include "uulib/uuint.h" |
7 | #include "uulib/uuint.h" |
8 | |
8 | |
9 | static int |
9 | static int |
10 | not_here(char *s) |
10 | not_here(char *s) |
11 | { |
11 | { |
… | |
… | |
58 | if (strEQ(name, "OPT_SAVEPATH")) return UUOPT_SAVEPATH; |
58 | if (strEQ(name, "OPT_SAVEPATH")) return UUOPT_SAVEPATH; |
59 | if (strEQ(name, "OPT_TINYB64")) return UUOPT_TINYB64; |
59 | if (strEQ(name, "OPT_TINYB64")) return UUOPT_TINYB64; |
60 | if (strEQ(name, "OPT_USETEXT")) return UUOPT_USETEXT; |
60 | if (strEQ(name, "OPT_USETEXT")) return UUOPT_USETEXT; |
61 | if (strEQ(name, "OPT_VERBOSE")) return UUOPT_VERBOSE; |
61 | if (strEQ(name, "OPT_VERBOSE")) return UUOPT_VERBOSE; |
62 | if (strEQ(name, "OPT_VERSION")) return UUOPT_VERSION; |
62 | if (strEQ(name, "OPT_VERSION")) return UUOPT_VERSION; |
|
|
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; |
63 | case 'R': |
66 | case 'R': |
64 | if (strEQ(name, "RET_CANCEL")) return UURET_CANCEL; |
67 | if (strEQ(name, "RET_CANCEL")) return UURET_CANCEL; |
65 | if (strEQ(name, "RET_CONT")) return UURET_CONT; |
68 | if (strEQ(name, "RET_CONT")) return UURET_CONT; |
66 | if (strEQ(name, "RET_EXISTS")) return UURET_EXISTS; |
69 | if (strEQ(name, "RET_EXISTS")) return UURET_EXISTS; |
67 | if (strEQ(name, "RET_ILLVAL")) return UURET_ILLVAL; |
70 | if (strEQ(name, "RET_ILLVAL")) return UURET_ILLVAL; |
… | |
… | |
80 | if (strEQ(name, "QP_ENCODED")) return QP_ENCODED; |
83 | if (strEQ(name, "QP_ENCODED")) return QP_ENCODED; |
81 | case 'U': |
84 | case 'U': |
82 | if (strEQ(name, "UU_ENCODED")) return UU_ENCODED; |
85 | if (strEQ(name, "UU_ENCODED")) return UU_ENCODED; |
83 | case 'X': |
86 | case 'X': |
84 | if (strEQ(name, "XX_ENCODED")) return XX_ENCODED; |
87 | if (strEQ(name, "XX_ENCODED")) return XX_ENCODED; |
|
|
88 | case 'Y': |
|
|
89 | if (strEQ(name, "YENC_ENCODED")) return YENC_ENCODED; |
85 | } |
90 | } |
86 | errno = EINVAL; |
91 | errno = EINVAL; |
87 | return 0; |
92 | return 0; |
88 | } |
93 | } |
89 | |
94 | |
… | |
… | |
140 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
145 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
141 | |
146 | |
142 | if (count != 1) |
147 | if (count != 1) |
143 | croak ("fnamefilter perl callback returned more than one argument"); |
148 | croak ("fnamefilter perl callback returned more than one argument"); |
144 | |
149 | |
145 | FP_free(str); str = FP_strdup (POPp); |
150 | _FP_free(str); str = _FP_strdup (POPp); |
146 | |
151 | |
147 | PUTBACK; FREETMPS; LEAVE; |
152 | PUTBACK; FREETMPS; LEAVE; |
148 | |
153 | |
149 | return str; |
154 | return str; |
150 | } |
155 | } |
… | |
… | |
175 | PUTBACK; FREETMPS; LEAVE; |
180 | PUTBACK; FREETMPS; LEAVE; |
176 | |
181 | |
177 | return retval; |
182 | return retval; |
178 | } |
183 | } |
179 | |
184 | |
|
|
185 | static char *uu_filename_callback (void *cb, char *subject, char *filename) |
|
|
186 | { |
|
|
187 | dSP; |
|
|
188 | int count; |
|
|
189 | SV *retval; |
|
|
190 | STRLEN dc; |
|
|
191 | |
|
|
192 | ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,3); |
|
|
193 | |
|
|
194 | PUSHs(sv_2mortal(newSVpv(subject, 0))); |
|
|
195 | PUSHs(filename ? sv_2mortal(newSVpv(filename, 0)) : &PL_sv_undef); |
|
|
196 | |
|
|
197 | PUTBACK; count = perl_call_sv ((SV *)cb, G_ARRAY); SPAGAIN; |
|
|
198 | |
|
|
199 | if (count > 1) |
|
|
200 | croak ("filenamecallback perl callback returned more than one argument"); |
|
|
201 | |
|
|
202 | if (count) |
|
|
203 | { |
|
|
204 | _FP_free (filename); |
|
|
205 | |
|
|
206 | retval = POPs; |
|
|
207 | |
|
|
208 | if (SvOK (retval)) |
|
|
209 | { |
|
|
210 | STRLEN len; |
|
|
211 | char *fn = SvPV (retval, len); |
|
|
212 | |
|
|
213 | filename = malloc (len + 1); |
|
|
214 | |
|
|
215 | if (filename) |
|
|
216 | { |
|
|
217 | memcpy (filename, fn, len); |
|
|
218 | filename[len] = 0; |
|
|
219 | } |
|
|
220 | } |
|
|
221 | else |
|
|
222 | filename = 0; |
|
|
223 | } |
|
|
224 | |
|
|
225 | PUTBACK; FREETMPS; LEAVE; |
|
|
226 | |
|
|
227 | return filename; |
|
|
228 | } |
|
|
229 | |
180 | static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv; |
230 | static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv, *uu_filename_sv; |
181 | |
231 | |
182 | #define FUNC_CB(cb) (void *)(sv_setsv (cb ## _sv, func), cb ## _sv), func ? cb ## _callback : NULL |
232 | #define FUNC_CB(cb) (void *)(sv_setsv (cb ## _sv, func), cb ## _sv), func ? cb ## _callback : NULL |
183 | |
233 | |
184 | static int uu_info_file(void *cb, char *info) |
234 | static int uu_info_file(void *cb, char *info) |
185 | { |
235 | { |
… | |
… | |
313 | void |
363 | void |
314 | UUSetFNameFilter(func=0) |
364 | UUSetFNameFilter(func=0) |
315 | SV * func |
365 | SV * func |
316 | CODE: |
366 | CODE: |
317 | UUSetFNameFilter (FUNC_CB(uu_fnamefilter)); |
367 | UUSetFNameFilter (FUNC_CB(uu_fnamefilter)); |
|
|
368 | |
|
|
369 | void |
|
|
370 | UUSetFileNameCallback(func=0) |
|
|
371 | SV * func |
|
|
372 | CODE: |
|
|
373 | UUSetFileNameCallback (FUNC_CB(uu_filename)); |
318 | |
374 | |
319 | char * |
375 | char * |
320 | UUFNameFilter(fname) |
376 | UUFNameFilter(fname) |
321 | char * fname |
377 | char * fname |
322 | |
378 | |
… | |
… | |
495 | uulist *li |
551 | uulist *li |
496 | char * newfilename |
552 | char * newfilename |
497 | CODE: |
553 | CODE: |
498 | if (newfilename) |
554 | if (newfilename) |
499 | { |
555 | { |
500 | FP_free (li->filename); |
556 | _FP_free (li->filename); |
501 | li->filename = FP_strdup (newfilename); |
557 | li->filename = _FP_strdup (newfilename); |
502 | } |
558 | } |
503 | RETVAL = li->filename; |
559 | RETVAL = li->filename; |
504 | OUTPUT: |
560 | OUTPUT: |
505 | RETVAL |
561 | RETVAL |
506 | |
562 | |
… | |
… | |
571 | p = p->NEXT; |
627 | p = p->NEXT; |
572 | } |
628 | } |
573 | } |
629 | } |
574 | |
630 | |
575 | BOOT: |
631 | BOOT: |
576 | uu_msg_sv = newSVsv(&PL_sv_undef); |
632 | uu_msg_sv = newSVsv(&PL_sv_undef); |
577 | uu_busy_sv = newSVsv(&PL_sv_undef); |
633 | uu_busy_sv = newSVsv(&PL_sv_undef); |
578 | uu_file_sv = newSVsv(&PL_sv_undef); |
634 | uu_file_sv = newSVsv(&PL_sv_undef); |
579 | uu_fnamefilter_sv = newSVsv(&PL_sv_undef); |
635 | uu_fnamefilter_sv = newSVsv(&PL_sv_undef); |
|
|
636 | uu_filename_sv = newSVsv(&PL_sv_undef); |
580 | |
637 | |