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