1/*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation. Oracle designates this
7 * particular file as subject to the "Classpath" exception as provided
8 * by Oracle in the LICENSE file that accompanied this code.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 */
24
25/****************************************************************************
26
27gif_lib_private.h - internal giflib routines and structures
28
29****************************************************************************/
30
31#ifndef _GIF_LIB_PRIVATE_H
32#define _GIF_LIB_PRIVATE_H
33
34#include "gif_lib.h"
35#include "gif_hash.h"
36
37#ifndef SIZE_MAX
38 #define SIZE_MAX UINTPTR_MAX
39#endif
40
41#define EXTENSION_INTRODUCER 0x21
42#define DESCRIPTOR_INTRODUCER 0x2c
43#define TERMINATOR_INTRODUCER 0x3b
44
45#define LZ_MAX_CODE 4095 /* Biggest code possible in 12 bits. */
46#define LZ_BITS 12
47
48#define FLUSH_OUTPUT 4096 /* Impossible code, to signal flush. */
49#define FIRST_CODE 4097 /* Impossible code, to signal first. */
50#define NO_SUCH_CODE 4098 /* Impossible code, to signal empty. */
51
52#define FILE_STATE_WRITE 0x01
53#define FILE_STATE_SCREEN 0x02
54#define FILE_STATE_IMAGE 0x04
55#define FILE_STATE_READ 0x08
56
57#define IS_READABLE(Private) (Private->FileState & FILE_STATE_READ)
58#define IS_WRITEABLE(Private) (Private->FileState & FILE_STATE_WRITE)
59
60typedef struct GifFilePrivateType {
61 GifWord FileState, FileHandle, /* Where all this data goes to! */
62 BitsPerPixel, /* Bits per pixel (Codes uses at least this + 1). */
63 ClearCode, /* The CLEAR LZ code. */
64 EOFCode, /* The EOF LZ code. */
65 RunningCode, /* The next code algorithm can generate. */
66 RunningBits, /* The number of bits required to represent RunningCode. */
67 MaxCode1, /* 1 bigger than max. possible code, in RunningBits bits. */
68 LastCode, /* The code before the current code. */
69 CrntCode, /* Current algorithm code. */
70 StackPtr, /* For character stack (see below). */
71 CrntShiftState; /* Number of bits in CrntShiftDWord. */
72 unsigned long CrntShiftDWord; /* For bytes decomposition into codes. */
73 unsigned long PixelCount; /* Number of pixels in image. */
74 FILE *File; /* File as stream. */
75 InputFunc Read; /* function to read gif input (TVT) */
76 OutputFunc Write; /* function to write gif output (MRB) */
77 GifByteType Buf[256]; /* Compressed input is buffered here. */
78 GifByteType Stack[LZ_MAX_CODE]; /* Decoded pixels are stacked here. */
79 GifByteType Suffix[LZ_MAX_CODE + 1]; /* So we can trace the codes. */
80 GifPrefixType Prefix[LZ_MAX_CODE + 1];
81 GifHashTableType *HashTable;
82 bool gif89;
83} GifFilePrivateType;
84
85#ifndef HAVE_REALLOCARRAY
86extern void *openbsd_reallocarray(void *optr, size_t nmemb, size_t size);
87#define reallocarray openbsd_reallocarray
88#endif
89
90#endif /* _GIF_LIB_PRIVATE_H */
91
92/* end */
93