67
67
* When OpenSSL is built on Windows, we do not want to require that
68
68
* the ZLIB.DLL be available in order for the OpenSSL DLLs to
69
69
* work. Therefore, all ZLIB routines are loaded at run time
70
* and we do not link to a .LIB file.
70
* and we do not link to a .LIB file when ZLIB_SHARED is set.
72
72
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
73
73
# include <windows.h>
75
# define Z_CALLCONV _stdcall
81
74
#endif /* !(OPENSSL_SYS_WINDOWS || OPENSSL_SYS_WIN32) */
84
77
#include <openssl/dso.h>
86
/* Prototypes for built in stubs */
88
static int stub_compress(Bytef *dest,uLongf *destLen,
89
const Bytef *source, uLong sourceLen);
91
static int stub_inflateEnd(z_streamp strm);
92
static int stub_inflate(z_streamp strm, int flush);
93
static int stub_inflateInit_(z_streamp strm, const char * version,
95
static int stub_deflateEnd(z_streamp strm);
96
static int stub_deflate(z_streamp strm, int flush);
97
static int stub_deflateInit_(z_streamp strm, int level,
98
const char * version, int stream_size);
100
79
/* Function pointers */
101
typedef int (Z_CALLCONV *compress_ft)(Bytef *dest,uLongf *destLen,
80
typedef int (*compress_ft)(Bytef *dest,uLongf *destLen,
102
81
const Bytef *source, uLong sourceLen);
103
typedef int (Z_CALLCONV *inflateEnd_ft)(z_streamp strm);
104
typedef int (Z_CALLCONV *inflate_ft)(z_streamp strm, int flush);
105
typedef int (Z_CALLCONV *inflateInit__ft)(z_streamp strm,
82
typedef int (*inflateEnd_ft)(z_streamp strm);
83
typedef int (*inflate_ft)(z_streamp strm, int flush);
84
typedef int (*inflateInit__ft)(z_streamp strm,
106
85
const char * version, int stream_size);
107
typedef int (Z_CALLCONV *deflateEnd_ft)(z_streamp strm);
108
typedef int (Z_CALLCONV *deflate_ft)(z_streamp strm, int flush);
109
typedef int (Z_CALLCONV *deflateInit__ft)(z_streamp strm, int level,
86
typedef int (*deflateEnd_ft)(z_streamp strm);
87
typedef int (*deflate_ft)(z_streamp strm, int flush);
88
typedef int (*deflateInit__ft)(z_streamp strm, int level,
110
89
const char * version, int stream_size);
111
90
static compress_ft p_compress=NULL;
112
91
static inflateEnd_ft p_inflateEnd=NULL;
119
98
static int zlib_loaded = 0; /* only attempt to init func pts once */
120
99
static DSO *zlib_dso = NULL;
122
#define compress stub_compress
123
#define inflateEnd stub_inflateEnd
124
#define inflate stub_inflate
125
#define inflateInit_ stub_inflateInit_
126
#define deflateEnd stub_deflateEnd
127
#define deflate stub_deflate
128
#define deflateInit_ stub_deflateInit_
101
#define compress p_compress
102
#define inflateEnd p_inflateEnd
103
#define inflate p_inflate
104
#define inflateInit_ p_inflateInit_
105
#define deflateEnd p_deflateEnd
106
#define deflate p_deflate
107
#define deflateInit_ p_deflateInit_
129
108
#endif /* ZLIB_SHARED */
131
110
struct zlib_state
362
341
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
363
342
zlib_dso = DSO_load(NULL, "ZLIB1", NULL, 0);
366
zlib_dso = DSO_load(NULL, "ZLIB", NULL, 0);
369
/* Clear the errors from the first failed
375
344
zlib_dso = DSO_load(NULL, "z", NULL, 0);
398
367
= (deflateInit__ft) DSO_bind_func(zlib_dso,
370
if (p_compress && p_inflateEnd && p_inflate
371
&& p_inflateInit_ && p_deflateEnd
372
&& p_deflate && p_deflateInit_)
405
381
#if defined(ZLIB) || defined(ZLIB_SHARED)
406
meth = &zlib_stateful_method;
382
meth = &zlib_stateful_method;
414
/* Stubs for each function to be dynamicly loaded */
416
stub_compress(Bytef *dest,uLongf *destLen,const Bytef *source, uLong sourceLen)
419
return(p_compress(dest,destLen,source,sourceLen));
426
stub_inflateEnd(z_streamp strm)
429
return(p_inflateEnd(strm));
435
stub_inflate(z_streamp strm, int flush)
438
return(p_inflate(strm,flush));
444
stub_inflateInit_(z_streamp strm, const char * version, int stream_size)
446
if ( p_inflateInit_ )
447
return(p_inflateInit_(strm,version,stream_size));
453
stub_deflateEnd(z_streamp strm)
456
return(p_deflateEnd(strm));
462
stub_deflate(z_streamp strm, int flush)
465
return(p_deflate(strm,flush));
471
stub_deflateInit_(z_streamp strm, int level,
472
const char * version, int stream_size)
474
if ( p_deflateInit_ )
475
return(p_deflateInit_(strm,level,version,stream_size));
480
#endif /* ZLIB_SHARED */