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.5 by root, Sun Mar 31 21:42:35 2002 UTC vs.
Revision 1.8 by root, Tue Oct 15 23:20:30 2002 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;
89 } 90 }
90 errno = EINVAL; 91 errno = EINVAL;
91 return 0; 92 return 0;
92} 93}
93 94
95static void
94static void uu_msg_callback (void *cb, char *msg, int level) 96uu_msg_callback (void *cb, char *msg, int level)
95{ 97{
96 dSP; 98 dSP;
97 99
98 ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,2); 100 ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,2);
99 101
102 104
103 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;
104 PUTBACK; FREETMPS; LEAVE; 106 PUTBACK; FREETMPS; LEAVE;
105} 107}
106 108
109static int
107static int uu_busy_callback (void *cb, uuprogress *uup) 110uu_busy_callback (void *cb, uuprogress *uup)
108{ 111{
109 dSP; 112 dSP;
110 int count; 113 int count;
111 int retval; 114 int retval;
112 115
129 PUTBACK; FREETMPS; LEAVE; 132 PUTBACK; FREETMPS; LEAVE;
130 133
131 return retval; 134 return retval;
132} 135}
133 136
137static char *
134static char *uu_fnamefilter_callback (void *cb, char *fname) 138uu_fnamefilter_callback (void *cb, char *fname)
135{ 139{
136 dSP; 140 dSP;
137 int count; 141 int count;
138 static char *str; 142 static char *str;
139 143
151 PUTBACK; FREETMPS; LEAVE; 155 PUTBACK; FREETMPS; LEAVE;
152 156
153 return str; 157 return str;
154} 158}
155 159
160static int
156static int uu_file_callback (void *cb, char *id, char *fname, int retrieve) 161uu_file_callback (void *cb, char *id, char *fname, int retrieve)
157{ 162{
158 dSP; 163 dSP;
159 int count; 164 int count;
160 int retval; 165 int retval;
161 SV *xfname = newSVpv ("", 0); 166 SV *xfname = newSVpv ("", 0);
179 PUTBACK; FREETMPS; LEAVE; 184 PUTBACK; FREETMPS; LEAVE;
180 185
181 return retval; 186 return retval;
182} 187}
183 188
189static char *
184static char *uu_filename_callback (void *cb, char *subject, char *filename) 190uu_filename_callback (void *cb, char *subject, char *filename)
185{ 191{
186 dSP; 192 dSP;
187 int count; 193 int count;
188 SV *retval; 194 SV *retval;
189 STRLEN dc; 195 STRLEN dc;
228 234
229static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv, *uu_filename_sv; 235static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv, *uu_filename_sv;
230 236
231#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
232 238
239static int
233static int uu_info_file(void *cb, char *info) 240uu_info_file (void *cb, char *info)
234{ 241{
235 dSP; 242 dSP;
236 int count; 243 int count;
237 int retval; 244 int retval;
238 245
271MODULE = Convert::UUlib PACKAGE = Convert::UUlib PREFIX = UU 278MODULE = Convert::UUlib PACKAGE = Convert::UUlib PREFIX = UU
272 279
273PROTOTYPES: ENABLE 280PROTOTYPES: ENABLE
274 281
275int 282int
276constant(name) 283constant (name)
277 char * name 284 char * name
278 285
279 286
280void 287void
281UUInitialize() 288UUInitialize ()
282 CODE: 289 CODE:
283 if (!uu_initialized) 290 if (!uu_initialized)
284 { 291 {
285 int retval; 292 int retval;
286 293
289 296
290 uu_initialized = 1; 297 uu_initialized = 1;
291 } 298 }
292 299
293void 300void
294UUCleanUp() 301UUCleanUp ()
295 CODE: 302 CODE:
296 if (uu_initialized) 303 if (uu_initialized)
297 UUCleanUp (); 304 UUCleanUp ();
298 305
299 uu_initialized = 0; 306 uu_initialized = 0;
300 307
301SV * 308SV *
302UUGetOption(opt) 309UUGetOption (opt)
303 int opt 310 int opt
304 CODE: 311 CODE:
305 { 312 {
306 if (opt == UUOPT_PROGRESS) 313 if (opt == UUOPT_PROGRESS)
307 croak ("GetOption(UUOPT_PROGRESS) is not yet implemented"); 314 croak ("GetOption(UUOPT_PROGRESS) is not yet implemented");
319 } 326 }
320 OUTPUT: 327 OUTPUT:
321 RETVAL 328 RETVAL
322 329
323int 330int
324UUSetOption(opt,val) 331UUSetOption (opt, val)
325 int opt 332 int opt
326 SV * val 333 SV * val
327 CODE: 334 CODE:
328 { 335 {
329 STRLEN dc; 336 STRLEN dc;
335 } 342 }
336 OUTPUT: 343 OUTPUT:
337 RETVAL 344 RETVAL
338 345
339char * 346char *
340UUstrerror(errcode) 347UUstrerror (errcode)
341 int errcode 348 int errcode
342 349
343void 350void
344UUSetMsgCallback(func=0) 351UUSetMsgCallback (func = 0)
345 SV * func 352 SV * func
346 CODE: 353 CODE:
347 UUSetMsgCallback (FUNC_CB(uu_msg)); 354 UUSetMsgCallback (FUNC_CB(uu_msg));
348 355
349void 356void
350UUSetBusyCallback(func=0,msecs=1000) 357UUSetBusyCallback (func = 0,msecs = 1000)
351 SV * func 358 SV * func
352 long msecs 359 long msecs
353 CODE: 360 CODE:
354 UUSetBusyCallback (FUNC_CB(uu_busy), msecs); 361 UUSetBusyCallback (FUNC_CB(uu_busy), msecs);
355 362
356void 363void
357UUSetFileCallback(func=0) 364UUSetFileCallback (func = 0)
358 SV * func 365 SV * func
359 CODE: 366 CODE:
360 UUSetFileCallback (FUNC_CB(uu_file)); 367 UUSetFileCallback (FUNC_CB(uu_file));
361 368
362void 369void
363UUSetFNameFilter(func=0) 370UUSetFNameFilter (func = 0)
364 SV * func 371 SV * func
365 CODE: 372 CODE:
366 UUSetFNameFilter (FUNC_CB(uu_fnamefilter)); 373 UUSetFNameFilter (FUNC_CB(uu_fnamefilter));
367 374
368void 375void
369UUSetFileNameCallback(func=0) 376UUSetFileNameCallback (func = 0)
370 SV * func 377 SV * func
371 CODE: 378 CODE:
372 UUSetFileNameCallback (FUNC_CB(uu_filename)); 379 UUSetFileNameCallback (FUNC_CB(uu_filename));
373 380
374char * 381char *
375UUFNameFilter(fname) 382UUFNameFilter (fname)
376 char * fname 383 char * fname
377 384
378void 385void
379UULoadFile(fname,id=0,delflag=0) 386UULoadFile (fname, id = 0, delflag = 0)
380 char * fname 387 char * fname
381 char * id 388 char * id
382 int delflag 389 int delflag
383 PPCODE: 390 PPCODE:
384 { 391 {
388 if (GIMME_V == G_ARRAY) 395 if (GIMME_V == G_ARRAY)
389 XPUSHs(sv_2mortal(newSViv(count))); 396 XPUSHs(sv_2mortal(newSViv(count)));
390 } 397 }
391 398
392int 399int
393UUSmerge(pass) 400UUSmerge (pass)
394 int pass 401 int pass
395 402
396int 403int
397UUQuickDecode(datain,dataout,boundary,maxpos) 404UUQuickDecode(datain,dataout,boundary,maxpos)
398 FILE * datain 405 FILE * datain
468 char * from 475 char * from
469 char * subject 476 char * subject
470 int isemail 477 int isemail
471 478
472uulist * 479uulist *
473UUGetFileListItem(num) 480UUGetFileListItem (num)
474 int num 481 int num
475 482
483MODULE = Convert::UUlib PACKAGE = Convert::UUlib::Item
484
476int 485int
477UURenameFile(item,newname) 486rename (item, newname)
478 uulist *item 487 uulist *item
479 char * newname 488 char * newname
480 ALIAS: 489 CODE:
481 Convert::UUlib::Item::rename = 1 490 RETVAL = UURenameFile (item, newname);
491 OUTPUT:
492 RETVAL
482 493
483int 494int
484UUDecodeToTemp(item) 495decode_temp (item)
485 uulist *item 496 uulist *item
486 ALIAS: 497 CODE:
487 Convert::UUlib::Item::decode_temp = 1 498 RETVAL = UUDecodeToTemp (item);
499 OUTPUT:
500 RETVAL
488 501
489int 502int
490UURemoveTemp(item) 503remove_temp (item)
491 uulist *item 504 uulist *item
492 ALIAS: 505 CODE:
493 Convert::UUlib::Item::remove_temp = 1 506 RETVAL = UURemoveTemp (item);
507 OUTPUT:
508 RETVAL
494 509
495int 510int
496UUDecodeFile(item,target=0) 511decode (item, target = 0)
497 uulist *item 512 uulist *item
498 char * target 513 char * target
499 ALIAS: 514 CODE:
500 Convert::UUlib::Item::decode = 1 515 RETVAL = UUDecodeFile (item, target);
516 OUTPUT:
517 RETVAL
501 518
502void 519void
503UUInfoFile(item,func) 520info (item, func)
504 uulist *item 521 uulist *item
505 SV * func 522 SV * func
506 CODE: 523 CODE:
507 UUInfoFile(item,(void *)func,uu_info_file); 524 UUInfoFile (item,(void *)func, uu_info_file);
508 ALIAS:
509 Convert::UUlib::Item::info = 1
510
511MODULE = Convert::UUlib PACKAGE = Convert::UUlib::Item
512 525
513short 526short
514state(li) 527state(li)
515 uulist *li 528 uulist *li
516 CODE: 529 CODE:
544 RETVAL = li->size; 557 RETVAL = li->size;
545 OUTPUT: 558 OUTPUT:
546 RETVAL 559 RETVAL
547 560
548char * 561char *
549filename(li,newfilename=0) 562filename (li, newfilename = 0)
550 uulist *li 563 uulist *li
551 char * newfilename 564 char * newfilename
552 CODE: 565 CODE:
553 if (newfilename) 566 if (newfilename)
554 { 567 {
558 RETVAL = li->filename; 571 RETVAL = li->filename;
559 OUTPUT: 572 OUTPUT:
560 RETVAL 573 RETVAL
561 574
562char * 575char *
563subfname(li) 576subfname (li)
564 uulist *li 577 uulist *li
565 CODE: 578 CODE:
566 RETVAL = li->subfname; 579 RETVAL = li->subfname;
567 OUTPUT: 580 OUTPUT:
568 RETVAL 581 RETVAL
569 582
570char * 583char *
571mimeid(li) 584mimeid (li)
572 uulist *li 585 uulist *li
573 CODE: 586 CODE:
574 RETVAL = li->mimeid; 587 RETVAL = li->mimeid;
575 OUTPUT: 588 OUTPUT:
576 RETVAL 589 RETVAL
577 590
578char * 591char *
579mimetype(li) 592mimetype (li)
580 uulist *li 593 uulist *li
581 CODE: 594 CODE:
582 RETVAL = li->mimetype; 595 RETVAL = li->mimetype;
583 OUTPUT: 596 OUTPUT:
584 RETVAL 597 RETVAL
585 598
586char * 599char *
587binfile(li) 600binfile (li)
588 uulist *li 601 uulist *li
589 CODE: 602 CODE:
590 RETVAL = li->binfile; 603 RETVAL = li->binfile;
591 OUTPUT: 604 OUTPUT:
592 RETVAL 605 RETVAL
593 606
594# functions accessing internal data(!) 607# methods accessing internal data(!)
595 608
596void 609void
597parts(li) 610parts (li)
598 uulist *li 611 uulist *li
599 PPCODE: 612 PPCODE:
600 { 613 {
601 struct _uufile *p = li->thisfile; 614 struct _uufile *p = li->thisfile;
602 615

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines