File: zlib.c

package info (click to toggle)
tcltrf 2.1.4-dfsg3-8
  • links: PTS
  • area: main
  • in suites: sid, trixie
  • size: 9,656 kB
  • sloc: ansic: 73,139; sh: 3,155; tcl: 1,343; makefile: 182; exp: 22
file content (100 lines) | stat: -rw-r--r-- 1,884 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
 * zlib.c --
 *
 *	Loader for 'zlib' compression library.
 *
 * Copyright (c) 1996 Jan Nijtmans (nijtmans.nici.kun.nl)
 * All rights reserved.
 *
 * CVS: $Id: zlib.c,v 1.15 2003/01/09 21:27:12 andreas_kupries Exp $
 */

#include "transformInt.h"

#ifdef __WIN32__
#define Z_LIB_NAME "zlib.dll"
#endif

#ifndef Z_LIB_NAME
#define Z_LIB_NAME LIBZ_DEFAULTNAME
#endif


static char* symbols [] = {
  "deflate",
  "deflateEnd",
  "deflateInit2_",
  "deflateReset",
  "inflate",
  "inflateEnd",
  "inflateInit2_",
  "inflateReset",
  "adler32",
  "crc32",
  (char *) NULL
};


/*
 * Global variable containing the vectors into the 'zlib'-library.
 */

#ifdef ZLIB_STATIC_BUILD
zFunctions zf = {
  0,
  deflate,
  deflateEnd,
  deflateInit2_,
  deflateReset,
  inflate,
  inflateEnd,
  inflateInit2_,
  inflateReset,
  adler32,
  crc32,
};
#else
zFunctions zf = {0}; /* THREADING: serialize initialization */
#endif

int
TrfLoadZlib (interp)
    Tcl_Interp* interp;
{
#ifndef ZLIB_STATIC_BUILD
  int res;

#ifdef HAVE_zlibtcl_PACKAGE
  /* Try to use zlibtcl first. This makes loading much easier.
   */

  if (Zlibtcl_InitStubs(interp, ZLIBTCL_VERSION, 0) != NULL) {
    /*
     * Copy stub information into the table the rest of Trf is using.
     */

    zf.handle         = 0;
    zf.zdeflate       = deflate      ;
    zf.zdeflateEnd    = deflateEnd   ;
    zf.zdeflateInit2_ = deflateInit2_;
    zf.zdeflateReset  = deflateReset ;
    zf.zinflate       = inflate      ;
    zf.zinflateEnd    = inflateEnd   ;
    zf.zinflateInit2_ = inflateInit2_;
    zf.zinflateReset  = inflateReset ;
    zf.zadler32       = adler32      ;
    zf.zcrc32         = crc32        ;
    return TCL_OK;
  }

#endif

  TrfLock; /* THREADING: serialize initialization */
  res = Trf_LoadLibrary (interp, Z_LIB_NAME, (VOID**) &zf, symbols, 10);
  TrfUnlock;

  return res;
#else
  return TCL_OK;
#endif
}