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; |
|
|
79 | if (strEQ (name, "OPT_AUTOCHECK")) return UUOPT_AUTOCHECK; |
69 | case 'R': |
80 | case 'R': |
70 | if (strEQ(name, "RET_CANCEL")) return UURET_CANCEL; |
81 | if (strEQ (name, "RET_CANCEL")) return UURET_CANCEL; |
71 | if (strEQ(name, "RET_CONT")) return UURET_CONT; |
82 | if (strEQ (name, "RET_CONT")) return UURET_CONT; |
72 | if (strEQ(name, "RET_EXISTS")) return UURET_EXISTS; |
83 | if (strEQ (name, "RET_EXISTS")) return UURET_EXISTS; |
73 | if (strEQ(name, "RET_ILLVAL")) return UURET_ILLVAL; |
84 | if (strEQ (name, "RET_ILLVAL")) return UURET_ILLVAL; |
74 | if (strEQ(name, "RET_IOERR")) return UURET_IOERR; |
85 | if (strEQ (name, "RET_IOERR")) return UURET_IOERR; |
75 | if (strEQ(name, "RET_NODATA")) return UURET_NODATA; |
86 | if (strEQ (name, "RET_NODATA")) return UURET_NODATA; |
76 | if (strEQ(name, "RET_NOEND")) return UURET_NOEND; |
87 | if (strEQ (name, "RET_NOEND")) return UURET_NOEND; |
77 | if (strEQ(name, "RET_NOMEM")) return UURET_NOMEM; |
88 | if (strEQ (name, "RET_NOMEM")) return UURET_NOMEM; |
78 | if (strEQ(name, "RET_OK")) return UURET_OK; |
89 | if (strEQ (name, "RET_OK")) return UURET_OK; |
79 | if (strEQ(name, "RET_UNSUP")) return UURET_UNSUP; |
90 | if (strEQ (name, "RET_UNSUP")) return UURET_UNSUP; |
80 | case 'B': |
91 | case 'B': |
81 | if (strEQ(name, "B64_ENCODED")) return B64ENCODED; |
92 | if (strEQ (name, "B64_ENCODED")) return B64ENCODED; |
82 | if (strEQ(name, "BH_ENCODED")) return BH_ENCODED; |
93 | if (strEQ (name, "BH_ENCODED")) return BH_ENCODED; |
83 | case 'P': |
94 | case 'P': |
84 | if (strEQ(name, "PT_ENCODED")) return PT_ENCODED; |
95 | if (strEQ (name, "PT_ENCODED")) return PT_ENCODED; |
85 | case 'Q': |
96 | case 'Q': |
86 | if (strEQ(name, "QP_ENCODED")) return QP_ENCODED; |
97 | if (strEQ (name, "QP_ENCODED")) return QP_ENCODED; |
87 | case 'U': |
98 | case 'U': |
88 | if (strEQ(name, "UU_ENCODED")) return UU_ENCODED; |
99 | if (strEQ (name, "UU_ENCODED")) return UU_ENCODED; |
89 | case 'X': |
100 | case 'X': |
90 | if (strEQ(name, "XX_ENCODED")) return XX_ENCODED; |
101 | if (strEQ (name, "XX_ENCODED")) return XX_ENCODED; |
91 | case 'Y': |
102 | case 'Y': |
92 | if (strEQ(name, "YENC_ENCODED")) return YENC_ENCODED; |
103 | if (strEQ (name, "YENC_ENCODED")) return YENC_ENCODED; |
93 | } |
104 | } |
94 | |
105 | |
95 | errno = EINVAL; |
106 | errno = EINVAL; |
96 | return 0; |
107 | return 0; |
97 | } |
108 | } |
98 | |
109 | |
99 | static void |
110 | static void |
100 | uu_msg_callback (void *cb, char *msg, int level) |
111 | uu_msg_callback (void *cb, char *msg, int level) |
101 | { |
112 | { |
|
|
113 | TEMP_ACQUIRE { |
|
|
114 | |
102 | dSP; |
115 | dSP; |
103 | |
116 | |
104 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); |
117 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); |
105 | |
118 | |
106 | PUSHs (sv_2mortal (newSVpv (msg, 0))); |
119 | PUSHs (sv_2mortal (newSVpv (msg, 0))); |
107 | PUSHs (sv_2mortal (newSViv (level))); |
120 | PUSHs (sv_2mortal (newSViv (level))); |
108 | |
121 | |
109 | 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; |
110 | PUTBACK; FREETMPS; LEAVE; |
123 | PUTBACK; FREETMPS; LEAVE; |
|
|
124 | |
|
|
125 | } TEMP_RELEASE; |
111 | } |
126 | } |
112 | |
127 | |
113 | static int |
128 | static int |
114 | uu_busy_callback (void *cb, uuprogress *uup) |
129 | uu_busy_callback (void *cb, uuprogress *uup) |
115 | { |
130 | { |
116 | dSP; |
|
|
117 | int count; |
|
|
118 | int retval; |
131 | int retval; |
|
|
132 | |
|
|
133 | TEMP_ACQUIRE { |
|
|
134 | |
|
|
135 | dSP; |
|
|
136 | int count; |
119 | |
137 | |
120 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 6); |
138 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 6); |
121 | |
139 | |
122 | PUSHs (sv_2mortal (newSViv (uup->action))); |
140 | PUSHs (sv_2mortal (newSViv (uup->action))); |
123 | PUSHs (sv_2mortal (newSVpv (uup->curfile, 0))); |
141 | PUSHs (sv_2mortal (newSVpv (uup->curfile, 0))); |
124 | PUSHs (sv_2mortal (newSViv (uup->partno))); |
142 | PUSHs (sv_2mortal (newSViv (uup->partno))); |
125 | PUSHs (sv_2mortal (newSViv (uup->numparts))); |
143 | PUSHs (sv_2mortal (newSViv (uup->numparts))); |
126 | PUSHs (sv_2mortal (newSViv (uup->fsize))); |
144 | PUSHs (sv_2mortal (newSViv (uup->fsize))); |
127 | PUSHs (sv_2mortal (newSViv (uup->percent))); |
145 | PUSHs (sv_2mortal (newSViv (uup->percent))); |
128 | |
146 | |
129 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
147 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
130 | |
148 | |
131 | if (count != 1) |
149 | if (count != 1) |
132 | croak ("busycallback perl callback returned more than one argument"); |
150 | croak ("busycallback perl callback returned more than one argument"); |
133 | |
151 | |
134 | retval = POPi; |
152 | retval = POPi; |
135 | |
153 | |
136 | PUTBACK; FREETMPS; LEAVE; |
154 | PUTBACK; FREETMPS; LEAVE; |
|
|
155 | |
|
|
156 | } TEMP_RELEASE; |
137 | |
157 | |
138 | return retval; |
158 | return retval; |
139 | } |
159 | } |
140 | |
160 | |
141 | static char * |
161 | static char * |
142 | uu_fnamefilter_callback (void *cb, char *fname) |
162 | uu_fnamefilter_callback (void *cb, char *fname) |
143 | { |
163 | { |
144 | dSP; |
|
|
145 | int count; |
|
|
146 | static char *str; |
164 | static char *str; |
|
|
165 | |
|
|
166 | TEMP_ACQUIRE { |
|
|
167 | |
|
|
168 | dSP; |
|
|
169 | int count; |
147 | |
170 | |
148 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 1); |
171 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 1); |
149 | |
172 | |
150 | PUSHs (sv_2mortal (newSVpv (fname, 0))); |
173 | PUSHs (sv_2mortal (newSVpv (fname, 0))); |
151 | |
174 | |
152 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
175 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
153 | |
176 | |
154 | if (count != 1) |
177 | if (count != 1) |
155 | croak ("fnamefilter perl callback MUST return a single filename exactly"); |
178 | croak ("fnamefilter perl callback MUST return a single filename exactly"); |
156 | |
179 | |
157 | _FP_free (str); str = _FP_strdup (SvPV_nolen (TOPs)); |
180 | _FP_free (str); str = _FP_strdup (SvPV_nolen (TOPs)); |
158 | |
181 | |
159 | PUTBACK; FREETMPS; LEAVE; |
182 | PUTBACK; FREETMPS; LEAVE; |
|
|
183 | |
|
|
184 | } TEMP_RELEASE; |
160 | |
185 | |
161 | return str; |
186 | return str; |
162 | } |
187 | } |
163 | |
188 | |
164 | static int |
189 | static int |
165 | uu_file_callback (void *cb, char *id, char *fname, int retrieve) |
190 | uu_file_callback (void *cb, char *id, char *fname, int retrieve) |
166 | { |
191 | { |
167 | dSP; |
|
|
168 | int count; |
|
|
169 | int retval; |
192 | int retval; |
|
|
193 | |
|
|
194 | TEMP_ACQUIRE { |
|
|
195 | |
|
|
196 | dSP; |
|
|
197 | int count; |
170 | SV *xfname = newSVpv ("", 0); |
198 | SV *xfname = newSVpv ("", 0); |
171 | |
199 | |
172 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 3); |
200 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 3); |
173 | |
201 | |
174 | PUSHs (sv_2mortal (newSVpv (id, 0))); |
202 | PUSHs (sv_2mortal (newSVpv (id, 0))); |
175 | PUSHs (sv_2mortal (xfname)); |
203 | PUSHs (sv_2mortal (xfname)); |
176 | PUSHs (sv_2mortal (newSViv (retrieve))); |
204 | PUSHs (sv_2mortal (newSViv (retrieve))); |
177 | |
205 | |
178 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
206 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
179 | |
207 | |
180 | if (count != 1) |
208 | if (count != 1) |
181 | croak ("filecallback perl callback must return a single return status"); |
209 | croak ("filecallback perl callback must return a single return status"); |
182 | |
210 | |
183 | strcpy (fname, SvPV_nolen (xfname)); |
211 | strcpy (fname, SvPV_nolen (xfname)); |
184 | retval = POPi; |
212 | retval = POPi; |
185 | |
213 | |
186 | PUTBACK; FREETMPS; LEAVE; |
214 | PUTBACK; FREETMPS; LEAVE; |
|
|
215 | |
|
|
216 | } TEMP_RELEASE; |
187 | |
217 | |
188 | return retval; |
218 | return retval; |
189 | } |
219 | } |
190 | |
220 | |
191 | static char * |
221 | static char * |
192 | uu_filename_callback (void *cb, char *subject, char *filename) |
222 | uu_filename_callback (void *cb, char *subject, char *filename) |
193 | { |
223 | { |
|
|
224 | TEMP_ACQUIRE { |
|
|
225 | |
194 | dSP; |
226 | dSP; |
195 | int count; |
227 | int count; |
196 | |
228 | |
197 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); |
229 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); |
198 | |
230 | |
199 | PUSHs (sv_2mortal(newSVpv(subject, 0))); |
231 | PUSHs (sv_2mortal(newSVpv(subject, 0))); |
200 | PUSHs (filename ? sv_2mortal(newSVpv(filename, 0)) : &PL_sv_undef); |
232 | PUSHs (filename ? sv_2mortal(newSVpv(filename, 0)) : &PL_sv_undef); |
201 | |
233 | |
202 | PUTBACK; count = perl_call_sv ((SV *)cb, G_ARRAY); SPAGAIN; |
234 | PUTBACK; count = perl_call_sv ((SV *)cb, G_ARRAY); SPAGAIN; |
203 | |
235 | |
204 | if (count > 1) |
236 | if (count > 1) |
205 | croak ("filenamecallback perl callback must return nothing or a single filename"); |
237 | croak ("filenamecallback perl callback must return nothing or a single filename"); |
206 | |
238 | |
207 | if (count) |
239 | if (count) |
208 | { |
240 | { |
209 | _FP_free (filename); |
241 | _FP_free (filename); |
210 | |
242 | |
211 | filename = SvOK (TOPs) |
243 | filename = SvOK (TOPs) |
212 | ? _FP_strdup (SvPV_nolen (TOPs)) |
244 | ? _FP_strdup (SvPV_nolen (TOPs)) |
213 | : 0; |
245 | : 0; |
214 | } |
246 | } |
215 | |
247 | |
216 | PUTBACK; FREETMPS; LEAVE; |
248 | PUTBACK; FREETMPS; LEAVE; |
|
|
249 | |
|
|
250 | } TEMP_RELEASE; |
217 | |
251 | |
218 | return filename; |
252 | return filename; |
219 | } |
253 | } |
220 | |
254 | |
221 | 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; |
… | |
… | |
223 | #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 |
224 | |
258 | |
225 | static int |
259 | static int |
226 | uu_info_file (void *cb, char *info) |
260 | uu_info_file (void *cb, char *info) |
227 | { |
261 | { |
228 | dSP; |
|
|
229 | int count; |
|
|
230 | int retval; |
262 | int retval; |
|
|
263 | |
|
|
264 | TEMP_ACQUIRE { |
|
|
265 | |
|
|
266 | dSP; |
|
|
267 | int count; |
231 | |
268 | |
232 | ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,1); |
269 | ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,1); |
233 | |
270 | |
234 | PUSHs(sv_2mortal(newSVpv(info,0))); |
271 | PUSHs(sv_2mortal(newSVpv(info,0))); |
235 | |
272 | |
236 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
273 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
237 | |
274 | |
238 | if (count != 1) |
275 | if (count != 1) |
239 | croak ("info_file perl callback returned more than one argument"); |
276 | croak ("info_file perl callback returned more than one argument"); |
240 | |
277 | |
241 | retval = POPi; |
278 | retval = POPi; |
242 | |
279 | |
243 | PUTBACK; FREETMPS; LEAVE; |
280 | PUTBACK; FREETMPS; LEAVE; |
|
|
281 | |
|
|
282 | } TEMP_RELEASE; |
244 | |
283 | |
245 | return retval; |
284 | return retval; |
246 | } |
285 | } |
247 | |
286 | |
248 | static int |
287 | static int |
… | |
… | |
257 | default: |
296 | default: |
258 | return 0; |
297 | return 0; |
259 | } |
298 | } |
260 | } |
299 | } |
261 | |
300 | |
262 | 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 | } |
263 | |
309 | |
264 | MODULE = Convert::UUlib PACKAGE = Convert::UUlib PREFIX = UU |
310 | MODULE = Convert::UUlib PACKAGE = Convert::UUlib PREFIX = UU |
265 | |
311 | |
266 | PROTOTYPES: ENABLE |
312 | PROTOTYPES: ENABLE |
267 | |
313 | |
268 | int |
314 | int |
269 | constant (name) |
315 | constant (name) |
270 | char * name |
316 | char * name |
271 | |
317 | |
272 | |
|
|
273 | void |
|
|
274 | UUInitialize () |
|
|
275 | CODE: |
|
|
276 | if (!uu_initialized) |
|
|
277 | { |
|
|
278 | int retval; |
|
|
279 | |
|
|
280 | if ((retval = UUInitialize ()) != UURET_OK) |
|
|
281 | croak ("unable to initialize uudeview library (%s)", UUstrerror (retval)); |
|
|
282 | |
|
|
283 | uu_initialized = 1; |
|
|
284 | } |
|
|
285 | |
|
|
286 | void |
318 | void |
287 | UUCleanUp () |
319 | UUCleanUp () |
288 | CODE: |
320 | CODE: |
289 | if (uu_initialized) |
|
|
290 | UUCleanUp (); |
321 | UUCleanUp (); |
291 | |
322 | initialise (); |
292 | uu_initialized = 0; |
|
|
293 | |
323 | |
294 | SV * |
324 | SV * |
295 | UUGetOption (opt) |
325 | UUGetOption (opt) |
296 | int opt |
326 | int opt |
297 | CODE: |
327 | CODE: |
298 | { |
328 | { |
299 | if (opt == UUOPT_PROGRESS) |
329 | if (opt == UUOPT_PROGRESS) |
300 | croak ("GetOption(UUOPT_PROGRESS) is not yet implemented"); |
330 | croak ("GetOption(UUOPT_PROGRESS) is not yet implemented"); |
301 | else if (uu_opt_isstring (opt)) |
331 | else if (uu_opt_isstring (opt)) |
302 | { |
332 | { |
303 | char cval[8192]; |
333 | char cval[8192]; |
304 | |
334 | |
305 | UUGetOption (opt, 0, cval, sizeof cval); |
335 | UUGetOption (opt, 0, cval, sizeof cval); |
306 | RETVAL = newSVpv (cval, 0); |
336 | RETVAL = newSVpv (cval, 0); |
307 | } |
337 | } |
308 | else |
338 | else |
309 | { |
339 | { |
310 | RETVAL = newSViv (UUGetOption (opt, 0, 0, 0)); |
340 | RETVAL = newSViv (UUGetOption (opt, 0, 0, 0)); |
311 | } |
341 | } |
312 | } |
342 | } |
313 | OUTPUT: |
343 | OUTPUT: |
314 | RETVAL |
344 | RETVAL |
315 | |
345 | |
316 | int |
346 | int |
317 | UUSetOption (opt, val) |
347 | UUSetOption (opt, val) |
318 | int opt |
348 | int opt |
319 | SV * val |
349 | SV * val |
320 | CODE: |
350 | CODE: |
321 | { |
351 | { |
322 | STRLEN dc; |
352 | STRLEN dc; |
323 | |
353 | |
324 | if (uu_opt_isstring (opt)) |
354 | if (uu_opt_isstring (opt)) |
325 | RETVAL = UUSetOption (opt, 0, SvPV (val, dc)); |
355 | RETVAL = UUSetOption (opt, 0, SvPV (val, dc)); |
326 | else |
356 | else |
327 | RETVAL = UUSetOption (opt, SvIV (val), (void *)0); |
357 | RETVAL = UUSetOption (opt, SvIV (val), (void *)0); |
328 | } |
358 | } |
329 | OUTPUT: |
359 | OUTPUT: |
330 | RETVAL |
360 | RETVAL |
331 | |
361 | |
332 | char * |
362 | char * |
333 | UUstrerror (errcode) |
363 | UUstrerror (errcode) |
… | |
… | |
373 | char * fname |
403 | char * fname |
374 | char * id |
404 | char * id |
375 | int delflag |
405 | int delflag |
376 | int partno |
406 | int partno |
377 | PPCODE: |
407 | PPCODE: |
378 | { |
408 | { |
379 | int count; |
409 | int count; |
380 | |
410 | IV ret; |
381 | 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))); |
382 | if (GIMME_V == G_ARRAY) |
417 | if (GIMME_V == G_ARRAY) |
383 | XPUSHs (sv_2mortal (newSViv (count))); |
418 | XPUSHs (sv_2mortal (newSViv (count))); |
384 | } |
419 | } |
385 | |
420 | |
386 | int |
421 | int |
387 | UUSmerge (pass) |
422 | UUSmerge (pass) |
388 | int pass |
423 | int pass |
389 | |
424 | |
… | |
… | |
465 | |
500 | |
466 | uulist * |
501 | uulist * |
467 | UUGetFileListItem (num) |
502 | UUGetFileListItem (num) |
468 | int num |
503 | int num |
469 | |
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 | |
470 | MODULE = Convert::UUlib PACKAGE = Convert::UUlib::Item |
511 | MODULE = Convert::UUlib PACKAGE = Convert::UUlib::Item |
471 | |
512 | |
472 | int |
513 | int |
473 | rename (item, newname) |
514 | rename (item, newname) |
474 | uulist *item |
515 | uulist *item |
… | |
… | |
480 | |
521 | |
481 | int |
522 | int |
482 | decode_temp (item) |
523 | decode_temp (item) |
483 | uulist *item |
524 | uulist *item |
484 | CODE: |
525 | CODE: |
|
|
526 | RELEASE; |
485 | RETVAL = UUDecodeToTemp (item); |
527 | RETVAL = UUDecodeToTemp (item); |
|
|
528 | ACQUIRE; |
486 | OUTPUT: |
529 | OUTPUT: |
487 | RETVAL |
530 | RETVAL |
488 | |
531 | |
489 | int |
532 | int |
490 | remove_temp (item) |
533 | remove_temp (item) |
491 | uulist *item |
534 | uulist *item |
492 | CODE: |
535 | CODE: |
|
|
536 | RELEASE; |
493 | RETVAL = UURemoveTemp (item); |
537 | RETVAL = UURemoveTemp (item); |
|
|
538 | ACQUIRE; |
494 | OUTPUT: |
539 | OUTPUT: |
495 | RETVAL |
540 | RETVAL |
496 | |
541 | |
497 | int |
542 | int |
498 | decode (item, target = 0) |
543 | decode (item, target = 0) |
499 | uulist *item |
544 | uulist *item |
500 | char * target |
545 | char * target |
501 | CODE: |
546 | CODE: |
|
|
547 | RELEASE; |
502 | RETVAL = UUDecodeFile (item, target); |
548 | RETVAL = UUDecodeFile (item, target); |
|
|
549 | ACQUIRE; |
503 | OUTPUT: |
550 | OUTPUT: |
504 | RETVAL |
551 | RETVAL |
505 | |
552 | |
506 | void |
553 | void |
507 | info (item, func) |
554 | info (item, func) |
508 | uulist *item |
555 | uulist *item |
509 | SV * func |
556 | SV * func |
510 | CODE: |
557 | CODE: |
|
|
558 | RELEASE; |
511 | UUInfoFile (item,(void *)func, uu_info_file); |
559 | UUInfoFile (item, (void *)func, uu_info_file); |
|
|
560 | ACQUIRE; |
512 | |
561 | |
513 | short |
562 | short |
514 | state(li) |
563 | state(li) |
515 | uulist *li |
564 | uulist *li |
516 | CODE: |
565 | CODE: |
… | |
… | |
595 | |
644 | |
596 | void |
645 | void |
597 | parts (li) |
646 | parts (li) |
598 | uulist *li |
647 | uulist *li |
599 | PPCODE: |
648 | PPCODE: |
600 | { |
649 | { |
601 | struct _uufile *p = li->thisfile; |
650 | struct _uufile *p = li->thisfile; |
602 | |
651 | |
603 | while (p) |
652 | while (p) |
604 | { |
653 | { |
605 | HV *pi = newHV (); |
654 | HV *pi = newHV (); |
606 | |
655 | |
607 | hv_store (pi, "partno" , 6, newSViv (p->partno) , 0); |
656 | hv_store (pi, "partno" , 6, newSViv (p->partno) , 0); |
608 | |
657 | |
609 | if (p->filename) |
658 | if (p->filename) |
610 | hv_store (pi, "filename", 8, newSVpv (p->filename, 0) , 0); |
659 | hv_store (pi, "filename", 8, newSVpv (p->filename, 0) , 0); |
611 | if(p->subfname) |
660 | if(p->subfname) |
612 | hv_store (pi, "subfname", 8, newSVpv (p->subfname, 0) , 0); |
661 | hv_store (pi, "subfname", 8, newSVpv (p->subfname, 0) , 0); |
613 | if(p->mimeid) |
662 | if(p->mimeid) |
614 | hv_store (pi, "mimeid" , 6, newSVpv (p->mimeid , 0) , 0); |
663 | hv_store (pi, "mimeid" , 6, newSVpv (p->mimeid , 0) , 0); |
615 | if(p->mimetype) |
664 | if(p->mimetype) |
616 | hv_store (pi, "mimetype", 8, newSVpv (p->mimetype, 0) , 0); |
665 | hv_store (pi, "mimetype", 8, newSVpv (p->mimetype, 0) , 0); |
617 | if (p->data->subject) |
666 | if (p->data->subject) |
618 | hv_store (pi, "subject" , 7, newSVpv (p->data->subject,0), 0); |
667 | hv_store (pi, "subject" , 7, newSVpv (p->data->subject,0), 0); |
619 | if (p->data->origin) |
668 | if (p->data->origin) |
620 | hv_store (pi, "origin" , 6, newSVpv (p->data->origin ,0), 0); |
669 | hv_store (pi, "origin" , 6, newSVpv (p->data->origin ,0), 0); |
621 | if (p->data->sfname) |
670 | if (p->data->sfname) |
622 | hv_store (pi, "sfname" , 6, newSVpv (p->data->sfname ,0), 0); |
671 | hv_store (pi, "sfname" , 6, newSVpv (p->data->sfname ,0), 0); |
623 | |
672 | |
624 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)pi))); |
673 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)pi))); |
625 | |
674 | |
626 | p = p->NEXT; |
675 | p = p->NEXT; |
627 | } |
|
|
628 | } |
676 | } |
|
|
677 | } |
629 | |
678 | |
630 | BOOT: |
679 | BOOT: |
631 | uu_msg_sv = newSVsv (&PL_sv_undef); |
680 | uu_msg_sv = newSVsv (&PL_sv_undef); |
632 | uu_busy_sv = newSVsv (&PL_sv_undef); |
681 | uu_busy_sv = newSVsv (&PL_sv_undef); |
633 | uu_file_sv = newSVsv (&PL_sv_undef); |
682 | uu_file_sv = newSVsv (&PL_sv_undef); |
634 | uu_fnamefilter_sv = newSVsv (&PL_sv_undef); |
683 | uu_fnamefilter_sv = newSVsv (&PL_sv_undef); |
635 | uu_filename_sv = newSVsv (&PL_sv_undef); |
684 | uu_filename_sv = newSVsv (&PL_sv_undef); |
|
|
685 | initialise (); |
636 | |
686 | |