snprintf
Russ Allbery
rra at stanford.edu
Sun Aug 27 00:45:54 UTC 2000
I'm working on adding an implementation of snprintf to the INN source
tree; it's just too useful for too much different stuff to keep trying to
do without it. After looking at a bunch of free snprintf implementations
available, I picked the version used in Mutt and available by itself from
<http://www.fiction.net/~blong/programs/>. Unlike many of the others
available, this one implements basic floating point (everything that INN
actually uses) and doesn't require libm. It's also in the public domain,
so there are no annoying license problems.
snprintf requires some configure support, since unfortunately there are
some platforms that have an implementation but an incorrect one.
According to C99
snprintf(NULL, 0, "%s", "abcd");
should return 4, the number of characters that would be printed if there
were space. The implementation in Solaris 2.6 returns -1 and the one in
glibc 2.0 returns 0, so we'll want to use our own implementation on those
platforms and others with similar problems.
I'm going to put lib/snprintf.c on a vendor branch similar to what I've
done with config.guess and config.sub so that we can easily merge in
further changes to the original source as they happen; I'm also not going
to reformat the source to match INN standards for similar reasons.
Once snprintf is in the tree, we can start using it where it makes sense
to; innd's logging and returning of errors to the remote peer is one of
the big spots that could use it.
--
Russ Allbery (rra at stanford.edu) <http://www.eyrie.org/~eagle/>
More information about the inn-workers
mailing list