next up previous
Next: The File List Up: Callback Functions Previous: File Callback


Filename Filter

For portability reasons, the library does not make any assumptions of the legality of certain filenames. It will pick up a ``garbage'' file name from the encoded file and happily use it if not told otherwise. For example, on DOS systems many filenames must be truncated in order to be valid.

If a ``Filename Filter'' is installed, the library will pass each potential filename to the filter and then use the filename that the filter function returns. The filter also has to remove all directory information from the filename - the library itself does not know about directories at all.

The filter function receives the potential filename as string and must return a pointer to a string with the corrected filename. It may either return a pointer to some position in the original string or a pointer to some static area, but it should not modify the source string.

Two examples of filename filters can be found among the UUDeview distribution as uufnflt.c. The DOS filter function disposes directory information, uses only the first 8 characters of the base filename and the first three characters after the last '.' (since a filename might have two extensions). Also, space characters are replaced by underscores. The Unix filter just returns a pointer to the filename part of the name (without directory information).

The ``garbage'' filename mentioned above was just for the sake of argument. It is generally safe to assume that the input filename is not too weird; after all, it is a filename valid on some system. Still, the user should always be granted the possibility of renaming a file before decoding it, to allow decoding of files with insane filenames.


next up previous
Next: The File List Up: Callback Functions Previous: File Callback
2005-01-26