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.6 by root, Sat Apr 6 01:53:29 2002 UTC vs.
Revision 1.12 by root, Mon May 2 19:58:40 2005 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 if (strEQ(name, "OPT_DOTDOT")) return UUOPT_DOTDOT;
66 if (strEQ(name, "OPT_RBUF")) return UUOPT_RBUF;
67 if (strEQ(name, "OPT_WBUF")) return UUOPT_WBUF;
66 case 'R': 68 case 'R':
67 if (strEQ(name, "RET_CANCEL")) return UURET_CANCEL; 69 if (strEQ(name, "RET_CANCEL")) return UURET_CANCEL;
68 if (strEQ(name, "RET_CONT")) return UURET_CONT; 70 if (strEQ(name, "RET_CONT")) return UURET_CONT;
69 if (strEQ(name, "RET_EXISTS")) return UURET_EXISTS; 71 if (strEQ(name, "RET_EXISTS")) return UURET_EXISTS;
70 if (strEQ(name, "RET_ILLVAL")) return UURET_ILLVAL; 72 if (strEQ(name, "RET_ILLVAL")) return UURET_ILLVAL;
73 if (strEQ(name, "RET_NOEND")) return UURET_NOEND; 75 if (strEQ(name, "RET_NOEND")) return UURET_NOEND;
74 if (strEQ(name, "RET_NOMEM")) return UURET_NOMEM; 76 if (strEQ(name, "RET_NOMEM")) return UURET_NOMEM;
75 if (strEQ(name, "RET_OK")) return UURET_OK; 77 if (strEQ(name, "RET_OK")) return UURET_OK;
76 if (strEQ(name, "RET_UNSUP")) return UURET_UNSUP; 78 if (strEQ(name, "RET_UNSUP")) return UURET_UNSUP;
77 case 'B': 79 case 'B':
78 if (strEQ(name, "B64ENCODED")) return B64ENCODED; 80 if (strEQ(name, "B64_ENCODED")) return B64ENCODED;
79 if (strEQ(name, "BH_ENCODED")) return BH_ENCODED; 81 if (strEQ(name, "BH_ENCODED")) return BH_ENCODED;
80 case 'P': 82 case 'P':
81 if (strEQ(name, "PT_ENCODED")) return PT_ENCODED; 83 if (strEQ(name, "PT_ENCODED")) return PT_ENCODED;
82 case 'Q': 84 case 'Q':
83 if (strEQ(name, "QP_ENCODED")) return QP_ENCODED; 85 if (strEQ(name, "QP_ENCODED")) return QP_ENCODED;
90 } 92 }
91 errno = EINVAL; 93 errno = EINVAL;
92 return 0; 94 return 0;
93} 95}
94 96
97static void
95static void uu_msg_callback (void *cb, char *msg, int level) 98uu_msg_callback (void *cb, char *msg, int level)
96{ 99{
97 dSP; 100 dSP;
98 101
99 ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,2); 102 ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2);
100 103
101 PUSHs(sv_2mortal(newSVpv(msg,0))); 104 PUSHs (sv_2mortal (newSVpv (msg, 0)));
102 PUSHs(sv_2mortal(newSViv(level))); 105 PUSHs (sv_2mortal (newSViv (level)));
103 106
104 PUTBACK; (void) perl_call_sv ((SV *)cb, G_VOID|G_DISCARD); SPAGAIN; 107 PUTBACK; (void) perl_call_sv ((SV *)cb, G_VOID|G_DISCARD); SPAGAIN;
105 PUTBACK; FREETMPS; LEAVE; 108 PUTBACK; FREETMPS; LEAVE;
106} 109}
107 110
111static int
108static int uu_busy_callback (void *cb, uuprogress *uup) 112uu_busy_callback (void *cb, uuprogress *uup)
109{ 113{
110 dSP; 114 dSP;
111 int count; 115 int count;
112 int retval; 116 int retval;
113 117
114 ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,6); 118 ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 6);
115 119
116 PUSHs(sv_2mortal(newSViv(uup->action))); 120 PUSHs (sv_2mortal (newSViv (uup->action)));
117 PUSHs(sv_2mortal(newSVpv(uup->curfile,0))); 121 PUSHs (sv_2mortal (newSVpv (uup->curfile, 0)));
118 PUSHs(sv_2mortal(newSViv(uup->partno))); 122 PUSHs (sv_2mortal (newSViv (uup->partno)));
119 PUSHs(sv_2mortal(newSViv(uup->numparts))); 123 PUSHs (sv_2mortal (newSViv (uup->numparts)));
120 PUSHs(sv_2mortal(newSViv(uup->fsize))); 124 PUSHs (sv_2mortal (newSViv (uup->fsize)));
121 PUSHs(sv_2mortal(newSViv(uup->percent))); 125 PUSHs (sv_2mortal (newSViv (uup->percent)));
122 126
123 PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; 127 PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN;
124 128
125 if (count != 1) 129 if (count != 1)
126 croak ("busycallback perl callback returned more than one argument"); 130 croak ("busycallback perl callback returned more than one argument");
130 PUTBACK; FREETMPS; LEAVE; 134 PUTBACK; FREETMPS; LEAVE;
131 135
132 return retval; 136 return retval;
133} 137}
134 138
139static char *
135static char *uu_fnamefilter_callback (void *cb, char *fname) 140uu_fnamefilter_callback (void *cb, char *fname)
136{ 141{
137 dSP; 142 dSP;
138 int count; 143 int count;
139 static char *str; 144 static char *str;
140 145
141 ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,1); 146 ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 1);
142 147
143 PUSHs(sv_2mortal(newSVpv(fname,0))); 148 PUSHs (sv_2mortal (newSVpv (fname, 0)));
144 149
145 PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; 150 PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN;
146 151
147 if (count != 1) 152 if (count != 1)
148 croak ("fnamefilter perl callback returned more than one argument"); 153 croak ("fnamefilter perl callback returned more than one argument");
152 PUTBACK; FREETMPS; LEAVE; 157 PUTBACK; FREETMPS; LEAVE;
153 158
154 return str; 159 return str;
155} 160}
156 161
162static int
157static int uu_file_callback (void *cb, char *id, char *fname, int retrieve) 163uu_file_callback (void *cb, char *id, char *fname, int retrieve)
158{ 164{
159 dSP; 165 dSP;
160 int count; 166 int count;
161 int retval; 167 int retval;
162 SV *xfname = newSVpv ("", 0); 168 SV *xfname = newSVpv ("", 0);
163 STRLEN dc; 169 STRLEN dc;
164 170
165 ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,3); 171 ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 3);
166 172
167 PUSHs(sv_2mortal(newSVpv(id,0))); 173 PUSHs (sv_2mortal (newSVpv (id, 0)));
168 PUSHs(sv_2mortal(xfname)); 174 PUSHs (sv_2mortal (xfname));
169 PUSHs(sv_2mortal(newSViv(retrieve))); 175 PUSHs (sv_2mortal (newSViv (retrieve)));
170 176
171 PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; 177 PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN;
172 178
173 if (count != 1) 179 if (count != 1)
174 croak ("filecallback perl callback returned more than one argument"); 180 croak ("filecallback perl callback returned more than one argument");
180 PUTBACK; FREETMPS; LEAVE; 186 PUTBACK; FREETMPS; LEAVE;
181 187
182 return retval; 188 return retval;
183} 189}
184 190
191static char *
185static char *uu_filename_callback (void *cb, char *subject, char *filename) 192uu_filename_callback (void *cb, char *subject, char *filename)
186{ 193{
187 dSP; 194 dSP;
188 int count; 195 int count;
189 SV *retval; 196 SV *retval;
190 STRLEN dc; 197 STRLEN dc;
229 236
230static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv, *uu_filename_sv; 237static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv, *uu_filename_sv;
231 238
232#define FUNC_CB(cb) (void *)(sv_setsv (cb ## _sv, func), cb ## _sv), func ? cb ## _callback : NULL 239#define FUNC_CB(cb) (void *)(sv_setsv (cb ## _sv, func), cb ## _sv), func ? cb ## _callback : NULL
233 240
241static int
234static int uu_info_file(void *cb, char *info) 242uu_info_file (void *cb, char *info)
235{ 243{
236 dSP; 244 dSP;
237 int count; 245 int count;
238 int retval; 246 int retval;
239 247
272MODULE = Convert::UUlib PACKAGE = Convert::UUlib PREFIX = UU 280MODULE = Convert::UUlib PACKAGE = Convert::UUlib PREFIX = UU
273 281
274PROTOTYPES: ENABLE 282PROTOTYPES: ENABLE
275 283
276int 284int
277constant(name) 285constant (name)
278 char * name 286 char * name
279 287
280 288
281void 289void
282UUInitialize() 290UUInitialize ()
283 CODE: 291 CODE:
284 if (!uu_initialized) 292 if (!uu_initialized)
285 { 293 {
286 int retval; 294 int retval;
287 295
290 298
291 uu_initialized = 1; 299 uu_initialized = 1;
292 } 300 }
293 301
294void 302void
295UUCleanUp() 303UUCleanUp ()
296 CODE: 304 CODE:
297 if (uu_initialized) 305 if (uu_initialized)
298 UUCleanUp (); 306 UUCleanUp ();
299 307
300 uu_initialized = 0; 308 uu_initialized = 0;
301 309
302SV * 310SV *
303UUGetOption(opt) 311UUGetOption (opt)
304 int opt 312 int opt
305 CODE: 313 CODE:
306 { 314 {
307 if (opt == UUOPT_PROGRESS) 315 if (opt == UUOPT_PROGRESS)
308 croak ("GetOption(UUOPT_PROGRESS) is not yet implemented"); 316 croak ("GetOption(UUOPT_PROGRESS) is not yet implemented");
320 } 328 }
321 OUTPUT: 329 OUTPUT:
322 RETVAL 330 RETVAL
323 331
324int 332int
325UUSetOption(opt,val) 333UUSetOption (opt, val)
326 int opt 334 int opt
327 SV * val 335 SV * val
328 CODE: 336 CODE:
329 { 337 {
330 STRLEN dc; 338 STRLEN dc;
336 } 344 }
337 OUTPUT: 345 OUTPUT:
338 RETVAL 346 RETVAL
339 347
340char * 348char *
341UUstrerror(errcode) 349UUstrerror (errcode)
342 int errcode 350 int errcode
343 351
344void 352void
345UUSetMsgCallback(func=0) 353UUSetMsgCallback (func = 0)
346 SV * func 354 SV * func
347 CODE: 355 CODE:
348 UUSetMsgCallback (FUNC_CB(uu_msg)); 356 UUSetMsgCallback (FUNC_CB(uu_msg));
349 357
350void 358void
351UUSetBusyCallback(func=0,msecs=1000) 359UUSetBusyCallback (func = 0,msecs = 1000)
352 SV * func 360 SV * func
353 long msecs 361 long msecs
354 CODE: 362 CODE:
355 UUSetBusyCallback (FUNC_CB(uu_busy), msecs); 363 UUSetBusyCallback (FUNC_CB(uu_busy), msecs);
356 364
357void 365void
358UUSetFileCallback(func=0) 366UUSetFileCallback (func = 0)
359 SV * func 367 SV * func
360 CODE: 368 CODE:
361 UUSetFileCallback (FUNC_CB(uu_file)); 369 UUSetFileCallback (FUNC_CB(uu_file));
362 370
363void 371void
364UUSetFNameFilter(func=0) 372UUSetFNameFilter (func = 0)
365 SV * func 373 SV * func
366 CODE: 374 CODE:
367 UUSetFNameFilter (FUNC_CB(uu_fnamefilter)); 375 UUSetFNameFilter (FUNC_CB(uu_fnamefilter));
368 376
369void 377void
370UUSetFileNameCallback(func=0) 378UUSetFileNameCallback (func = 0)
371 SV * func 379 SV * func
372 CODE: 380 CODE:
373 UUSetFileNameCallback (FUNC_CB(uu_filename)); 381 UUSetFileNameCallback (FUNC_CB(uu_filename));
374 382
375char * 383char *
376UUFNameFilter(fname) 384UUFNameFilter (fname)
377 char * fname 385 char * fname
378 386
379void 387void
380UULoadFile(fname,id=0,delflag=0) 388UULoadFile (fname, id = 0, delflag = 0, partno = -1)
381 char * fname 389 char * fname
382 char * id 390 char * id
383 int delflag 391 int delflag
392 int partno
384 PPCODE: 393 PPCODE:
385 { 394 {
386 int count; 395 int count;
387 396
388 XPUSHs(sv_2mortal(newSViv(UULoadFile (fname, id, delflag, &count)))); 397 XPUSHs (sv_2mortal (newSViv (UULoadFileWithPartNo (fname, id, delflag, partno, &count))));
389 if (GIMME_V == G_ARRAY) 398 if (GIMME_V == G_ARRAY)
390 XPUSHs(sv_2mortal(newSViv(count))); 399 XPUSHs (sv_2mortal (newSViv (count)));
391 } 400 }
392 401
393int 402int
394UUSmerge(pass) 403UUSmerge (pass)
395 int pass 404 int pass
396 405
397int 406int
398UUQuickDecode(datain,dataout,boundary,maxpos) 407UUQuickDecode(datain,dataout,boundary,maxpos)
399 FILE * datain 408 FILE * datain
469 char * from 478 char * from
470 char * subject 479 char * subject
471 int isemail 480 int isemail
472 481
473uulist * 482uulist *
474UUGetFileListItem(num) 483UUGetFileListItem (num)
475 int num 484 int num
476 485
486MODULE = Convert::UUlib PACKAGE = Convert::UUlib::Item
487
477int 488int
478UURenameFile(item,newname) 489rename (item, newname)
479 uulist *item 490 uulist *item
480 char * newname 491 char * newname
481 ALIAS: 492 CODE:
482 Convert::UUlib::Item::rename = 1 493 RETVAL = UURenameFile (item, newname);
494 OUTPUT:
495 RETVAL
483 496
484int 497int
485UUDecodeToTemp(item) 498decode_temp (item)
486 uulist *item 499 uulist *item
487 ALIAS: 500 CODE:
488 Convert::UUlib::Item::decode_temp = 1 501 RETVAL = UUDecodeToTemp (item);
502 OUTPUT:
503 RETVAL
489 504
490int 505int
491UURemoveTemp(item) 506remove_temp (item)
492 uulist *item 507 uulist *item
493 ALIAS: 508 CODE:
494 Convert::UUlib::Item::remove_temp = 1 509 RETVAL = UURemoveTemp (item);
510 OUTPUT:
511 RETVAL
495 512
496int 513int
497UUDecodeFile(item,target=0) 514decode (item, target = 0)
498 uulist *item 515 uulist *item
499 char * target 516 char * target
500 ALIAS: 517 CODE:
501 Convert::UUlib::Item::decode = 1 518 RETVAL = UUDecodeFile (item, target);
519 OUTPUT:
520 RETVAL
502 521
503void 522void
504UUInfoFile(item,func) 523info (item, func)
505 uulist *item 524 uulist *item
506 SV * func 525 SV * func
507 CODE: 526 CODE:
508 UUInfoFile(item,(void *)func,uu_info_file); 527 UUInfoFile (item,(void *)func, uu_info_file);
509 ALIAS:
510 Convert::UUlib::Item::info = 1
511
512MODULE = Convert::UUlib PACKAGE = Convert::UUlib::Item
513 528
514short 529short
515state(li) 530state(li)
516 uulist *li 531 uulist *li
517 CODE: 532 CODE:
545 RETVAL = li->size; 560 RETVAL = li->size;
546 OUTPUT: 561 OUTPUT:
547 RETVAL 562 RETVAL
548 563
549char * 564char *
550filename(li,newfilename=0) 565filename (li, newfilename = 0)
551 uulist *li 566 uulist *li
552 char * newfilename 567 char * newfilename
553 CODE: 568 CODE:
554 if (newfilename) 569 if (newfilename)
555 { 570 {
559 RETVAL = li->filename; 574 RETVAL = li->filename;
560 OUTPUT: 575 OUTPUT:
561 RETVAL 576 RETVAL
562 577
563char * 578char *
564subfname(li) 579subfname (li)
565 uulist *li 580 uulist *li
566 CODE: 581 CODE:
567 RETVAL = li->subfname; 582 RETVAL = li->subfname;
568 OUTPUT: 583 OUTPUT:
569 RETVAL 584 RETVAL
570 585
571char * 586char *
572mimeid(li) 587mimeid (li)
573 uulist *li 588 uulist *li
574 CODE: 589 CODE:
575 RETVAL = li->mimeid; 590 RETVAL = li->mimeid;
576 OUTPUT: 591 OUTPUT:
577 RETVAL 592 RETVAL
578 593
579char * 594char *
580mimetype(li) 595mimetype (li)
581 uulist *li 596 uulist *li
582 CODE: 597 CODE:
583 RETVAL = li->mimetype; 598 RETVAL = li->mimetype;
584 OUTPUT: 599 OUTPUT:
585 RETVAL 600 RETVAL
586 601
587char * 602char *
588binfile(li) 603binfile (li)
589 uulist *li 604 uulist *li
590 CODE: 605 CODE:
591 RETVAL = li->binfile; 606 RETVAL = li->binfile;
592 OUTPUT: 607 OUTPUT:
593 RETVAL 608 RETVAL
594 609
595# functions accessing internal data(!) 610# methods accessing internal data(!)
596 611
597void 612void
598parts(li) 613parts (li)
599 uulist *li 614 uulist *li
600 PPCODE: 615 PPCODE:
601 { 616 {
602 struct _uufile *p = li->thisfile; 617 struct _uufile *p = li->thisfile;
603 618

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines