Yesterday I wrote the type-safe stack stuff I've been threatening. In
order to test them, I had to use them, of course. This resulted in a
vast patch. It also spreads into type-safe ASN1 sets and other good
stuff. Rather than spam you all with the patch, which you will then
ignore, I'm going to commit it (unless I hear major squawks soon). This
is because it touches loads of files so its going to be a bugger to
maintain if I don't.

If everyone thinks it is a terrible idea I'm prepared to undo it. I'll
fight first, though, coz I think it is a great idea :-)

For those who don't want to read code, the essence is this:

STACK *thing; /* stack of X509s */

becomes:

STACK_OF(X509) *thing;

and:

thing=sk_new_null();
sk_push(thing,(char *)someval);
X509 *val=(X509 *)sk_value(thing,23);

becomes:

thing=sk_X509_new_null();
sk_X509_push(thing,someval);
X509 *val=sk_X509_value(thing,32);

and is implemented using X509 * and STACK_OF(X509) * rather than void *
so it is typechecked.

All function definitions and implementations are done by macros, so
adding a new stack type is as simple as:

DECLARE_STACK_OF(X509)

in some header, and:

IMPLEMENT_STACK_OF(X509)

in some C file. I'm a long way from converting everything to type-safe
stacks, but I'm getting there. I'll stop for a while now, though, so I
don't have to back out too much. I've done everything in ssl.h.

Oh, and the _really_ cool part is that old code will work, but it will
generate warnings...

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]

Reply via email to