dma
dma copied to clipboard
Rewrite of configuration parsing
Hello,
I've rewritten the configuration parsing to make use of simple lex/yacc parsers just as for the aliases file. Furthermore I've added reasonable data hiding so that the program uses a defined interface for accessing the config data.
Advantages:
- Modular design, the internals of the config settings may be changed without affecting the rest of the program
- Easy adding of new configuration settings
- Allows sanity checks of the parsed values through a check function for each configuration setting (at the moment implemented for the "FINGERPRINT" setting (this was already part of the code)). This could be enhanced to check for correct path names, read permissions, unreachable smarthosts, etc right when parsing the file.
- Reduce string manipulation
Implementation:
- The config settings are implemented using a singly-linked list, which should be fine for the current number of configuration settings. Should that number become considerably higher anytime in the future, the list can be changed to more sophisticated data structures, all while keeping the outside API.
I've kept the changes in the core code to a bare minimum, just made changes to make use of the "public" interface of the configuration parser.
If you like it, you're welcome to merge it. It's passed my tests, if you spot any errors though, I'll be happy to fix them.
PS: I've had to change the *BSD Makefile to be able to compile multiple lex/yacc files. It's not going to win any beauty-contest, but it's working on FreeBSD and Dragonfly BSD. Nonetheless any custom Makefiles for the *BSD ports-system would probably need to be changed as well.
What's the status of this PR? Did we address all reviews?
I'm pretty sure, I've covered all of the points of the review. If I missed something, let me know.