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.16 by root, Fri Jul 10 01:17:08 2015 UTC vs.
Revision 1.17 by root, Fri Feb 28 06:57:25 2020 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 "perlmulticore.h"
6
5#include "uulib/fptools.h" 7#include "uulib/fptools.h"
6#include "uulib/uudeview.h" 8#include "uulib/uudeview.h"
7#include "uulib/uuint.h" 9#include "uulib/uuint.h"
10
11static int released;
12
13#define RELEASE do { released = 1; perlinterp_release (); } while (0)
14#define ACQUIRE do { perlinterp_acquire (); released = 0; } while (0)
15
16#define TEMP_ACQUIRE if (released) perlinterp_acquire ();
17#define TEMP_RELEASE if (released) perlinterp_release ();
8 18
9static int 19static int
10not_here (char *s) 20not_here (char *s)
11{ 21{
12 croak("%s not implemented", s); 22 croak("%s not implemented", s);
98} 108}
99 109
100static void 110static void
101uu_msg_callback (void *cb, char *msg, int level) 111uu_msg_callback (void *cb, char *msg, int level)
102{ 112{
113 TEMP_ACQUIRE {
114
103 dSP; 115 dSP;
104 116
105 ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); 117 ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2);
106 118
107 PUSHs (sv_2mortal (newSVpv (msg, 0))); 119 PUSHs (sv_2mortal (newSVpv (msg, 0)));
108 PUSHs (sv_2mortal (newSViv (level))); 120 PUSHs (sv_2mortal (newSViv (level)));
109 121
110 PUTBACK; (void) perl_call_sv ((SV *)cb, G_VOID|G_DISCARD); SPAGAIN; 122 PUTBACK; (void) perl_call_sv ((SV *)cb, G_VOID|G_DISCARD); SPAGAIN;
111 PUTBACK; FREETMPS; LEAVE; 123 PUTBACK; FREETMPS; LEAVE;
124
125 } TEMP_RELEASE;
112} 126}
113 127
114static int 128static int
115uu_busy_callback (void *cb, uuprogress *uup) 129uu_busy_callback (void *cb, uuprogress *uup)
116{ 130{
131 int retval;
132
133 TEMP_ACQUIRE {
134
117 dSP; 135 dSP;
118 int count; 136 int count;
119 int retval;
120 137
121 ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 6); 138 ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 6);
122 139
123 PUSHs (sv_2mortal (newSViv (uup->action))); 140 PUSHs (sv_2mortal (newSViv (uup->action)));
124 PUSHs (sv_2mortal (newSVpv (uup->curfile, 0))); 141 PUSHs (sv_2mortal (newSVpv (uup->curfile, 0)));
134 151
135 retval = POPi; 152 retval = POPi;
136 153
137 PUTBACK; FREETMPS; LEAVE; 154 PUTBACK; FREETMPS; LEAVE;
138 155
156 } TEMP_RELEASE;
157
139 return retval; 158 return retval;
140} 159}
141 160
142static char * 161static char *
143uu_fnamefilter_callback (void *cb, char *fname) 162uu_fnamefilter_callback (void *cb, char *fname)
144{ 163{
164 static char *str;
165
166 TEMP_ACQUIRE {
167
145 dSP; 168 dSP;
146 int count; 169 int count;
147 static char *str;
148 170
149 ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 1); 171 ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 1);
150 172
151 PUSHs (sv_2mortal (newSVpv (fname, 0))); 173 PUSHs (sv_2mortal (newSVpv (fname, 0)));
152 174
157 179
158 _FP_free (str); str = _FP_strdup (SvPV_nolen (TOPs)); 180 _FP_free (str); str = _FP_strdup (SvPV_nolen (TOPs));
159 181
160 PUTBACK; FREETMPS; LEAVE; 182 PUTBACK; FREETMPS; LEAVE;
161 183
184 } TEMP_RELEASE;
185
162 return str; 186 return str;
163} 187}
164 188
165static int 189static int
166uu_file_callback (void *cb, char *id, char *fname, int retrieve) 190uu_file_callback (void *cb, char *id, char *fname, int retrieve)
167{ 191{
192 int retval;
193
194 TEMP_ACQUIRE {
195
168 dSP; 196 dSP;
169 int count; 197 int count;
170 int retval;
171 SV *xfname = newSVpv ("", 0); 198 SV *xfname = newSVpv ("", 0);
172 199
173 ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 3); 200 ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 3);
174 201
175 PUSHs (sv_2mortal (newSVpv (id, 0))); 202 PUSHs (sv_2mortal (newSVpv (id, 0)));
184 strcpy (fname, SvPV_nolen (xfname)); 211 strcpy (fname, SvPV_nolen (xfname));
185 retval = POPi; 212 retval = POPi;
186 213
187 PUTBACK; FREETMPS; LEAVE; 214 PUTBACK; FREETMPS; LEAVE;
188 215
216 } TEMP_RELEASE;
217
189 return retval; 218 return retval;
190} 219}
191 220
192static char * 221static char *
193uu_filename_callback (void *cb, char *subject, char *filename) 222uu_filename_callback (void *cb, char *subject, char *filename)
194{ 223{
224 TEMP_ACQUIRE {
225
195 dSP; 226 dSP;
196 int count; 227 int count;
197 228
198 ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); 229 ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2);
199 230
214 : 0; 245 : 0;
215 } 246 }
216 247
217 PUTBACK; FREETMPS; LEAVE; 248 PUTBACK; FREETMPS; LEAVE;
218 249
250 } TEMP_RELEASE;
251
219 return filename; 252 return filename;
220} 253}
221 254
222static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv, *uu_filename_sv; 255static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv, *uu_filename_sv;
223 256
224#define FUNC_CB(cb) (void *)(sv_setsv (cb ## _sv, func), cb ## _sv), func ? cb ## _callback : NULL 257#define FUNC_CB(cb) (void *)(sv_setsv (cb ## _sv, func), cb ## _sv), func ? cb ## _callback : NULL
225 258
226static int 259static int
227uu_info_file (void *cb, char *info) 260uu_info_file (void *cb, char *info)
228{ 261{
262 int retval;
263
264 TEMP_ACQUIRE {
265
229 dSP; 266 dSP;
230 int count; 267 int count;
231 int retval;
232 268
233 ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,1); 269 ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,1);
234 270
235 PUSHs(sv_2mortal(newSVpv(info,0))); 271 PUSHs(sv_2mortal(newSVpv(info,0)));
236 272
240 croak ("info_file perl callback returned more than one argument"); 276 croak ("info_file perl callback returned more than one argument");
241 277
242 retval = POPi; 278 retval = POPi;
243 279
244 PUTBACK; FREETMPS; LEAVE; 280 PUTBACK; FREETMPS; LEAVE;
281
282 } TEMP_RELEASE;
245 283
246 return retval; 284 return retval;
247} 285}
248 286
249static int 287static int
376 int delflag 414 int delflag
377 int partno 415 int partno
378 PPCODE: 416 PPCODE:
379{ 417{
380 int count; 418 int count;
419 IV ret;
381 420
382 XPUSHs (sv_2mortal (newSViv (UULoadFileWithPartNo (fname, id, delflag, partno, &count)))); 421 RELEASE;
422 ret = UULoadFileWithPartNo (fname, id, delflag, partno, &count);
423 ACQUIRE;
424
425 XPUSHs (sv_2mortal (newSViv (ret)));
383 if (GIMME_V == G_ARRAY) 426 if (GIMME_V == G_ARRAY)
384 XPUSHs (sv_2mortal (newSViv (count))); 427 XPUSHs (sv_2mortal (newSViv (count)));
385} 428}
386 429
387int 430int
481 524
482int 525int
483decode_temp (item) 526decode_temp (item)
484 uulist *item 527 uulist *item
485 CODE: 528 CODE:
529 RELEASE;
486 RETVAL = UUDecodeToTemp (item); 530 RETVAL = UUDecodeToTemp (item);
531 ACQUIRE;
487 OUTPUT: 532 OUTPUT:
488 RETVAL 533 RETVAL
489 534
490int 535int
491remove_temp (item) 536remove_temp (item)
492 uulist *item 537 uulist *item
493 CODE: 538 CODE:
539 RELEASE;
494 RETVAL = UURemoveTemp (item); 540 RETVAL = UURemoveTemp (item);
541 ACQUIRE;
495 OUTPUT: 542 OUTPUT:
496 RETVAL 543 RETVAL
497 544
498int 545int
499decode (item, target = 0) 546decode (item, target = 0)
500 uulist *item 547 uulist *item
501 char * target 548 char * target
502 CODE: 549 CODE:
550 RELEASE;
503 RETVAL = UUDecodeFile (item, target); 551 RETVAL = UUDecodeFile (item, target);
552 ACQUIRE;
504 OUTPUT: 553 OUTPUT:
505 RETVAL 554 RETVAL
506 555
507void 556void
508info (item, func) 557info (item, func)
509 uulist *item 558 uulist *item
510 SV * func 559 SV * func
511 CODE: 560 CODE:
561 RELEASE;
512 UUInfoFile (item,(void *)func, uu_info_file); 562 UUInfoFile (item, (void *)func, uu_info_file);
563 ACQUIRE;
513 564
514short 565short
515state(li) 566state(li)
516 uulist *li 567 uulist *li
517 CODE: 568 CODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines