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