ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Convert-UUlib/UUlib.pm
(Generate patch)

Comparing Convert-UUlib/UUlib.pm (file contents):
Revision 1.12 by root, Sun Oct 13 13:51:00 2002 UTC vs.
Revision 1.13 by root, Tue Oct 15 23:20:29 2002 UTC

2 2
3use Carp; 3use Carp;
4 4
5require Exporter; 5require Exporter;
6require DynaLoader; 6require DynaLoader;
7use AutoLoader;
8 7
9$VERSION = 0.3; 8$VERSION = 0.31;
10 9
11@ISA = qw(Exporter DynaLoader); 10@ISA = qw(Exporter DynaLoader);
12 11
13@_consts = qw( 12@_consts = qw(
14 ACT_COPYING ACT_DECODING ACT_ENCODING ACT_IDLE ACT_SCANNING 13 ACT_COPYING ACT_DECODING ACT_ENCODING ACT_IDLE ACT_SCANNING
99=head1 SYNOPSIS 98=head1 SYNOPSIS
100 99
101 use Convert::UUlib ':all'; 100 use Convert::UUlib ':all';
102 101
103 # read all the files named on the commandline and decode them 102 # read all the files named on the commandline and decode them
103 # into the CURRENT directory. See below for a longer example.
104 LoadFile($_) for @ARGV; 104 LoadFile $_ for @ARGV;
105 for($i=0; $uu=GetFileListItem($i); $i++) { 105 for (my $i = 0; my $uu = GetFileListItem $i; $i++) {
106 $uu->decode if $uu->state & FILE_OK; 106 if ($uu->state & FILE_OK) {
107 $uu->decode;
108 print $uu->filename, "\n";
109 }
107 } 110 }
108 111
109=head1 DESCRIPTION 112=head1 DESCRIPTION
110 113
111Read the file doc/library.pdf from the distribution for in-depth 114Read the file doc/library.pdf from the distribution for in-depth
171 174
172 This code is zero, i.e. "false": 175 This code is zero, i.e. "false":
173 176
174 UUFILE_READ Read in, but not further processed 177 UUFILE_READ Read in, but not further processed
175 178
176 The following state codes are ored together: 179 The following state codes are or'ed together:
177 180
178 FILE_MISPART Missing Part(s) detected 181 FILE_MISPART Missing Part(s) detected
179 FILE_NOBEGIN No 'begin' found 182 FILE_NOBEGIN No 'begin' found
180 FILE_NOEND No 'end' found 183 FILE_NOEND No 'end' found
181 FILE_NODATA File does not contain valid uudata 184 FILE_NODATA File does not contain valid uudata
197=head1 EXPORTED FUNCTIONS 200=head1 EXPORTED FUNCTIONS
198 201
199=head2 Initializing and cleanup 202=head2 Initializing and cleanup
200 203
201Initialize is automatically called when the module is loaded and allocates 204Initialize is automatically called when the module is loaded and allocates
202quite a bit of memory. CleanUp releases that again. 205quite a small amount of memory for todays machines ;) CleanUp releases that
206again.
203 207
204 Initialize; # not normally necessary 208=over 4
209
210=item Initialize
211
212Not normally necessary, (re-)initializes the library.
213
214=item CleanUp
215
205 CleanUp; # could be called at the end to release memory 216Not normally necessary, could be called at the end to release memory
217before starting a new decoding round.
218
219=back
206 220
207=head2 Setting and querying options 221=head2 Setting and querying options
208 222
223=over 4
224
209 $option = GetOption OPT_xxx; 225=item $option = GetOption OPT_xxx
226
210 SetOption OPT_xxx, opt-value; 227=item SetOption OPT_xxx, opt-value
228
229=back
230
231See the C<OPT_xxx> constants above to see which options exist.
211 232
212=head2 Setting various callbacks 233=head2 Setting various callbacks
213 234
235=over 4
236
214 SetMsgCallback [callback-function]; 237=item SetMsgCallback [callback-function]
238
215 SetBusyCallback [callback-function]; 239=item SetBusyCallback [callback-function]
240
216 SetFileCallback [callback-function]; 241=item SetFileCallback [callback-function]
242
217 SetFNameFilter [callback-function]; 243=item SetFNameFilter [callback-function]
244
245=back
218 246
219=head2 Call the currently selected FNameFilter 247=head2 Call the currently selected FNameFilter
220 248
249=over 4
250
221 $file = FNameFilter $file; 251=item $file = FNameFilter $file
252
253=back
222 254
223=head2 Loading sourcefiles, optionally fuzzy merge and start decoding 255=head2 Loading sourcefiles, optionally fuzzy merge and start decoding
224 256
257=over 4
258
225 ($retval, $count) = LoadFile $fname, [$id, [$delflag]]; 259=item ($retval, $count) = LoadFile $fname, [$id, [$delflag]]
260
261Load the given file and scan it for encoded contents. Optionally tag it
262with the given id, and if C<$delflag> is true, delete the file after it is
263no longer necessary.
264
226 $retval = Smerge $pass; 265=item $retval = Smerge $pass
266
267If you are desperate, try to call C<Smerge> with increasing C<$pass>
268values, beginning at C<0>, to try to merge parts that usually would not
269have been merged.
270
271Most probably this will result in garbled files, so never do this by
272default.
273
227 $item = GetFileListItem $item_number; 274=item $item = GetFileListItem $item_number
228 275
229=head2 The procedural interface is undocumented, use the following methods instead 276Return the C<$item> structure for the C<$item_number>'th found file, or
277C<undef> of no file with that number exists.
230 278
279The first file has number C<0>, and the series has no holes, so you can
280iterate over all files by starting with zero and incrementing until you
281hit C<undef>.
282
283=back
284
285=head2 Decoding files
286
287=over 4
288
231 $retval = $item->rename($newname); 289=item $retval = $item->rename($newname)
290
291Change the ondisk filename where the decoded file will be saved.
292
232 $retval = $item->decode_temp; 293=item $retval = $item->decode_temp
294
295Decode the file into a temporary location, use C<< $item->infile >> to
296retrieve the temporary filename.
297
233 $retval = $item->remove_temp; 298=item $retval = $item->remove_temp
299
300Remove the temporarily decoded file again.
301
234 $retval = $item->decode([$target_path]); 302=item $retval = $item->decode([$target_path])
303
304Decode the file to it's destination, or the given target path.
305
235 $retval = $item->info(callback-function); 306=item $retval = $item->info(callback-function)
307
308=back
236 309
237=head2 Querying (and setting) item attributes 310=head2 Querying (and setting) item attributes
238 311
312=over 4
313
239 $state = $item->state; 314=item $state = $item->state
315
240 $mode = $item->mode([newmode]); 316=item $mode = $item->mode([newmode])
317
241 $uudet = $item->uudet; 318=item $uudet = $item->uudet
319
242 $size = $item->size; 320=item $size = $item->size
321
243 $filename = $item->filename([newfilename}); 322=item $filename = $item->filename([newfilename})
323
244 $subfname = $item->subfname; 324=item $subfname = $item->subfname
325
245 $mimeid = $item->mimeid; 326=item $mimeid = $item->mimeid
327
246 $mimetype = $item->mimetype; 328=item $mimetype = $item->mimetype
329
247 $binfile = $item->binfile; 330=item $binfile = $item->binfile
248 331
249=head2 Totally undocumented but well tested ;) 332=back
250 333
334=head2 Information about source parts
335
336=over 4
337
251 $parts = $item->parts; 338=item $parts = $item->parts
339
340Return information about all parts (source files) used to decode the file
341as a list of hashrefs with the following structure:
342
343 {
344 partno => <integer describing the part number, starting with 1>,
345 # the following member sonly exist when they contain useful information
346 sfname => <local pathname of the file where this part is from>,
347 filename => <the ondisk filename of the decoded file>,
348 subfname => <used to cluster postings, possibly the posting filename>,
349 subject => <the subject of the posting/mail>,
350 origin => <the possible source (From) address>,
351 mimetype => <the possible mimetype of the decoded file>,
352 mimeid => <the id part of the Content-Type>,
353 }
354
355Usually you are interested mostly the C<sfname> and possibly the C<partno>
356and C<filename> members.
357
358=back
252 359
253=head2 Functions below not documented and not very well tested 360=head2 Functions below not documented and not very well tested
254 361
255 QuickDecode 362 QuickDecode
256 EncodeMulti 363 EncodeMulti

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines