… | |
… | |
179 | PUTBACK; FREETMPS; LEAVE; |
179 | PUTBACK; FREETMPS; LEAVE; |
180 | |
180 | |
181 | return retval; |
181 | return retval; |
182 | } |
182 | } |
183 | |
183 | |
|
|
184 | static char *uu_filename_callback (void *cb, char *subject, char *filename) |
|
|
185 | { |
|
|
186 | dSP; |
|
|
187 | int count; |
|
|
188 | SV *retval; |
|
|
189 | STRLEN dc; |
|
|
190 | |
|
|
191 | ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,3); |
|
|
192 | |
|
|
193 | PUSHs(sv_2mortal(newSVpv(subject, 0))); |
|
|
194 | PUSHs(filename ? sv_2mortal(newSVpv(filename, 0)) : &PL_sv_undef); |
|
|
195 | |
|
|
196 | PUTBACK; count = perl_call_sv ((SV *)cb, G_ARRAY); SPAGAIN; |
|
|
197 | |
|
|
198 | if (count > 1) |
|
|
199 | croak ("filenamecallback perl callback returned more than one argument"); |
|
|
200 | |
|
|
201 | if (count) |
|
|
202 | { |
|
|
203 | _FP_free (filename); |
|
|
204 | |
|
|
205 | retval = POPs; |
|
|
206 | |
|
|
207 | if (SvOK (retval)) |
|
|
208 | { |
|
|
209 | STRLEN len; |
|
|
210 | char *fn = SvPV (retval, len); |
|
|
211 | |
|
|
212 | filename = malloc (len + 1); |
|
|
213 | |
|
|
214 | if (filename) |
|
|
215 | { |
|
|
216 | memcpy (filename, fn, len); |
|
|
217 | filename[len] = 0; |
|
|
218 | } |
|
|
219 | } |
|
|
220 | else |
|
|
221 | filename = 0; |
|
|
222 | } |
|
|
223 | |
|
|
224 | PUTBACK; FREETMPS; LEAVE; |
|
|
225 | |
|
|
226 | return filename; |
|
|
227 | } |
|
|
228 | |
184 | static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv; |
229 | static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv, *uu_filename_sv; |
185 | |
230 | |
186 | #define FUNC_CB(cb) (void *)(sv_setsv (cb ## _sv, func), cb ## _sv), func ? cb ## _callback : NULL |
231 | #define FUNC_CB(cb) (void *)(sv_setsv (cb ## _sv, func), cb ## _sv), func ? cb ## _callback : NULL |
187 | |
232 | |
188 | static int uu_info_file(void *cb, char *info) |
233 | static int uu_info_file(void *cb, char *info) |
189 | { |
234 | { |
… | |
… | |
317 | void |
362 | void |
318 | UUSetFNameFilter(func=0) |
363 | UUSetFNameFilter(func=0) |
319 | SV * func |
364 | SV * func |
320 | CODE: |
365 | CODE: |
321 | UUSetFNameFilter (FUNC_CB(uu_fnamefilter)); |
366 | UUSetFNameFilter (FUNC_CB(uu_fnamefilter)); |
|
|
367 | |
|
|
368 | void |
|
|
369 | UUSetFileNameCallback(func=0) |
|
|
370 | SV * func |
|
|
371 | CODE: |
|
|
372 | UUSetFileNameCallback (FUNC_CB(uu_filename)); |
322 | |
373 | |
323 | char * |
374 | char * |
324 | UUFNameFilter(fname) |
375 | UUFNameFilter(fname) |
325 | char * fname |
376 | char * fname |
326 | |
377 | |
… | |
… | |
575 | p = p->NEXT; |
626 | p = p->NEXT; |
576 | } |
627 | } |
577 | } |
628 | } |
578 | |
629 | |
579 | BOOT: |
630 | BOOT: |
580 | uu_msg_sv = newSVsv(&PL_sv_undef); |
631 | uu_msg_sv = newSVsv(&PL_sv_undef); |
581 | uu_busy_sv = newSVsv(&PL_sv_undef); |
632 | uu_busy_sv = newSVsv(&PL_sv_undef); |
582 | uu_file_sv = newSVsv(&PL_sv_undef); |
633 | uu_file_sv = newSVsv(&PL_sv_undef); |
583 | uu_fnamefilter_sv = newSVsv(&PL_sv_undef); |
634 | uu_fnamefilter_sv = newSVsv(&PL_sv_undef); |
|
|
635 | uu_filename_sv = newSVsv(&PL_sv_undef); |
584 | |
636 | |