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 | |
|
|
11 | static int perlinterp_released; |
|
|
12 | |
|
|
13 | #define RELEASE do { perlinterp_released = 1; perlinterp_release (); } while (0) |
|
|
14 | #define ACQUIRE do { perlinterp_acquire (); perlinterp_released = 0; } while (0) |
|
|
15 | |
|
|
16 | #define TEMP_ACQUIRE if (perlinterp_released) perlinterp_acquire (); |
|
|
17 | #define TEMP_RELEASE if (perlinterp_released) perlinterp_release (); |
8 | |
18 | |
9 | static int |
19 | static int |
10 | not_here (char *s) |
20 | not_here (char *s) |
11 | { |
21 | { |
12 | croak("%s not implemented", s); |
22 | croak("%s not implemented", s); |
… | |
… | |
18 | { |
28 | { |
19 | errno = 0; |
29 | errno = 0; |
20 | switch (*name) |
30 | switch (*name) |
21 | { |
31 | { |
22 | case 'A': |
32 | case 'A': |
23 | if (strEQ(name, "ACT_COPYING")) return UUACT_COPYING; |
33 | if (strEQ (name, "ACT_COPYING")) return UUACT_COPYING; |
24 | if (strEQ(name, "ACT_DECODING")) return UUACT_DECODING; |
34 | if (strEQ (name, "ACT_DECODING")) return UUACT_DECODING; |
25 | if (strEQ(name, "ACT_ENCODING")) return UUACT_ENCODING; |
35 | if (strEQ (name, "ACT_ENCODING")) return UUACT_ENCODING; |
26 | if (strEQ(name, "ACT_IDLE")) return UUACT_IDLE; |
36 | if (strEQ (name, "ACT_IDLE")) return UUACT_IDLE; |
27 | if (strEQ(name, "ACT_SCANNING")) return UUACT_SCANNING; |
37 | if (strEQ (name, "ACT_SCANNING")) return UUACT_SCANNING; |
28 | case 'F': |
38 | case 'F': |
29 | if (strEQ(name, "FILE_DECODED")) return UUFILE_DECODED; |
39 | if (strEQ (name, "FILE_DECODED")) return UUFILE_DECODED; |
30 | if (strEQ(name, "FILE_ERROR")) return UUFILE_ERROR; |
40 | if (strEQ (name, "FILE_ERROR")) return UUFILE_ERROR; |
31 | if (strEQ(name, "FILE_MISPART")) return UUFILE_MISPART; |
41 | if (strEQ (name, "FILE_MISPART")) return UUFILE_MISPART; |
32 | if (strEQ(name, "FILE_NOBEGIN")) return UUFILE_NOBEGIN; |
42 | if (strEQ (name, "FILE_NOBEGIN")) return UUFILE_NOBEGIN; |
33 | if (strEQ(name, "FILE_NODATA")) return UUFILE_NODATA; |
43 | if (strEQ (name, "FILE_NODATA")) return UUFILE_NODATA; |
34 | if (strEQ(name, "FILE_NOEND")) return UUFILE_NOEND; |
44 | if (strEQ (name, "FILE_NOEND")) return UUFILE_NOEND; |
35 | if (strEQ(name, "FILE_OK")) return UUFILE_OK; |
45 | if (strEQ (name, "FILE_OK")) return UUFILE_OK; |
36 | if (strEQ(name, "FILE_READ")) return UUFILE_READ; |
46 | if (strEQ (name, "FILE_READ")) return UUFILE_READ; |
37 | if (strEQ(name, "FILE_TMPFILE")) return UUFILE_TMPFILE; |
47 | if (strEQ (name, "FILE_TMPFILE")) return UUFILE_TMPFILE; |
38 | break; |
48 | break; |
39 | case 'M': |
49 | case 'M': |
40 | if (strEQ(name, "MSG_ERROR")) return UUMSG_ERROR; |
50 | if (strEQ (name, "MSG_ERROR")) return UUMSG_ERROR; |
41 | if (strEQ(name, "MSG_FATAL")) return UUMSG_FATAL; |
51 | if (strEQ (name, "MSG_FATAL")) return UUMSG_FATAL; |
42 | if (strEQ(name, "MSG_MESSAGE")) return UUMSG_MESSAGE; |
52 | if (strEQ (name, "MSG_MESSAGE")) return UUMSG_MESSAGE; |
43 | if (strEQ(name, "MSG_NOTE")) return UUMSG_NOTE; |
53 | if (strEQ (name, "MSG_NOTE")) return UUMSG_NOTE; |
44 | if (strEQ(name, "MSG_PANIC")) return UUMSG_PANIC; |
54 | if (strEQ (name, "MSG_PANIC")) return UUMSG_PANIC; |
45 | if (strEQ(name, "MSG_WARNING")) return UUMSG_WARNING; |
55 | if (strEQ (name, "MSG_WARNING")) return UUMSG_WARNING; |
46 | case 'O': |
56 | case 'O': |
47 | if (strEQ(name, "OPT_VERSION")) return UUOPT_VERSION; |
57 | if (strEQ (name, "OPT_VERSION")) return UUOPT_VERSION; |
48 | if (strEQ(name, "OPT_FAST")) return UUOPT_FAST; |
58 | if (strEQ (name, "OPT_FAST")) return UUOPT_FAST; |
49 | if (strEQ(name, "OPT_DUMBNESS")) return UUOPT_DUMBNESS; |
59 | if (strEQ (name, "OPT_DUMBNESS")) return UUOPT_DUMBNESS; |
50 | if (strEQ(name, "OPT_BRACKPOL")) return UUOPT_BRACKPOL; |
60 | if (strEQ (name, "OPT_BRACKPOL")) return UUOPT_BRACKPOL; |
51 | if (strEQ(name, "OPT_VERBOSE")) return UUOPT_VERBOSE; |
61 | if (strEQ (name, "OPT_VERBOSE")) return UUOPT_VERBOSE; |
52 | if (strEQ(name, "OPT_DESPERATE")) return UUOPT_DESPERATE; |
62 | if (strEQ (name, "OPT_DESPERATE")) return UUOPT_DESPERATE; |
53 | if (strEQ(name, "OPT_IGNREPLY")) return UUOPT_IGNREPLY; |
63 | if (strEQ (name, "OPT_IGNREPLY")) return UUOPT_IGNREPLY; |
54 | if (strEQ(name, "OPT_OVERWRITE")) return UUOPT_OVERWRITE; |
64 | if (strEQ (name, "OPT_OVERWRITE")) return UUOPT_OVERWRITE; |
55 | if (strEQ(name, "OPT_SAVEPATH")) return UUOPT_SAVEPATH; |
65 | if (strEQ (name, "OPT_SAVEPATH")) return UUOPT_SAVEPATH; |
56 | if (strEQ(name, "OPT_IGNMODE")) return UUOPT_IGNMODE; |
66 | if (strEQ (name, "OPT_IGNMODE")) return UUOPT_IGNMODE; |
57 | if (strEQ(name, "OPT_DEBUG")) return UUOPT_DEBUG; |
67 | if (strEQ (name, "OPT_DEBUG")) return UUOPT_DEBUG; |
58 | if (strEQ(name, "OPT_ERRNO")) return UUOPT_ERRNO; |
68 | if (strEQ (name, "OPT_ERRNO")) return UUOPT_ERRNO; |
59 | if (strEQ(name, "OPT_PROGRESS")) return UUOPT_PROGRESS; |
69 | if (strEQ (name, "OPT_PROGRESS")) return UUOPT_PROGRESS; |
60 | if (strEQ(name, "OPT_USETEXT")) return UUOPT_USETEXT; |
70 | if (strEQ (name, "OPT_USETEXT")) return UUOPT_USETEXT; |
61 | if (strEQ(name, "OPT_PREAMB")) return UUOPT_PREAMB; |
71 | if (strEQ (name, "OPT_PREAMB")) return UUOPT_PREAMB; |
62 | if (strEQ(name, "OPT_TINYB64")) return UUOPT_TINYB64; |
72 | if (strEQ (name, "OPT_TINYB64")) return UUOPT_TINYB64; |
63 | if (strEQ(name, "OPT_ENCEXT")) return UUOPT_ENCEXT; |
73 | if (strEQ (name, "OPT_ENCEXT")) return UUOPT_ENCEXT; |
64 | if (strEQ(name, "OPT_REMOVE")) return UUOPT_REMOVE; |
74 | if (strEQ (name, "OPT_REMOVE")) return UUOPT_REMOVE; |
65 | if (strEQ(name, "OPT_MOREMIME")) return UUOPT_MOREMIME; |
75 | if (strEQ (name, "OPT_MOREMIME")) return UUOPT_MOREMIME; |
66 | if (strEQ(name, "OPT_DOTDOT")) return UUOPT_DOTDOT; |
76 | if (strEQ (name, "OPT_DOTDOT")) return UUOPT_DOTDOT; |
67 | if (strEQ(name, "OPT_RBUF")) return UUOPT_RBUF; |
77 | if (strEQ (name, "OPT_RBUF")) return UUOPT_RBUF; |
68 | if (strEQ(name, "OPT_WBUF")) return UUOPT_WBUF; |
78 | if (strEQ (name, "OPT_WBUF")) return UUOPT_WBUF; |
69 | if (strEQ(name, "OPT_AUTOCHECK")) return UUOPT_AUTOCHECK; |
79 | if (strEQ (name, "OPT_AUTOCHECK")) return UUOPT_AUTOCHECK; |
70 | case 'R': |
80 | case 'R': |
71 | if (strEQ(name, "RET_CANCEL")) return UURET_CANCEL; |
81 | if (strEQ (name, "RET_CANCEL")) return UURET_CANCEL; |
72 | if (strEQ(name, "RET_CONT")) return UURET_CONT; |
82 | if (strEQ (name, "RET_CONT")) return UURET_CONT; |
73 | if (strEQ(name, "RET_EXISTS")) return UURET_EXISTS; |
83 | if (strEQ (name, "RET_EXISTS")) return UURET_EXISTS; |
74 | if (strEQ(name, "RET_ILLVAL")) return UURET_ILLVAL; |
84 | if (strEQ (name, "RET_ILLVAL")) return UURET_ILLVAL; |
75 | if (strEQ(name, "RET_IOERR")) return UURET_IOERR; |
85 | if (strEQ (name, "RET_IOERR")) return UURET_IOERR; |
76 | if (strEQ(name, "RET_NODATA")) return UURET_NODATA; |
86 | if (strEQ (name, "RET_NODATA")) return UURET_NODATA; |
77 | if (strEQ(name, "RET_NOEND")) return UURET_NOEND; |
87 | if (strEQ (name, "RET_NOEND")) return UURET_NOEND; |
78 | if (strEQ(name, "RET_NOMEM")) return UURET_NOMEM; |
88 | if (strEQ (name, "RET_NOMEM")) return UURET_NOMEM; |
79 | if (strEQ(name, "RET_OK")) return UURET_OK; |
89 | if (strEQ (name, "RET_OK")) return UURET_OK; |
80 | if (strEQ(name, "RET_UNSUP")) return UURET_UNSUP; |
90 | if (strEQ (name, "RET_UNSUP")) return UURET_UNSUP; |
81 | case 'B': |
91 | case 'B': |
82 | if (strEQ(name, "B64_ENCODED")) return B64ENCODED; |
92 | if (strEQ (name, "B64_ENCODED")) return B64ENCODED; |
83 | if (strEQ(name, "BH_ENCODED")) return BH_ENCODED; |
93 | if (strEQ (name, "BH_ENCODED")) return BH_ENCODED; |
84 | case 'P': |
94 | case 'P': |
85 | if (strEQ(name, "PT_ENCODED")) return PT_ENCODED; |
95 | if (strEQ (name, "PT_ENCODED")) return PT_ENCODED; |
86 | case 'Q': |
96 | case 'Q': |
87 | if (strEQ(name, "QP_ENCODED")) return QP_ENCODED; |
97 | if (strEQ (name, "QP_ENCODED")) return QP_ENCODED; |
88 | case 'U': |
98 | case 'U': |
89 | if (strEQ(name, "UU_ENCODED")) return UU_ENCODED; |
99 | if (strEQ (name, "UU_ENCODED")) return UU_ENCODED; |
90 | case 'X': |
100 | case 'X': |
91 | if (strEQ(name, "XX_ENCODED")) return XX_ENCODED; |
101 | if (strEQ (name, "XX_ENCODED")) return XX_ENCODED; |
92 | case 'Y': |
102 | case 'Y': |
93 | if (strEQ(name, "YENC_ENCODED")) return YENC_ENCODED; |
103 | if (strEQ (name, "YENC_ENCODED")) return YENC_ENCODED; |
94 | } |
104 | } |
95 | |
105 | |
96 | errno = EINVAL; |
106 | errno = EINVAL; |
97 | return 0; |
107 | return 0; |
98 | } |
108 | } |
99 | |
109 | |
100 | static void |
110 | static void |
101 | uu_msg_callback (void *cb, char *msg, int level) |
111 | uu_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 | |
114 | static int |
128 | static int |
115 | uu_busy_callback (void *cb, uuprogress *uup) |
129 | uu_busy_callback (void *cb, uuprogress *uup) |
116 | { |
130 | { |
117 | dSP; |
|
|
118 | int count; |
|
|
119 | int retval; |
131 | int retval; |
|
|
132 | |
|
|
133 | TEMP_ACQUIRE { |
|
|
134 | |
|
|
135 | dSP; |
|
|
136 | int count; |
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))); |
125 | PUSHs (sv_2mortal (newSViv (uup->partno))); |
142 | PUSHs (sv_2mortal (newSViv (uup->partno))); |
126 | PUSHs (sv_2mortal (newSViv (uup->numparts))); |
143 | PUSHs (sv_2mortal (newSViv (uup->numparts))); |
127 | PUSHs (sv_2mortal (newSViv (uup->fsize))); |
144 | PUSHs (sv_2mortal (newSViv (uup->fsize))); |
128 | PUSHs (sv_2mortal (newSViv (uup->percent))); |
145 | PUSHs (sv_2mortal (newSViv (uup->percent))); |
129 | |
146 | |
130 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
147 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
131 | |
148 | |
132 | if (count != 1) |
149 | if (count != 1) |
133 | croak ("busycallback perl callback returned more than one argument"); |
150 | croak ("busycallback perl callback returned more than one argument"); |
134 | |
151 | |
135 | retval = POPi; |
152 | retval = POPi; |
136 | |
153 | |
137 | PUTBACK; FREETMPS; LEAVE; |
154 | PUTBACK; FREETMPS; LEAVE; |
|
|
155 | |
|
|
156 | } TEMP_RELEASE; |
138 | |
157 | |
139 | return retval; |
158 | return retval; |
140 | } |
159 | } |
141 | |
160 | |
142 | static char * |
161 | static char * |
143 | uu_fnamefilter_callback (void *cb, char *fname) |
162 | uu_fnamefilter_callback (void *cb, char *fname) |
144 | { |
163 | { |
145 | dSP; |
|
|
146 | int count; |
|
|
147 | static char *str; |
164 | static char *str; |
|
|
165 | |
|
|
166 | TEMP_ACQUIRE { |
|
|
167 | |
|
|
168 | dSP; |
|
|
169 | int count; |
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 | |
153 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
175 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
154 | |
176 | |
155 | if (count != 1) |
177 | if (count != 1) |
156 | croak ("fnamefilter perl callback MUST return a single filename exactly"); |
178 | croak ("fnamefilter perl callback MUST return a single filename exactly"); |
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; |
|
|
183 | |
|
|
184 | } TEMP_RELEASE; |
161 | |
185 | |
162 | return str; |
186 | return str; |
163 | } |
187 | } |
164 | |
188 | |
165 | static int |
189 | static int |
166 | uu_file_callback (void *cb, char *id, char *fname, int retrieve) |
190 | uu_file_callback (void *cb, char *id, char *fname, int retrieve) |
167 | { |
191 | { |
168 | dSP; |
|
|
169 | int count; |
|
|
170 | int retval; |
192 | int retval; |
|
|
193 | |
|
|
194 | TEMP_ACQUIRE { |
|
|
195 | |
|
|
196 | dSP; |
|
|
197 | int count; |
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))); |
176 | PUSHs (sv_2mortal (xfname)); |
203 | PUSHs (sv_2mortal (xfname)); |
177 | PUSHs (sv_2mortal (newSViv (retrieve))); |
204 | PUSHs (sv_2mortal (newSViv (retrieve))); |
178 | |
205 | |
179 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
206 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
180 | |
207 | |
181 | if (count != 1) |
208 | if (count != 1) |
182 | croak ("filecallback perl callback must return a single return status"); |
209 | croak ("filecallback perl callback must return a single return status"); |
183 | |
210 | |
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; |
|
|
215 | |
|
|
216 | } TEMP_RELEASE; |
188 | |
217 | |
189 | return retval; |
218 | return retval; |
190 | } |
219 | } |
191 | |
220 | |
192 | static char * |
221 | static char * |
193 | uu_filename_callback (void *cb, char *subject, char *filename) |
222 | uu_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 | |
200 | PUSHs (sv_2mortal(newSVpv(subject, 0))); |
231 | PUSHs (sv_2mortal(newSVpv(subject, 0))); |
201 | PUSHs (filename ? sv_2mortal(newSVpv(filename, 0)) : &PL_sv_undef); |
232 | PUSHs (filename ? sv_2mortal(newSVpv(filename, 0)) : &PL_sv_undef); |
202 | |
233 | |
203 | PUTBACK; count = perl_call_sv ((SV *)cb, G_ARRAY); SPAGAIN; |
234 | PUTBACK; count = perl_call_sv ((SV *)cb, G_ARRAY); SPAGAIN; |
204 | |
235 | |
205 | if (count > 1) |
236 | if (count > 1) |
206 | croak ("filenamecallback perl callback must return nothing or a single filename"); |
237 | croak ("filenamecallback perl callback must return nothing or a single filename"); |
207 | |
238 | |
208 | if (count) |
239 | if (count) |
209 | { |
240 | { |
210 | _FP_free (filename); |
241 | _FP_free (filename); |
211 | |
242 | |
212 | filename = SvOK (TOPs) |
243 | filename = SvOK (TOPs) |
213 | ? _FP_strdup (SvPV_nolen (TOPs)) |
244 | ? _FP_strdup (SvPV_nolen (TOPs)) |
214 | : 0; |
245 | : 0; |
215 | } |
246 | } |
216 | |
247 | |
217 | PUTBACK; FREETMPS; LEAVE; |
248 | PUTBACK; FREETMPS; LEAVE; |
|
|
249 | |
|
|
250 | } TEMP_RELEASE; |
218 | |
251 | |
219 | return filename; |
252 | return filename; |
220 | } |
253 | } |
221 | |
254 | |
222 | static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv, *uu_filename_sv; |
255 | static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv, *uu_filename_sv; |
… | |
… | |
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 | |
226 | static int |
259 | static int |
227 | uu_info_file (void *cb, char *info) |
260 | uu_info_file (void *cb, char *info) |
228 | { |
261 | { |
229 | dSP; |
|
|
230 | int count; |
|
|
231 | int retval; |
262 | int retval; |
|
|
263 | |
|
|
264 | TEMP_ACQUIRE { |
|
|
265 | |
|
|
266 | dSP; |
|
|
267 | int count; |
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 | |
237 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
273 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
238 | |
274 | |
239 | if (count != 1) |
275 | if (count != 1) |
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 | |
249 | static int |
287 | static int |
… | |
… | |
258 | default: |
296 | default: |
259 | return 0; |
297 | return 0; |
260 | } |
298 | } |
261 | } |
299 | } |
262 | |
300 | |
263 | static int uu_initialized; |
301 | static void |
|
|
302 | initialise (void) |
|
|
303 | { |
|
|
304 | int retval = UUInitialize (); |
|
|
305 | |
|
|
306 | if (retval != UURET_OK) |
|
|
307 | croak ("unable to initialize uudeview library (%s)", UUstrerror (retval)); |
|
|
308 | } |
264 | |
309 | |
265 | MODULE = Convert::UUlib PACKAGE = Convert::UUlib PREFIX = UU |
310 | MODULE = Convert::UUlib PACKAGE = Convert::UUlib PREFIX = UU |
266 | |
311 | |
267 | PROTOTYPES: ENABLE |
312 | PROTOTYPES: ENABLE |
268 | |
313 | |
269 | int |
314 | int |
270 | constant (name) |
315 | constant (name) |
271 | char * name |
316 | char * name |
272 | |
317 | |
273 | |
|
|
274 | void |
|
|
275 | UUInitialize () |
|
|
276 | CODE: |
|
|
277 | if (!uu_initialized) |
|
|
278 | { |
|
|
279 | int retval; |
|
|
280 | |
|
|
281 | if ((retval = UUInitialize ()) != UURET_OK) |
|
|
282 | croak ("unable to initialize uudeview library (%s)", UUstrerror (retval)); |
|
|
283 | |
|
|
284 | uu_initialized = 1; |
|
|
285 | } |
|
|
286 | |
|
|
287 | void |
318 | void |
288 | UUCleanUp () |
319 | UUCleanUp () |
289 | CODE: |
320 | CODE: |
290 | if (uu_initialized) |
|
|
291 | UUCleanUp (); |
321 | UUCleanUp (); |
292 | |
322 | initialise (); |
293 | uu_initialized = 0; |
|
|
294 | |
323 | |
295 | SV * |
324 | SV * |
296 | UUGetOption (opt) |
325 | UUGetOption (opt) |
297 | int opt |
326 | int opt |
298 | CODE: |
327 | CODE: |
299 | { |
328 | { |
300 | if (opt == UUOPT_PROGRESS) |
329 | if (opt == UUOPT_PROGRESS) |
301 | croak ("GetOption(UUOPT_PROGRESS) is not yet implemented"); |
330 | croak ("GetOption(UUOPT_PROGRESS) is not yet implemented"); |
302 | else if (uu_opt_isstring (opt)) |
331 | else if (uu_opt_isstring (opt)) |
303 | { |
332 | { |
304 | char cval[8192]; |
333 | char cval[8192]; |
305 | |
334 | |
306 | UUGetOption (opt, 0, cval, sizeof cval); |
335 | UUGetOption (opt, 0, cval, sizeof cval); |
307 | RETVAL = newSVpv (cval, 0); |
336 | RETVAL = newSVpv (cval, 0); |
308 | } |
337 | } |
309 | else |
338 | else |
310 | { |
339 | { |
311 | RETVAL = newSViv (UUGetOption (opt, 0, 0, 0)); |
340 | RETVAL = newSViv (UUGetOption (opt, 0, 0, 0)); |
312 | } |
341 | } |
313 | } |
342 | } |
314 | OUTPUT: |
343 | OUTPUT: |
315 | RETVAL |
344 | RETVAL |
316 | |
345 | |
317 | int |
346 | int |
318 | UUSetOption (opt, val) |
347 | UUSetOption (opt, val) |
319 | int opt |
348 | int opt |
320 | SV * val |
349 | SV * val |
321 | CODE: |
350 | CODE: |
322 | { |
351 | { |
323 | STRLEN dc; |
352 | STRLEN dc; |
324 | |
353 | |
325 | if (uu_opt_isstring (opt)) |
354 | if (uu_opt_isstring (opt)) |
326 | RETVAL = UUSetOption (opt, 0, SvPV (val, dc)); |
355 | RETVAL = UUSetOption (opt, 0, SvPV (val, dc)); |
327 | else |
356 | else |
328 | RETVAL = UUSetOption (opt, SvIV (val), (void *)0); |
357 | RETVAL = UUSetOption (opt, SvIV (val), (void *)0); |
329 | } |
358 | } |
330 | OUTPUT: |
359 | OUTPUT: |
331 | RETVAL |
360 | RETVAL |
332 | |
361 | |
333 | char * |
362 | char * |
334 | UUstrerror (errcode) |
363 | UUstrerror (errcode) |
… | |
… | |
374 | char * fname |
403 | char * fname |
375 | char * id |
404 | char * id |
376 | int delflag |
405 | int delflag |
377 | int partno |
406 | int partno |
378 | PPCODE: |
407 | PPCODE: |
379 | { |
408 | { |
380 | int count; |
409 | int count; |
381 | |
410 | IV ret; |
382 | XPUSHs (sv_2mortal (newSViv (UULoadFileWithPartNo (fname, id, delflag, partno, &count)))); |
411 | |
|
|
412 | RELEASE; |
|
|
413 | ret = UULoadFileWithPartNo (fname, id, delflag, partno, &count); |
|
|
414 | ACQUIRE; |
|
|
415 | |
|
|
416 | XPUSHs (sv_2mortal (newSViv (ret))); |
383 | if (GIMME_V == G_ARRAY) |
417 | if (GIMME_V == G_ARRAY) |
384 | XPUSHs (sv_2mortal (newSViv (count))); |
418 | XPUSHs (sv_2mortal (newSViv (count))); |
385 | } |
419 | } |
386 | |
|
|
387 | void |
|
|
388 | UUCheckGlobalList () |
|
|
389 | |
420 | |
390 | int |
421 | int |
391 | UUSmerge (pass) |
422 | UUSmerge (pass) |
392 | int pass |
423 | int pass |
393 | |
424 | |
… | |
… | |
469 | |
500 | |
470 | uulist * |
501 | uulist * |
471 | UUGetFileListItem (num) |
502 | UUGetFileListItem (num) |
472 | int num |
503 | int num |
473 | |
504 | |
|
|
505 | void |
|
|
506 | GetFileList () |
|
|
507 | PPCODE: |
|
|
508 | for (uulist *iter = UUGlobalFileList; iter; iter = iter->NEXT) |
|
|
509 | XPUSHs (sv_setref_pv (sv_newmortal (), "Convert::UUlib::Item", iter)); |
|
|
510 | |
474 | MODULE = Convert::UUlib PACKAGE = Convert::UUlib::Item |
511 | MODULE = Convert::UUlib PACKAGE = Convert::UUlib::Item |
475 | |
512 | |
476 | int |
513 | int |
477 | rename (item, newname) |
514 | rename (item, newname) |
478 | uulist *item |
515 | uulist *item |
… | |
… | |
484 | |
521 | |
485 | int |
522 | int |
486 | decode_temp (item) |
523 | decode_temp (item) |
487 | uulist *item |
524 | uulist *item |
488 | CODE: |
525 | CODE: |
|
|
526 | RELEASE; |
489 | RETVAL = UUDecodeToTemp (item); |
527 | RETVAL = UUDecodeToTemp (item); |
|
|
528 | ACQUIRE; |
490 | OUTPUT: |
529 | OUTPUT: |
491 | RETVAL |
530 | RETVAL |
492 | |
531 | |
493 | int |
532 | int |
494 | remove_temp (item) |
533 | remove_temp (item) |
495 | uulist *item |
534 | uulist *item |
496 | CODE: |
535 | CODE: |
|
|
536 | RELEASE; |
497 | RETVAL = UURemoveTemp (item); |
537 | RETVAL = UURemoveTemp (item); |
|
|
538 | ACQUIRE; |
498 | OUTPUT: |
539 | OUTPUT: |
499 | RETVAL |
540 | RETVAL |
500 | |
541 | |
501 | int |
542 | int |
502 | decode (item, target = 0) |
543 | decode (item, target = 0) |
503 | uulist *item |
544 | uulist *item |
504 | char * target |
545 | char * target |
505 | CODE: |
546 | CODE: |
|
|
547 | RELEASE; |
506 | RETVAL = UUDecodeFile (item, target); |
548 | RETVAL = UUDecodeFile (item, target); |
|
|
549 | ACQUIRE; |
507 | OUTPUT: |
550 | OUTPUT: |
508 | RETVAL |
551 | RETVAL |
509 | |
552 | |
510 | void |
553 | void |
511 | info (item, func) |
554 | info (item, func) |
512 | uulist *item |
555 | uulist *item |
513 | SV * func |
556 | SV * func |
514 | CODE: |
557 | CODE: |
|
|
558 | RELEASE; |
515 | UUInfoFile (item,(void *)func, uu_info_file); |
559 | UUInfoFile (item, (void *)func, uu_info_file); |
|
|
560 | ACQUIRE; |
516 | |
561 | |
517 | short |
562 | short |
518 | state(li) |
563 | state(li) |
519 | uulist *li |
564 | uulist *li |
520 | CODE: |
565 | CODE: |
… | |
… | |
599 | |
644 | |
600 | void |
645 | void |
601 | parts (li) |
646 | parts (li) |
602 | uulist *li |
647 | uulist *li |
603 | PPCODE: |
648 | PPCODE: |
604 | { |
649 | { |
605 | struct _uufile *p = li->thisfile; |
650 | struct _uufile *p = li->thisfile; |
606 | |
651 | |
607 | while (p) |
652 | while (p) |
608 | { |
653 | { |
609 | HV *pi = newHV (); |
654 | HV *pi = newHV (); |
610 | |
655 | |
611 | hv_store (pi, "partno" , 6, newSViv (p->partno) , 0); |
656 | hv_store (pi, "partno" , 6, newSViv (p->partno) , 0); |
612 | |
657 | |
613 | if (p->filename) |
658 | if (p->filename) |
614 | hv_store (pi, "filename", 8, newSVpv (p->filename, 0) , 0); |
659 | hv_store (pi, "filename", 8, newSVpv (p->filename, 0) , 0); |
615 | if(p->subfname) |
660 | if(p->subfname) |
616 | hv_store (pi, "subfname", 8, newSVpv (p->subfname, 0) , 0); |
661 | hv_store (pi, "subfname", 8, newSVpv (p->subfname, 0) , 0); |
617 | if(p->mimeid) |
662 | if(p->mimeid) |
618 | hv_store (pi, "mimeid" , 6, newSVpv (p->mimeid , 0) , 0); |
663 | hv_store (pi, "mimeid" , 6, newSVpv (p->mimeid , 0) , 0); |
619 | if(p->mimetype) |
664 | if(p->mimetype) |
620 | hv_store (pi, "mimetype", 8, newSVpv (p->mimetype, 0) , 0); |
665 | hv_store (pi, "mimetype", 8, newSVpv (p->mimetype, 0) , 0); |
621 | if (p->data->subject) |
666 | if (p->data->subject) |
622 | hv_store (pi, "subject" , 7, newSVpv (p->data->subject,0), 0); |
667 | hv_store (pi, "subject" , 7, newSVpv (p->data->subject,0), 0); |
623 | if (p->data->origin) |
668 | if (p->data->origin) |
624 | hv_store (pi, "origin" , 6, newSVpv (p->data->origin ,0), 0); |
669 | hv_store (pi, "origin" , 6, newSVpv (p->data->origin ,0), 0); |
625 | if (p->data->sfname) |
670 | if (p->data->sfname) |
626 | hv_store (pi, "sfname" , 6, newSVpv (p->data->sfname ,0), 0); |
671 | hv_store (pi, "sfname" , 6, newSVpv (p->data->sfname ,0), 0); |
627 | |
672 | |
628 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)pi))); |
673 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)pi))); |
629 | |
674 | |
630 | p = p->NEXT; |
675 | p = p->NEXT; |
631 | } |
|
|
632 | } |
676 | } |
|
|
677 | } |
633 | |
678 | |
634 | BOOT: |
679 | BOOT: |
635 | uu_msg_sv = newSVsv (&PL_sv_undef); |
680 | uu_msg_sv = newSVsv (&PL_sv_undef); |
636 | uu_busy_sv = newSVsv (&PL_sv_undef); |
681 | uu_busy_sv = newSVsv (&PL_sv_undef); |
637 | uu_file_sv = newSVsv (&PL_sv_undef); |
682 | uu_file_sv = newSVsv (&PL_sv_undef); |
638 | uu_fnamefilter_sv = newSVsv (&PL_sv_undef); |
683 | uu_fnamefilter_sv = newSVsv (&PL_sv_undef); |
639 | uu_filename_sv = newSVsv (&PL_sv_undef); |
684 | uu_filename_sv = newSVsv (&PL_sv_undef); |
|
|
685 | initialise (); |
640 | |
686 | |