paths

David Relson relson at osagesoftware.com
Mon Mar 28 15:02:12 CEST 2005


Matthias,

As you know, bogofilter filenaming is a mess.  FWIW, I've divided the
mess into parameter, manipulation, and usage sections: 

Parameters:  Some options have a directory name as the parameter, while
others have a wordlist name, while others can work with either.  Also
there are ordering considerations.  For example the wordlist name might
be specified before the bogofilter directory.

Manipulation: There are a variety of functions for working with
filenames.  They're in several different files, and they're called from
many places.  Examples include get_file_from_path(),
get_directory_from_path(), tildeexpand(), etc.

Usage:  The functions that use filenames have varying needs.  Some need
just the directory name while others need the full path to the file.
As examples we have:

void *ds_init(const char *directory, const char *filename)
void *dbe_init(bfdir *directory, bffile *file)

I've been thinking about this and have an idea.  First have a structure
containing dirname, filename, and path (dirname+filename) components.
Second put all the code for setting and manipulating these values in
one file, for example paths.c.  The structure might be:

typedef struct bf_path {
   char * dirname;   /* directory only   */
   char * filename;  /* filename only    *
   char * path;      /* dirname/filename */
} bf_path;

Additional flags like isdir and isfile _may_ be useful.

Option processing would create these structure as they're needed.  At
the end of options, bogohome would be determined and all the structures
would be processed to split the given name into dirname and filename
components, perform tilde expansions, fill in bogohome, etc.

The functions that presently take dirname & filename parameters would
need only a bf_path parameter.  Also, with all bf_path variables set
(at the end of option processing), there should be no need for
build_path(), or similar calls, in (for example) the datastore
functions.

I'm excited about this idea, though I'll be at work for the day and
won't be able to do any coding.

Regards,

David

_______________________________________________
Bogofilter-dev mailing list
Bogofilter-dev at bogofilter.org
http://www.bogofilter.org/mailman/listinfo/bogofilter-dev



More information about the bogofilter-dev mailing list