Small configuration file parser

I’ve recently taken the Kerberos V5 profile library, which I had originally written ten years ago (!!!) to parse /etc/krb5.conf, and taken the version from krb5 1.4.2, and simplified the heck out of it (took out locking for multi-threading support, the ability to modify config files from the program, etc.) and boiled it into a single C source file, so that e2fsck could have its own fast, simple, and lightweight configuration file. The end result is here, and compiles down to 6.5k of x86 object code. I could probably get it to be even smaller, but still, that’s not bad.

After finishing, I wondered what other choices I might have used. I haven’t done a formal release yet, so it’s still possible for me to try something else, if there is some other small, robust, configuration file parser that would be better. Since e2fsck needs to fit on potentially small root filesystems (or other small boot-time environments), we can rule out libxml2 — one megabyte of compiled code can’t be all bad — but that kind of bloatware is just scary. The smallest XML parser I could find is ezxml, which is still over 3 times the size of my win.ini parser, and which, like most XML parsers, has an API which is not terribly convenient to use.

It is amazing to me how there seems to be so little interest in small, compact, elegant pieces of code that can be reused. The trend these days seems to be towards large pieces of bloatware, and it doesn’t matter whether programs are written in C, C++, Java, or Perl. Sigh.