NCBI C++ ToolKit
ct_nlmzip_i.h
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef __NLMZIPint__
2 #define __NLMZIPint__
3 
4 /* $Id: ct_nlmzip_i.h 80118 2017-11-08 13:21:12Z ivanov $ */
5 /*****************************************************************************
6 
7  Name: nlmzip_i.h internal/compr/nlmzip_i.h
8 
9  Description: Internal definitions for compress/uncompress sybsystem.
10 
11  Author: Grisha Starchenko
12  InforMax, Inc.
13  Gaithersburg, USA.
14 
15  ***************************************************************************
16 
17  PUBLIC DOMAIN NOTICE
18  National Center for Biotechnology Information
19 
20  This software/database is a "United States Government Work" under the
21  terms of the United States Copyright Act. It was written as part of
22  the author's official duties as a United States Government employee
23  and thus cannot be copyrighted. This software/database is freely
24  available to the public for use. The National Library of Medicine and
25  the U.S. Government have not placed any restriction on its use or
26  reproduction.
27 
28  Although all reasonable efforts have been taken to ensure the accuracy
29  and reliability of the software and data, the NLM and the U.S.
30  Government do not and cannot warrant the performance or results that
31  may be obtained by using this software or data. The NLM and the U.S.
32  Government disclaim all warranties, express or implied, including
33  warranties of performance, merchantability or fitness for any
34  particular purpose.
35 
36  Please cite the author in any work or product based on this material.
37 
38  ***************************************************************************
39 
40  Modification History:
41  $Log: nlmzip_i.h,v $
42  Revision 1.3 2001/05/09 00:57:42 kimelman
43  cosmetics
44 
45  Revision 1.2 1998/05/18 16:31:01 kimelman
46  osf/1 porting
47 
48  Revision 1.1 1998/05/15 19:05:18 kimelman
49  all old 'gzip' names changed to be suitable for library names.
50  prefix Nlmzip_ is now used for all of this local stuff.
51  interface headers changed their names, moving from artdb/ur to nlmzip
52 
53  05 Aug 1995 - grisha - original written
54 
55  Bugs and restriction on use:
56 
57  Notes:
58  1. To save memory for 16 bit systems, some arrays are
59  overlaid between the various modules:
60  Nlmzip_deflate: Nlmzip_prev+head Nlmzip_window Nlmzip_d_buf l_buf Nlmzip_outbuf
61  Nlmzip_inflate: Nlmzip_window Nlmzip_inbuf
62  For compression, input is done in Nlmzip_window[]. For decompression,
63  output is done in Nlmzip_window.
64 
65 *****************************************************************************/
66 
67 /****************************************************************************/
68 /* INCLUDES */
69 /****************************************************************************/
70 #include <stdio.h>
71 #include <string.h>
73 
75 
76 
77 #ifndef _
78 #define _(proto) proto
79 #endif
80 
81 /****************************************************************************/
82 /* TYPEDEFS */
83 /****************************************************************************/
84 typedef unsigned char uch;
85 typedef unsigned short ush;
86 typedef Uint4 ulg;
87 
88 /****************************************************************************/
89 /* EXTERNS */
90 /****************************************************************************/
91 extern unsigned char Nlmzip_inbuf[]; /* input buffer */
92 extern unsigned char Nlmzip_outbuf[]; /* output buffer */
93 extern unsigned short Nlmzip_d_buf[]; /* buffer for distances, see trees.c */
94 extern unsigned char Nlmzip_window[]; /* Sliding Nlmzip_window and suffix table */
95 extern unsigned short Nlmzip_prev[];
96 
97 /* Compressions parameters */
98 extern int Nlmzip_method; /* compression Nlmzip_method */
99 extern int Nlmzip_level; /* compression Nlmzip_level */
100 
101 extern Uint4 Nlmzip_insize; /* valid bytes in Nlmzip_inbuf */
102 extern Uint4 Nlmzip_outcnt; /* bytes in output buffer */
103 
104 /* Nlmzip_window position at the beginning of the current output block.
105  Gets negative when the Nlmzip_window is moved backwards.
106 */
107 extern Int4 Nlmzip_block_start;
108 extern Uint4 Nlmzip_strstart; /* start of string to insert */
109 
110 /****************************************************************************/
111 /* DEFINES */
112 /****************************************************************************/
113 #define local static
114 #define OF(args) args
115 
116 /* Return codes from gzip */
117 #define NLMZIP_OK 0
118 #define NLMZIP_ERROR 1
119 #define NLMZIP_WARNING 2
120 
121 /* Compression methods (see algorithm.doc) */
122 #define NLMZIP_STORED 0
123 #define NLMZIP_COMPRESSED 1
124 #define NLMZIP_PACKED 2
125 #define NLMZIP_LZHED 3
126 #define NLMZIP_DEFLATED 8
127 #define NLMZIP_MAX_METHODS 9
128 
129 /* Main work buffers size */
130 #define INBUFSIZ 0x8000 /* input buffer size */
131 #define DIST_BUFSIZE 0x8000 /* buffer for distances, see trees.c */
132 #define WSIZE 0x8000 /* Nlmzip_window size--must be a power of two, and */
133  /* at least 32K for zip's Nlmzip_deflate Nlmzip_method */
134 #define OUTBUFSIZ 16384 /* output buffer size */
135 #define BITS 16
136 
137 /* Hash buffer will be in Nlmzip_prev */
138 #define head (Nlmzip_prev+WSIZE) /* hash head (see Nlmzip_deflate.c) */
139 
140 /* Special codes to be compatible with gzip */
141 #define MAGIC_KEY "\037\213" /* Magic key for check header, 1F 8B */
142 #define OS_CODE 0x03 /* assume Unix */
143 
144 /* gzip flag byte */
145 #define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
146 #define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
147 #define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
148 #define ORIG_NAME 0x08 /* bit 3 set: original file name present */
149 #define COMMENT 0x10 /* bit 4 set: file comment present */
150 #define ENCRYPTED 0x20 /* bit 5 set: file is encrypted */
151 #define RESERVED 0xC0 /* bit 6,7: reserved */
152 
153 /* internal file attribute */
154 #define UNKNOWN 0xffff
155 #define BINARY 0
156 #define ASCII 1
157 
158 /* The minimum and maximum match lengths */
159 #define MIN_MATCH 3
160 #define MAX_MATCH 258
161 
162 /* Minimum amount of lookahead, except at the end of the input file.
163  See Nlmzip_deflate.c for comments about the MIN_MATCH+1.
164 */
165 #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
166 
167 /* In order to simplify the code, particularly on 16 bit machines, match
168  distances are limited to MAX_DIST instead of WSIZE.
169  */
170 /*
171 #define MAX_DIST (WSIZE-MIN_LOOKAHEAD)
172 */
173 #define MAX_DIST 1024
174 
175 /* Macros for getting two-byte and four-byte header values */
176 #define SH(p) ((ush)(uch)((p)[0]) | ((ush)(uch)((p)[1]) << 8))
177 #define LG(p) ((ulg)(SH(p)) | ((ulg)(SH((p)+2)) << 16))
178 
179 /* Macros for error reporting */
180 #define URCOMPRERR(x) Nlmzip_Err(__FILE__,__LINE__,x)
181 
182 /****************************************************************************/
183 /* FUNCTION PROTOTYPES */
184 /****************************************************************************/
185 
186 void Nlmzip_lm_init _((int,unsigned short*));
187 ulg Nlmzip_deflate _((void));
188 void Nlmzip_ct_init _((unsigned short*,int*));
189 int Nlmzip_ct_tally _((int,int));
190 ulg Nlmzip_flush_block _((char*,ulg,int));
191 void Nlmzip_bi_init _((void));
192 void Nlmzip_send_bits _((int,int));
194 void Nlmzip_bi_windup _((void));
195 void Nlmzip_copy_block _((char*,Uint4,int));
196 ulg Nlmzip_updcrc _((unsigned char*, Uint4));
197 void Nlmzip_clear_bufs _((void));
198 void Nlmzip_flush_window _((void));
199 int Nlmzip_inflate _((void));
200 void Nlmzip_Err _((const char*,int,const char*));
201 unsigned char Nlmzip_ReadByte _((void));
202 int Nlmzip_ReadData _((unsigned char*,int));
203 void Nlmzip_ReadUndo _((void));
204 void Nlmzip_WriteByte _((unsigned char));
205 void Nlmzip_WriteShort _((unsigned short));
206 void Nlmzip_WriteLong _((ulg));
207 void Nlmzip_WriteData _((unsigned char*,int));
208 
209 
211 
212 #endif /* __NLMZIPint__ */
void Nlmzip_bi_init(void)
Uint4 Nlmzip_strstart
void Nlmzip_WriteShort(unsigned short)
void Nlmzip_flush_window(void)
int Nlmzip_inflate(void)
unsigned short ush
Definition: ct_nlmzip_i.h:85
void Nlmzip_clear_bufs(void)
void Nlmzip_send_bits(int, int)
void Nlmzip_Err(const char *, int, const char *)
unsigned short Nlmzip_prev[]
void Nlmzip_WriteData(unsigned char *, int)
void Nlmzip_copy_block(char *, Uint4, int)
int Nlmzip_ReadData(unsigned char *, int)
ulg Nlmzip_deflate(void)
unsigned char Nlmzip_window[]
int Nlmzip_ct_tally(int, int)
unsigned char Nlmzip_outbuf[]
int Nlmzip_level
unsigned char Nlmzip_inbuf[]
void Nlmzip_ReadUndo(void)
ulg Nlmzip_flush_block(char *, ulg, int)
Uint4 Nlmzip_bi_reverse(Uint4, int)
void Nlmzip_lm_init(int, unsigned short *)
Int4 Nlmzip_block_start
Uint4 Nlmzip_outcnt
#define _(proto)
Definition: ct_nlmzip_i.h:78
unsigned char Nlmzip_ReadByte(void)
void Nlmzip_ct_init(unsigned short *, int *)
void Nlmzip_WriteByte(unsigned char)
void Nlmzip_WriteLong(ulg)
int Nlmzip_method
Uint4 Nlmzip_insize
void Nlmzip_bi_windup(void)
Uint4 ulg
Definition: ct_nlmzip_i.h:86
unsigned short Nlmzip_d_buf[]
unsigned char uch
Definition: ct_nlmzip_i.h:84
ulg Nlmzip_updcrc(unsigned char *, Uint4)
#define BEGIN_CTRANSITION_SCOPE
Definition: ncbilcl.hpp:49
#define END_CTRANSITION_SCOPE
Definition: ncbilcl.hpp:50
int32_t Int4
4-byte (32-bit) signed integer
Definition: ncbitype.h:102
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
unsigned long ulg
Definition: zutil.h:43
Modified on Fri Sep 20 14:58:30 2024 by modify_doxy.py rev. 669887