Commit ef33b970 authored by Richard Levitte's avatar Richard Levitte
Browse files

Using checks of the existence of HEADER_{foo}_H in other header files

was a really bad idea.  For example, the following:

	#include <x509.h>
	#include <bio.h>
	#include <asn1.h>

would make sure that things like ASN1_UTCTIME_print() wasn't defined
unless you moved the inclusion of bio.h to above the inclusion of
x509.h.  The reason is that x509.h includes asn1.h, and the
declaration of ASN1_UTCTIME_print() depended on the definition of
HEADER_BIO_H.  That's what I call an obscure bug.

Instead, this change makes sure that whatever header files are needed
for the correct process of one header file are included automagically,
and that the definitions of, for example, BIO-related things are
dependent on the absence of the NO_{foo} macros.  This is also
consistent with the way parts of OpenSSL can be excluded at will.
parent 814ed26c
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -60,6 +60,9 @@
#define HEADER_ASN1_H

#include <time.h>
#ifndef NO_BIO
#include <openssl/bio.h>
#endif
#include <openssl/bn.h>
#include <openssl/stack.h>
#include <openssl/safestack.h>
@@ -695,7 +698,7 @@ int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d,
int		ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
int		ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);

#ifdef HEADER_BIO_H
#ifndef NO_BIO
int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
				BIT_STRING_BITNAME *tbl, int indent);
#endif
@@ -823,7 +826,7 @@ STACK * d2i_ASN1_SET(STACK **a, unsigned char **pp, long length,
			char *(*func)(), void (*free_func)(),
			int ex_tag, int ex_class);

#ifdef HEADER_BIO_H
#ifndef NO_BIO
int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a);
int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size);
int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a);
@@ -878,7 +881,7 @@ char *ASN1_d2i_fp(char *(*xnew)(),char *(*d2i)(),FILE *fp,unsigned char **x);
int ASN1_i2d_fp(int (*i2d)(),FILE *out,unsigned char *x);
#endif

#ifdef HEADER_BIO_H
#ifndef NO_BIO
char *ASN1_d2i_bio(char *(*xnew)(),char *(*d2i)(),BIO *bp,unsigned char **x);
int ASN1_i2d_bio(int (*i2d)(),BIO *out,unsigned char *x);
int ASN1_UTCTIME_print(BIO *fp,ASN1_UTCTIME *a);
+4 −1
Original line number Diff line number Diff line
@@ -63,6 +63,9 @@
#error DH is disabled.
#endif

#ifndef NO_BIO
#include <openssl/bio.h>
#endif
#include <openssl/bn.h>
#include <openssl/crypto.h>
	
@@ -169,7 +172,7 @@ int i2d_DHparams(DH *a,unsigned char **pp);
#ifndef NO_FP_API
int	DHparams_print_fp(FILE *fp, DH *x);
#endif
#ifdef HEADER_BIO_H
#ifndef NO_BIO
int	DHparams_print(BIO *bp, DH *x);
#else
int	DHparams_print(char *bp, DH *x);
+4 −1
Original line number Diff line number Diff line
@@ -69,6 +69,9 @@
#error DSA is disabled.
#endif

#ifndef NO_BIO
#include <openssl/bio.h>
#endif
#include <openssl/bn.h>
#include <openssl/crypto.h>
#ifndef NO_DH
@@ -188,7 +191,7 @@ int i2d_DSAPublicKey(DSA *a, unsigned char **pp);
int 	i2d_DSAPrivateKey(DSA *a, unsigned char **pp);
int	i2d_DSAparams(DSA *a,unsigned char **pp);

#ifdef HEADER_BIO_H
#ifndef NO_BIO
int	DSAparams_print(BIO *bp, DSA *x);
int	DSA_print(BIO *bp, DSA *x, int off);
#endif
+9 −2
Original line number Diff line number Diff line
@@ -64,6 +64,13 @@
#include <stdlib.h>
#endif

#ifndef NO_BIO
#include <openssl/bio.h>
#endif
#ifndef NO_LHASH
#include <openssl/lhash.h>
#endif

#ifdef	__cplusplus
extern "C" {
#endif
@@ -241,7 +248,7 @@ const char *ERR_reason_error_string(unsigned long e);
#ifndef NO_FP_API
void ERR_print_errors_fp(FILE *fp);
#endif
#ifdef HEADER_BIO_H
#ifndef NO_BIO
void ERR_print_errors(BIO *bp);
void ERR_add_error_data(int num, ...);
#endif
@@ -253,7 +260,7 @@ void ERR_free_strings(void);
void ERR_remove_state(unsigned long pid); /* if zero we look it up */
ERR_STATE *ERR_get_state(void);

#ifdef HEADER_LHASH_H
#ifndef NO_LHASH
LHASH *ERR_get_string_table(void);
LHASH *ERR_get_err_state_table(void); /* even less thread-safe than
				       * ERR_get_string_table :-) */
+4 −1
Original line number Diff line number Diff line
@@ -67,6 +67,9 @@
# undef OPENSSL_ALGORITHM_DEFINES
#endif

#ifndef NO_BIO
#include <openssl/bio.h>
#endif
#ifndef NO_MD2
#include <openssl/md2.h>
#endif
@@ -593,7 +596,7 @@ int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);

#ifdef HEADER_BIO_H
#ifndef NO_BIO
BIO_METHOD *BIO_f_md(void);
BIO_METHOD *BIO_f_base64(void);
BIO_METHOD *BIO_f_cipher(void);
Loading