ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/UUlib.xs
(Generate patch)

Comparing Convert-UUlib/UUlib.xs (file contents):
Revision 1.1 by root, Mon Jun 11 19:48:55 2001 UTC vs.
Revision 1.5 by root, Sun Mar 31 21:42:35 2002 UTC

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
9static int 9static int
10not_here(char *s) 10not_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;
63 case 'R': 65 case 'R':
64 if (strEQ(name, "RET_CANCEL")) return UURET_CANCEL; 66 if (strEQ(name, "RET_CANCEL")) return UURET_CANCEL;
65 if (strEQ(name, "RET_CONT")) return UURET_CONT; 67 if (strEQ(name, "RET_CONT")) return UURET_CONT;
66 if (strEQ(name, "RET_EXISTS")) return UURET_EXISTS; 68 if (strEQ(name, "RET_EXISTS")) return UURET_EXISTS;
67 if (strEQ(name, "RET_ILLVAL")) return UURET_ILLVAL; 69 if (strEQ(name, "RET_ILLVAL")) return UURET_ILLVAL;
80 if (strEQ(name, "QP_ENCODED")) return QP_ENCODED; 82 if (strEQ(name, "QP_ENCODED")) return QP_ENCODED;
81 case 'U': 83 case 'U':
82 if (strEQ(name, "UU_ENCODED")) return UU_ENCODED; 84 if (strEQ(name, "UU_ENCODED")) return UU_ENCODED;
83 case 'X': 85 case 'X':
84 if (strEQ(name, "XX_ENCODED")) return XX_ENCODED; 86 if (strEQ(name, "XX_ENCODED")) return XX_ENCODED;
87 case 'Y':
88 if (strEQ(name, "YENC_ENCODED")) return YENC_ENCODED;
85 } 89 }
86 errno = EINVAL; 90 errno = EINVAL;
87 return 0; 91 return 0;
88} 92}
89 93
140 PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; 144 PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN;
141 145
142 if (count != 1) 146 if (count != 1)
143 croak ("fnamefilter perl callback returned more than one argument"); 147 croak ("fnamefilter perl callback returned more than one argument");
144 148
145 FP_free(str); str = FP_strdup (POPp); 149 _FP_free(str); str = _FP_strdup (POPp);
146 150
147 PUTBACK; FREETMPS; LEAVE; 151 PUTBACK; FREETMPS; LEAVE;
148 152
149 return str; 153 return str;
150} 154}
175 PUTBACK; FREETMPS; LEAVE; 179 PUTBACK; FREETMPS; LEAVE;
176 180
177 return retval; 181 return retval;
178} 182}
179 183
184static 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
180static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv; 229static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv, *uu_filename_sv;
181 230
182#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
183 232
184static int uu_info_file(void *cb, char *info) 233static int uu_info_file(void *cb, char *info)
185{ 234{
313void 362void
314UUSetFNameFilter(func=0) 363UUSetFNameFilter(func=0)
315 SV * func 364 SV * func
316 CODE: 365 CODE:
317 UUSetFNameFilter (FUNC_CB(uu_fnamefilter)); 366 UUSetFNameFilter (FUNC_CB(uu_fnamefilter));
367
368void
369UUSetFileNameCallback(func=0)
370 SV * func
371 CODE:
372 UUSetFileNameCallback (FUNC_CB(uu_filename));
318 373
319char * 374char *
320UUFNameFilter(fname) 375UUFNameFilter(fname)
321 char * fname 376 char * fname
322 377
495 uulist *li 550 uulist *li
496 char * newfilename 551 char * newfilename
497 CODE: 552 CODE:
498 if (newfilename) 553 if (newfilename)
499 { 554 {
500 FP_free (li->filename); 555 _FP_free (li->filename);
501 li->filename = FP_strdup (newfilename); 556 li->filename = _FP_strdup (newfilename);
502 } 557 }
503 RETVAL = li->filename; 558 RETVAL = li->filename;
504 OUTPUT: 559 OUTPUT:
505 RETVAL 560 RETVAL
506 561
571 p = p->NEXT; 626 p = p->NEXT;
572 } 627 }
573 } 628 }
574 629
575BOOT: 630BOOT:
576uu_msg_sv = newSVsv(&PL_sv_undef); 631 uu_msg_sv = newSVsv(&PL_sv_undef);
577uu_busy_sv = newSVsv(&PL_sv_undef); 632 uu_busy_sv = newSVsv(&PL_sv_undef);
578uu_file_sv = newSVsv(&PL_sv_undef); 633 uu_file_sv = newSVsv(&PL_sv_undef);
579uu_fnamefilter_sv = newSVsv(&PL_sv_undef); 634 uu_fnamefilter_sv = newSVsv(&PL_sv_undef);
635 uu_filename_sv = newSVsv(&PL_sv_undef);
580 636

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines