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.2 by root, Mon Jun 11 20:42:36 2001 UTC vs.
Revision 1.9 by root, Thu Nov 6 13:33:40 2003 UTC

5#include "uulib/fptools.h" 5#include "uulib/fptools.h"
6#include "uulib/uudeview.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{
12 croak("%s not implemented on this architecture", s); 12 croak("%s not implemented", s);
13 return -1; 13 return -1;
14} 14}
15 15
16static int 16static int
17constant(char *name) 17constant (char *name)
18{ 18{
19 errno = 0; 19 errno = 0;
20 switch (*name) { 20 switch (*name) {
21 case 'A': 21 case 'A':
22 if (strEQ(name, "ACT_COPYING")) return UUACT_COPYING; 22 if (strEQ(name, "ACT_COPYING")) return UUACT_COPYING;
41 if (strEQ(name, "MSG_MESSAGE")) return UUMSG_MESSAGE; 41 if (strEQ(name, "MSG_MESSAGE")) return UUMSG_MESSAGE;
42 if (strEQ(name, "MSG_NOTE")) return UUMSG_NOTE; 42 if (strEQ(name, "MSG_NOTE")) return UUMSG_NOTE;
43 if (strEQ(name, "MSG_PANIC")) return UUMSG_PANIC; 43 if (strEQ(name, "MSG_PANIC")) return UUMSG_PANIC;
44 if (strEQ(name, "MSG_WARNING")) return UUMSG_WARNING; 44 if (strEQ(name, "MSG_WARNING")) return UUMSG_WARNING;
45 case 'O': 45 case 'O':
46 if (strEQ(name, "OPT_VERSION")) return UUOPT_VERSION;
47 if (strEQ(name, "OPT_FAST")) return UUOPT_FAST;
48 if (strEQ(name, "OPT_DUMBNESS")) return UUOPT_DUMBNESS;
46 if (strEQ(name, "OPT_BRACKPOL")) return UUOPT_BRACKPOL; 49 if (strEQ(name, "OPT_BRACKPOL")) return UUOPT_BRACKPOL;
47 if (strEQ(name, "OPT_DEBUG")) return UUOPT_DEBUG; 50 if (strEQ(name, "OPT_VERBOSE")) return UUOPT_VERBOSE;
48 if (strEQ(name, "OPT_DESPERATE")) return UUOPT_DESPERATE; 51 if (strEQ(name, "OPT_DESPERATE")) return UUOPT_DESPERATE;
49 if (strEQ(name, "OPT_DUMBNESS")) return UUOPT_DUMBNESS;
50 if (strEQ(name, "OPT_ENCEXT")) return UUOPT_ENCEXT;
51 if (strEQ(name, "OPT_ERRNO")) return UUOPT_ERRNO;
52 if (strEQ(name, "OPT_FAST")) return UUOPT_FAST;
53 if (strEQ(name, "OPT_IGNMODE")) return UUOPT_IGNMODE;
54 if (strEQ(name, "OPT_IGNREPLY")) return UUOPT_IGNREPLY; 52 if (strEQ(name, "OPT_IGNREPLY")) return UUOPT_IGNREPLY;
55 if (strEQ(name, "OPT_OVERWRITE")) return UUOPT_OVERWRITE; 53 if (strEQ(name, "OPT_OVERWRITE")) return UUOPT_OVERWRITE;
54 if (strEQ(name, "OPT_SAVEPATH")) return UUOPT_SAVEPATH;
55 if (strEQ(name, "OPT_IGNMODE")) return UUOPT_IGNMODE;
56 if (strEQ(name, "OPT_DEBUG")) return UUOPT_DEBUG;
57 if (strEQ(name, "OPT_ERRNO")) return UUOPT_ERRNO;
58 if (strEQ(name, "OPT_PROGRESS")) return UUOPT_PROGRESS;
59 if (strEQ(name, "OPT_USETEXT")) return UUOPT_USETEXT;
56 if (strEQ(name, "OPT_PREAMB")) return UUOPT_PREAMB; 60 if (strEQ(name, "OPT_PREAMB")) return UUOPT_PREAMB;
57 if (strEQ(name, "OPT_PROGRESS")) return UUOPT_PROGRESS;
58 if (strEQ(name, "OPT_SAVEPATH")) return UUOPT_SAVEPATH;
59 if (strEQ(name, "OPT_TINYB64")) return UUOPT_TINYB64; 61 if (strEQ(name, "OPT_TINYB64")) return UUOPT_TINYB64;
60 if (strEQ(name, "OPT_USETEXT")) return UUOPT_USETEXT; 62 if (strEQ(name, "OPT_ENCEXT")) return UUOPT_ENCEXT;
61 if (strEQ(name, "OPT_VERBOSE")) return UUOPT_VERBOSE;
62 if (strEQ(name, "OPT_VERSION")) return UUOPT_VERSION;
63 if (strEQ(name, "OPT_REMOVE")) return UUOPT_REMOVE; 63 if (strEQ(name, "OPT_REMOVE")) return UUOPT_REMOVE;
64 if (strEQ(name, "OPT_MOREMIME")) return UUOPT_MOREMIME; 64 if (strEQ(name, "OPT_MOREMIME")) return UUOPT_MOREMIME;
65 if (strEQ(name, "OPT_DOTDOT")) return UUOPT_DOTDOT;
65 case 'R': 66 case 'R':
66 if (strEQ(name, "RET_CANCEL")) return UURET_CANCEL; 67 if (strEQ(name, "RET_CANCEL")) return UURET_CANCEL;
67 if (strEQ(name, "RET_CONT")) return UURET_CONT; 68 if (strEQ(name, "RET_CONT")) return UURET_CONT;
68 if (strEQ(name, "RET_EXISTS")) return UURET_EXISTS; 69 if (strEQ(name, "RET_EXISTS")) return UURET_EXISTS;
69 if (strEQ(name, "RET_ILLVAL")) return UURET_ILLVAL; 70 if (strEQ(name, "RET_ILLVAL")) return UURET_ILLVAL;
72 if (strEQ(name, "RET_NOEND")) return UURET_NOEND; 73 if (strEQ(name, "RET_NOEND")) return UURET_NOEND;
73 if (strEQ(name, "RET_NOMEM")) return UURET_NOMEM; 74 if (strEQ(name, "RET_NOMEM")) return UURET_NOMEM;
74 if (strEQ(name, "RET_OK")) return UURET_OK; 75 if (strEQ(name, "RET_OK")) return UURET_OK;
75 if (strEQ(name, "RET_UNSUP")) return UURET_UNSUP; 76 if (strEQ(name, "RET_UNSUP")) return UURET_UNSUP;
76 case 'B': 77 case 'B':
77 if (strEQ(name, "B64ENCODED")) return B64ENCODED; 78 if (strEQ(name, "B64_ENCODED")) return B64ENCODED;
78 if (strEQ(name, "BH_ENCODED")) return BH_ENCODED; 79 if (strEQ(name, "BH_ENCODED")) return BH_ENCODED;
79 case 'P': 80 case 'P':
80 if (strEQ(name, "PT_ENCODED")) return PT_ENCODED; 81 if (strEQ(name, "PT_ENCODED")) return PT_ENCODED;
81 case 'Q': 82 case 'Q':
82 if (strEQ(name, "QP_ENCODED")) return QP_ENCODED; 83 if (strEQ(name, "QP_ENCODED")) return QP_ENCODED;
83 case 'U': 84 case 'U':
84 if (strEQ(name, "UU_ENCODED")) return UU_ENCODED; 85 if (strEQ(name, "UU_ENCODED")) return UU_ENCODED;
85 case 'X': 86 case 'X':
86 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;
87 } 90 }
88 errno = EINVAL; 91 errno = EINVAL;
89 return 0; 92 return 0;
90} 93}
91 94
95static void
92static void uu_msg_callback (void *cb, char *msg, int level) 96uu_msg_callback (void *cb, char *msg, int level)
93{ 97{
94 dSP; 98 dSP;
95 99
96 ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,2); 100 ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,2);
97 101
100 104
101 PUTBACK; (void) perl_call_sv ((SV *)cb, G_VOID|G_DISCARD); SPAGAIN; 105 PUTBACK; (void) perl_call_sv ((SV *)cb, G_VOID|G_DISCARD); SPAGAIN;
102 PUTBACK; FREETMPS; LEAVE; 106 PUTBACK; FREETMPS; LEAVE;
103} 107}
104 108
109static int
105static int uu_busy_callback (void *cb, uuprogress *uup) 110uu_busy_callback (void *cb, uuprogress *uup)
106{ 111{
107 dSP; 112 dSP;
108 int count; 113 int count;
109 int retval; 114 int retval;
110 115
127 PUTBACK; FREETMPS; LEAVE; 132 PUTBACK; FREETMPS; LEAVE;
128 133
129 return retval; 134 return retval;
130} 135}
131 136
137static char *
132static char *uu_fnamefilter_callback (void *cb, char *fname) 138uu_fnamefilter_callback (void *cb, char *fname)
133{ 139{
134 dSP; 140 dSP;
135 int count; 141 int count;
136 static char *str; 142 static char *str;
137 143
142 PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; 148 PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN;
143 149
144 if (count != 1) 150 if (count != 1)
145 croak ("fnamefilter perl callback returned more than one argument"); 151 croak ("fnamefilter perl callback returned more than one argument");
146 152
147 FP_free(str); str = FP_strdup (POPp); 153 _FP_free(str); str = _FP_strdup (POPp);
148 154
149 PUTBACK; FREETMPS; LEAVE; 155 PUTBACK; FREETMPS; LEAVE;
150 156
151 return str; 157 return str;
152} 158}
153 159
160static int
154static int uu_file_callback (void *cb, char *id, char *fname, int retrieve) 161uu_file_callback (void *cb, char *id, char *fname, int retrieve)
155{ 162{
156 dSP; 163 dSP;
157 int count; 164 int count;
158 int retval; 165 int retval;
159 SV *xfname = newSVpv ("", 0); 166 SV *xfname = newSVpv ("", 0);
177 PUTBACK; FREETMPS; LEAVE; 184 PUTBACK; FREETMPS; LEAVE;
178 185
179 return retval; 186 return retval;
180} 187}
181 188
189static char *
190uu_filename_callback (void *cb, char *subject, char *filename)
191{
192 dSP;
193 int count;
194 SV *retval;
195 STRLEN dc;
196
197 ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,3);
198
199 PUSHs(sv_2mortal(newSVpv(subject, 0)));
200 PUSHs(filename ? sv_2mortal(newSVpv(filename, 0)) : &PL_sv_undef);
201
202 PUTBACK; count = perl_call_sv ((SV *)cb, G_ARRAY); SPAGAIN;
203
204 if (count > 1)
205 croak ("filenamecallback perl callback returned more than one argument");
206
207 if (count)
208 {
209 _FP_free (filename);
210
211 retval = POPs;
212
213 if (SvOK (retval))
214 {
215 STRLEN len;
216 char *fn = SvPV (retval, len);
217
218 filename = malloc (len + 1);
219
220 if (filename)
221 {
222 memcpy (filename, fn, len);
223 filename[len] = 0;
224 }
225 }
226 else
227 filename = 0;
228 }
229
230 PUTBACK; FREETMPS; LEAVE;
231
232 return filename;
233}
234
182static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv; 235static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv, *uu_filename_sv;
183 236
184#define FUNC_CB(cb) (void *)(sv_setsv (cb ## _sv, func), cb ## _sv), func ? cb ## _callback : NULL 237#define FUNC_CB(cb) (void *)(sv_setsv (cb ## _sv, func), cb ## _sv), func ? cb ## _callback : NULL
185 238
239static int
186static int uu_info_file(void *cb, char *info) 240uu_info_file (void *cb, char *info)
187{ 241{
188 dSP; 242 dSP;
189 int count; 243 int count;
190 int retval; 244 int retval;
191 245
224MODULE = Convert::UUlib PACKAGE = Convert::UUlib PREFIX = UU 278MODULE = Convert::UUlib PACKAGE = Convert::UUlib PREFIX = UU
225 279
226PROTOTYPES: ENABLE 280PROTOTYPES: ENABLE
227 281
228int 282int
229constant(name) 283constant (name)
230 char * name 284 char * name
231 285
232 286
233void 287void
234UUInitialize() 288UUInitialize ()
235 CODE: 289 CODE:
236 if (!uu_initialized) 290 if (!uu_initialized)
237 { 291 {
238 int retval; 292 int retval;
239 293
242 296
243 uu_initialized = 1; 297 uu_initialized = 1;
244 } 298 }
245 299
246void 300void
247UUCleanUp() 301UUCleanUp ()
248 CODE: 302 CODE:
249 if (uu_initialized) 303 if (uu_initialized)
250 UUCleanUp (); 304 UUCleanUp ();
251 305
252 uu_initialized = 0; 306 uu_initialized = 0;
253 307
254SV * 308SV *
255UUGetOption(opt) 309UUGetOption (opt)
256 int opt 310 int opt
257 CODE: 311 CODE:
258 { 312 {
259 if (opt == UUOPT_PROGRESS) 313 if (opt == UUOPT_PROGRESS)
260 croak ("GetOption(UUOPT_PROGRESS) is not yet implemented"); 314 croak ("GetOption(UUOPT_PROGRESS) is not yet implemented");
272 } 326 }
273 OUTPUT: 327 OUTPUT:
274 RETVAL 328 RETVAL
275 329
276int 330int
277UUSetOption(opt,val) 331UUSetOption (opt, val)
278 int opt 332 int opt
279 SV * val 333 SV * val
280 CODE: 334 CODE:
281 { 335 {
282 STRLEN dc; 336 STRLEN dc;
288 } 342 }
289 OUTPUT: 343 OUTPUT:
290 RETVAL 344 RETVAL
291 345
292char * 346char *
293UUstrerror(errcode) 347UUstrerror (errcode)
294 int errcode 348 int errcode
295 349
296void 350void
297UUSetMsgCallback(func=0) 351UUSetMsgCallback (func = 0)
298 SV * func 352 SV * func
299 CODE: 353 CODE:
300 UUSetMsgCallback (FUNC_CB(uu_msg)); 354 UUSetMsgCallback (FUNC_CB(uu_msg));
301 355
302void 356void
303UUSetBusyCallback(func=0,msecs=1000) 357UUSetBusyCallback (func = 0,msecs = 1000)
304 SV * func 358 SV * func
305 long msecs 359 long msecs
306 CODE: 360 CODE:
307 UUSetBusyCallback (FUNC_CB(uu_busy), msecs); 361 UUSetBusyCallback (FUNC_CB(uu_busy), msecs);
308 362
309void 363void
310UUSetFileCallback(func=0) 364UUSetFileCallback (func = 0)
311 SV * func 365 SV * func
312 CODE: 366 CODE:
313 UUSetFileCallback (FUNC_CB(uu_file)); 367 UUSetFileCallback (FUNC_CB(uu_file));
314 368
315void 369void
316UUSetFNameFilter(func=0) 370UUSetFNameFilter (func = 0)
317 SV * func 371 SV * func
318 CODE: 372 CODE:
319 UUSetFNameFilter (FUNC_CB(uu_fnamefilter)); 373 UUSetFNameFilter (FUNC_CB(uu_fnamefilter));
320 374
375void
376UUSetFileNameCallback (func = 0)
377 SV * func
378 CODE:
379 UUSetFileNameCallback (FUNC_CB(uu_filename));
380
321char * 381char *
322UUFNameFilter(fname) 382UUFNameFilter (fname)
323 char * fname 383 char * fname
324 384
325void 385void
326UULoadFile(fname,id=0,delflag=0) 386UULoadFile (fname, id = 0, delflag = 0, int partno = -1)
327 char * fname 387 char * fname
328 char * id 388 char * id
329 int delflag 389 int delflag
330 PPCODE: 390 PPCODE:
331 { 391 {
332 int count; 392 int count;
333 393
334 XPUSHs(sv_2mortal(newSViv(UULoadFile (fname, id, delflag, &count)))); 394 XPUSHs(sv_2mortal(newSViv(UULoadFile (fname, id, delflag, partno, &count))));
335 if (GIMME_V == G_ARRAY) 395 if (GIMME_V == G_ARRAY)
336 XPUSHs(sv_2mortal(newSViv(count))); 396 XPUSHs(sv_2mortal(newSViv(count)));
337 } 397 }
338 398
339int 399int
340UUSmerge(pass) 400UUSmerge (pass)
341 int pass 401 int pass
342 402
343int 403int
344UUQuickDecode(datain,dataout,boundary,maxpos) 404UUQuickDecode(datain,dataout,boundary,maxpos)
345 FILE * datain 405 FILE * datain
415 char * from 475 char * from
416 char * subject 476 char * subject
417 int isemail 477 int isemail
418 478
419uulist * 479uulist *
420UUGetFileListItem(num) 480UUGetFileListItem (num)
421 int num 481 int num
422 482
483MODULE = Convert::UUlib PACKAGE = Convert::UUlib::Item
484
423int 485int
424UURenameFile(item,newname) 486rename (item, newname)
425 uulist *item 487 uulist *item
426 char * newname 488 char * newname
427 ALIAS: 489 CODE:
428 Convert::UUlib::Item::rename = 1 490 RETVAL = UURenameFile (item, newname);
491 OUTPUT:
492 RETVAL
429 493
430int 494int
431UUDecodeToTemp(item) 495decode_temp (item)
432 uulist *item 496 uulist *item
433 ALIAS: 497 CODE:
434 Convert::UUlib::Item::decode_temp = 1 498 RETVAL = UUDecodeToTemp (item);
499 OUTPUT:
500 RETVAL
435 501
436int 502int
437UURemoveTemp(item) 503remove_temp (item)
438 uulist *item 504 uulist *item
439 ALIAS: 505 CODE:
440 Convert::UUlib::Item::remove_temp = 1 506 RETVAL = UURemoveTemp (item);
507 OUTPUT:
508 RETVAL
441 509
442int 510int
443UUDecodeFile(item,target=0) 511decode (item, target = 0)
444 uulist *item 512 uulist *item
445 char * target 513 char * target
446 ALIAS: 514 CODE:
447 Convert::UUlib::Item::decode = 1 515 RETVAL = UUDecodeFile (item, target);
516 OUTPUT:
517 RETVAL
448 518
449void 519void
450UUInfoFile(item,func) 520info (item, func)
451 uulist *item 521 uulist *item
452 SV * func 522 SV * func
453 CODE: 523 CODE:
454 UUInfoFile(item,(void *)func,uu_info_file); 524 UUInfoFile (item,(void *)func, uu_info_file);
455 ALIAS:
456 Convert::UUlib::Item::info = 1
457
458MODULE = Convert::UUlib PACKAGE = Convert::UUlib::Item
459 525
460short 526short
461state(li) 527state(li)
462 uulist *li 528 uulist *li
463 CODE: 529 CODE:
491 RETVAL = li->size; 557 RETVAL = li->size;
492 OUTPUT: 558 OUTPUT:
493 RETVAL 559 RETVAL
494 560
495char * 561char *
496filename(li,newfilename=0) 562filename (li, newfilename = 0)
497 uulist *li 563 uulist *li
498 char * newfilename 564 char * newfilename
499 CODE: 565 CODE:
500 if (newfilename) 566 if (newfilename)
501 { 567 {
502 FP_free (li->filename); 568 _FP_free (li->filename);
503 li->filename = FP_strdup (newfilename); 569 li->filename = _FP_strdup (newfilename);
504 } 570 }
505 RETVAL = li->filename; 571 RETVAL = li->filename;
506 OUTPUT: 572 OUTPUT:
507 RETVAL 573 RETVAL
508 574
509char * 575char *
510subfname(li) 576subfname (li)
511 uulist *li 577 uulist *li
512 CODE: 578 CODE:
513 RETVAL = li->subfname; 579 RETVAL = li->subfname;
514 OUTPUT: 580 OUTPUT:
515 RETVAL 581 RETVAL
516 582
517char * 583char *
518mimeid(li) 584mimeid (li)
519 uulist *li 585 uulist *li
520 CODE: 586 CODE:
521 RETVAL = li->mimeid; 587 RETVAL = li->mimeid;
522 OUTPUT: 588 OUTPUT:
523 RETVAL 589 RETVAL
524 590
525char * 591char *
526mimetype(li) 592mimetype (li)
527 uulist *li 593 uulist *li
528 CODE: 594 CODE:
529 RETVAL = li->mimetype; 595 RETVAL = li->mimetype;
530 OUTPUT: 596 OUTPUT:
531 RETVAL 597 RETVAL
532 598
533char * 599char *
534binfile(li) 600binfile (li)
535 uulist *li 601 uulist *li
536 CODE: 602 CODE:
537 RETVAL = li->binfile; 603 RETVAL = li->binfile;
538 OUTPUT: 604 OUTPUT:
539 RETVAL 605 RETVAL
540 606
541# functions accessing internal data(!) 607# methods accessing internal data(!)
542 608
543void 609void
544parts(li) 610parts (li)
545 uulist *li 611 uulist *li
546 PPCODE: 612 PPCODE:
547 { 613 {
548 struct _uufile *p = li->thisfile; 614 struct _uufile *p = li->thisfile;
549 615
573 p = p->NEXT; 639 p = p->NEXT;
574 } 640 }
575 } 641 }
576 642
577BOOT: 643BOOT:
578uu_msg_sv = newSVsv(&PL_sv_undef); 644 uu_msg_sv = newSVsv(&PL_sv_undef);
579uu_busy_sv = newSVsv(&PL_sv_undef); 645 uu_busy_sv = newSVsv(&PL_sv_undef);
580uu_file_sv = newSVsv(&PL_sv_undef); 646 uu_file_sv = newSVsv(&PL_sv_undef);
581uu_fnamefilter_sv = newSVsv(&PL_sv_undef); 647 uu_fnamefilter_sv = newSVsv(&PL_sv_undef);
648 uu_filename_sv = newSVsv(&PL_sv_undef);
582 649

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines