… | |
… | |
4 | |
4 | |
5 | require Exporter; |
5 | require Exporter; |
6 | require DynaLoader; |
6 | require DynaLoader; |
7 | use AutoLoader; |
7 | use AutoLoader; |
8 | |
8 | |
9 | $VERSION = 0.111; |
9 | $VERSION = 0.211; |
10 | |
10 | |
11 | @ISA = qw(Exporter DynaLoader); |
11 | @ISA = qw(Exporter DynaLoader); |
12 | |
12 | |
13 | @_consts = qw( |
13 | @_consts = qw( |
14 | ACT_COPYING ACT_DECODING ACT_ENCODING ACT_IDLE ACT_SCANNING |
14 | ACT_COPYING ACT_DECODING ACT_ENCODING ACT_IDLE ACT_SCANNING |
… | |
… | |
19 | MSG_ERROR MSG_FATAL MSG_MESSAGE MSG_NOTE MSG_PANIC MSG_WARNING |
19 | MSG_ERROR MSG_FATAL MSG_MESSAGE MSG_NOTE MSG_PANIC MSG_WARNING |
20 | |
20 | |
21 | OPT_BRACKPOL OPT_DEBUG OPT_DESPERATE OPT_DUMBNESS OPT_ENCEXT |
21 | OPT_BRACKPOL OPT_DEBUG OPT_DESPERATE OPT_DUMBNESS OPT_ENCEXT |
22 | OPT_ERRNO OPT_FAST OPT_IGNMODE OPT_IGNREPLY OPT_OVERWRITE OPT_PREAMB |
22 | OPT_ERRNO OPT_FAST OPT_IGNMODE OPT_IGNREPLY OPT_OVERWRITE OPT_PREAMB |
23 | OPT_PROGRESS OPT_SAVEPATH OPT_TINYB64 OPT_USETEXT OPT_VERBOSE |
23 | OPT_PROGRESS OPT_SAVEPATH OPT_TINYB64 OPT_USETEXT OPT_VERBOSE |
24 | OPT_VERSION |
24 | OPT_VERSION OPT_REMOVE OPT_MOREMIME OPT_DOTDOT |
25 | |
25 | |
26 | RET_CANCEL RET_CONT RET_EXISTS RET_ILLVAL RET_IOERR RET_NODATA |
26 | RET_CANCEL RET_CONT RET_EXISTS RET_ILLVAL RET_IOERR RET_NODATA |
27 | RET_NOEND RET_NOMEM RET_OK RET_UNSUP |
27 | RET_NOEND RET_NOMEM RET_OK RET_UNSUP |
28 | |
28 | |
29 | B64ENCODED BH_ENCODED PT_ENCODED QP_ENCODED |
29 | B64ENCODED BH_ENCODED PT_ENCODED QP_ENCODED |
30 | XX_ENCODED UU_ENCODED |
30 | XX_ENCODED UU_ENCODED YENC_ENCODED |
31 | ); |
31 | ); |
32 | |
32 | |
33 | @_funcs = qw( |
33 | @_funcs = qw( |
34 | Initialize CleanUp GetOption SetOption strerror |
34 | Initialize CleanUp GetOption SetOption strerror SetMsgCallback |
35 | SetMsgCallback SetBusyCallback SetFileCallback |
35 | SetBusyCallback SetFileCallback SetFNameFilter SetFileNameCallback |
36 | SetFNameFilter FNameFilter LoadFile GetFileListItem |
36 | FNameFilter LoadFile GetFileListItem RenameFile DecodeToTemp |
37 | RenameFile DecodeToTemp RemoveTemp DecodeFile |
37 | RemoveTemp DecodeFile InfoFile Smerge QuickDecode EncodeMulti |
38 | InfoFile Smerge QuickDecode EncodeMulti EncodePartial |
38 | EncodePartial EncodeToStream EncodeToFile E_PrepSingle |
39 | EncodeToStream EncodeToFile E_PrepSingle E_PrepPartial |
39 | E_PrepPartial |
40 | |
40 | |
41 | straction strencoding strmsglevel |
41 | straction strencoding strmsglevel |
42 | ); |
42 | ); |
43 | |
43 | |
44 | @EXPORT = @_consts; |
44 | @EXPORT = @_consts; |
… | |
… | |
62 | return 'copying' if $_[0] == &ACT_COPYING; |
62 | return 'copying' if $_[0] == &ACT_COPYING; |
63 | return 'decoding' if $_[0] == &ACT_DECODING; |
63 | return 'decoding' if $_[0] == &ACT_DECODING; |
64 | return 'encoding' if $_[0] == &ACT_ENCODING; |
64 | return 'encoding' if $_[0] == &ACT_ENCODING; |
65 | return 'idle' if $_[0] == &ACT_IDLE; |
65 | return 'idle' if $_[0] == &ACT_IDLE; |
66 | return 'scanning' if $_[0] == &ACT_SCANNING; |
66 | return 'scanning' if $_[0] == &ACT_SCANNING; |
67 | (); |
67 | 'unknown'; |
68 | } |
68 | } |
69 | |
69 | |
70 | # encoding type -> string mapping |
70 | # encoding type -> string mapping |
71 | sub strencoding($) { |
71 | sub strencoding($) { |
|
|
72 | return 'uuencode' if $_[0] == &UU_ENCODED; |
72 | return 'base64' if $_[0] == &B64ENCODED; |
73 | return 'base64' if $_[0] == &B64ENCODED; |
|
|
74 | return 'yenc' if $_[0] == &YENC_ENCODED; |
73 | return 'binhex' if $_[0] == &BH_ENCODED; |
75 | return 'binhex' if $_[0] == &BH_ENCODED; |
74 | return 'plaintext' if $_[0] == &PT_ENCODED; |
76 | return 'plaintext' if $_[0] == &PT_ENCODED; |
75 | return 'quoted-printable' if $_[0] == &QP_ENCODED; |
77 | return 'quoted-printable' if $_[0] == &QP_ENCODED; |
76 | return 'xxencode' if $_[0] == &XX_ENCODED; |
78 | return 'xxencode' if $_[0] == &XX_ENCODED; |
77 | return 'uuencode' if $_[0] == &UU_ENCODED; |
79 | 'unknown'; |
78 | (); |
|
|
79 | } |
80 | } |
80 | |
81 | |
81 | sub strmsglevel($) { |
82 | sub strmsglevel($) { |
82 | return 'message' if $_[0] == &MSG_MESSAGE; |
83 | return 'message' if $_[0] == &MSG_MESSAGE; |
83 | return 'note' if $_[0] == &MSG_NOTE; |
84 | return 'note' if $_[0] == &MSG_NOTE; |
84 | return 'warning' if $_[0] == &MSG_WARNING; |
85 | return 'warning' if $_[0] == &MSG_WARNING; |
85 | return 'error' if $_[0] == &MSG_ERROR; |
86 | return 'error' if $_[0] == &MSG_ERROR; |
86 | return 'panic' if $_[0] == &MSG_PANIC; |
87 | return 'panic' if $_[0] == &MSG_PANIC; |
87 | return 'fatal' if $_[0] == &MSG_FATAL; |
88 | return 'fatal' if $_[0] == &MSG_FATAL; |
88 | (); |
89 | 'unknown'; |
89 | } |
90 | } |
90 | |
91 | |
91 | 1; |
92 | 1; |
92 | __END__ |
93 | __END__ |
93 | |
94 | |
… | |
… | |
216 | |
217 | |
217 | OPT_BRACKPOL OPT_DEBUG OPT_DESPERATE OPT_DUMBNESS |
218 | OPT_BRACKPOL OPT_DEBUG OPT_DESPERATE OPT_DUMBNESS |
218 | OPT_ENCEXT OPT_ERRNO OPT_FAST OPT_IGNMODE |
219 | OPT_ENCEXT OPT_ERRNO OPT_FAST OPT_IGNMODE |
219 | OPT_IGNREPLY OPT_OVERWRITE OPT_PREAMB OPT_PROGRESS |
220 | OPT_IGNREPLY OPT_OVERWRITE OPT_PREAMB OPT_PROGRESS |
220 | OPT_SAVEPATH OPT_TINYB64 OPT_USETEXT OPT_VERBOSE |
221 | OPT_SAVEPATH OPT_TINYB64 OPT_USETEXT OPT_VERBOSE |
221 | OPT_VERSION |
222 | OPT_VERSION OPT_REMOVE OPT_MOREMIME |
222 | |
223 | |
223 | Error/Result codes: |
224 | Error/Result codes: |
224 | |
225 | |
225 | RET_CANCEL RET_CONT RET_EXISTS RET_ILLVAL RET_IOERR |
226 | RET_CANCEL RET_CONT RET_EXISTS RET_ILLVAL RET_IOERR |
226 | RET_NODATA RET_NOEND RET_NOMEM RET_OK RET_UNSUP |
227 | RET_NODATA RET_NOEND RET_NOMEM RET_OK RET_UNSUP |
227 | |
228 | |
228 | Encoding types: |
229 | Encoding types: |
229 | |
230 | |
230 | B64ENCODED BH_ENCODED PT_ENCODED |
231 | B64ENCODED BH_ENCODED PT_ENCODED QP_ENCODED XX_ENCODED |
231 | QP_ENCODED XX_ENCODED UU_ENCODED |
232 | UU_ENCODED YENC_ENCODED |
232 | |
233 | |
233 | =head1 Exported functions |
234 | =head1 Exported functions |
234 | |
235 | |
235 | Initializing and cleanup (Initialize is automatically called when the |
236 | Initializing and cleanup (Initialize is automatically called when the |
236 | module is loaded and allocates quite a bit of memory. CleanUp releases |
237 | module is loaded and allocates quite a bit of memory. CleanUp releases |
… | |
… | |
298 | int EncodeToStream () ; |
299 | int EncodeToStream () ; |
299 | int EncodeToFile () ; |
300 | int EncodeToFile () ; |
300 | int E_PrepSingle () ; |
301 | int E_PrepSingle () ; |
301 | int E_PrepPartial () ; |
302 | int E_PrepPartial () ; |
302 | |
303 | |
|
|
304 | =head2 EXTENSION FUNCTIONS |
|
|
305 | |
|
|
306 | Functions found in this module but not documented in the uulib documentation: |
|
|
307 | |
|
|
308 | =over 4 |
|
|
309 | |
|
|
310 | =item SetFileNameCallback $cb |
|
|
311 | |
|
|
312 | Sets (or queries) the FileNameCallback, which is called whenever the |
|
|
313 | decoding library can't find a filename and wants to extract a filename |
|
|
314 | from the subject line of a posting. The callback will be called with |
|
|
315 | two arguments, the subject line and the current candidate for the |
|
|
316 | filename. The latter argument can be C<undef>, which means that no |
|
|
317 | filename could be found (and likely no one exists, so it is safe to also |
|
|
318 | return C<undef> in this case). If it doesn't return anything (not even |
|
|
319 | C<undef>!), then nothing happens, so this is a no-op callback: |
|
|
320 | |
|
|
321 | sub cb { |
|
|
322 | return (); |
|
|
323 | } |
|
|
324 | |
|
|
325 | If it returns C<undef>, then this indicates that no filename could be |
|
|
326 | found. In all other cases, the return value is taken to be the filename. |
|
|
327 | |
|
|
328 | This is a slightly more useful callback: |
|
|
329 | |
|
|
330 | sub cb { |
|
|
331 | return unless $_[1]; # skip "Re:"-plies et al. |
|
|
332 | my ($subject, $filename) = @_; |
|
|
333 | # if we find some *.rar, take it |
|
|
334 | return $1 if $subject =~ /(\w+\.rar)/; |
|
|
335 | # otherwise just pass what we have |
|
|
336 | return (); |
|
|
337 | } |
|
|
338 | |
|
|
339 | =back |
|
|
340 | |
303 | =head1 AUTHOR |
341 | =head1 AUTHOR |
304 | |
342 | |
305 | Marc Lehmann <pcg@goof.com>, the original uulib library was written by |
343 | Marc Lehmann <pcg@goof.com>, the original uulib library was written by |
306 | Frank Pilhofer <fp@informatik.uni-frankfurt.de>. |
344 | Frank Pilhofer <fp@informatik.uni-frankfurt.de>. |
307 | |
345 | |