c_zlib.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
COMP_METHOD *COMP_zlib(void );
static COMP_METHOD zlib_method_nozlib={
"(undef)",
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
};
#ifndef ZLIB
#else
#include <zlib.h>
static COMP_METHOD zlib_method={
NULL,
NULL,
NULL,
NULL,
};
/*
* When OpenSSL is built on Windows, we do not want to require that
* the ZLIB.DLL be available in order for the OpenSSL DLLs to
* work. Therefore, all ZLIB routines are loaded at run time
* and we do not link to a .LIB file.
*/
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
# include <windows.h>
# define Z_CALLCONV _stdcall
# define ZLIB_SHARED
#else
# define Z_CALLCONV
#endif /* !(OPENSSL_SYS_WINDOWS || OPENSSL_SYS_WIN32) */
#ifdef ZLIB_SHARED
/* Prototypes for built in stubs */
int stream_size);
/* Function pointers */
const char * version, int stream_size);
static int zlib_loaded = 0; /* only attempt to init func pts once */
#define compress stub_compress
#define inflateEnd stub_inflateEnd
#define inflate stub_inflate
#define inflateInit_ stub_inflateInit_
#endif /* ZLIB_SHARED */
{
unsigned long l;
int i;
int clear=1;
if (ilen > 128)
{
out[0]=1;
l=olen-1;
if (i != Z_OK)
return(-1);
if (ilen > l)
{
clear=0;
l++;
}
}
if (clear)
{
out[0]=0;
l=ilen+1;
}
#ifdef DEBUG_ZLIB
#endif
return((int)l);
}
{
unsigned long l;
int i;
if (in[0])
{
l=olen;
if (i != Z_OK)
return(-1);
}
else
{
l=ilen-1;
}
#ifdef DEBUG_ZLIB
#endif
return((int)l);
}
{
int err;
/* Check for source > 64K on 16-bit machine: */
if (err != Z_STREAM_END) {
inflateEnd(&stream);
return err;
}
return err;
}
#endif
COMP_METHOD *COMP_zlib(void)
{
#ifdef ZLIB_SHARED
if (!zlib_loaded)
{
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32)
#else
#endif
{
"compress");
"inflateEnd");
"inflate");
"inflateInit_");
zlib_loaded++;
}
}
#endif
#if defined(ZLIB) || defined(ZLIB_SHARED)
meth = &zlib_method;
#endif
return(meth);
}
#ifdef ZLIB_SHARED
/* Stubs for each function to be dynamicly loaded */
static int
{
if (p_compress)
else
return(Z_MEM_ERROR);
}
static int
{
if ( p_inflateEnd )
return(p_inflateEnd(strm));
else
return(Z_MEM_ERROR);
}
static int
{
if ( p_inflate )
else
return(Z_MEM_ERROR);
}
static int
{
if ( p_inflateInit_ )
else
return(Z_MEM_ERROR);
}
#endif /* ZLIB_SHARED */