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 | |
|
|
10 | static int perlinterp_released; |
|
|
11 | |
|
|
12 | #define RELEASE do { perlinterp_released = 1; perlinterp_release (); } while (0) |
|
|
13 | #define ACQUIRE do { perlinterp_acquire (); perlinterp_released = 0; } while (0) |
|
|
14 | |
|
|
15 | #define TEMP_ACQUIRE if (perlinterp_released) perlinterp_acquire (); |
|
|
16 | #define TEMP_RELEASE if (perlinterp_released) perlinterp_release (); |
|
|
17 | |
|
|
18 | static void |
|
|
19 | uu_msg_callback (void *cb, char *msg, int level) |
|
|
20 | { |
|
|
21 | TEMP_ACQUIRE { |
|
|
22 | |
|
|
23 | dSP; |
|
|
24 | |
|
|
25 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); |
|
|
26 | |
|
|
27 | PUSHs (sv_2mortal (newSVpv (msg, 0))); |
|
|
28 | PUSHs (sv_2mortal (newSViv (level))); |
|
|
29 | |
|
|
30 | PUTBACK; (void) perl_call_sv ((SV *)cb, G_VOID|G_DISCARD); SPAGAIN; |
|
|
31 | PUTBACK; FREETMPS; LEAVE; |
|
|
32 | |
|
|
33 | } TEMP_RELEASE; |
|
|
34 | } |
8 | |
35 | |
9 | static int |
36 | static int |
10 | not_here(char *s) |
37 | uu_busy_callback (void *cb, uuprogress *uup) |
11 | { |
38 | { |
12 | croak("%s not implemented on this architecture", s); |
39 | int retval; |
13 | return -1; |
40 | |
|
|
41 | TEMP_ACQUIRE { |
|
|
42 | |
|
|
43 | dSP; |
|
|
44 | int count; |
|
|
45 | |
|
|
46 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 6); |
|
|
47 | |
|
|
48 | PUSHs (sv_2mortal (newSViv (uup->action))); |
|
|
49 | PUSHs (sv_2mortal (newSVpv (uup->curfile, 0))); |
|
|
50 | PUSHs (sv_2mortal (newSViv (uup->partno))); |
|
|
51 | PUSHs (sv_2mortal (newSViv (uup->numparts))); |
|
|
52 | PUSHs (sv_2mortal (newSViv (uup->fsize))); |
|
|
53 | PUSHs (sv_2mortal (newSViv (uup->percent))); |
|
|
54 | |
|
|
55 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
|
|
56 | |
|
|
57 | if (count != 1) |
|
|
58 | croak ("busycallback perl callback returned more than one argument"); |
|
|
59 | |
|
|
60 | retval = POPi; |
|
|
61 | |
|
|
62 | PUTBACK; FREETMPS; LEAVE; |
|
|
63 | |
|
|
64 | } TEMP_RELEASE; |
|
|
65 | |
|
|
66 | return retval; |
|
|
67 | } |
|
|
68 | |
|
|
69 | static char * |
|
|
70 | uu_fnamefilter_callback (void *cb, char *fname) |
|
|
71 | { |
|
|
72 | static char *str; |
|
|
73 | |
|
|
74 | TEMP_ACQUIRE { |
|
|
75 | |
|
|
76 | dSP; |
|
|
77 | int count; |
|
|
78 | |
|
|
79 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 1); |
|
|
80 | |
|
|
81 | PUSHs (sv_2mortal (newSVpv (fname, 0))); |
|
|
82 | |
|
|
83 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
|
|
84 | |
|
|
85 | if (count != 1) |
|
|
86 | croak ("fnamefilter perl callback MUST return a single filename exactly"); |
|
|
87 | |
|
|
88 | FP_free (str); str = FP_strdup (SvPV_nolen (TOPs)); |
|
|
89 | |
|
|
90 | PUTBACK; FREETMPS; LEAVE; |
|
|
91 | |
|
|
92 | } TEMP_RELEASE; |
|
|
93 | |
|
|
94 | return str; |
14 | } |
95 | } |
15 | |
96 | |
16 | static int |
97 | static int |
17 | constant(char *name) |
98 | uu_file_callback (void *cb, char *id, char *fname, int retrieve) |
18 | { |
99 | { |
19 | errno = 0; |
|
|
20 | switch (*name) { |
|
|
21 | case 'A': |
|
|
22 | if (strEQ(name, "ACT_COPYING")) return UUACT_COPYING; |
|
|
23 | if (strEQ(name, "ACT_DECODING")) return UUACT_DECODING; |
|
|
24 | if (strEQ(name, "ACT_ENCODING")) return UUACT_ENCODING; |
|
|
25 | if (strEQ(name, "ACT_IDLE")) return UUACT_IDLE; |
|
|
26 | if (strEQ(name, "ACT_SCANNING")) return UUACT_SCANNING; |
|
|
27 | case 'F': |
|
|
28 | if (strEQ(name, "FILE_DECODED")) return UUFILE_DECODED; |
|
|
29 | if (strEQ(name, "FILE_ERROR")) return UUFILE_ERROR; |
|
|
30 | if (strEQ(name, "FILE_MISPART")) return UUFILE_MISPART; |
|
|
31 | if (strEQ(name, "FILE_NOBEGIN")) return UUFILE_NOBEGIN; |
|
|
32 | if (strEQ(name, "FILE_NODATA")) return UUFILE_NODATA; |
|
|
33 | if (strEQ(name, "FILE_NOEND")) return UUFILE_NOEND; |
|
|
34 | if (strEQ(name, "FILE_OK")) return UUFILE_OK; |
|
|
35 | if (strEQ(name, "FILE_READ")) return UUFILE_READ; |
|
|
36 | if (strEQ(name, "FILE_TMPFILE")) return UUFILE_TMPFILE; |
|
|
37 | break; |
|
|
38 | case 'M': |
|
|
39 | if (strEQ(name, "MSG_ERROR")) return UUMSG_ERROR; |
|
|
40 | if (strEQ(name, "MSG_FATAL")) return UUMSG_FATAL; |
|
|
41 | if (strEQ(name, "MSG_MESSAGE")) return UUMSG_MESSAGE; |
|
|
42 | if (strEQ(name, "MSG_NOTE")) return UUMSG_NOTE; |
|
|
43 | if (strEQ(name, "MSG_PANIC")) return UUMSG_PANIC; |
|
|
44 | if (strEQ(name, "MSG_WARNING")) return UUMSG_WARNING; |
|
|
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; |
|
|
49 | if (strEQ(name, "OPT_BRACKPOL")) return UUOPT_BRACKPOL; |
|
|
50 | if (strEQ(name, "OPT_VERBOSE")) return UUOPT_VERBOSE; |
|
|
51 | if (strEQ(name, "OPT_DESPERATE")) return UUOPT_DESPERATE; |
|
|
52 | if (strEQ(name, "OPT_IGNREPLY")) return UUOPT_IGNREPLY; |
|
|
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; |
|
|
60 | if (strEQ(name, "OPT_PREAMB")) return UUOPT_PREAMB; |
|
|
61 | if (strEQ(name, "OPT_TINYB64")) return UUOPT_TINYB64; |
|
|
62 | if (strEQ(name, "OPT_ENCEXT")) return UUOPT_ENCEXT; |
|
|
63 | if (strEQ(name, "OPT_REMOVE")) return UUOPT_REMOVE; |
|
|
64 | if (strEQ(name, "OPT_MOREMIME")) return UUOPT_MOREMIME; |
|
|
65 | if (strEQ(name, "OPT_DOTDOT")) return UUOPT_DOTDOT; |
|
|
66 | case 'R': |
|
|
67 | if (strEQ(name, "RET_CANCEL")) return UURET_CANCEL; |
|
|
68 | if (strEQ(name, "RET_CONT")) return UURET_CONT; |
|
|
69 | if (strEQ(name, "RET_EXISTS")) return UURET_EXISTS; |
|
|
70 | if (strEQ(name, "RET_ILLVAL")) return UURET_ILLVAL; |
|
|
71 | if (strEQ(name, "RET_IOERR")) return UURET_IOERR; |
|
|
72 | if (strEQ(name, "RET_NODATA")) return UURET_NODATA; |
|
|
73 | if (strEQ(name, "RET_NOEND")) return UURET_NOEND; |
|
|
74 | if (strEQ(name, "RET_NOMEM")) return UURET_NOMEM; |
|
|
75 | if (strEQ(name, "RET_OK")) return UURET_OK; |
|
|
76 | if (strEQ(name, "RET_UNSUP")) return UURET_UNSUP; |
|
|
77 | case 'B': |
|
|
78 | if (strEQ(name, "B64_ENCODED")) return B64ENCODED; |
|
|
79 | if (strEQ(name, "BH_ENCODED")) return BH_ENCODED; |
|
|
80 | case 'P': |
|
|
81 | if (strEQ(name, "PT_ENCODED")) return PT_ENCODED; |
|
|
82 | case 'Q': |
|
|
83 | if (strEQ(name, "QP_ENCODED")) return QP_ENCODED; |
|
|
84 | case 'U': |
|
|
85 | if (strEQ(name, "UU_ENCODED")) return UU_ENCODED; |
|
|
86 | case 'X': |
|
|
87 | if (strEQ(name, "XX_ENCODED")) return XX_ENCODED; |
|
|
88 | case 'Y': |
|
|
89 | if (strEQ(name, "YENC_ENCODED")) return YENC_ENCODED; |
|
|
90 | } |
|
|
91 | errno = EINVAL; |
|
|
92 | return 0; |
|
|
93 | } |
|
|
94 | |
|
|
95 | static void uu_msg_callback (void *cb, char *msg, int level) |
|
|
96 | { |
|
|
97 | dSP; |
|
|
98 | |
|
|
99 | ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,2); |
|
|
100 | |
|
|
101 | PUSHs(sv_2mortal(newSVpv(msg,0))); |
|
|
102 | PUSHs(sv_2mortal(newSViv(level))); |
|
|
103 | |
|
|
104 | PUTBACK; (void) perl_call_sv ((SV *)cb, G_VOID|G_DISCARD); SPAGAIN; |
|
|
105 | PUTBACK; FREETMPS; LEAVE; |
|
|
106 | } |
|
|
107 | |
|
|
108 | static int uu_busy_callback (void *cb, uuprogress *uup) |
|
|
109 | { |
|
|
110 | dSP; |
|
|
111 | int count; |
|
|
112 | int retval; |
100 | int retval; |
|
|
101 | |
|
|
102 | TEMP_ACQUIRE { |
|
|
103 | |
|
|
104 | dSP; |
|
|
105 | int count; |
|
|
106 | SV *xfname = newSVpv ("", 0); |
113 | |
107 | |
114 | ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,6); |
108 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 3); |
115 | |
109 | |
116 | PUSHs(sv_2mortal(newSViv(uup->action))); |
|
|
117 | PUSHs(sv_2mortal(newSVpv(uup->curfile,0))); |
110 | PUSHs (sv_2mortal (newSVpv (id, 0))); |
118 | PUSHs(sv_2mortal(newSViv(uup->partno))); |
111 | PUSHs (sv_2mortal (xfname)); |
119 | PUSHs(sv_2mortal(newSViv(uup->numparts))); |
|
|
120 | PUSHs(sv_2mortal(newSViv(uup->fsize))); |
|
|
121 | PUSHs(sv_2mortal(newSViv(uup->percent))); |
112 | PUSHs (sv_2mortal (newSViv (retrieve))); |
122 | |
113 | |
123 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
114 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
124 | |
115 | |
125 | if (count != 1) |
116 | if (count != 1) |
126 | croak ("busycallback perl callback returned more than one argument"); |
117 | croak ("filecallback perl callback must return a single return status"); |
127 | |
118 | |
|
|
119 | strcpy (fname, SvPV_nolen (xfname)); |
128 | retval = POPi; |
120 | retval = POPi; |
129 | |
121 | |
130 | PUTBACK; FREETMPS; LEAVE; |
122 | PUTBACK; FREETMPS; LEAVE; |
|
|
123 | |
|
|
124 | } TEMP_RELEASE; |
131 | |
125 | |
132 | return retval; |
126 | return retval; |
133 | } |
127 | } |
134 | |
128 | |
135 | static char *uu_fnamefilter_callback (void *cb, char *fname) |
129 | static char * |
|
|
130 | uu_filename_callback (void *cb, char *subject, char *filename) |
136 | { |
131 | { |
|
|
132 | TEMP_ACQUIRE { |
|
|
133 | |
137 | dSP; |
134 | dSP; |
138 | int count; |
135 | int count; |
139 | static char *str; |
|
|
140 | |
136 | |
141 | ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,1); |
137 | ENTER; SAVETMPS; PUSHMARK (SP); EXTEND (SP, 2); |
142 | |
138 | |
143 | PUSHs(sv_2mortal(newSVpv(fname,0))); |
139 | PUSHs (sv_2mortal (newSVpv (subject, 0))); |
|
|
140 | PUSHs (filename ? sv_2mortal (newSVpv (filename, 0)) : &PL_sv_undef); |
144 | |
141 | |
145 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
142 | PUTBACK; count = perl_call_sv ((SV *)cb, G_ARRAY); SPAGAIN; |
146 | |
143 | |
147 | if (count != 1) |
144 | if (count > 1) |
148 | croak ("fnamefilter perl callback returned more than one argument"); |
145 | croak ("filenamecallback perl callback must return nothing or a single filename"); |
149 | |
146 | |
150 | _FP_free(str); str = _FP_strdup (POPp); |
147 | if (count) |
|
|
148 | { |
|
|
149 | FP_free (filename); |
151 | |
150 | |
|
|
151 | filename = SvOK (TOPs) |
|
|
152 | ? FP_strdup (SvPV_nolen (TOPs)) |
|
|
153 | : 0; |
|
|
154 | } |
|
|
155 | |
152 | PUTBACK; FREETMPS; LEAVE; |
156 | PUTBACK; FREETMPS; LEAVE; |
153 | |
157 | |
154 | return str; |
158 | } TEMP_RELEASE; |
155 | } |
|
|
156 | |
159 | |
157 | static int uu_file_callback (void *cb, char *id, char *fname, int retrieve) |
160 | return filename; |
|
|
161 | } |
|
|
162 | |
|
|
163 | static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv, *uu_filename_sv; |
|
|
164 | |
|
|
165 | #define FUNC_CB(cb) (void *)(sv_setsv (cb ## _sv, func), cb ## _sv), func ? cb ## _callback : NULL |
|
|
166 | |
|
|
167 | static int |
|
|
168 | uu_info_file (void *cb, char *info) |
158 | { |
169 | { |
159 | dSP; |
|
|
160 | int count; |
|
|
161 | int retval; |
170 | int retval; |
162 | SV *xfname = newSVpv ("", 0); |
171 | |
163 | STRLEN dc; |
172 | TEMP_ACQUIRE { |
|
|
173 | |
|
|
174 | dSP; |
|
|
175 | int count; |
164 | |
176 | |
165 | ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,3); |
177 | ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,1); |
166 | |
178 | |
167 | PUSHs(sv_2mortal(newSVpv(id,0))); |
179 | PUSHs(sv_2mortal(newSVpv(info,0))); |
168 | PUSHs(sv_2mortal(xfname)); |
|
|
169 | PUSHs(sv_2mortal(newSViv(retrieve))); |
|
|
170 | |
180 | |
171 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
181 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
172 | |
182 | |
173 | if (count != 1) |
183 | if (count != 1) |
174 | croak ("filecallback perl callback returned more than one argument"); |
|
|
175 | |
|
|
176 | strcpy (fname, SvPV (xfname, dc)); |
|
|
177 | |
|
|
178 | retval = POPi; |
|
|
179 | |
|
|
180 | PUTBACK; FREETMPS; LEAVE; |
|
|
181 | |
|
|
182 | return retval; |
|
|
183 | } |
|
|
184 | |
|
|
185 | static char *uu_filename_callback (void *cb, char *subject, char *filename) |
|
|
186 | { |
|
|
187 | dSP; |
|
|
188 | int count; |
|
|
189 | SV *retval; |
|
|
190 | STRLEN dc; |
|
|
191 | |
|
|
192 | ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,3); |
|
|
193 | |
|
|
194 | PUSHs(sv_2mortal(newSVpv(subject, 0))); |
|
|
195 | PUSHs(filename ? sv_2mortal(newSVpv(filename, 0)) : &PL_sv_undef); |
|
|
196 | |
|
|
197 | PUTBACK; count = perl_call_sv ((SV *)cb, G_ARRAY); SPAGAIN; |
|
|
198 | |
|
|
199 | if (count > 1) |
|
|
200 | croak ("filenamecallback perl callback returned more than one argument"); |
|
|
201 | |
|
|
202 | if (count) |
|
|
203 | { |
|
|
204 | _FP_free (filename); |
|
|
205 | |
|
|
206 | retval = POPs; |
|
|
207 | |
|
|
208 | if (SvOK (retval)) |
|
|
209 | { |
|
|
210 | STRLEN len; |
|
|
211 | char *fn = SvPV (retval, len); |
|
|
212 | |
|
|
213 | filename = malloc (len + 1); |
|
|
214 | |
|
|
215 | if (filename) |
|
|
216 | { |
|
|
217 | memcpy (filename, fn, len); |
|
|
218 | filename[len] = 0; |
|
|
219 | } |
|
|
220 | } |
|
|
221 | else |
|
|
222 | filename = 0; |
|
|
223 | } |
|
|
224 | |
|
|
225 | PUTBACK; FREETMPS; LEAVE; |
|
|
226 | |
|
|
227 | return filename; |
|
|
228 | } |
|
|
229 | |
|
|
230 | static SV *uu_msg_sv, *uu_busy_sv, *uu_file_sv, *uu_fnamefilter_sv, *uu_filename_sv; |
|
|
231 | |
|
|
232 | #define FUNC_CB(cb) (void *)(sv_setsv (cb ## _sv, func), cb ## _sv), func ? cb ## _callback : NULL |
|
|
233 | |
|
|
234 | static int uu_info_file(void *cb, char *info) |
|
|
235 | { |
|
|
236 | dSP; |
|
|
237 | int count; |
|
|
238 | int retval; |
|
|
239 | |
|
|
240 | ENTER; SAVETMPS; PUSHMARK(SP); EXTEND(SP,1); |
|
|
241 | |
|
|
242 | PUSHs(sv_2mortal(newSVpv(info,0))); |
|
|
243 | |
|
|
244 | PUTBACK; count = perl_call_sv ((SV *)cb, G_SCALAR); SPAGAIN; |
|
|
245 | |
|
|
246 | if (count != 1) |
|
|
247 | croak ("info_file perl callback returned more than one argument"); |
184 | croak ("info_file perl callback returned more than one argument"); |
248 | |
185 | |
249 | retval = POPi; |
186 | retval = POPi; |
250 | |
187 | |
251 | PUTBACK; FREETMPS; LEAVE; |
188 | PUTBACK; FREETMPS; LEAVE; |
|
|
189 | |
|
|
190 | } TEMP_RELEASE; |
252 | |
191 | |
253 | return retval; |
192 | return retval; |
254 | } |
193 | } |
255 | |
194 | |
256 | static int |
195 | static int |
… | |
… | |
265 | default: |
204 | default: |
266 | return 0; |
205 | return 0; |
267 | } |
206 | } |
268 | } |
207 | } |
269 | |
208 | |
270 | static int uu_initialized; |
209 | static void |
|
|
210 | initialise (void) |
|
|
211 | { |
|
|
212 | int retval = UUInitialize (); |
|
|
213 | |
|
|
214 | if (retval != UURET_OK) |
|
|
215 | croak ("unable to initialize uudeview library (%s)", UUstrerror (retval)); |
|
|
216 | } |
271 | |
217 | |
272 | MODULE = Convert::UUlib PACKAGE = Convert::UUlib PREFIX = UU |
218 | MODULE = Convert::UUlib PACKAGE = Convert::UUlib PREFIX = UU |
273 | |
219 | |
274 | PROTOTYPES: ENABLE |
220 | PROTOTYPES: ENABLE |
275 | |
221 | |
276 | int |
|
|
277 | constant(name) |
|
|
278 | char * name |
|
|
279 | |
|
|
280 | |
|
|
281 | void |
222 | void |
282 | UUInitialize() |
223 | UUCleanUp () |
283 | CODE: |
224 | CODE: |
284 | if (!uu_initialized) |
225 | UUCleanUp (); |
|
|
226 | initialise (); |
|
|
227 | |
|
|
228 | SV * |
|
|
229 | UUGetOption (opt) |
|
|
230 | int opt |
|
|
231 | CODE: |
|
|
232 | { |
|
|
233 | if (opt == UUOPT_PROGRESS) |
|
|
234 | croak ("GetOption(UUOPT_PROGRESS) is not yet implemented"); |
|
|
235 | else if (uu_opt_isstring (opt)) |
285 | { |
236 | { |
286 | int retval; |
237 | char cval[8192]; |
287 | |
238 | |
288 | if ((retval = UUInitialize ()) != UURET_OK) |
239 | UUGetOption (opt, 0, cval, sizeof cval); |
289 | croak ("unable to initialize uudeview library (%s)", UUstrerror (retval)); |
240 | RETVAL = newSVpv (cval, 0); |
290 | |
|
|
291 | uu_initialized = 1; |
|
|
292 | } |
241 | } |
293 | |
|
|
294 | void |
|
|
295 | UUCleanUp() |
|
|
296 | CODE: |
|
|
297 | if (uu_initialized) |
|
|
298 | UUCleanUp (); |
|
|
299 | |
|
|
300 | uu_initialized = 0; |
|
|
301 | |
|
|
302 | SV * |
|
|
303 | UUGetOption(opt) |
|
|
304 | int opt |
|
|
305 | CODE: |
|
|
306 | { |
|
|
307 | if (opt == UUOPT_PROGRESS) |
|
|
308 | croak ("GetOption(UUOPT_PROGRESS) is not yet implemented"); |
|
|
309 | else if (uu_opt_isstring (opt)) |
|
|
310 | { |
|
|
311 | char cval[8192]; |
|
|
312 | |
|
|
313 | UUGetOption (opt, 0, cval, sizeof cval); |
|
|
314 | RETVAL = newSVpv (cval, 0); |
|
|
315 | } |
|
|
316 | else |
242 | else |
317 | { |
243 | { |
318 | RETVAL = newSViv (UUGetOption (opt, 0, 0, 0)); |
244 | RETVAL = newSViv (UUGetOption (opt, 0, 0, 0)); |
319 | } |
245 | } |
320 | } |
246 | } |
321 | OUTPUT: |
247 | OUTPUT: |
322 | RETVAL |
248 | RETVAL |
323 | |
249 | |
324 | int |
250 | int |
325 | UUSetOption(opt,val) |
251 | UUSetOption (opt, val) |
326 | int opt |
252 | int opt |
327 | SV * val |
253 | SV * val |
328 | CODE: |
254 | CODE: |
329 | { |
255 | { |
330 | STRLEN dc; |
256 | STRLEN dc; |
331 | |
257 | |
332 | if (uu_opt_isstring (opt)) |
258 | if (uu_opt_isstring (opt)) |
333 | RETVAL = UUSetOption (opt, 0, SvPV (val, dc)); |
259 | RETVAL = UUSetOption (opt, 0, SvPV (val, dc)); |
334 | else |
260 | else |
335 | RETVAL = UUSetOption (opt, SvIV (val), (void *)0); |
261 | RETVAL = UUSetOption (opt, SvIV (val), (void *)0); |
336 | } |
262 | } |
337 | OUTPUT: |
263 | OUTPUT: |
338 | RETVAL |
264 | RETVAL |
339 | |
265 | |
340 | char * |
266 | char * |
341 | UUstrerror(errcode) |
267 | UUstrerror (errcode) |
342 | int errcode |
268 | int errcode |
343 | |
269 | |
344 | void |
270 | void |
345 | UUSetMsgCallback(func=0) |
271 | UUSetMsgCallback (func = 0) |
346 | SV * func |
272 | SV * func |
347 | CODE: |
273 | CODE: |
348 | UUSetMsgCallback (FUNC_CB(uu_msg)); |
274 | UUSetMsgCallback (FUNC_CB (uu_msg)); |
349 | |
275 | |
350 | void |
276 | void |
351 | UUSetBusyCallback(func=0,msecs=1000) |
277 | UUSetBusyCallback (func = 0,msecs = 1000) |
352 | SV * func |
278 | SV * func |
353 | long msecs |
279 | long msecs |
354 | CODE: |
280 | CODE: |
355 | UUSetBusyCallback (FUNC_CB(uu_busy), msecs); |
281 | UUSetBusyCallback (FUNC_CB (uu_busy), msecs); |
356 | |
282 | |
357 | void |
283 | void |
358 | UUSetFileCallback(func=0) |
284 | UUSetFileCallback (func = 0) |
359 | SV * func |
285 | SV * func |
360 | CODE: |
286 | CODE: |
361 | UUSetFileCallback (FUNC_CB(uu_file)); |
287 | UUSetFileCallback (FUNC_CB (uu_file)); |
362 | |
288 | |
363 | void |
289 | void |
364 | UUSetFNameFilter(func=0) |
290 | UUSetFNameFilter (func = 0) |
365 | SV * func |
291 | SV * func |
366 | CODE: |
292 | CODE: |
367 | UUSetFNameFilter (FUNC_CB(uu_fnamefilter)); |
293 | UUSetFNameFilter (FUNC_CB (uu_fnamefilter)); |
368 | |
294 | |
369 | void |
295 | void |
370 | UUSetFileNameCallback(func=0) |
296 | UUSetFileNameCallback (func = 0) |
371 | SV * func |
297 | SV * func |
372 | CODE: |
298 | CODE: |
373 | UUSetFileNameCallback (FUNC_CB(uu_filename)); |
299 | UUSetFileNameCallback (FUNC_CB (uu_filename)); |
374 | |
300 | |
375 | char * |
301 | char * |
376 | UUFNameFilter(fname) |
302 | UUFNameFilter (fname) |
377 | char * fname |
303 | char * fname |
378 | |
304 | |
379 | void |
305 | void |
380 | UULoadFile(fname,id=0,delflag=0) |
306 | UULoadFile (fname, id = 0, delflag = 0, partno = -1) |
381 | char * fname |
307 | char * fname |
382 | char * id |
308 | char * id |
383 | int delflag |
309 | int delflag |
|
|
310 | int partno |
384 | PPCODE: |
311 | PPCODE: |
385 | { |
312 | { |
386 | int count; |
313 | int count; |
387 | |
314 | IV ret; |
388 | XPUSHs(sv_2mortal(newSViv(UULoadFile (fname, id, delflag, &count)))); |
315 | |
|
|
316 | RELEASE; |
|
|
317 | ret = UULoadFileWithPartNo (fname, id, delflag, partno, &count); |
|
|
318 | ACQUIRE; |
|
|
319 | |
|
|
320 | XPUSHs (sv_2mortal (newSViv (ret))); |
389 | if (GIMME_V == G_ARRAY) |
321 | if (GIMME_V == G_ARRAY) |
390 | XPUSHs(sv_2mortal(newSViv(count))); |
322 | XPUSHs (sv_2mortal (newSViv (count))); |
391 | } |
323 | } |
392 | |
324 | |
393 | int |
325 | int |
394 | UUSmerge(pass) |
326 | UUSmerge (pass) |
395 | int pass |
327 | int pass |
396 | |
328 | |
397 | int |
329 | int |
398 | UUQuickDecode(datain,dataout,boundary,maxpos) |
330 | UUQuickDecode(datain,dataout,boundary,maxpos) |
399 | FILE * datain |
331 | FILE * datain |
… | |
… | |
410 | char * outfname |
342 | char * outfname |
411 | char * mimetype |
343 | char * mimetype |
412 | int filemode |
344 | int filemode |
413 | |
345 | |
414 | int |
346 | int |
415 | UUEncodePartial(outfile,infile,infname,encoding,outfname,mimetype,filemode,partno,linperfile) |
347 | UUEncodePartial(outfile,infile,infname,encoding,outfname,mimetype,filemode,partno,linperfile,crc) |
416 | FILE * outfile |
348 | FILE * outfile |
417 | FILE * infile |
349 | FILE * infile |
418 | char * infname |
350 | char * infname |
419 | int encoding |
351 | int encoding |
420 | char * outfname |
352 | char * outfname |
421 | char * mimetype |
353 | char * mimetype |
422 | int filemode |
354 | int filemode |
423 | int partno |
355 | int partno |
424 | long linperfile |
356 | long linperfile |
|
|
357 | U32 &crc |
|
|
358 | OUTPUT: |
|
|
359 | RETVAL |
|
|
360 | crc |
425 | |
361 | |
426 | int |
362 | int |
427 | UUEncodeToStream(outfile,infile,infname,encoding,outfname,filemode) |
363 | UUEncodeToStream(outfile,infile,infname,encoding,outfname,filemode) |
428 | FILE * outfile |
364 | FILE * outfile |
429 | FILE * infile |
365 | FILE * infile |
… | |
… | |
469 | char * from |
405 | char * from |
470 | char * subject |
406 | char * subject |
471 | int isemail |
407 | int isemail |
472 | |
408 | |
473 | uulist * |
409 | uulist * |
474 | UUGetFileListItem(num) |
410 | UUGetFileListItem (num) |
475 | int num |
411 | int num |
476 | |
412 | |
|
|
413 | void |
|
|
414 | GetFileList () |
|
|
415 | PPCODE: |
|
|
416 | { |
|
|
417 | uulist *iter; |
|
|
418 | |
|
|
419 | for (iter = UUGlobalFileList; iter; iter = iter->NEXT) |
|
|
420 | XPUSHs (sv_setref_pv (sv_newmortal (), "Convert::UUlib::Item", iter)); |
|
|
421 | } |
|
|
422 | |
|
|
423 | MODULE = Convert::UUlib PACKAGE = Convert::UUlib::Item |
|
|
424 | |
477 | int |
425 | int |
478 | UURenameFile(item,newname) |
426 | rename (item, newname) |
479 | uulist *item |
427 | uulist *item |
480 | char * newname |
428 | char * newname |
481 | ALIAS: |
429 | CODE: |
482 | Convert::UUlib::Item::rename = 1 |
430 | RETVAL = UURenameFile (item, newname); |
|
|
431 | OUTPUT: |
|
|
432 | RETVAL |
483 | |
433 | |
484 | int |
434 | int |
485 | UUDecodeToTemp(item) |
435 | decode_temp (item) |
486 | uulist *item |
436 | uulist *item |
487 | ALIAS: |
437 | CODE: |
488 | Convert::UUlib::Item::decode_temp = 1 |
438 | RELEASE; |
|
|
439 | RETVAL = UUDecodeToTemp (item); |
|
|
440 | ACQUIRE; |
|
|
441 | OUTPUT: |
|
|
442 | RETVAL |
489 | |
443 | |
490 | int |
444 | int |
491 | UURemoveTemp(item) |
445 | remove_temp (item) |
492 | uulist *item |
446 | uulist *item |
493 | ALIAS: |
447 | CODE: |
494 | Convert::UUlib::Item::remove_temp = 1 |
448 | RELEASE; |
|
|
449 | RETVAL = UURemoveTemp (item); |
|
|
450 | ACQUIRE; |
|
|
451 | OUTPUT: |
|
|
452 | RETVAL |
495 | |
453 | |
496 | int |
454 | int |
497 | UUDecodeFile(item,target=0) |
455 | decode (item, target = 0) |
498 | uulist *item |
456 | uulist *item |
499 | char * target |
457 | char * target |
500 | ALIAS: |
458 | CODE: |
501 | Convert::UUlib::Item::decode = 1 |
459 | RELEASE; |
|
|
460 | RETVAL = UUDecodeFile (item, target); |
|
|
461 | ACQUIRE; |
|
|
462 | OUTPUT: |
|
|
463 | RETVAL |
502 | |
464 | |
503 | void |
465 | void |
504 | UUInfoFile(item,func) |
466 | info (item, func) |
505 | uulist *item |
467 | uulist *item |
506 | SV * func |
468 | SV * func |
507 | CODE: |
469 | CODE: |
|
|
470 | RELEASE; |
508 | UUInfoFile(item,(void *)func,uu_info_file); |
471 | UUInfoFile (item, (void *)func, uu_info_file); |
509 | ALIAS: |
472 | ACQUIRE; |
510 | Convert::UUlib::Item::info = 1 |
|
|
511 | |
|
|
512 | MODULE = Convert::UUlib PACKAGE = Convert::UUlib::Item |
|
|
513 | |
473 | |
514 | short |
474 | short |
515 | state(li) |
475 | state(li) |
516 | uulist *li |
476 | uulist *li |
517 | CODE: |
477 | CODE: |
… | |
… | |
545 | RETVAL = li->size; |
505 | RETVAL = li->size; |
546 | OUTPUT: |
506 | OUTPUT: |
547 | RETVAL |
507 | RETVAL |
548 | |
508 | |
549 | char * |
509 | char * |
550 | filename(li,newfilename=0) |
510 | filename (li, newfilename = 0) |
551 | uulist *li |
511 | uulist *li |
552 | char * newfilename |
512 | char * newfilename |
553 | CODE: |
513 | CODE: |
554 | if (newfilename) |
514 | if (newfilename) |
555 | { |
515 | { |
556 | _FP_free (li->filename); |
516 | FP_free (li->filename); |
557 | li->filename = _FP_strdup (newfilename); |
517 | li->filename = FP_strdup (newfilename); |
558 | } |
518 | } |
559 | RETVAL = li->filename; |
519 | RETVAL = li->filename; |
560 | OUTPUT: |
520 | OUTPUT: |
561 | RETVAL |
521 | RETVAL |
562 | |
522 | |
563 | char * |
523 | char * |
564 | subfname(li) |
524 | subfname (li) |
565 | uulist *li |
525 | uulist *li |
566 | CODE: |
526 | CODE: |
567 | RETVAL = li->subfname; |
527 | RETVAL = li->subfname; |
568 | OUTPUT: |
528 | OUTPUT: |
569 | RETVAL |
529 | RETVAL |
570 | |
530 | |
571 | char * |
531 | char * |
572 | mimeid(li) |
532 | mimeid (li) |
573 | uulist *li |
533 | uulist *li |
574 | CODE: |
534 | CODE: |
575 | RETVAL = li->mimeid; |
535 | RETVAL = li->mimeid; |
576 | OUTPUT: |
536 | OUTPUT: |
577 | RETVAL |
537 | RETVAL |
578 | |
538 | |
579 | char * |
539 | char * |
580 | mimetype(li) |
540 | mimetype (li) |
581 | uulist *li |
541 | uulist *li |
582 | CODE: |
542 | CODE: |
583 | RETVAL = li->mimetype; |
543 | RETVAL = li->mimetype; |
584 | OUTPUT: |
544 | OUTPUT: |
585 | RETVAL |
545 | RETVAL |
586 | |
546 | |
587 | char * |
547 | char * |
588 | binfile(li) |
548 | binfile (li) |
589 | uulist *li |
549 | uulist *li |
590 | CODE: |
550 | CODE: |
591 | RETVAL = li->binfile; |
551 | RETVAL = li->binfile; |
592 | OUTPUT: |
552 | OUTPUT: |
593 | RETVAL |
553 | RETVAL |
594 | |
554 | |
595 | # functions accessing internal data(!) |
555 | # methods accessing internal data(!) |
596 | |
556 | |
597 | void |
557 | void |
598 | parts(li) |
558 | parts (li) |
599 | uulist *li |
559 | uulist *li |
600 | PPCODE: |
560 | PPCODE: |
601 | { |
561 | { |
602 | struct _uufile *p = li->thisfile; |
562 | struct _uufile *p = li->thisfile; |
603 | |
563 | |
604 | while (p) |
564 | while (p) |
605 | { |
565 | { |
606 | HV *pi = newHV (); |
566 | HV *pi = newHV (); |
607 | |
567 | |
608 | hv_store (pi, "partno" , 6, newSViv (p->partno) , 0); |
568 | hv_store (pi, "partno" , 6, newSViv (p->partno) , 0); |
609 | |
|
|
610 | if (p->filename) |
|
|
611 | hv_store (pi, "filename", 8, newSVpv (p->filename, 0) , 0); |
569 | if (p->filename ) hv_store (pi, "filename", 8, newSVpv (p->filename, 0) , 0); |
612 | if(p->subfname) |
|
|
613 | hv_store (pi, "subfname", 8, newSVpv (p->subfname, 0) , 0); |
570 | if (p->subfname ) hv_store (pi, "subfname", 8, newSVpv (p->subfname, 0) , 0); |
614 | if(p->mimeid) |
571 | if (p->mimeid ) hv_store (pi, "mimeid" , 6, newSVpv (p->mimeid , 0) , 0); |
615 | hv_store (pi, "mimeid" , 6, newSVpv (p->mimeid , 0) , 0); |
|
|
616 | if(p->mimetype) |
|
|
617 | hv_store (pi, "mimetype", 8, newSVpv (p->mimetype, 0) , 0); |
572 | if (p->mimetype ) hv_store (pi, "mimetype", 8, newSVpv (p->mimetype, 0) , 0); |
618 | if (p->data->subject) |
|
|
619 | hv_store (pi, "subject" , 7, newSVpv (p->data->subject,0), 0); |
573 | if (p->data->subject) hv_store (pi, "subject" , 7, newSVpv (p->data->subject,0), 0); |
620 | if (p->data->origin) |
574 | if (p->data->origin ) hv_store (pi, "origin" , 6, newSVpv (p->data->origin ,0), 0); |
621 | hv_store (pi, "origin" , 6, newSVpv (p->data->origin ,0), 0); |
575 | if (p->data->sfname ) hv_store (pi, "sfname" , 6, newSVpv (p->data->sfname ,0), 0); |
622 | if (p->data->sfname) |
|
|
623 | hv_store (pi, "sfname" , 6, newSVpv (p->data->sfname ,0), 0); |
|
|
624 | |
576 | |
625 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)pi))); |
577 | XPUSHs (sv_2mortal (newRV_noinc ((SV *)pi))); |
626 | |
578 | |
627 | p = p->NEXT; |
579 | p = p->NEXT; |
628 | } |
|
|
629 | } |
580 | } |
|
|
581 | } |
630 | |
582 | |
631 | BOOT: |
583 | BOOT: |
|
|
584 | { |
|
|
585 | HV *stash = GvSTASH (CvGV (cv)); |
|
|
586 | |
|
|
587 | static const struct { |
|
|
588 | const char *name; |
|
|
589 | IV iv; |
|
|
590 | } *civ, const_iv[] = { |
|
|
591 | # define const_iv(name, value) { # name, (IV) value }, |
|
|
592 | const_iv (ACT_COPYING , UUACT_COPYING) |
|
|
593 | const_iv (ACT_DECODING , UUACT_DECODING) |
|
|
594 | const_iv (ACT_ENCODING , UUACT_ENCODING) |
|
|
595 | const_iv (ACT_IDLE , UUACT_IDLE) |
|
|
596 | const_iv (ACT_SCANNING , UUACT_SCANNING) |
|
|
597 | const_iv (FILE_DECODED , UUFILE_DECODED) |
|
|
598 | const_iv (FILE_ERROR , UUFILE_ERROR) |
|
|
599 | const_iv (FILE_MISPART , UUFILE_MISPART) |
|
|
600 | const_iv (FILE_NOBEGIN , UUFILE_NOBEGIN) |
|
|
601 | const_iv (FILE_NODATA , UUFILE_NODATA) |
|
|
602 | const_iv (FILE_NOEND , UUFILE_NOEND) |
|
|
603 | const_iv (FILE_OK , UUFILE_OK) |
|
|
604 | const_iv (FILE_READ , UUFILE_READ) |
|
|
605 | const_iv (FILE_TMPFILE , UUFILE_TMPFILE) |
|
|
606 | const_iv (MSG_ERROR , UUMSG_ERROR) |
|
|
607 | const_iv (MSG_FATAL , UUMSG_FATAL) |
|
|
608 | const_iv (MSG_MESSAGE , UUMSG_MESSAGE) |
|
|
609 | const_iv (MSG_NOTE , UUMSG_NOTE) |
|
|
610 | const_iv (MSG_PANIC , UUMSG_PANIC) |
|
|
611 | const_iv (MSG_WARNING , UUMSG_WARNING) |
|
|
612 | const_iv (OPT_VERSION , UUOPT_VERSION) |
|
|
613 | const_iv (OPT_FAST , UUOPT_FAST) |
|
|
614 | const_iv (OPT_DUMBNESS , UUOPT_DUMBNESS) |
|
|
615 | const_iv (OPT_BRACKPOL , UUOPT_BRACKPOL) |
|
|
616 | const_iv (OPT_VERBOSE , UUOPT_VERBOSE) |
|
|
617 | const_iv (OPT_DESPERATE, UUOPT_DESPERATE) |
|
|
618 | const_iv (OPT_IGNREPLY , UUOPT_IGNREPLY) |
|
|
619 | const_iv (OPT_OVERWRITE, UUOPT_OVERWRITE) |
|
|
620 | const_iv (OPT_SAVEPATH , UUOPT_SAVEPATH) |
|
|
621 | const_iv (OPT_IGNMODE , UUOPT_IGNMODE) |
|
|
622 | const_iv (OPT_DEBUG , UUOPT_DEBUG) |
|
|
623 | const_iv (OPT_ERRNO , UUOPT_ERRNO) |
|
|
624 | const_iv (OPT_PROGRESS , UUOPT_PROGRESS) |
|
|
625 | const_iv (OPT_USETEXT , UUOPT_USETEXT) |
|
|
626 | const_iv (OPT_PREAMB , UUOPT_PREAMB) |
|
|
627 | const_iv (OPT_TINYB64 , UUOPT_TINYB64) |
|
|
628 | const_iv (OPT_ENCEXT , UUOPT_ENCEXT) |
|
|
629 | const_iv (OPT_REMOVE , UUOPT_REMOVE) |
|
|
630 | const_iv (OPT_MOREMIME , UUOPT_MOREMIME) |
|
|
631 | const_iv (OPT_DOTDOT , UUOPT_DOTDOT) |
|
|
632 | const_iv (OPT_RBUF , UUOPT_RBUF) |
|
|
633 | const_iv (OPT_WBUF , UUOPT_WBUF) |
|
|
634 | const_iv (OPT_AUTOCHECK, UUOPT_AUTOCHECK) |
|
|
635 | const_iv (RET_CANCEL , UURET_CANCEL) |
|
|
636 | const_iv (RET_CONT , UURET_CONT) |
|
|
637 | const_iv (RET_EXISTS , UURET_EXISTS) |
|
|
638 | const_iv (RET_ILLVAL , UURET_ILLVAL) |
|
|
639 | const_iv (RET_IOERR , UURET_IOERR) |
|
|
640 | const_iv (RET_NODATA , UURET_NODATA) |
|
|
641 | const_iv (RET_NOEND , UURET_NOEND) |
|
|
642 | const_iv (RET_NOMEM , UURET_NOMEM) |
|
|
643 | const_iv (RET_OK , UURET_OK) |
|
|
644 | const_iv (RET_UNSUP , UURET_UNSUP) |
|
|
645 | const_iv (B64_ENCODED , B64ENCODED) |
|
|
646 | const_iv (BH_ENCODED , BH_ENCODED) |
|
|
647 | const_iv (PT_ENCODED , PT_ENCODED) |
|
|
648 | const_iv (QP_ENCODED , QP_ENCODED) |
|
|
649 | const_iv (UU_ENCODED , UU_ENCODED) |
|
|
650 | const_iv (XX_ENCODED , XX_ENCODED) |
|
|
651 | const_iv (YENC_ENCODED , YENC_ENCODED) |
|
|
652 | }; |
|
|
653 | |
|
|
654 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
|
|
655 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
|
|
656 | |
632 | uu_msg_sv = newSVsv(&PL_sv_undef); |
657 | uu_msg_sv = newSVsv (&PL_sv_undef); |
633 | uu_busy_sv = newSVsv(&PL_sv_undef); |
658 | uu_busy_sv = newSVsv (&PL_sv_undef); |
634 | uu_file_sv = newSVsv(&PL_sv_undef); |
659 | uu_file_sv = newSVsv (&PL_sv_undef); |
635 | uu_fnamefilter_sv = newSVsv(&PL_sv_undef); |
660 | uu_fnamefilter_sv = newSVsv (&PL_sv_undef); |
636 | uu_filename_sv = newSVsv(&PL_sv_undef); |
661 | uu_filename_sv = newSVsv (&PL_sv_undef); |
637 | |
662 | |
|
|
663 | initialise (); |
|
|
664 | } |
|
|
665 | |