1 /**************************************************************************** 2 3 gif_lib_private.h - internal giflib routines and structures 4 5 ****************************************************************************/ 6 7 #ifndef _GIF_LIB_PRIVATE_H 8 #define _GIF_LIB_PRIVATE_H 9 10 #include "gif_lib.h" 11 #include "gif_hash.h" 12 13 #ifndef SIZE_MAX 14 #define SIZE_MAX UINTPTR_MAX 15 #endif 16 17 #define EXTENSION_INTRODUCER 0x21 18 #define DESCRIPTOR_INTRODUCER 0x2c 19 #define TERMINATOR_INTRODUCER 0x3b 20 21 #define LZ_MAX_CODE 4095 /* Biggest code possible in 12 bits. */ 22 #define LZ_BITS 12 23 24 #define FLUSH_OUTPUT 4096 /* Impossible code, to signal flush. */ 25 #define FIRST_CODE 4097 /* Impossible code, to signal first. */ 26 #define NO_SUCH_CODE 4098 /* Impossible code, to signal empty. */ 27 28 #define FILE_STATE_WRITE 0x01 29 #define FILE_STATE_SCREEN 0x02 30 #define FILE_STATE_IMAGE 0x04 31 #define FILE_STATE_READ 0x08 32 33 #define IS_READABLE(Private) (Private->FileState & FILE_STATE_READ) 34 #define IS_WRITEABLE(Private) (Private->FileState & FILE_STATE_WRITE) 35 36 typedef struct GifFilePrivateType { 37 GifWord FileState, FileHandle, /* Where all this data goes to! */ 38 BitsPerPixel, /* Bits per pixel (Codes uses at least this + 1). */ 39 ClearCode, /* The CLEAR LZ code. */ 40 EOFCode, /* The EOF LZ code. */ 41 RunningCode, /* The next code algorithm can generate. */ 42 RunningBits, /* The number of bits required to represent RunningCode. */ 43 MaxCode1, /* 1 bigger than max. possible code, in RunningBits bits. */ 44 LastCode, /* The code before the current code. */ 45 CrntCode, /* Current algorithm code. */ 46 StackPtr, /* For character stack (see below). */ 47 CrntShiftState; /* Number of bits in CrntShiftDWord. */ 48 unsigned long CrntShiftDWord; /* For bytes decomposition into codes. */ 49 unsigned long PixelCount; /* Number of pixels in image. */ 50 FILE *File; /* File as stream. */ 51 InputFunc Read; /* function to read gif input (TVT) */ 52 OutputFunc Write; /* function to write gif output (MRB) */ 53 GifByteType Buf[256]; /* Compressed input is buffered here. */ 54 GifByteType Stack[LZ_MAX_CODE]; /* Decoded pixels are stacked here. */ 55 GifByteType Suffix[LZ_MAX_CODE + 1]; /* So we can trace the codes. */ 56 GifPrefixType Prefix[LZ_MAX_CODE + 1]; 57 GifHashTableType *HashTable; 58 bool gif89; 59 } GifFilePrivateType; 60 61 #ifndef HAVE_REALLOCARRAY 62 extern void *openbsd_reallocarray(void *optr, size_t nmemb, size_t size); 63 #define reallocarray openbsd_reallocarray 64 #endif 65 66 #endif /* _GIF_LIB_PRIVATE_H */ 67 68 /* end */