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 27 gif_lib_private.h - internal giflib routines and structures 28 29 SPDX-License-Identifier: MIT 30 31 ****************************************************************************/ 32 33 #ifndef _GIF_LIB_PRIVATE_H 34 #define _GIF_LIB_PRIVATE_H 35 36 #include "gif_lib.h" 37 #include "gif_hash.h" 38 39 #ifndef SIZE_MAX 40 #define SIZE_MAX UINTPTR_MAX 41 #endif 42 43 #define EXTENSION_INTRODUCER 0x21 44 #define DESCRIPTOR_INTRODUCER 0x2c 45 #define TERMINATOR_INTRODUCER 0x3b 46 47 #define LZ_MAX_CODE 4095 /* Biggest code possible in 12 bits. */ 48 #define LZ_BITS 12 49 50 #define FLUSH_OUTPUT 4096 /* Impossible code, to signal flush. */ 51 #define FIRST_CODE 4097 /* Impossible code, to signal first. */ 52 #define NO_SUCH_CODE 4098 /* Impossible code, to signal empty. */ 53 54 #define FILE_STATE_WRITE 0x01 55 #define FILE_STATE_SCREEN 0x02 56 #define FILE_STATE_IMAGE 0x04 57 #define FILE_STATE_READ 0x08 58 59 #define IS_READABLE(Private) (Private->FileState & FILE_STATE_READ) 60 #define IS_WRITEABLE(Private) (Private->FileState & FILE_STATE_WRITE) 61 62 typedef struct GifFilePrivateType { 63 GifWord FileState, FileHandle, /* Where all this data goes to! */ 64 BitsPerPixel, /* Bits per pixel (Codes uses at least this + 1). */ 65 ClearCode, /* The CLEAR LZ code. */ 66 EOFCode, /* The EOF LZ code. */ 67 RunningCode, /* The next code algorithm can generate. */ 68 RunningBits, /* The number of bits required to represent RunningCode. */ 69 MaxCode1, /* 1 bigger than max. possible code, in RunningBits bits. */ 70 LastCode, /* The code before the current code. */ 71 CrntCode, /* Current algorithm code. */ 72 StackPtr, /* For character stack (see below). */ 73 CrntShiftState; /* Number of bits in CrntShiftDWord. */ 74 unsigned long CrntShiftDWord; /* For bytes decomposition into codes. */ 75 unsigned long PixelCount; /* Number of pixels in image. */ 76 FILE *File; /* File as stream. */ 77 InputFunc Read; /* function to read gif input (TVT) */ 78 OutputFunc Write; /* function to write gif output (MRB) */ 79 GifByteType Buf[256]; /* Compressed input is buffered here. */ 80 GifByteType Stack[LZ_MAX_CODE]; /* Decoded pixels are stacked here. */ 81 GifByteType Suffix[LZ_MAX_CODE + 1]; /* So we can trace the codes. */ 82 GifPrefixType Prefix[LZ_MAX_CODE + 1]; 83 GifHashTableType *HashTable; 84 bool gif89; 85 } GifFilePrivateType; 86 87 #ifndef HAVE_REALLOCARRAY 88 extern void *openbsd_reallocarray(void *optr, size_t nmemb, size_t size); 89 #define reallocarray openbsd_reallocarray 90 #endif 91 92 #endif /* _GIF_LIB_PRIVATE_H */ 93 94 /* end */ 95