Bodo Moeller wrote:
>
> "Wade L. Scholine" <[EMAIL PROTECTED]>:
>
> > An alternative not mentioned is to make the callback type have a
> > variable number of arguments, like
> >
> > typedef int (*password_cb(char *buf, int size, int rwflag, ...));
> >
> > where the arg list is terminated with a null pointer constant or something.
> >
> > This would still break existing code, but which would allow for more
> > or less arbitrary parameters to callbacks. [...]
>
> Actually this version, while looking reasonably at first sight, does
> not work at all: The library cannot know with parameter list should be
> used when calling the callback functions. After all, the extra
> parameters are not for data that the library thinks the callback
> should know about, but for data about which the library knows nothing,
> but which the application wants to "tunnel" to its callback functions.
I presume the intention was that ... would either be a void *, or
nothing. In which case, passing the extra parameter is strictly
incorrect (you shouldn't access parameters that weren't actually passed)
but likely to be harmless. However, I prefer the alternative, so I'm
only saying this for correctness.
> A void* parameter seems to be the way to go; and with the extra
> #defines for the then-historical three-parameter form, it won't hurt
> existing C programs too much. To achieve compatibility on other than
> C sourcecode level, we can add function stubs using the old function
> names, e.g. as follows (with the implementation in a new, separate
> file, so that it won't be linked into applications that use the
> macros):
>
> /* include/openssl/pem.h */
>
> #undef PEM_read_PrivateKey
> EVP_PKEY *PEM_read_PrivateKey(FILE *fp,EVP_PKEY **x, pem_password_cb *);
> EVP_PKEY *PEM_read_PrivateKey_ex(FILE *fp,EVP_PKEY **x,pem_password_cb*,void*);
> #define PEM_read_PrivateKey(fp,pkeyp,callback) \
> PEM_read_PrivateKey_ex(fp,pkeyp,callback,NULL)
Go for it.
> /* crypto/pem/pem_stubs.c */
>
> #include <openssl/pem.h>
>
> #undef PEM_read_PrivateKey
> EVP_PKEY *PEM_read_PrivateKey(FILE *fp,EVP_PKEY **x, pem_password_cb *cb)
> {
> return PEM_read_PrivateKey_ex(fp, x, cb, NULL);
> }
Not sure there's much point in this, but if you want...
Cheers,
Ben.
--
http://www.apache-ssl.org/ben.html
"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
- Indira Gandhi
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]