Subject: How to add a support function to libc
To: None <firstname.lastname@example.org>
From: Allen Briggs <email@example.com>
Date: 10/19/2000 12:01:44
This is a naming and namespace question...
I'd like to add a function to libc that will be used in some calls
to printf() functions. Such as:
printf(newfunction(user_format, "%s %ld %d"),
string_arg, long_arg, int_arg);
This function will be used in libraries and programs to ensure that
the user_format is compatible with the supplied arguments. The
assumption being that this would be used when user_format comes from
some untrusted location--perhaps a message catalog.
I think the function should live in libc/stdio, next to the printf(3)
family, but I'm not sure where it should be prototyped, or how it
should be named to avoid namespace collisions (I'm not clear on which
namespaces are reserved for whom).
The working name for the function is __fmtcheck(), prototyped as
const char *__fmtcheck __P((const char *, const char *))
So what's the correct approach? My naive approach is to just drop
the prototype in the "Routines that are purely local" section of
stdio.h (with fgetln, fpurge, et al.). Instruction in a less
naive approach welcome.