imaptool-0.9.orig/0040755000000000000000000000000007041467247012662 5ustar rootrootimaptool-0.9.orig/Makefile0100644000000000000000000000133107040176125014304 0ustar rootroot#Do you want to use jpeg-library??? JPEG_INCLUDE=-I/usr/local/include/ JPEG_CHOICE=-DUSE_JPEG_LIB $(JPEG_INCLUDE) #JPEG_CHOICE= LIBRARIES=-lXt -lXaw -lXmu -lXext -lX11 -ljpeg -lm #LIBRARIES=-lXt -lXaw -lXmu -lXext -lX11 -lm CC=gcc -I/usr/X11R6/include/ LIBDIR=-L/usr/local/lib -L/usr/X11R6/lib OBJECTS=imaptool.o file2pixmap.o dgif_lib.o gif_err.o gifalloc.o imaptool: $(OBJECTS) $(CC) -o imaptool $(LIBDIR) $(OBJECTS) $(LIBRARIES) imaptool.o: imaptool.c icon iconmask $(CC) -c imaptool.c file2pixmap.o: file2pixmap.c $(CC) -c file2pixmap.c $(JPEG_CHOICE) dgif_lib.o: dgif_lib.c $(CC) -c dgif_lib.c gif_err.o: gif_err.c $(CC) -c gif_err.c gifalloc.o: gifalloc.c $(CC) -c gifalloc.c clean: rm $(OBJECTS) imaptool imaptool-0.9.orig/dgif_lib.c0100644000000000000000000007612707040176125014566 0ustar rootroot/****************************************************************************** * "Gif-Lib" - Yet another gif library. * * * * Written by: Gershon Elber IBM PC Ver 1.1, Aug. 1990 * ******************************************************************************* * The kernel of the GIF Decoding process can be found here. * ******************************************************************************* * History: * * 16 Jun 89 - Version 1.0 by Gershon Elber. * * 3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names). * ******************************************************************************/ #ifdef __MSDOS__ #include #include #include #include #else #include #include #endif /* __MSDOS__ */ #include #include #include #include "gif_lib.h" #include "gif_hash.h" #define PROGRAM_NAME "GIF_LIBRARY" #define COMMENT_EXT_FUNC_CODE 0xfe /* Extension function code for comment. */ #define GIF_STAMP "GIFVER" /* First chars in file - GIF stamp. */ #define GIF_STAMP_LEN sizeof(GIF_STAMP) - 1 #define GIF_VERSION_POS 3 /* Version first character in stamp. */ #define LZ_MAX_CODE 4095 /* Biggest code possible in 12 bits. */ #define LZ_BITS 12 #define FILE_STATE_READ 0x01/* 1 write, 0 read - EGIF_LIB compatible.*/ #define FLUSH_OUTPUT 4096 /* Impossible code, to signal flush. */ #define FIRST_CODE 4097 /* Impossible code, to signal first. */ #define NO_SUCH_CODE 4098 /* Impossible code, to signal empty. */ #define IS_READABLE(Private) (!(Private->FileState & FILE_STATE_READ)) typedef struct GifFilePrivateType { int FileState, FileHandle, /* Where all this data goes to! */ BitsPerPixel, /* Bits per pixel (Codes uses at list this + 1). */ ClearCode, /* The CLEAR LZ code. */ EOFCode, /* The EOF LZ code. */ RunningCode, /* The next code algorithm can generate. */ RunningBits,/* The number of bits required to represent RunningCode. */ MaxCode1, /* 1 bigger than max. possible code, in RunningBits bits. */ LastCode, /* The code before the current code. */ CrntCode, /* Current algorithm code. */ StackPtr, /* For character stack (see below). */ CrntShiftState; /* Number of bits in CrntShiftDWord. */ unsigned long CrntShiftDWord; /* For bytes decomposition into codes. */ long PixelCount; /* Number of pixels in image. */ FILE *File; /* File as stream. */ GifByteType Buf[256]; /* Compressed input is buffered here. */ GifByteType Stack[LZ_MAX_CODE]; /* Decoded pixels are stacked here. */ GifByteType Suffix[LZ_MAX_CODE+1]; /* So we can trace the codes. */ unsigned int Prefix[LZ_MAX_CODE+1]; } GifFilePrivateType; #ifdef SYSV static char *VersionStr = "Gif library module,\t\tGershon Elber\n\ (C) Copyright 1989 Gershon Elber, Non commercial use only.\n"; #else static char *VersionStr = PROGRAM_NAME " IBMPC " GIF_LIB_VERSION " Gershon Elber, " __DATE__ ", " __TIME__ "\n" "(C) Copyright 1989 Gershon Elber, Non commercial use only.\n"; #endif /* SYSV */ extern int _GifError; static int DGifGetWord(FILE *File, int *Word); static int DGifSetupDecompress(GifFileType *GifFile); static int DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line, int LineLen); static int DGifGetPrefixChar(unsigned int *Prefix, int Code, int ClearCode); static int DGifDecompressInput(GifFilePrivateType *Private, int *Code); static int DGifBufferedInput(FILE *File, GifByteType *Buf, GifByteType *NextByte); /****************************************************************************** * Open a new gif file for read, given by its name. * * Returns GifFileType pointer dynamically allocated which serves as the gif * * info record. _GifError is cleared if succesfull. * ******************************************************************************/ GifFileType *DGifOpenFileName(const char *FileName) { int FileHandle; if ((FileHandle = open(FileName, O_RDONLY #ifdef __MSDOS__ | O_BINARY #endif /* __MSDOS__ */ )) == -1) { _GifError = D_GIF_ERR_OPEN_FAILED; return NULL; } return DGifOpenFileHandle(FileHandle); } /****************************************************************************** * Update a new gif file, given its file handle. * * Returns GifFileType pointer dynamically allocated which serves as the gif * * info record. _GifError is cleared if succesfull. * ******************************************************************************/ GifFileType *DGifOpenFileHandle(int FileHandle) { char Buf[GIF_STAMP_LEN+1]; GifFileType *GifFile; GifFilePrivateType *Private; FILE *f; #ifdef __MSDOS__ setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */ f = fdopen(FileHandle, "rb"); /* Make it into a stream: */ setvbuf(f, NULL, _IOFBF, GIF_FILE_BUFFER_SIZE);/* And inc. stream buffer.*/ #else f = fdopen(FileHandle, "r"); /* Make it into a stream: */ #endif /* __MSDOS__ */ if ((GifFile = (GifFileType *) malloc(sizeof(GifFileType))) == NULL) { _GifError = D_GIF_ERR_NOT_ENOUGH_MEM; return NULL; } memset(GifFile, '\0', sizeof(GifFileType)); if ((Private = (GifFilePrivateType *) malloc(sizeof(GifFilePrivateType))) == NULL) { _GifError = D_GIF_ERR_NOT_ENOUGH_MEM; free((char *) GifFile); return NULL; } GifFile->Private = (VoidPtr) Private; Private->FileHandle = FileHandle; Private->File = f; Private->FileState = 0; /* Make sure bit 0 = 0 (File open for read). */ /* Lets see if this is a GIF file: */ if (fread(Buf, 1, GIF_STAMP_LEN, Private->File) != GIF_STAMP_LEN) { _GifError = D_GIF_ERR_READ_FAILED; free((char *) Private); free((char *) GifFile); return NULL; } /* The GIF Version number is ignored at this time. Maybe we should do */ /* something more useful with it. */ Buf[GIF_STAMP_LEN] = 0; if (strncmp(GIF_STAMP, Buf, GIF_VERSION_POS) != 0) { _GifError = D_GIF_ERR_NOT_GIF_FILE; free((char *) Private); free((char *) GifFile); return NULL; } if (DGifGetScreenDesc(GifFile) == GIF_ERROR) { free((char *) Private); free((char *) GifFile); return NULL; } _GifError = 0; return GifFile; } /****************************************************************************** * This routine should be called before any other DGif calls. Note that * * this routine is called automatically from DGif file open routines. * ******************************************************************************/ int DGifGetScreenDesc(GifFileType *GifFile) { int i, BitsPerPixel; GifByteType Buf[3]; GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; if (!IS_READABLE(Private)) { /* This file was NOT open for reading: */ _GifError = D_GIF_ERR_NOT_READABLE; return GIF_ERROR; } /* Put the screen descriptor into the file: */ if (DGifGetWord(Private->File, &GifFile->SWidth) == GIF_ERROR || DGifGetWord(Private->File, &GifFile->SHeight) == GIF_ERROR) return GIF_ERROR; if (fread(Buf, 1, 3, Private->File) != 3) { _GifError = D_GIF_ERR_READ_FAILED; return GIF_ERROR; } GifFile->SColorResolution = (((Buf[0] & 0x70) + 1) >> 4) + 1; BitsPerPixel = (Buf[0] & 0x07) + 1; GifFile->SBackGroundColor = Buf[1]; if (Buf[0] & 0x80) { /* Do we have global color map? */ GifFile->SColorMap = MakeMapObject(1 << BitsPerPixel, NULL); /* Get the global color map: */ for (i = 0; i < GifFile->SColorMap->ColorCount; i++) { if (fread(Buf, 1, 3, Private->File) != 3) { _GifError = D_GIF_ERR_READ_FAILED; return GIF_ERROR; } GifFile->SColorMap->Colors[i].Red = Buf[0]; GifFile->SColorMap->Colors[i].Green = Buf[1]; GifFile->SColorMap->Colors[i].Blue = Buf[2]; } } return GIF_OK; } /****************************************************************************** * This routine should be called before any attemp to read an image. * ******************************************************************************/ int DGifGetRecordType(GifFileType *GifFile, GifRecordType *Type) { GifByteType Buf; GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; if (!IS_READABLE(Private)) { /* This file was NOT open for reading: */ _GifError = D_GIF_ERR_NOT_READABLE; return GIF_ERROR; } if (fread(&Buf, 1, 1, Private->File) != 1) { _GifError = D_GIF_ERR_READ_FAILED; return GIF_ERROR; } switch (Buf) { case ',': *Type = IMAGE_DESC_RECORD_TYPE; break; case '!': *Type = EXTENSION_RECORD_TYPE; break; case ';': *Type = TERMINATE_RECORD_TYPE; break; default: *Type = UNDEFINED_RECORD_TYPE; _GifError = D_GIF_ERR_WRONG_RECORD; return GIF_ERROR; } return GIF_OK; } /****************************************************************************** * This routine should be called before any attemp to read an image. * * Note it is assumed the Image desc. header (',') has been read. * ******************************************************************************/ int DGifGetImageDesc(GifFileType *GifFile) { int i, BitsPerPixel; GifByteType Buf[3]; GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; if (!IS_READABLE(Private)) { /* This file was NOT open for reading: */ _GifError = D_GIF_ERR_NOT_READABLE; return GIF_ERROR; } if (DGifGetWord(Private->File, &GifFile->Image.Left) == GIF_ERROR || DGifGetWord(Private->File, &GifFile->Image.Top) == GIF_ERROR || DGifGetWord(Private->File, &GifFile->Image.Width) == GIF_ERROR || DGifGetWord(Private->File, &GifFile->Image.Height) == GIF_ERROR) return GIF_ERROR; if (fread(Buf, 1, 1, Private->File) != 1) { _GifError = D_GIF_ERR_READ_FAILED; return GIF_ERROR; } BitsPerPixel = (Buf[0] & 0x07) + 1; GifFile->Image.Interlace = (Buf[0] & 0x40); if (Buf[0] & 0x80) { /* Does this image have local color map? */ if (GifFile->Image.ColorMap && GifFile->SavedImages == NULL) FreeMapObject(GifFile->Image.ColorMap); GifFile->Image.ColorMap = MakeMapObject(1 << BitsPerPixel, NULL); /* Get the image local color map: */ for (i = 0; i < GifFile->Image.ColorMap->ColorCount; i++) { if (fread(Buf, 1, 3, Private->File) != 3) { _GifError = D_GIF_ERR_READ_FAILED; return GIF_ERROR; } GifFile->Image.ColorMap->Colors[i].Red = Buf[0]; GifFile->Image.ColorMap->Colors[i].Green = Buf[1]; GifFile->Image.ColorMap->Colors[i].Blue = Buf[2]; } } if (GifFile->SavedImages) { SavedImage *sp; if ((GifFile->SavedImages = (SavedImage *)realloc(GifFile->SavedImages, sizeof(SavedImage) * (GifFile->ImageCount + 1))) == NULL) { _GifError = D_GIF_ERR_NOT_ENOUGH_MEM; return GIF_ERROR; } sp = &GifFile->SavedImages[GifFile->ImageCount]; memcpy(&sp->ImageDesc, &GifFile->Image, sizeof(GifImageDesc)); sp->RasterBits = (char *)NULL; sp->ExtensionBlockCount = 0; sp->ExtensionBlocks = (ExtensionBlock *)NULL; } GifFile->ImageCount++; Private->PixelCount = (long) GifFile->Image.Width * (long) GifFile->Image.Height; DGifSetupDecompress(GifFile); /* Reset decompress algorithm parameters. */ return GIF_OK; } /****************************************************************************** * Get one full scanned line (Line) of length LineLen from GIF file. * ******************************************************************************/ int DGifGetLine(GifFileType *GifFile, GifPixelType *Line, int LineLen) { GifByteType *Dummy; GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; if (!IS_READABLE(Private)) { /* This file was NOT open for reading: */ _GifError = D_GIF_ERR_NOT_READABLE; return GIF_ERROR; } if (!LineLen) LineLen = GifFile->Image.Width; #ifdef __MSDOS__ if ((Private->PixelCount -= LineLen) > 0xffff0000UL) { #else if ((Private->PixelCount -= LineLen) > 0xffff0000) { #endif /* __MSDOS__ */ _GifError = D_GIF_ERR_DATA_TOO_BIG; return GIF_ERROR; } if (DGifDecompressLine(GifFile, Line, LineLen) == GIF_OK) { if (Private->PixelCount == 0) { /* We probably would not be called any more, so lets clean */ /* everything before we return: need to flush out all rest of */ /* image until empty block (size 0) detected. We use GetCodeNext.*/ do if (DGifGetCodeNext(GifFile, &Dummy) == GIF_ERROR) return GIF_ERROR; while (Dummy != NULL); } return GIF_OK; } else return GIF_ERROR; } /****************************************************************************** * Put one pixel (Pixel) into GIF file. * ******************************************************************************/ int DGifGetPixel(GifFileType *GifFile, GifPixelType Pixel) { GifByteType *Dummy; GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; if (!IS_READABLE(Private)) { /* This file was NOT open for reading: */ _GifError = D_GIF_ERR_NOT_READABLE; return GIF_ERROR; } #ifdef __MSDOS__ if (--Private->PixelCount > 0xffff0000UL) #else if (--Private->PixelCount > 0xffff0000) #endif /* __MSDOS__ */ { _GifError = D_GIF_ERR_DATA_TOO_BIG; return GIF_ERROR; } if (DGifDecompressLine(GifFile, &Pixel, 1) == GIF_OK) { if (Private->PixelCount == 0) { /* We probably would not be called any more, so lets clean */ /* everything before we return: need to flush out all rest of */ /* image until empty block (size 0) detected. We use GetCodeNext.*/ do if (DGifGetCodeNext(GifFile, &Dummy) == GIF_ERROR) return GIF_ERROR; while (Dummy != NULL); } return GIF_OK; } else return GIF_ERROR; } /****************************************************************************** * Get an extension block (see GIF manual) from gif file. This routine only * * returns the first data block, and DGifGetExtensionNext shouldbe called * * after this one until NULL extension is returned. * * The Extension should NOT be freed by the user (not dynamically allocated).* * Note it is assumed the Extension desc. header ('!') has been read. * ******************************************************************************/ int DGifGetExtension(GifFileType *GifFile, int *ExtCode, GifByteType **Extension) { GifByteType Buf; GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; if (!IS_READABLE(Private)) { /* This file was NOT open for reading: */ _GifError = D_GIF_ERR_NOT_READABLE; return GIF_ERROR; } if (fread(&Buf, 1, 1, Private->File) != 1) { _GifError = D_GIF_ERR_READ_FAILED; return GIF_ERROR; } *ExtCode = Buf; return DGifGetExtensionNext(GifFile, Extension); } /****************************************************************************** * Get a following extension block (see GIF manual) from gif file. This * * routine sould be called until NULL Extension is returned. * * The Extension should NOT be freed by the user (not dynamically allocated).* ******************************************************************************/ int DGifGetExtensionNext(GifFileType *GifFile, GifByteType **Extension) { GifByteType Buf; GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; if (fread(&Buf, 1, 1, Private->File) != 1) { _GifError = D_GIF_ERR_READ_FAILED; return GIF_ERROR; } if (Buf > 0) { *Extension = Private->Buf; /* Use private unused buffer. */ (*Extension)[0] = Buf; /* Pascal strings notation (pos. 0 is len.). */ if (fread(&((*Extension)[1]), 1, Buf, Private->File) != Buf) { _GifError = D_GIF_ERR_READ_FAILED; return GIF_ERROR; } } else *Extension = NULL; return GIF_OK; } /****************************************************************************** * This routine should be called last, to close the GIF file. * ******************************************************************************/ int DGifCloseFile(GifFileType *GifFile) { GifFilePrivateType *Private; FILE *File; if (GifFile == NULL) return GIF_ERROR; Private = (GifFilePrivateType *) GifFile->Private; if (!IS_READABLE(Private)) { /* This file was NOT open for reading: */ _GifError = D_GIF_ERR_NOT_READABLE; return GIF_ERROR; } File = Private->File; if (GifFile->Image.ColorMap) FreeMapObject(GifFile->Image.ColorMap); if (GifFile->SColorMap) FreeMapObject(GifFile->SColorMap); if (Private) free((char *) Private); if (GifFile->SavedImages) FreeSavedImages(GifFile); free(GifFile); if (fclose(File) != 0) { _GifError = D_GIF_ERR_CLOSE_FAILED; return GIF_ERROR; } return GIF_OK; } /****************************************************************************** * Get 2 bytes (word) from the given file: * ******************************************************************************/ static int DGifGetWord(FILE *File, int *Word) { unsigned char c[2]; if (fread(c, 1, 2, File) != 2) { _GifError = D_GIF_ERR_READ_FAILED; return GIF_ERROR; } *Word = (((unsigned int) c[1]) << 8) + c[0]; return GIF_OK; } /****************************************************************************** * Get the image code in compressed form. his routine can be called if the * * information needed to be piped out as is. Obviously this is much faster * * than decoding and encoding again. This routine should be followed by calls * * to DGifGetCodeNext, until NULL block is returned. * * The block should NOT be freed by the user (not dynamically allocated). * ******************************************************************************/ int DGifGetCode(GifFileType *GifFile, int *CodeSize, GifByteType **CodeBlock) { GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; if (!IS_READABLE(Private)) { /* This file was NOT open for reading: */ _GifError = D_GIF_ERR_NOT_READABLE; return GIF_ERROR; } *CodeSize = Private->BitsPerPixel; return DGifGetCodeNext(GifFile, CodeBlock); } /****************************************************************************** * Continue to get the image code in compressed form. This routine should be * * called until NULL block is returned. * * The block should NOT be freed by the user (not dynamically allocated). * ******************************************************************************/ int DGifGetCodeNext(GifFileType *GifFile, GifByteType **CodeBlock) { GifByteType Buf; GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; if (fread(&Buf, 1, 1, Private->File) != 1) { _GifError = D_GIF_ERR_READ_FAILED; return GIF_ERROR; } if (Buf > 0) { *CodeBlock = Private->Buf; /* Use private unused buffer. */ (*CodeBlock)[0] = Buf; /* Pascal strings notation (pos. 0 is len.). */ if (fread(&((*CodeBlock)[1]), 1, Buf, Private->File) != Buf) { _GifError = D_GIF_ERR_READ_FAILED; return GIF_ERROR; } } else { *CodeBlock = NULL; Private->Buf[0] = 0; /* Make sure the buffer is empty! */ Private->PixelCount = 0; /* And local info. indicate image read. */ } return GIF_OK; } /****************************************************************************** * Setup the LZ decompression for this image: * ******************************************************************************/ static int DGifSetupDecompress(GifFileType *GifFile) { int i, BitsPerPixel; GifByteType CodeSize; unsigned int *Prefix; GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; fread(&CodeSize, 1, 1, Private->File); /* Read Code size from file. */ BitsPerPixel = CodeSize; Private->Buf[0] = 0; /* Input Buffer empty. */ Private->BitsPerPixel = BitsPerPixel; Private->ClearCode = (1 << BitsPerPixel); Private->EOFCode = Private->ClearCode + 1; Private->RunningCode = Private->EOFCode + 1; Private->RunningBits = BitsPerPixel + 1; /* Number of bits per code. */ Private->MaxCode1 = 1 << Private->RunningBits; /* Max. code + 1. */ Private->StackPtr = 0; /* No pixels on the pixel stack. */ Private->LastCode = NO_SUCH_CODE; Private->CrntShiftState = 0; /* No information in CrntShiftDWord. */ Private->CrntShiftDWord = 0; Prefix = Private->Prefix; for (i = 0; i <= LZ_MAX_CODE; i++) Prefix[i] = NO_SUCH_CODE; return GIF_OK; } /****************************************************************************** * The LZ decompression routine: * * This version decompress the given gif file into Line of length LineLen. * * This routine can be called few times (one per scan line, for example), in * * order the complete the whole image. * ******************************************************************************/ static int DGifDecompressLine(GifFileType *GifFile, GifPixelType *Line, int LineLen) { int i = 0, j, CrntCode, EOFCode, ClearCode, CrntPrefix, LastCode, StackPtr; GifByteType *Stack, *Suffix; unsigned int *Prefix; GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; StackPtr = Private->StackPtr; Prefix = Private->Prefix; Suffix = Private->Suffix; Stack = Private->Stack; EOFCode = Private->EOFCode; ClearCode = Private->ClearCode; LastCode = Private->LastCode; if (StackPtr != 0) { /* Let pop the stack off before continueing to read the gif file: */ while (StackPtr != 0 && i < LineLen) Line[i++] = Stack[--StackPtr]; } while (i < LineLen) { /* Decode LineLen items. */ if (DGifDecompressInput(Private, &CrntCode) == GIF_ERROR) return GIF_ERROR; if (CrntCode == EOFCode) { /* Note however that usually we will not be here as we will stop */ /* decoding as soon as we got all the pixel, or EOF code will */ /* not be read at all, and DGifGetLine/Pixel clean everything. */ if (i != LineLen - 1 || Private->PixelCount != 0) { _GifError = D_GIF_ERR_EOF_TOO_SOON; return GIF_ERROR; } i++; } else if (CrntCode == ClearCode) { /* We need to start over again: */ for (j = 0; j <= LZ_MAX_CODE; j++) Prefix[j] = NO_SUCH_CODE; Private->RunningCode = Private->EOFCode + 1; Private->RunningBits = Private->BitsPerPixel + 1; Private->MaxCode1 = 1 << Private->RunningBits; LastCode = Private->LastCode = NO_SUCH_CODE; } else { /* Its regular code - if in pixel range simply add it to output */ /* stream, otherwise trace to codes linked list until the prefix */ /* is in pixel range: */ if (CrntCode < ClearCode) { /* This is simple - its pixel scalar, so add it to output: */ Line[i++] = CrntCode; } else { /* Its a code to needed to be traced: trace the linked list */ /* until the prefix is a pixel, while pushing the suffix */ /* pixels on our stack. If we done, pop the stack in reverse */ /* (thats what stack is good for!) order to output. */ if (Prefix[CrntCode] == NO_SUCH_CODE) { /* Only allowed if CrntCode is exactly the running code: */ /* In that case CrntCode = XXXCode, CrntCode or the */ /* prefix code is last code and the suffix char is */ /* exactly the prefix of last code! */ if (CrntCode == Private->RunningCode - 2) { CrntPrefix = LastCode; Suffix[Private->RunningCode - 2] = Stack[StackPtr++] = DGifGetPrefixChar(Prefix, LastCode, ClearCode); } else { _GifError = D_GIF_ERR_IMAGE_DEFECT; return GIF_ERROR; } } else CrntPrefix = CrntCode; /* Now (if image is O.K.) we should not get an NO_SUCH_CODE */ /* During the trace. As we might loop forever, in case of */ /* defective image, we count the number of loops we trace */ /* and stop if we got LZ_MAX_CODE. obviously we can not */ /* loop more than that. */ j = 0; while (j++ <= LZ_MAX_CODE && CrntPrefix > ClearCode && CrntPrefix <= LZ_MAX_CODE) { Stack[StackPtr++] = Suffix[CrntPrefix]; CrntPrefix = Prefix[CrntPrefix]; } if (j >= LZ_MAX_CODE || CrntPrefix > LZ_MAX_CODE) { _GifError = D_GIF_ERR_IMAGE_DEFECT; return GIF_ERROR; } /* Push the last character on stack: */ Stack[StackPtr++] = CrntPrefix; /* Now lets pop all the stack into output: */ while (StackPtr != 0 && i < LineLen) Line[i++] = Stack[--StackPtr]; } if (LastCode != NO_SUCH_CODE) { Prefix[Private->RunningCode - 2] = LastCode; if (CrntCode == Private->RunningCode - 2) { /* Only allowed if CrntCode is exactly the running code: */ /* In that case CrntCode = XXXCode, CrntCode or the */ /* prefix code is last code and the suffix char is */ /* exactly the prefix of last code! */ Suffix[Private->RunningCode - 2] = DGifGetPrefixChar(Prefix, LastCode, ClearCode); } else { Suffix[Private->RunningCode - 2] = DGifGetPrefixChar(Prefix, CrntCode, ClearCode); } } LastCode = CrntCode; } } Private->LastCode = LastCode; Private->StackPtr = StackPtr; return GIF_OK; } /****************************************************************************** * Routine to trace the Prefixes linked list until we get a prefix which is * * not code, but a pixel value (less than ClearCode). Returns that pixel value.* * If image is defective, we might loop here forever, so we limit the loops to * * the maximum possible if image O.k. - LZ_MAX_CODE times. * ******************************************************************************/ static int DGifGetPrefixChar(unsigned int *Prefix, int Code, int ClearCode) { int i = 0; while (Code > ClearCode && i++ <= LZ_MAX_CODE) Code = Prefix[Code]; return Code; } /****************************************************************************** * Interface for accessing the LZ codes directly. Set Code to the real code * * (12bits), or to -1 if EOF code is returned. * ******************************************************************************/ int DGifGetLZCodes(GifFileType *GifFile, int *Code) { GifByteType *CodeBlock; GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; if (!IS_READABLE(Private)) { /* This file was NOT open for reading: */ _GifError = D_GIF_ERR_NOT_READABLE; return GIF_ERROR; } if (DGifDecompressInput(Private, Code) == GIF_ERROR) return GIF_ERROR; if (*Code == Private->EOFCode) { /* Skip rest of codes (hopefully only NULL terminating block): */ do if (DGifGetCodeNext(GifFile, &CodeBlock) == GIF_ERROR) return GIF_ERROR; while (CodeBlock != NULL); *Code = -1; } else if (*Code == Private->ClearCode) { /* We need to start over again: */ Private->RunningCode = Private->EOFCode + 1; Private->RunningBits = Private->BitsPerPixel + 1; Private->MaxCode1 = 1 << Private->RunningBits; } return GIF_OK; } /****************************************************************************** * The LZ decompression input routine: * * This routine is responsable for the decompression of the bit stream from * * 8 bits (bytes) packets, into the real codes. * * Returns GIF_OK if read succesfully. * ******************************************************************************/ static int DGifDecompressInput(GifFilePrivateType *Private, int *Code) { GifByteType NextByte; static unsigned int CodeMasks[] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, 0x01ff, 0x03ff, 0x07ff, 0x0fff }; while (Private->CrntShiftState < Private->RunningBits) { /* Needs to get more bytes from input stream for next code: */ if (DGifBufferedInput(Private->File, Private->Buf, &NextByte) == GIF_ERROR) { return GIF_ERROR; } Private->CrntShiftDWord |= ((unsigned long) NextByte) << Private->CrntShiftState; Private->CrntShiftState += 8; } *Code = Private->CrntShiftDWord & CodeMasks[Private->RunningBits]; Private->CrntShiftDWord >>= Private->RunningBits; Private->CrntShiftState -= Private->RunningBits; /* If code cannt fit into RunningBits bits, must raise its size. Note */ /* however that codes above 4095 are used for special signaling. */ if (++Private->RunningCode > Private->MaxCode1 && Private->RunningBits < LZ_BITS) { Private->MaxCode1 <<= 1; Private->RunningBits++; } return GIF_OK; } /****************************************************************************** * This routines read one gif data block at a time and buffers it internally * * so that the decompression routine could access it. * * The routine returns the next byte from its internal buffer (or read next * * block in if buffer empty) and returns GIF_OK if succesful. * ******************************************************************************/ static int DGifBufferedInput(FILE *File, GifByteType *Buf, GifByteType *NextByte) { if (Buf[0] == 0) { /* Needs to read the next buffer - this one is empty: */ if (fread(Buf, 1, 1, File) != 1) { _GifError = D_GIF_ERR_READ_FAILED; return GIF_ERROR; } if (fread(&Buf[1], 1, Buf[0], File) != Buf[0]) { _GifError = D_GIF_ERR_READ_FAILED; return GIF_ERROR; } *NextByte = Buf[1]; Buf[1] = 2; /* We use now the second place as last char read! */ Buf[0]--; } else { *NextByte = Buf[Buf[1]++]; Buf[0]--; } return GIF_OK; } /****************************************************************************** * This routine reads an entire GIF into core, hanging all its state info off * * the GifFileType pointer. Call DGifOpenFileName() or DGifOpenFileHandle() * * first to initialize I/O. Its inverse is EGifSpew(). * ******************************************************************************/ int DGifSlurp(GifFileType *GifFile) { int fakefunction; int i, j, Error, ImageSize; GifRecordType RecordType; SavedImage *sp; ExtensionBlock *ep; GifByteType *ExtData; /* Some versions of malloc dislike 0-length requests */ GifFile->SavedImages = (SavedImage *)malloc(sizeof(SavedImage)); do { if (DGifGetRecordType(GifFile, &RecordType) == GIF_ERROR) return(GIF_ERROR); switch (RecordType) { case IMAGE_DESC_RECORD_TYPE: if (DGifGetImageDesc(GifFile) == GIF_ERROR) return(GIF_ERROR); sp = &GifFile->SavedImages[GifFile->ImageCount-1]; ImageSize = sp->ImageDesc.Width * sp->ImageDesc.Height; sp->RasterBits = (GifPixelType*) malloc(ImageSize * sizeof(GifPixelType)); if (DGifGetLine(GifFile, sp->RasterBits, ImageSize) == GIF_ERROR) return(GIF_ERROR); break; case EXTENSION_RECORD_TYPE: /* There was something wrong with that so, we just skip extensions - UC*/ printf("debug: yes, we found an extension\n"); if (DGifGetExtension(GifFile,&fakefunction,&ExtData)==GIF_ERROR) return(GIF_ERROR); else { while (ExtData != NULL) { if (DGifGetExtensionNext(GifFile, &ExtData) == GIF_ERROR) return(GIF_ERROR); } } break; case TERMINATE_RECORD_TYPE: break; default: /* Should be trapped by DGifGetRecordType */ break; } } while (RecordType != TERMINATE_RECORD_TYPE); return(GIF_OK); } imaptool-0.9.orig/file2pixmap.c0100644000000000000000000001547707040176125015250 0ustar rootroot/* * file2pixmap.c * Copyright (C) 1996-1998 Teemu Maijala - uucee@sci.fi * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include "file2pixmap.h" #include "gif_lib.h" #ifdef USE_JPEG_LIB #include #include #endif /* Filetypes */ typedef int FILETYPE; #define UNKNOWN 0 #define GIF 1 #define JPEG 2 #define TOTAL_NUMBER_OF_FILETYPES 2 char *postfixes[2] = {".gif", ".jpg"}; FILETYPE filetypes[2] = {GIF, JPEG}; typedef unsigned long Pixel; /* function prototypes */ int load_gif_to_pixmap(char *filename, Display *display, int screennum, int *witdh, int *height, Pixmap *pixmap); int load_jpeg_to_pixmap(char *filename, Display *display, int screennum, int *witdh, int *height, Pixmap *pixmap); int gif_errorhandler(); FILETYPE filetype(char *filename); /* function definitions */ int load_file_to_pixmap(char *filename, Display *display, int screennum, int *width, int *height, Pixmap *pixmap) { switch(filetype(filename)) { #ifdef USE_JPEG_LIB case JPEG: return load_jpeg_to_pixmap(filename, display, screennum, width, height, pixmap); break; #endif case GIF: return load_gif_to_pixmap(filename, display, screennum, width, height, pixmap); break; case UNKNOWN: return NOT_VALID_FILETYPE; break; } return NOT_VALID_FILETYPE; } int load_gif_to_pixmap(char *filename, Display *display, int screennum, int *width, int *height, Pixmap *pixmap) { int startline[4] = {0, 4, 2, 1}; int offset[4] = {8, 8, 4, 2}; int x, y, i, group; unsigned char colorvalue; GifFileType *giftype; Pixel *pixels; GC gc; XImage *image; XColor color; if (!(giftype = DGifOpenFileName(filename))) return gif_errorhandler(); if (DGifSlurp(giftype)!=GIF_OK) return gif_errorhandler(); *pixmap = XCreatePixmap(display, RootWindow(display, screennum), giftype->SWidth, giftype->SHeight, DefaultDepth(display, screennum)); image = XGetImage(display, *pixmap, 0,0, giftype->SWidth, giftype->SHeight, AllPlanes, ZPixmap); gc = XCreateGC(display, *pixmap, 0, NULL); pixels = (Pixel*)malloc(sizeof(Pixel)*giftype->SColorMap->ColorCount); for(i=0;iSColorMap->ColorCount;i++) { color.red = giftype->SColorMap->Colors[i].Red*255; color.green = giftype->SColorMap->Colors[i].Green*255; color.blue = giftype->SColorMap->Colors[i].Blue*255; XAllocColor(display, DefaultColormap(display, screennum), &color); pixels[i] = color.pixel; } if (!giftype->Image.Interlace) { for(y=0;ySHeight;y++) { for(x=0;xSWidth;x++) { colorvalue = giftype->SavedImages->RasterBits[y*giftype->SWidth+x]; XPutPixel(image, x, y, pixels[colorvalue]); } } } else { for(group=0,i=0;group<4;group++) { for(y=startline[group];ySHeight;y+=offset[group],i++) { for(x=0;xSWidth;x++) { colorvalue = giftype->SavedImages->RasterBits[i*giftype->SWidth+x]; XPutPixel(image, x, y, pixels[colorvalue]); } } } } *width = giftype->SWidth; *height = giftype->SHeight; XPutImage(display, *pixmap, gc, image, 0, 0, 0, 0, giftype->SWidth, giftype->SHeight); free(pixels); DGifCloseFile(giftype); XDestroyImage(image); return LOADING_OK; } int gif_errorhandler() { PrintGifError(); switch(GifLastError()) { case D_GIF_ERR_OPEN_FAILED: return CANNOT_OPEN_FILE; break; case D_GIF_ERR_READ_FAILED: return CANNOT_READ_FILE; break; case D_GIF_ERR_NOT_GIF_FILE: return NOT_VALID_FILETYPE; break; default: return NOT_VALID_FILETYPE; break; } } #ifdef USE_JPEG_LIB int load_jpeg_to_pixmap(char *filename, Display *display, int screennum, int *width, int *height, Pixmap *pixmap) { FILE *jpegfile; GC gc; JSAMPROW scanline; Pixel *pixels; XColor color; XImage *image; int i, x, y; struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr jerr; unsigned char colorvalue; cinfo.err = jpeg_std_error(&jerr); jpeg_create_decompress(&cinfo); if ((jpegfile = fopen(filename, "rb")) == NULL) return 0; jpeg_stdio_src(&cinfo, jpegfile); jpeg_read_header(&cinfo, TRUE); cinfo.quantize_colors = TRUE; /* colormap wanted */ cinfo.dither_mode = JDITHER_ORDERED; jpeg_start_decompress(&cinfo); *pixmap = XCreatePixmap(display, RootWindow(display, screennum), cinfo.output_width, cinfo.output_height, DefaultDepth(display, screennum)); image = XGetImage(display, *pixmap, 0,0, cinfo.output_width, cinfo.output_height, AllPlanes, ZPixmap); gc = XCreateGC(display, *pixmap, 0, NULL); pixels = (Pixel*)malloc(sizeof(Pixel)*cinfo.actual_number_of_colors); if (cinfo.out_color_components > 1) { for(i=0;i #include "gif_lib.h" #define PROGRAM_NAME "GIF_LIBRARY" int _GifError = 0; #ifdef SYSV static char *VersionStr = "Gif library module,\t\tGershon Elber\n\ (C) Copyright 1989 Gershon Elber, Non commercial use only.\n"; #else static char *VersionStr = PROGRAM_NAME " IBMPC " GIF_LIB_VERSION " Gershon Elber, " __DATE__ ", " __TIME__ "\n" "(C) Copyright 1989 Gershon Elber, Non commercial use only.\n"; #endif /* SYSV */ /***************************************************************************** * Return the last GIF error (0 if none) and reset the error. * *****************************************************************************/ int GifLastError(void) { int i = _GifError; _GifError = 0; return i; } /***************************************************************************** * Print the last GIF error to stderr. * *****************************************************************************/ void PrintGifError(void) { char *Err; switch(_GifError) { case E_GIF_ERR_OPEN_FAILED: Err = "Failed to open given file"; break; case E_GIF_ERR_WRITE_FAILED: Err = "Failed to Write to given file"; break; case E_GIF_ERR_HAS_SCRN_DSCR: Err = "Screen Descriptor already been set"; break; case E_GIF_ERR_HAS_IMAG_DSCR: Err = "Image Descriptor is still active"; break; case E_GIF_ERR_NO_COLOR_MAP: Err = "Neither Global Nor Local color map"; break; case E_GIF_ERR_DATA_TOO_BIG: Err = "#Pixels bigger than Width * Height"; break; case E_GIF_ERR_NOT_ENOUGH_MEM: Err = "Fail to allocate required memory"; break; case E_GIF_ERR_DISK_IS_FULL: Err = "Write failed (disk full?)"; break; case E_GIF_ERR_CLOSE_FAILED: Err = "Failed to close given file"; break; case E_GIF_ERR_NOT_WRITEABLE: Err = "Given file was not opened for write"; break; case D_GIF_ERR_OPEN_FAILED: Err = "Failed to open given file"; break; case D_GIF_ERR_READ_FAILED: Err = "Failed to Read from given file"; break; case D_GIF_ERR_NOT_GIF_FILE: Err = "Given file is NOT GIF file"; break; case D_GIF_ERR_NO_SCRN_DSCR: Err = "No Screen Descriptor detected"; break; case D_GIF_ERR_NO_IMAG_DSCR: Err = "No Image Descriptor detected"; break; case D_GIF_ERR_NO_COLOR_MAP: Err = "Neither Global Nor Local color map"; break; case D_GIF_ERR_WRONG_RECORD: Err = "Wrong record type detected"; break; case D_GIF_ERR_DATA_TOO_BIG: Err = "#Pixels bigger than Width * Height"; break; case D_GIF_ERR_NOT_ENOUGH_MEM: Err = "Fail to allocate required memory"; break; case D_GIF_ERR_CLOSE_FAILED: Err = "Failed to close given file"; break; case D_GIF_ERR_NOT_READABLE: Err = "Given file was not opened for read"; break; case D_GIF_ERR_IMAGE_DEFECT: Err = "Image is defective, decoding aborted"; break; case D_GIF_ERR_EOF_TOO_SOON: Err = "Image EOF detected, before image complete"; break; default: Err = NULL; break; } if (Err != NULL) fprintf(stderr, "\nGIF-LIB error: %s.\n", Err); else fprintf(stderr, "\nGIF-LIB undefined error %d.\n", _GifError); } imaptool-0.9.orig/gif_lib.h0100644000000000000000000002461107040176125014416 0ustar rootroot/****************************************************************************** * In order to make life a little bit easier when using the GIF file format, * * this library was written, and which does all the dirty work... * * * * Written by Gershon Elber, Jun. 1989 * * Hacks by Eric S. Raymond, Sep. 1992 * ******************************************************************************* * History: * * 14 Jun 89 - Version 1.0 by Gershon Elber. * * 3 Sep 90 - Version 1.1 by Gershon Elber (Support for Gif89, Unique names). * * 15 Sep 90 - Version 2.0 by Eric S. Raymond (Changes to suoport GIF slurp) * ******************************************************************************/ #ifndef GIF_LIB_H #define GIF_LIB_H #define GIF_LIB_VERSION " Version 2.0, " #define GIF_ERROR 0 #define GIF_OK 1 #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif #ifndef NULL #define NULL 0 #endif /* NULL */ #define GIF_FILE_BUFFER_SIZE 16384 /* Files uses bigger buffers than usual. */ typedef int GifBooleanType; typedef unsigned char GifPixelType; typedef unsigned char * GifRowType; typedef unsigned char GifByteType; #define GIF_MESSAGE(Msg) fprintf(stderr, "\n%s: %s\n", PROGRAM_NAME, Msg) #define GIF_EXIT(Msg) { GIF_MESSAGE(Msg); exit(-3); } #ifdef SYSV #define VoidPtr char * #else #define VoidPtr void * #endif /* SYSV */ typedef struct GifColorType { GifByteType Red, Green, Blue; } GifColorType; typedef struct ColorMapObject { int ColorCount; int BitsPerPixel; GifColorType *Colors; /* on malloc(3) heap */ } ColorMapObject; typedef struct GifImageDesc { int Left, Top, Width, Height, /* Current image dimensions. */ Interlace; /* Sequential/Interlaced lines. */ ColorMapObject *ColorMap; /* The local color map */ } GifImageDesc; typedef struct GifFileType { int SWidth, SHeight, /* Screen dimensions. */ SColorResolution, /* How many colors can we generate? */ SBackGroundColor; /* I hope you understand this one... */ ColorMapObject *SColorMap; /* NULL if not exists. */ int ImageCount; /* Number of current image */ GifImageDesc Image; /* Block describing current image */ struct SavedImage *SavedImages; /* Use this to accumulate file state */ VoidPtr Private; /* Don't mess with this! */ } GifFileType; typedef enum { UNDEFINED_RECORD_TYPE, SCREEN_DESC_RECORD_TYPE, IMAGE_DESC_RECORD_TYPE, /* Begin with ',' */ EXTENSION_RECORD_TYPE, /* Begin with '!' */ TERMINATE_RECORD_TYPE /* Begin with ';' */ } GifRecordType; /* DumpScreen2Gif routine constants identify type of window/screen to dump. */ /* Note all values below 1000 are reserved for the IBMPC different display */ /* devices (it has many!) and are compatible with the numbering TC2.0 */ /* (Turbo C 2.0 compiler for IBM PC) gives to these devices. */ typedef enum { GIF_DUMP_SGI_WINDOW = 1000, GIF_DUMP_X_WINDOW = 1001 } GifScreenDumpType; /****************************************************************************** * O.K., here are the routines one can access in order to encode GIF file: * * (GIF_LIB file EGIF_LIB.C). * ******************************************************************************/ GifFileType *EGifOpenFileName(char *GifFileName, int GifTestExistance); GifFileType *EGifOpenFileHandle(int GifFileHandle); int EGifSpew(GifFileType *GifFile); void EGifSetGifVersion(char *Version); int EGifPutScreenDesc(GifFileType *GifFile, int GifWidth, int GifHeight, int GifColorRes, int GifBackGround, ColorMapObject *GifColorMap); int EGifPutImageDesc(GifFileType *GifFile, int GifLeft, int GifTop, int Width, int GifHeight, int GifInterlace, ColorMapObject *GifColorMap); int EGifPutLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen); int EGifPutPixel(GifFileType *GifFile, GifPixelType GifPixel); int EGifPutComment(GifFileType *GifFile, char *GifComment); int EGifPutExtension(GifFileType *GifFile, int GifExtCode, int GifExtLen, VoidPtr GifExtension); int EGifPutCode(GifFileType *GifFile, int GifCodeSize, GifByteType *GifCodeBlock); int EGifPutCodeNext(GifFileType *GifFile, GifByteType *GifCodeBlock); int EGifCloseFile(GifFileType *GifFile); #define E_GIF_ERR_OPEN_FAILED 1 /* And EGif possible errors. */ #define E_GIF_ERR_WRITE_FAILED 2 #define E_GIF_ERR_HAS_SCRN_DSCR 3 #define E_GIF_ERR_HAS_IMAG_DSCR 4 #define E_GIF_ERR_NO_COLOR_MAP 5 #define E_GIF_ERR_DATA_TOO_BIG 6 #define E_GIF_ERR_NOT_ENOUGH_MEM 7 #define E_GIF_ERR_DISK_IS_FULL 8 #define E_GIF_ERR_CLOSE_FAILED 9 #define E_GIF_ERR_NOT_WRITEABLE 10 /****************************************************************************** * O.K., here are the routines one can access in order to decode GIF file: * * (GIF_LIB file DGIF_LIB.C). * ******************************************************************************/ GifFileType *DGifOpenFileName(const char *GifFileName); GifFileType *DGifOpenFileHandle(int GifFileHandle); int DGifSlurp(GifFileType *GifFile); int DGifGetScreenDesc(GifFileType *GifFile); int DGifGetRecordType(GifFileType *GifFile, GifRecordType *GifType); int DGifGetImageDesc(GifFileType *GifFile); int DGifGetLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen); int DGifGetPixel(GifFileType *GifFile, GifPixelType GifPixel); int DGifGetComment(GifFileType *GifFile, char *GifComment); int DGifGetExtension(GifFileType *GifFile, int *GifExtCode, GifByteType **GifExtension); int DGifGetExtensionNext(GifFileType *GifFile, GifByteType **GifExtension); int DGifGetCode(GifFileType *GifFile, int *GifCodeSize, GifByteType **GifCodeBlock); int DGifGetCodeNext(GifFileType *GifFile, GifByteType **GifCodeBlock); int DGifGetLZCodes(GifFileType *GifFile, int *GifCode); int DGifCloseFile(GifFileType *GifFile); #define D_GIF_ERR_OPEN_FAILED 101 /* And DGif possible errors. */ #define D_GIF_ERR_READ_FAILED 102 #define D_GIF_ERR_NOT_GIF_FILE 103 #define D_GIF_ERR_NO_SCRN_DSCR 104 #define D_GIF_ERR_NO_IMAG_DSCR 105 #define D_GIF_ERR_NO_COLOR_MAP 106 #define D_GIF_ERR_WRONG_RECORD 107 #define D_GIF_ERR_DATA_TOO_BIG 108 #define D_GIF_ERR_NOT_ENOUGH_MEM 109 #define D_GIF_ERR_CLOSE_FAILED 110 #define D_GIF_ERR_NOT_READABLE 111 #define D_GIF_ERR_IMAGE_DEFECT 112 #define D_GIF_ERR_EOF_TOO_SOON 113 /****************************************************************************** * O.K., here are the routines from GIF_LIB file QUANTIZE.C. * ******************************************************************************/ int QuantizeBuffer(unsigned int Width, unsigned int Height, int *ColorMapSize, GifByteType *RedInput, GifByteType *GreenInput, GifByteType *BlueInput, GifByteType *OutputBuffer, GifColorType *OutputColorMap); /****************************************************************************** * O.K., here are the routines from GIF_LIB file QPRINTF.C. * ******************************************************************************/ extern int GifQuietPrint; #ifdef USE_VARARGS extern void GifQprintf(); #else extern void GifQprintf(char *Format, ...); #endif /* USE_VARARGS */ /****************************************************************************** * O.K., here are the routines from GIF_LIB file GIF_ERR.C. * ******************************************************************************/ extern void PrintGifError(void); extern int GifLastError(void); /****************************************************************************** * O.K., here are the routines from GIF_LIB file DEV2GIF.C. * ******************************************************************************/ extern int DumpScreen2Gif(char *FileName, int ReqGraphDriver, int ReqGraphMode1, int ReqGraphMode2, int ReqGraphMode3); /***************************************************************************** * * Everything below this point is new after version 1.2, supporting `slurp * mode' for doing I/O in two big belts with all the image-bashing in core. * *****************************************************************************/ /****************************************************************************** * Color Map handling from ALLOCGIF.C * ******************************************************************************/ extern ColorMapObject *MakeMapObject(int ColorCount, GifColorType *ColorMap); extern void FreeMapObject(ColorMapObject *Object); extern ColorMapObject *UnionColorMap(ColorMapObject *ColorIn1, ColorMapObject *ColorIn2, GifPixelType ColorTransIn2[]); extern int BitSize(int n); /****************************************************************************** * Support for the in-core structures allocation (slurp mode). * ******************************************************************************/ /* This is the in-core version of an extension record */ typedef struct { int ByteCount; char *Bytes; /* on malloc(3) heap */ } ExtensionBlock; /* This holds an image header, its unpacked raster bits, and extensions */ typedef struct SavedImage { GifImageDesc ImageDesc; char *RasterBits; /* on malloc(3) heap */ int Function; int ExtensionBlockCount; ExtensionBlock *ExtensionBlocks; /* on malloc(3) heap */ } SavedImage; extern void ApplyTranslation(SavedImage *Image, GifPixelType Translation[]); extern void MakeExtension(SavedImage *New, int Function); extern int AddExtensionBlock(SavedImage *New, int Len, char ExtData[]); extern void FreeExtension(SavedImage *Image); extern SavedImage *MakeSavedImage(GifFileType *GifFile, SavedImage *CopyFrom); extern void FreeSavedImages(GifFileType *GifFile); /****************************************************************************** * The library's internal utility font * ******************************************************************************/ #define GIF_FONT_WIDTH 8 #define GIF_FONT_HEIGHT 8 extern unsigned char AsciiTable[][GIF_FONT_WIDTH]; extern void DrawText(SavedImage *Image, const int x, const int y, const char *legend, const int color); extern void DrawBox(SavedImage *Image, const int x, const int y, const int w, const int d, const int color); void DrawRectangle(SavedImage *Image, const int x, const int y, const int w, const int d, const int color); extern void DrawBoxedText(SavedImage *Image, const int x, const int y, const char *legend, const int border, const int bg, const int fg); #endif /* GIF_LIB_H */ imaptool-0.9.orig/gif_hash.h0100644000000000000000000000266007040176125014573 0ustar rootroot/****************************************************************************** * Declarations, global to other of the GIF-HASH.C module. * * * * Written by Gershon Elber, Jun 1989 * ******************************************************************************* * History: * * 14 Jun 89 - Version 1.0 by Gershon Elber. * ******************************************************************************/ #define HT_SIZE 8192 /* 12bits = 4096 or twice as big! */ #define HT_KEY_MASK 0x1FFF /* 13bits keys */ #define HT_KEY_NUM_BITS 13 /* 13bits keys */ #define HT_MAX_KEY 8191 /* 13bits - 1, maximal code possible */ #define HT_MAX_CODE 4095 /* Biggest code possible in 12 bits. */ /* The 32 bits of the long are divided into two parts for the key & code: */ /* 1. The code is 12 bits as our compression algorithm is limited to 12bits */ /* 2. The key is 12 bits Prefix code + 8 bit new char or 20 bits. */ #define HT_GET_KEY(l) (l >> 12) #define HT_GET_CODE(l) (l & 0x0FFF) #define HT_PUT_KEY(l) (l << 12) #define HT_PUT_CODE(l) (l & 0x0FFF) typedef struct GifHashTableType { unsigned long HTable[HT_SIZE]; } GifHashTableType; GifHashTableType *_InitHashTable(void); void _ClearHashTable(GifHashTableType *HashTable); void _InsertHashTable(GifHashTableType *HashTable, unsigned long Key, int Code); int _ExistsHashTable(GifHashTableType *HashTable, unsigned long Key); imaptool-0.9.orig/gifalloc.c0100644000000000000000000002223307040176125014574 0ustar rootroot/***************************************************************************** * "Gif-Lib" - Yet another gif library. * * * * Written by: Gershon Elber Ver 0.1, Jun. 1989 * * Extensively hacked by: Eric S. Raymond Ver 1.?, Sep 1992 * ****************************************************************************** * GIF construction tools * ****************************************************************************** * History: * * 15 Sep 92 - Version 1.0 by Eric Raymond. * *****************************************************************************/ #include #include "gif_lib.h" #define MAX(x, y) (((x) > (y)) ? (x) : (y)) /****************************************************************************** * Miscellaneous utility functions * ******************************************************************************/ int BitSize(int n) /* return smallest bitfield size n will fit in */ { register i; for (i = 1; i <= 8; i++) if ((1 << i) >= n) break; return(i); } /****************************************************************************** * Color map object functions * ******************************************************************************/ ColorMapObject *MakeMapObject(int ColorCount, GifColorType *ColorMap) /* * Allocate a color map of given size; initialize with contents of * ColorMap if that pointer is non-NULL. */ { ColorMapObject *Object; if (ColorCount != (1 << BitSize(ColorCount))) return((ColorMapObject *)NULL); Object = (ColorMapObject *)malloc(sizeof(ColorMapObject)); if (Object == (ColorMapObject *)NULL) return((ColorMapObject *)NULL); Object->Colors = (GifColorType *)calloc(ColorCount, sizeof(GifColorType)); if (Object->Colors == (GifColorType *)NULL) return((ColorMapObject *)NULL); Object->ColorCount = ColorCount; Object->BitsPerPixel = BitSize(ColorCount); if (ColorMap) memcpy((char *)Object->Colors, (char *)ColorMap, ColorCount * sizeof(GifColorType)); return(Object); } void FreeMapObject(ColorMapObject *Object) /* * Free a color map object */ { free(Object->Colors); free(Object); } #ifdef DEBUG void DumpColorMap(ColorMapObject *Object, FILE *fp) { if (Object) { int i, j, Len = Object->ColorCount; for (i = 0; i < Len; i+=4) { for (j = 0; j < 4 && j < Len; j++) { fprintf(fp, "%3d: %02x %02x %02x ", i + j, Object->Colors[i + j].Red, Object->Colors[i + j].Green, Object->Colors[i + j].Blue); } fprintf(fp, "\n"); } } } #endif /* DEBUG */ ColorMapObject *UnionColorMap( ColorMapObject *ColorIn1, ColorMapObject *ColorIn2, GifPixelType ColorTransIn2[]) /* * Compute the union of two given color maps and return it. If result can't * fit into 256 colors, NULL is returned, the allocated union otherwise. * ColorIn1 is copied as it to ColorUnion, while colors from ColorIn2 are * copied iff they didn't exist before. ColorTransIn2 maps the old * ColorIn2 into ColorUnion color map table. */ { int i, j, CrntSlot, RoundUpTo, NewBitSize; ColorMapObject *ColorUnion; /* * Allocate table which will hold the result for sure. */ ColorUnion = MakeMapObject(MAX(ColorIn1->ColorCount,ColorIn2->ColorCount)*2,NULL); if (ColorUnion == NULL) return(NULL); /* Copy ColorIn1 to ColorUnionSize; */ for (i = 0; i < ColorIn1->ColorCount; i++) ColorUnion->Colors[i] = ColorIn1->Colors[i]; CrntSlot = ColorIn1->ColorCount; /* * Potentially obnoxious hack: * * Back CrntSlot down past all contiguous {0, 0, 0} slots at the end * of table 1. This is very useful if your display is limited to * 16 colors. */ while (ColorIn1->Colors[CrntSlot-1].Red == 0 && ColorIn1->Colors[CrntSlot-1].Green == 0 && ColorIn1->Colors[CrntSlot-1].Red == 0) CrntSlot--; /* Copy ColorIn2 to ColorUnionSize (use old colors if they exist): */ for (i = 0; i < ColorIn2->ColorCount && CrntSlot<=256; i++) { /* Let's see if this color already exists: */ for (j = 0; j < ColorIn1->ColorCount; j++) if (memcmp(&ColorIn1->Colors[j], &ColorIn2->Colors[i], sizeof(GifColorType)) == 0) break; if (j < ColorIn1->ColorCount) ColorTransIn2[i] = j; /* color exists in Color1 */ else { /* Color is new - copy it to a new slot: */ ColorUnion->Colors[CrntSlot] = ColorIn2->Colors[i]; ColorTransIn2[i] = CrntSlot++; } } if (CrntSlot > 256) { FreeMapObject(ColorUnion); return((ColorMapObject *)NULL); } NewBitSize = BitSize(CrntSlot); RoundUpTo = (1 << NewBitSize); if (RoundUpTo != ColorUnion->ColorCount) { register GifColorType *Map = ColorUnion->Colors; /* * Zero out slots up to next power of 2. * We know these slots exist because of the way ColorUnion's * start dimension was computed. */ for (j = CrntSlot; j < RoundUpTo; j++) Map[j].Red = Map[j].Green = Map[j].Blue = 0; /* perhaps we can shrink the map? */ if (RoundUpTo < ColorUnion->ColorCount) ColorUnion->Colors = (GifColorType *)realloc(Map, sizeof(GifColorType)*RoundUpTo); } ColorUnion->ColorCount = RoundUpTo; ColorUnion->BitsPerPixel = NewBitSize; return(ColorUnion); } void ApplyTranslation(SavedImage *Image, GifPixelType Translation[]) /* * Apply a given color translation to the raster bits of an image */ { register int i; register int RasterSize = Image->ImageDesc.Height * Image->ImageDesc.Width; for (i = 0; i < RasterSize; i++) Image->RasterBits[i] = Translation[Image->RasterBits[i]]; } /****************************************************************************** * Extension record functions * ******************************************************************************/ void MakeExtension(SavedImage *New, int Function) { New->Function = Function; /* * Someday we might have to deal with multiple extensions. */ } int AddExtensionBlock(SavedImage *New, int Len, char ExtData[]) { ExtensionBlock *ep; if (New->ExtensionBlocks == NULL) New->ExtensionBlocks = (ExtensionBlock *)malloc(sizeof(ExtensionBlock)); else New->ExtensionBlocks = (ExtensionBlock *)realloc(New->ExtensionBlocks, sizeof(ExtensionBlock) * (New->ExtensionBlockCount + 1)); if (New->ExtensionBlocks == NULL) return(GIF_ERROR); ep = &New->ExtensionBlocks[New->ExtensionBlockCount++]; if ((ep->Bytes = (char *)malloc(ep->ByteCount = Len)) == NULL) return(GIF_ERROR); if (ExtData) memcpy(ep->Bytes, ExtData, Len); return(GIF_OK); } void FreeExtension(SavedImage *Image) { ExtensionBlock *ep; for (ep = Image->ExtensionBlocks; ep < Image->ExtensionBlocks + Image->ExtensionBlockCount; ep++) (void) free((char *)ep->Bytes); free((char *)Image->ExtensionBlocks); Image->ExtensionBlocks = NULL; } /****************************************************************************** * Image block allocation functions * ******************************************************************************/ SavedImage *MakeSavedImage(GifFileType *GifFile, SavedImage *CopyFrom) /* * Append an image block to the SavedImages array */ { SavedImage *sp; if (GifFile->SavedImages == NULL) GifFile->SavedImages = (SavedImage *)malloc(sizeof(SavedImage)); else GifFile->SavedImages = (SavedImage *)realloc(GifFile->SavedImages, sizeof(SavedImage) * (GifFile->ImageCount+1)); if (GifFile->SavedImages == NULL) return((SavedImage *)NULL); else { sp = &GifFile->SavedImages[GifFile->ImageCount++]; memset((char *)sp, '\0', sizeof(SavedImage)); if (CopyFrom) { memcpy((char *)sp, CopyFrom, sizeof(SavedImage)); /* * Make our own allocated copies of the heap fields in the * copied record. This guards against potential aliasing * problems. */ /* first, the local color map */ if (sp->ImageDesc.ColorMap) sp->ImageDesc.ColorMap = MakeMapObject(CopyFrom->ImageDesc.ColorMap->ColorCount, CopyFrom->ImageDesc.ColorMap->Colors); /* next, the raster */ sp->RasterBits = (char *)malloc(sizeof(GifPixelType) * CopyFrom->ImageDesc.Height * CopyFrom->ImageDesc.Width); memcpy(sp->RasterBits, CopyFrom->RasterBits, sizeof(GifPixelType) * CopyFrom->ImageDesc.Height * CopyFrom->ImageDesc.Width); /* finally, the extension blocks */ if (sp->ExtensionBlocks) { sp->ExtensionBlocks = (ExtensionBlock*)malloc(sizeof(ExtensionBlock) * CopyFrom->ExtensionBlockCount); memcpy(sp->ExtensionBlocks, CopyFrom->ExtensionBlocks, sizeof(ExtensionBlock) * CopyFrom->ExtensionBlockCount); /* * For the moment, the actual blocks can take their * chances with free(). We'll fix this later. */ } } return(sp); } } void FreeSavedImages(GifFileType *GifFile) { SavedImage *sp; for (sp = GifFile->SavedImages; sp < GifFile->SavedImages + GifFile->ImageCount; sp++) { if (sp->ImageDesc.ColorMap) FreeMapObject(sp->ImageDesc.ColorMap); if (sp->RasterBits) free((char *)sp->RasterBits); if (sp->ExtensionBlocks) FreeExtension(sp); } free((char *) GifFile->SavedImages); } imaptool-0.9.orig/imaptool.c0100644000000000000000000006201207040536330014635 0ustar rootroot/* * imaptool.c * Copyright (C) 2000 Seth Spitzer - sspitzer@sspitzer.org * Copyright (C) 1996-1998 Teemu Maijala - uucee@sci.fi * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "file2pixmap.h" #include "icon" #include "iconmask" #define VERSION "0.9" #define HTMLCOMMENT "\n" #define PROGINFO "imaptool %s\n\n(C) 2000 Seth Spitzer - sspitzer@sspitzer.org\n(C) 1996-1998 Teemu Maijala - uucee@sci.fi\n\nimaptool comes with ABSOLUTELY NO WARRANTY; for details see LICENCE.TXT.\n" #define QUIT_BUTTON_TEXT "Quit" #define DUMP_HTML_BUTTON_TEXT "Dump HTML" #define CLEAR_HTML_BUTTON_TEXT "Clear HTML" #define SHAPE_BUTTON_TEXT "Shape" #define CIRCLE_MENU_ITEM_UNSELECTED " Circle" #define CIRCLE_MENU_ITEM_SELECTED "o Circle" #define RECTANGLE_MENU_ITEM_UNSELECTED " Rectangle" #define RECTANGLE_MENU_ITEM_SELECTED "o Rectangle" #define POLYGON_MENU_ITEM_UNSELECTED " Polygon (use the right mouse button to close the polygon)" #define POLYGON_MENU_ITEM_SELECTED "o Polygon (use the right mouse button to close the polygon)" /* Shapes */ #define RECTANGLE 1 #define CIRCLE 2 #define POLYGON 3 /* Buttonstatus */ #define UP 0 #define DOWN 1 /* Maximum number of breakpoints in polygon */ #define POL_MAX_POINTS 100 /* Maximum number of areas, hard coded for now. */ #define MAX_AREAS 1000 /* the longest HTML line for a map area */ #define MAX_AREA_TEXT_LEN 1124 /* Some macros */ #define min(a,b) (ab)?a:b /* Misc functions */ void createpicturewindow(); void parseparams(int argc, char *argv[]); void printusage(); void printversion(); void changeinfotext(char *infotext); void insert(char *position); void printrectangle(char *str); void printcircle(char *str); void printpolygon(char *str); /* Event handlers for vviewwindow */ void buttondown(Widget w, XtPointer client_data, XEvent *event, Boolean *ctd); void buttonup(Widget w, XtPointer client_data, XEvent *event, Boolean *ctd); void expose(Widget w, XtPointer client_data, XEvent *event, Boolean *ctd); void enterwindow(Widget w, XtPointer client_data, XEvent *event, Boolean *ctd); void leavewindow(Widget w, XtPointer client_data, XEvent *event, Boolean *ctd); void motion(Widget w, XtPointer client_data, XEvent *event, Boolean *ctd); /* Event handler for client_message & selections (for WM_DELETE_WINDOW) */ void event_handler(Widget w, XtPointer client_data, XEvent *event, Boolean *ctd); /* Callback functions */ void quit(Widget w, XtPointer call_data, XtPointer client_data); void dump(Widget w, XtPointer call_data, XtPointer client_data); void clear(Widget w, XtPointer call_data, XtPointer client_data); void shapeselect(Widget w, XtPointer call_data, XtPointer client_data); /* Functions to draw shapes on vviewwindow */ void drawcircle(Widget w); void drawpolygon(Widget w); void drawrectangle(Widget w); void erase_polygon_motionline(Widget w); /* Global variables */ Atom wm_protocols, wm_delete_window; char *picturefilename; /* name of current gif/jpeg-file */ GC defgc; /* GC for LineDoubleDash */ Pixmap pixmap; /* Pixmap for gif/jpeg-file */ Pixmap iconpixmap, iconmask; /* Pixmap for imaptool-icon and -mask*/ int currentarea = 0; char areas[MAX_AREAS][MAX_AREA_TEXT_LEN]; #define QUIT_SAVENOTIFY 1 #define OTHER_SAVENOTIFY 0 struct _pixmasize { int width, height; } pixmapsize; /* size of current pixmap */ int nextshape = RECTANGLE; /* shape selected in shapemenu */ int currentshape = RECTANGLE; /* shape on screen */ struct _rectangle { /* geometry of rectangle */ int x1, y1, x2, y2; } rectangle = {0,0,0,0}; struct _circle { /* geometry of circle */ int x, y, r; } circle = {0,0,0}; struct _polygon_motionline { /* motionline when drawing polygon */ int x, y; Boolean active; } polygon_motionline = {0,0, FALSE}; XPoint polygon[POL_MAX_POINTS]; /* A table containing brakpoints of polygon */ int polcount; /* total abount of breakpoints in polygon */ /* if active is true, drawcircle, drawrectangle and drawpolygon should draw polygon, otherwise they should erase it. Usually the functions are first called width active false and then with active true. */ Boolean active = FALSE; Boolean outputHtmlInLowerCase = FALSE; int buttonstatus; /* status of mousebuttons */ /* Widgets */ Widget root, picturewindow; Widget vform, vmenubox, vbox, vviewwindow, vquit, vinfobox, vdump, vclear; Widget vshapemenu, vshapemenubutton, vrectangle, vcircle, vpolygon; int main(int argc, char *argv[]) { int screennum; XtAppContext app_context; int cursor_shape = XC_tcross; Cursor cursor; XGCValues values; root = XtVaAppInitialize(&app_context, "imaptool", NULL, 0, &argc, argv, NULL, NULL); screennum = XScreenNumberOfScreen(XtScreen(root)); parseparams(argc, argv); /* loading picture to pixmap */ if (!load_file_to_pixmap(picturefilename, XtDisplay(root), screennum, &pixmapsize.width, &pixmapsize.height, &pixmap)) { printusage(); exit(1); } /* creating pixmaps for icon & iconmask */ iconpixmap = XCreatePixmapFromBitmapData(XtDisplay(root), RootWindow(XtDisplay(root), screennum), (char*)icon_bits, icon_width, icon_height, WhitePixel(XtDisplay(root), screennum), BlackPixel(XtDisplay(root), screennum), DefaultDepth(XtDisplay(root), screennum)); iconmask = XCreatePixmapFromBitmapData(XtDisplay(root), RootWindow(XtDisplay(root), screennum), (char*)iconmask_bits, iconmask_width, iconmask_height, WhitePixel(XtDisplay(root), screennum), BlackPixel(XtDisplay(root), screennum), 1); /* creating window widgets */ createpicturewindow(); /* showing windows */ XtPopup(picturewindow, XtGrabNone); cursor = XCreateFontCursor(XtDisplay(vviewwindow), cursor_shape); XDefineCursor(XtDisplay(vviewwindow), XtWindow(vviewwindow), cursor); /* setting up default GC */ values.foreground = WhitePixel(XtDisplay(picturewindow), XScreenNumberOfScreen(XtScreen(picturewindow))); values.background = BlackPixel(XtDisplay(picturewindow), XScreenNumberOfScreen(XtScreen(picturewindow))); values.line_style = LineDoubleDash; defgc = XCreateGC(XtDisplay(picturewindow), XtWindow(picturewindow), (GCForeground|GCBackground|GCLineStyle), &values); XtAddEventHandler(vviewwindow, 0, TRUE, event_handler, (XtPointer)NULL); /* going to main loop */ XtAppMainLoop(app_context); } void createpicturewindow() { Pixel menuboxcolor; picturewindow = XtVaCreatePopupShell("picturewindow", applicationShellWidgetClass, root, XtNtitle, picturefilename, XtNiconName, picturefilename, XtNiconPixmap, iconpixmap, XtNiconMask, iconmask, NULL); vform = XtVaCreateManagedWidget("rootform", formWidgetClass, picturewindow, XtNresizable, TRUE, NULL); vmenubox = XtVaCreateManagedWidget("menubox", boxWidgetClass, vform, XtNborderWidth, 0, XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainLeft, XtNorientation, XtorientHorizontal, XtNresizable, TRUE, NULL); XtVaGetValues(vmenubox, XtNbackground, &menuboxcolor, NULL); vquit = XtVaCreateManagedWidget(QUIT_BUTTON_TEXT, commandWidgetClass, vmenubox, NULL); XtAddCallback(vquit, XtNcallback, quit, (XtPointer)NULL); vdump = XtVaCreateManagedWidget(DUMP_HTML_BUTTON_TEXT, commandWidgetClass, vmenubox, NULL); XtAddCallback(vdump, XtNcallback, dump, (XtPointer)NULL); vclear= XtVaCreateManagedWidget(CLEAR_HTML_BUTTON_TEXT, commandWidgetClass, vmenubox, NULL); XtAddCallback(vclear, XtNcallback, clear, (XtPointer)NULL); vshapemenu = XtVaCreatePopupShell("vshapemenu", simpleMenuWidgetClass, picturewindow, NULL); vshapemenubutton = XtVaCreateManagedWidget("vshapemenubutton", menuButtonWidgetClass, vmenubox, XtNmenuName, "vshapemenu", XtNlabel, SHAPE_BUTTON_TEXT, NULL); vrectangle = XtVaCreateManagedWidget(RECTANGLE_MENU_ITEM_SELECTED, smeBSBObjectClass, vshapemenu, NULL); vcircle = XtVaCreateManagedWidget(CIRCLE_MENU_ITEM_UNSELECTED, smeBSBObjectClass, vshapemenu, NULL); vpolygon = XtVaCreateManagedWidget(POLYGON_MENU_ITEM_UNSELECTED, smeBSBObjectClass, vshapemenu, NULL); XtAddCallback(vrectangle, XtNcallback, shapeselect, (XtPointer)RECTANGLE); XtAddCallback(vcircle, XtNcallback, shapeselect, (XtPointer)CIRCLE); XtAddCallback(vpolygon, XtNcallback, shapeselect, (XtPointer)POLYGON); vinfobox = XtVaCreateManagedWidget("infobox", labelWidgetClass, vmenubox, XtNborderWidth, 0, XtNbackground, menuboxcolor, XtNlabel, " ", XtNresizable, TRUE, NULL); vbox = XtVaCreateManagedWidget("box", boxWidgetClass, vform, XtNfromVert, vmenubox, XtNhSpace, 0, XtNvSpace, 0, XtNtop, XawChainTop, XtNbottom, XawChainTop, XtNleft, XawChainLeft, XtNright, XawChainLeft, NULL); vviewwindow = XtVaCreateManagedWidget("viewwindow", coreWidgetClass, vbox, XtNinternalHeight, 0, XtNinternalWidth, 0, XtNborderWidth, 0, NULL); XtAddEventHandler(vviewwindow, ButtonPressMask, FALSE, buttondown, (XtPointer)NULL); XtAddEventHandler(vviewwindow, ButtonReleaseMask, FALSE, buttonup, (XtPointer)NULL); XtAddEventHandler(vviewwindow, ExposureMask, FALSE, expose, (XtPointer)NULL); XtAddEventHandler(vviewwindow, PointerMotionMask, FALSE, motion, (XtPointer)NULL); XtAddEventHandler(vviewwindow, EnterWindowMask, FALSE, enterwindow, (XtPointer)NULL); XtAddEventHandler(vviewwindow, LeaveWindowMask, FALSE, leavewindow, (XtPointer)NULL); XtVaSetValues(vviewwindow, XtNwidth, pixmapsize.width, XtNheight, pixmapsize.height, NULL); } void parseparams(int argc, char *argv[]) { if (argc < 2) { printusage(); exit(0); } if ((strcmp("-h",argv[1]) == 0) || (strcmp("-help",argv[1]) == 0) || (strcmp("--help",argv[1]) == 0)) { printusage(); exit(0); } if ((strcmp("-v",argv[1]) == 0) || (strcmp("-version",argv[1]) == 0) || (strcmp("--version",argv[1]) == 0)) { printversion(); exit(0); } if ((strcmp("-l",argv[1]) == 0) || (strcmp("-lower",argv[1]) == 0) || (strcmp("--lower",argv[1]) == 0)) { if (argc == 3) { outputHtmlInLowerCase = TRUE; picturefilename = argv[2]; return; } else { printusage(); exit(0); } } if ((strcmp("-u",argv[1]) == 0) || (strcmp("-upper",argv[1]) == 0) || (strcmp("--upper",argv[1]) == 0)) { if (argc == 3) { outputHtmlInLowerCase = FALSE; picturefilename = argv[2]; return; } else { printusage(); exit(0); } } if (argc == 2) { picturefilename = argv[1]; return; } else { printusage(); exit(0); } } void printversion() { printf(PROGINFO,VERSION); } void printusage() { printf("Usage: imaptool [options] file\n"); printf("options:\n"); printf("\t-v\tversion\n"); printf("\t-h\tusage\n"); printf("\t-l\toutput html in lowercase\n"); printf("\t-u\toutput html in uppercase\n"); printf("\n"); printf("file types currently supported JPEG and GIF\n"); printf("\n"); printf("Report bugs to sspitzer@sspitzer.org\n"); } void changeinfotext(char *text) { int width, height; XExposeEvent xeev; char *current_label; XtVaGetValues(vinfobox, XtNlabel, ¤t_label, NULL); if(strcmp(current_label, text)) { xeev.type = Expose; xeev.display = XtDisplay(vinfobox); xeev.window = XtWindow(vinfobox); xeev.x = xeev.y = 0; XtVaGetValues(vinfobox, XtNwidth, &width, XtNheight, &height, NULL); xeev.width = width; xeev.height = height; XtVaSetValues(vinfobox, XtNlabel, text, NULL); (XtClass(vinfobox))->core_class.expose (vinfobox, (XEvent*)&xeev, NULL); } } void buttondown(Widget w, XtPointer client_data, XEvent *event, Boolean *ctd) { active = FALSE; switch(currentshape) { case RECTANGLE: drawrectangle(w); break; case CIRCLE: drawcircle(w); break; case POLYGON: if (nextshape!=POLYGON) drawpolygon(w); break; } switch(nextshape) { case RECTANGLE: currentshape = RECTANGLE; rectangle.x1 = event->xbutton.x; rectangle.y1 = event->xbutton.y; rectangle.x2 = event->xbutton.x; rectangle.y2 = event->xbutton.y; buttonstatus = DOWN; break; case CIRCLE: currentshape = CIRCLE; circle.x = event->xbutton.x; circle.y = event->xbutton.y; circle.r = 0; break; case POLYGON: currentshape = POLYGON; break; } buttonstatus = DOWN; } void incrementcurrentarea() { currentarea++; if (currentarea >= MAX_AREAS) { printf("maximum number of areas reached. overwriting the last area\n"); currentarea = MAX_AREAS-1; } } void buttonup(Widget w, XtPointer client_data, XEvent *event, Boolean *ctd) { int x, y; XSetSelectionOwner(XtDisplay(w), XA_PRIMARY, XtWindow(w), CurrentTime); switch(currentshape) { case RECTANGLE: active = FALSE; drawrectangle(w); rectangle.x2 = event->xbutton.x; rectangle.y2 = event->xbutton.y; active = TRUE; drawrectangle(w); printrectangle(areas[currentarea]); incrementcurrentarea(); break; case CIRCLE: active = FALSE; drawcircle(w); x = circle.x-event->xbutton.x; y = circle.y-event->xbutton.y; circle.r = (int)sqrt(x*x+y*y); active = TRUE; drawcircle(w); printcircle(areas[currentarea]); incrementcurrentarea(); break; case POLYGON: if (event->xbutton.button==1) { if (polcountxbutton.x; polygon[polcount].y = event->xbutton.y; polcount++; } active = TRUE; drawpolygon(w); polygon_motionline.active = TRUE; } else if (event->xbutton.button==2) { /* ignore middle button events */ } else if (event->xbutton.button==3) { active = FALSE; drawpolygon(w); printpolygon(areas[currentarea]); incrementcurrentarea(); if (polygon_motionline.active == TRUE) erase_polygon_motionline(w); polcount = 0; polygon_motionline.active = FALSE; } break; } buttonstatus = UP; } void expose(Widget w, XtPointer client_data, XEvent *event, Boolean *ctd) { XCopyArea(XtDisplay(w), pixmap, XtWindow(w), defgc, event->xexpose.x, event->xexpose.y, event->xexpose.width, event->xexpose.height, event->xexpose.x, event->xexpose.y); switch(currentshape) { case RECTANGLE: drawrectangle(w); break; case CIRCLE: drawcircle(w); break; case POLYGON: drawpolygon(w); break; } } void enterwindow(Widget w, XtPointer client_data, XEvent *event, Boolean *ctd) { if ((currentshape==POLYGON)&&(polygon_motionline.active==TRUE)) { polygon_motionline.x = event->xcrossing.x; polygon_motionline.y = event->xcrossing.y; XDrawLine(XtDisplay(w), XtWindow(w), defgc, polygon[polcount-1].x, polygon[polcount-1].y, polygon_motionline.x, polygon_motionline.y); } } void leavewindow(Widget w, XtPointer client_data, XEvent *event, Boolean *ctd) { if ((currentshape==POLYGON)&&(polygon_motionline.active==TRUE)) { erase_polygon_motionline(w); active = TRUE; drawpolygon(w); } } void motion(Widget w, XtPointer client_data, XEvent *event, Boolean *ctd) { char infotext[80]; int x1, x2, y1, y2; switch(currentshape) { case RECTANGLE: if (buttonstatus==DOWN) { active = FALSE; drawrectangle(w); rectangle.x2 = event->xmotion.x; rectangle.y2 = event->xmotion.y; active = TRUE; drawrectangle(w); } x1 = min(rectangle.x1, rectangle.x2); y1 = min(rectangle.y1, rectangle.y2); x2 = max(rectangle.x1, rectangle.x2); y2 = max(rectangle.y1, rectangle.y2); sprintf(infotext, "%d,%d : %d,%d,%d,%d", event->xmotion.x, event->xmotion.y, x1, y1, x2, y2); changeinfotext(infotext); break; case CIRCLE: if (buttonstatus==DOWN) { active = FALSE; drawcircle(w); circle.r = (int)hypot((circle.x-event->xbutton.x), (circle.y-event->xbutton.y)); active = TRUE; drawcircle(w); } sprintf(infotext, "%d,%d : %d,%d,%d", event->xmotion.x, event->xmotion.y, circle.x, circle.y, circle.r); changeinfotext(infotext); break; case POLYGON: if (polygon_motionline.active == TRUE) { erase_polygon_motionline(w); polygon_motionline.x = event->xmotion.x; polygon_motionline.y = event->xmotion.y; active = TRUE; drawpolygon(w); XDrawLine(XtDisplay(w), XtWindow(w), defgc, polygon_motionline.x, polygon_motionline.y, polygon[polcount-1].x, polygon[polcount-1].y); XFlush(XtDisplay(w)); } sprintf(infotext, "%d,%d : %d,%d - %d,%d", event->xmotion.x, event->xmotion.y, polygon[0].x, polygon[0].y, polygon[polcount-1].x, polygon[polcount-1].y); changeinfotext(infotext); break; } } void event_handler(Widget w, XtPointer client_data, XEvent *event, Boolean *ctd) { if (event->type==SelectionClear) { active = FALSE; switch(currentshape) { case RECTANGLE: drawrectangle(w); break; case CIRCLE: drawcircle(w); break; case POLYGON: drawpolygon(w); polcount = 0; polygon_motionline.active = FALSE; break; } } if (event->type==SelectionRequest) { char position[MAX_AREA_TEXT_LEN]; int i; XEvent sendevent; insert(position); sendevent.type = SelectionNotify; sendevent.xselection.display = XtDisplay(w); sendevent.xselection.requestor = event->xselectionrequest.requestor; sendevent.xselection.selection = event->xselectionrequest.selection; sendevent.xselection.target = event->xselectionrequest.target; sendevent.xselection.property = event->xselectionrequest.property; sendevent.xselection.time = event->xselectionrequest.time; XChangeProperty(XtDisplay(root), event->xselectionrequest.requestor, event->xselectionrequest.property, event->xselectionrequest.target, 8, PropModeReplace, position, strlen(position)); XSendEvent(XtDisplay(root), event->xselectionrequest.requestor, True, 0, &sendevent); XFlush(XtDisplay(root)); } } void printrectangle(char *str) { int x1, x2, y1, y2, i; x1 = min(rectangle.x1, rectangle.x2); y1 = min(rectangle.y1, rectangle.y2); x2 = max(rectangle.x1, rectangle.x2); y2 = max(rectangle.y1, rectangle.y2); if (outputHtmlInLowerCase) { sprintf(str, "", x1, y1, x2, y2); } else { sprintf(str, "", x1, y1, x2, y2); } } void printcircle(char *str) { if (outputHtmlInLowerCase) { sprintf(str, "", circle.x, circle.y, circle.r); } else { sprintf(str, "", circle.x, circle.y, circle.r); } } void printpolygon(char *str) { char temp[255]; int i; if (outputHtmlInLowerCase) { sprintf(str, "1020) break; } if (outputHtmlInLowerCase) { strcpy(str+strlen(str)-1, "\" href=\"\">"); } else { strcpy(str+strlen(str)-1, "\" HREF=\"\">"); } } void insert(char *position) { switch(currentshape) { case RECTANGLE: printrectangle(position); break; case CIRCLE: printcircle(position); break; case POLYGON: printpolygon(position); } } void clear(Widget w, XtPointer client_data, XtPointer call_data) { currentarea = 0; } void dump(Widget w, XtPointer client_data, XtPointer call_data) { int i; /* if the picturefile name is "/tmp/foobar.gif", let the mapname be "foobar.gif" */ char *mapname = NULL; mapname = strrchr(picturefilename,'/'); if (!mapname) { printf("unexpected error\n"); return; } /* skip over the "\" */ mapname++; if (outputHtmlInLowerCase) { printf("\n",mapname); } else { printf("\n",mapname); } for (i=0;i\n"); printf(HTMLCOMMENT,VERSION); printf("\"map-%s\"\n",mapname,mapname,mapname); } else { printf("\n"); printf(HTMLCOMMENT,VERSION); printf("\"map-%s\"\n",mapname,mapname,mapname); } printf("\n\n\n"); } void quit(Widget w, XtPointer client_data, XtPointer call_data) { XtPopdown(picturewindow); XFreePixmap(XtDisplay(root), pixmap); XtDestroyWidget(root); exit(0); } void shapeselect(Widget w, XtPointer call_data, XtPointer client_data) { switch(nextshape) { case RECTANGLE: XtVaSetValues(vrectangle, XtNlabel, RECTANGLE_MENU_ITEM_UNSELECTED, NULL); break; case CIRCLE: XtVaSetValues(vcircle, XtNlabel, CIRCLE_MENU_ITEM_UNSELECTED, NULL); break; case POLYGON: XtVaSetValues(vpolygon, XtNlabel, POLYGON_MENU_ITEM_UNSELECTED, NULL); break; } nextshape = (int)call_data; switch(nextshape) { case RECTANGLE: polygon_motionline.active = FALSE; XtVaSetValues(vrectangle, XtNlabel, RECTANGLE_MENU_ITEM_SELECTED, NULL); break; case CIRCLE: polygon_motionline.active = FALSE; XtVaSetValues(vcircle, XtNlabel, CIRCLE_MENU_ITEM_SELECTED, NULL); break; case POLYGON: if (currentshape != POLYGON) { polcount = 0; polygon_motionline.active = FALSE; } XtVaSetValues(vpolygon, XtNlabel, POLYGON_MENU_ITEM_SELECTED, NULL); break; } } void drawcircle(Widget w) { if (active) { XDrawArc(XtDisplay(w), XtWindow(w), defgc, circle.x-circle.r, circle.y-circle.r, 2*circle.r, 2*circle.r, 0, 360*64); } else { int x, y; x = circle.x-circle.r; y = circle.y-circle.r; if (x<0) x=0; if (y<0) y=0; XCopyArea(XtDisplay(w), pixmap, XtWindow(w), defgc, x, y, 2*circle.r+1, 2*circle.r+1, x, y); } XFlush(XtDisplay(w)); } void drawpolygon(Widget w) { if (active) { XDrawLines(XtDisplay(w), XtWindow(w), defgc, polygon, polcount, CoordModeOrigin); } else { int minx, miny, maxx, maxy, i; minx = miny = maxx = maxy = 0; for (i=0;imaxx) maxx = polygon[i].x; if (polygon[i].y>maxy) maxy = polygon[i].y; } XCopyArea(XtDisplay(w), pixmap, XtWindow(w), defgc, minx, miny, maxx-minx+1, maxy-miny+1, minx, miny); } XFlush(XtDisplay(w)); } void drawrectangle(Widget w) { int x1, x2, y1, y2; x1 = min(rectangle.x1, rectangle.x2); y1 = min(rectangle.y1, rectangle.y2); x2 = max(rectangle.x1, rectangle.x2); y2 = max(rectangle.y1, rectangle.y2); if (active) { XDrawRectangle(XtDisplay(w), XtWindow(w), defgc, x1, y1, x2-x1, y2-y1); } else { GC gc; gc = XCreateGC(XtDisplay(w), XtWindow(w), 0, NULL); if (x1<0) x1=0; if (y1<0) y1=0; XCopyArea(XtDisplay(w), pixmap, XtWindow(w), gc, x1, y1, x2-x1+1, y2-y1+1, x1, y1); XFreeGC(XtDisplay(w), gc); } XFlush(XtDisplay(w)); } void erase_polygon_motionline(Widget w) { int x1, y1, x2, y2; x1 = min(polygon[polcount-1].x, polygon_motionline.x); y1 = min(polygon[polcount-1].y, polygon_motionline.y); x2 = max(polygon[polcount-1].x, polygon_motionline.x); y2 = max(polygon[polcount-1].y, polygon_motionline.y); XCopyArea(XtDisplay(w), pixmap, XtWindow(w), defgc, x1, y1, x2-x1+1, y2-y1+1, x1, y1); XFlush(XtDisplay(w)); } imaptool-0.9.orig/LICENCE.TXT0100644000000000000000000004312007040460752014313 0ustar rootroot GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. imaptool-0.9.orig/icon0100644000000000000000000000632407040176125013526 0ustar rootroot#define icon_width 64 #define icon_height 64 static unsigned char icon_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x80, 0x07, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x80, 0x1d, 0x00, 0xe0, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x79, 0x00, 0x60, 0x0a, 0x00, 0x08, 0x00, 0x00, 0xe3, 0x01, 0x00, 0x0a, 0x00, 0x0c, 0x0c, 0x00, 0x83, 0x06, 0x00, 0x06, 0x00, 0x0c, 0x0c, 0x00, 0x03, 0x1b, 0x00, 0x46, 0x00, 0x0e, 0x14, 0x00, 0x03, 0x2c, 0x00, 0xc6, 0x00, 0x0a, 0x16, 0x00, 0x03, 0x30, 0x00, 0xc6, 0x01, 0x0b, 0x36, 0x00, 0x03, 0x1c, 0x00, 0xc5, 0x02, 0x09, 0x22, 0x00, 0x02, 0x07, 0x00, 0x85, 0x86, 0x08, 0x22, 0x00, 0xc2, 0x01, 0x00, 0x85, 0x85, 0x08, 0x63, 0x00, 0x7e, 0x00, 0x00, 0x85, 0x49, 0x0c, 0x41, 0x00, 0x16, 0x00, 0x00, 0x83, 0x51, 0x04, 0x41, 0x80, 0x0f, 0x00, 0x00, 0x83, 0x31, 0x04, 0xe1, 0x00, 0x07, 0x00, 0x00, 0x83, 0x21, 0x84, 0xdf, 0x80, 0x04, 0x00, 0x80, 0x82, 0x01, 0x84, 0xbd, 0x01, 0x04, 0x00, 0x80, 0x82, 0x01, 0x84, 0x83, 0x01, 0x04, 0x00, 0x80, 0x02, 0x01, 0xc4, 0x00, 0x01, 0x04, 0x00, 0x80, 0x02, 0x03, 0xc4, 0x00, 0x03, 0x04, 0x00, 0x80, 0x02, 0x03, 0x44, 0x00, 0x03, 0x0c, 0x00, 0x80, 0x09, 0x03, 0x64, 0x00, 0x46, 0x0c, 0x00, 0x40, 0x15, 0x23, 0x64, 0x00, 0xc6, 0x08, 0x00, 0x40, 0x0f, 0x50, 0x00, 0x10, 0x80, 0x0b, 0x00, 0xc0, 0x03, 0x28, 0x00, 0x20, 0x00, 0x0f, 0x00, 0xc0, 0x01, 0x14, 0x00, 0x20, 0x00, 0x0c, 0x00, 0x60, 0x00, 0x0c, 0x00, 0x60, 0x00, 0x38, 0x00, 0x28, 0x00, 0x06, 0x00, 0x60, 0x00, 0x70, 0x00, 0x08, 0x00, 0x03, 0x00, 0x60, 0x00, 0x40, 0x00, 0x00, 0x80, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x01, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x58, 0x01, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x01, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x80, 0xc1, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x40, 0xc1, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0xa0, 0xa0, 0xc0, 0x00, 0x03, 0x03, 0x00, 0x00, 0x40, 0xa0, 0xa0, 0x01, 0x07, 0x03, 0x00, 0x00, 0x20, 0xa0, 0x60, 0x81, 0x0d, 0x03, 0x00, 0x00, 0x00, 0xa0, 0x50, 0x82, 0x19, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x50, 0xc2, 0x30, 0x02, 0x00, 0x00, 0x00, 0x60, 0x28, 0xc6, 0x50, 0x06, 0x00, 0x00, 0x00, 0x50, 0x18, 0x44, 0xa0, 0x06, 0x00, 0x00, 0x00, 0x50, 0x14, 0x4c, 0xc0, 0x06, 0x40, 0x00, 0x00, 0x50, 0x0c, 0x86, 0x60, 0x0c, 0xb0, 0x00, 0x00, 0x50, 0x18, 0x86, 0x20, 0x0c, 0x6c, 0x00, 0x00, 0x50, 0x18, 0x83, 0x11, 0x0c, 0x1b, 0x00, 0x00, 0x50, 0x30, 0x83, 0x09, 0xcc, 0x06, 0x00, 0x00, 0x28, 0xb0, 0x01, 0x05, 0xb8, 0x01, 0x00, 0x00, 0x28, 0xd0, 0x01, 0x07, 0x78, 0x00, 0x00, 0x00, 0x28, 0xe0, 0x00, 0x03, 0x18, 0x00, 0x00, 0x00, 0x20, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; imaptool-0.9.orig/iconmask0100644000000000000000000000634007040176125014400 0ustar rootroot#define iconmask_width 64 #define iconmask_height 64 static unsigned char iconmask_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6c, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xde, 0x00, 0x00, 0x00, 0x80, 0x07, 0x00, 0x80, 0xbf, 0x01, 0x00, 0x00, 0x80, 0x1f, 0x00, 0xe0, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0xe0, 0x3f, 0x00, 0x08, 0x00, 0x00, 0xf7, 0x01, 0xc0, 0x3f, 0x00, 0x1c, 0x0c, 0x00, 0xe7, 0x07, 0x80, 0x3f, 0x00, 0x3c, 0x1c, 0x00, 0x8f, 0x1f, 0x00, 0x6e, 0x00, 0x3e, 0x3c, 0x00, 0x0f, 0x3e, 0x00, 0xde, 0x00, 0x3e, 0x3e, 0x00, 0x0f, 0x7c, 0x00, 0xde, 0x01, 0x3f, 0x7e, 0x00, 0x0f, 0xfc, 0x00, 0xdd, 0x03, 0x3f, 0x7e, 0x00, 0x0e, 0xff, 0x00, 0x9f, 0x87, 0x3e, 0xfe, 0x00, 0xce, 0x7f, 0x00, 0x9f, 0x8f, 0x3d, 0xef, 0x00, 0xfe, 0x1f, 0x00, 0x9f, 0x5b, 0x3f, 0xcf, 0x00, 0xfe, 0x07, 0x00, 0x9f, 0xd7, 0x3e, 0xcf, 0x81, 0xff, 0x01, 0x00, 0x97, 0xb7, 0x3d, 0xe7, 0x01, 0x5f, 0x00, 0x00, 0x8f, 0x67, 0x9d, 0xdf, 0x81, 0x3e, 0x00, 0x80, 0x8e, 0xc7, 0x9c, 0xbf, 0x03, 0x1d, 0x00, 0x80, 0x8f, 0x87, 0x9c, 0xff, 0x03, 0x1e, 0x00, 0x80, 0x0f, 0x07, 0xdc, 0xf7, 0x07, 0x1c, 0x00, 0x80, 0x0f, 0x07, 0xdc, 0x0f, 0x07, 0x1c, 0x00, 0x80, 0x0f, 0x07, 0xdc, 0x03, 0x07, 0x1c, 0x00, 0x80, 0x0f, 0x0f, 0xfc, 0x03, 0x4e, 0x1c, 0x00, 0x40, 0x1f, 0x2f, 0xfc, 0x01, 0xce, 0x38, 0x00, 0xc0, 0x2f, 0x5e, 0xd8, 0x11, 0x9c, 0x3b, 0x00, 0xc0, 0x5f, 0xac, 0x90, 0x21, 0x18, 0x3f, 0x00, 0xc0, 0x3f, 0x54, 0x01, 0x60, 0x00, 0x3e, 0x00, 0xe0, 0x0f, 0xac, 0x00, 0xe0, 0x00, 0x3c, 0x00, 0xe8, 0x07, 0x5e, 0x00, 0xe0, 0x00, 0x70, 0x00, 0xd8, 0x01, 0x3f, 0x00, 0xe0, 0x01, 0xe0, 0x00, 0xb0, 0x80, 0x1f, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0x20, 0xc0, 0x0f, 0x00, 0xc0, 0x01, 0x00, 0x01, 0x00, 0xe0, 0x07, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x00, 0xf0, 0x07, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x07, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x80, 0x03, 0x00, 0x00, 0x00, 0xff, 0x05, 0x00, 0x80, 0x07, 0x00, 0x00, 0x80, 0xdf, 0x03, 0x00, 0x80, 0x07, 0x00, 0x00, 0x40, 0xcf, 0x03, 0x00, 0x00, 0x07, 0x00, 0x00, 0xa0, 0xa6, 0xc3, 0x00, 0x03, 0x07, 0x00, 0x00, 0x40, 0xe5, 0xa3, 0x01, 0x07, 0x0f, 0x00, 0x00, 0xa0, 0xe2, 0x63, 0x83, 0x0f, 0x0f, 0x00, 0x00, 0x40, 0xe1, 0xd3, 0x86, 0x1f, 0x0e, 0x00, 0x00, 0x80, 0xe0, 0xf3, 0xc7, 0x37, 0x0e, 0x00, 0x00, 0x00, 0xe0, 0xeb, 0xcf, 0x77, 0x0e, 0x00, 0x00, 0x00, 0xd0, 0x5a, 0xcd, 0xe3, 0x0e, 0x00, 0x00, 0x00, 0xf0, 0xb5, 0xdc, 0xc3, 0x1f, 0x40, 0x00, 0x00, 0xf0, 0x6d, 0x9e, 0xe1, 0x1f, 0xb0, 0x00, 0x00, 0xf0, 0x59, 0xbe, 0xe1, 0x1f, 0x6c, 0x01, 0x00, 0xf0, 0x39, 0x9f, 0xd3, 0x3d, 0xdb, 0x02, 0x00, 0xf0, 0x71, 0x9f, 0xab, 0xfc, 0xb6, 0x01, 0x00, 0xe8, 0xf1, 0x0f, 0x57, 0xb8, 0x6d, 0x00, 0x00, 0x78, 0xf1, 0x0f, 0x2f, 0x78, 0x1b, 0x00, 0x00, 0xf8, 0xe0, 0x07, 0x1f, 0xf8, 0x06, 0x00, 0x00, 0xf0, 0xe0, 0x07, 0x1e, 0xf0, 0x01, 0x00, 0x00, 0xe0, 0xc0, 0x03, 0x0c, 0x60, 0x00, 0x00, 0x00, 0x80, 0x80, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; imaptool-0.9.orig/imaptool.man0100644000000000000000000000243207040176125015170 0ustar rootroot.TH IMAPTOOL 1x .\" NAME should be all caps, SECTION should be 1-8, maybe w/ subsection .\" other parms are allowed: see man(7), man(1) .SH NAME imaptool \- tool for creating client-side image maps .SH SYNOPSIS .B imaptool .I "<.gif|.jpeg file>" .br .SH "DESCRIPTION" This manual page documents briefly the .BR imaptool command. This manual page was written for the Debian GNU/Linux distribution because the original program does not have a manual page. .PP .B imaptool is a tool that helps in the creation of client-side image maps. .PP For more information on client-side image maps refer see - http://home.netscape.com/assist/net_sites/html_extensions_3.html .PP .B imaptool is pretty easy to use. .PP Invoke .B imaptool on a .gif or .jpeg image. Click on 'Shape' and choose a shape (Available shapes - Rectangle, Circle and Polygon). Click on the image and drag the mouse to enclose the required area. The HTML tag for this client-side image map area is now in your X buffer. .PP Once you have enclosed the required area, change to your favorite editor (running in another window) and click Button 2 to paste the client-side image map tag. .PP .SH AUTHOR This manual page was written by Sudhakar Chandrasekharan , for the Debian GNU/Linux system (but may be used by others).