removed libxpm
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14355 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
339
src/xpm/Attrib.c
339
src/xpm/Attrib.c
@@ -1,339 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* Attrib.c: *
|
||||
* *
|
||||
* XPM library *
|
||||
* Functions related to the XpmAttributes structure *
|
||||
* *
|
||||
* Developed by Arnaud Le Hors *
|
||||
\*****************************************************************************/
|
||||
|
||||
#include "XpmI.h"
|
||||
|
||||
/* 3.2 backward compatibility code */
|
||||
LFUNC(CreateOldColorTable, int, (XpmColor *ct, int ncolors,
|
||||
XpmColor ***oldct));
|
||||
|
||||
LFUNC(FreeOldColorTable, void, (XpmColor **colorTable, int ncolors));
|
||||
|
||||
/*
|
||||
* Create a colortable compatible with the old style colortable
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static int
|
||||
CreateOldColorTable(XpmColor* ct, int ncolors, XpmColor*** oldct)
|
||||
#else
|
||||
static int
|
||||
CreateOldColorTable(ct, ncolors, oldct)
|
||||
XpmColor *ct;
|
||||
int ncolors;
|
||||
XpmColor ***oldct;
|
||||
#endif
|
||||
{
|
||||
XpmColor **colorTable, **color;
|
||||
int a;
|
||||
|
||||
colorTable = (XpmColor **) XpmMalloc(ncolors * sizeof(XpmColor *));
|
||||
if (!colorTable) {
|
||||
*oldct = NULL;
|
||||
return (XpmNoMemory);
|
||||
}
|
||||
for (a = 0, color = colorTable; a < ncolors; a++, color++, ct++)
|
||||
*color = ct;
|
||||
*oldct = colorTable;
|
||||
return (XpmSuccess);
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static void FreeOldColorTable(XpmColor** colorTable, int ncolors)
|
||||
#else
|
||||
static void
|
||||
FreeOldColorTable(colorTable, ncolors)
|
||||
XpmColor **colorTable;
|
||||
int ncolors;
|
||||
#endif
|
||||
{
|
||||
int a, b;
|
||||
XpmColor **color;
|
||||
char **sptr;
|
||||
|
||||
if (colorTable) {
|
||||
for (a = 0, color = colorTable; a < ncolors; a++, color++) {
|
||||
for (b = 0, sptr = (char **) *color; b <= NKEYS; b++, sptr++)
|
||||
if (*sptr)
|
||||
XpmFree(*sptr);
|
||||
}
|
||||
XpmFree(*colorTable);
|
||||
XpmFree(colorTable);
|
||||
}
|
||||
}
|
||||
|
||||
/* end 3.2 bc */
|
||||
|
||||
/*
|
||||
* Free the computed color table
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
void xpmFreeColorTable(XpmColor* colorTable, int ncolors)
|
||||
#else
|
||||
void
|
||||
xpmFreeColorTable(colorTable, ncolors)
|
||||
XpmColor *colorTable;
|
||||
int ncolors;
|
||||
#endif
|
||||
{
|
||||
int a, b;
|
||||
XpmColor *color;
|
||||
char **sptr;
|
||||
|
||||
if (colorTable) {
|
||||
for (a = 0, color = colorTable; a < ncolors; a++, color++) {
|
||||
for (b = 0, sptr = (char **) color; b <= NKEYS; b++, sptr++)
|
||||
if (*sptr)
|
||||
XpmFree(*sptr);
|
||||
}
|
||||
XpmFree(colorTable);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Free array of extensions
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
void XpmFreeExtensions(XpmExtension* extensions, int nextensions)
|
||||
#else
|
||||
void
|
||||
XpmFreeExtensions(extensions, nextensions)
|
||||
XpmExtension *extensions;
|
||||
int nextensions;
|
||||
#endif
|
||||
{
|
||||
unsigned int i, j, nlines;
|
||||
XpmExtension *ext;
|
||||
char **sptr;
|
||||
|
||||
if (extensions) {
|
||||
for (i = 0, ext = extensions; i < (unsigned)nextensions; i++, ext++) {
|
||||
if (ext->name)
|
||||
XpmFree(ext->name);
|
||||
nlines = ext->nlines;
|
||||
for (j = 0, sptr = ext->lines; j < nlines; j++, sptr++)
|
||||
if (*sptr)
|
||||
XpmFree(*sptr);
|
||||
if (ext->lines)
|
||||
XpmFree(ext->lines);
|
||||
}
|
||||
XpmFree(extensions);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the XpmAttributes structure size
|
||||
*/
|
||||
|
||||
int
|
||||
XpmAttributesSize()
|
||||
{
|
||||
return sizeof(XpmAttributes);
|
||||
}
|
||||
|
||||
/*
|
||||
* Init returned data to free safely later on
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
void
|
||||
xpmInitAttributes(XpmAttributes* attributes)
|
||||
#else
|
||||
void
|
||||
xpmInitAttributes(attributes)
|
||||
XpmAttributes *attributes;
|
||||
#endif
|
||||
{
|
||||
if (attributes) {
|
||||
attributes->pixels = NULL;
|
||||
attributes->npixels = 0;
|
||||
attributes->colorTable = NULL;
|
||||
attributes->ncolors = 0;
|
||||
/* 3.2 backward compatibility code */
|
||||
attributes->hints_cmt = NULL;
|
||||
attributes->colors_cmt = NULL;
|
||||
attributes->pixels_cmt = NULL;
|
||||
/* end 3.2 bc */
|
||||
if (attributes->valuemask & XpmReturnExtensions) {
|
||||
attributes->extensions = NULL;
|
||||
attributes->nextensions = 0;
|
||||
}
|
||||
if (attributes->valuemask & XpmReturnAllocPixels) {
|
||||
attributes->alloc_pixels = NULL;
|
||||
attributes->nalloc_pixels = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Fill in the XpmAttributes with the XpmImage and the XpmInfo
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
void xpmSetAttributes(XpmAttributes* attributes, XpmImage* image, XpmInfo* info)
|
||||
#else
|
||||
void
|
||||
xpmSetAttributes(attributes, image, info)
|
||||
XpmAttributes *attributes;
|
||||
XpmImage *image;
|
||||
XpmInfo *info;
|
||||
#endif
|
||||
{
|
||||
if (attributes->valuemask & XpmReturnColorTable) {
|
||||
attributes->colorTable = image->colorTable;
|
||||
attributes->ncolors = image->ncolors;
|
||||
|
||||
/* avoid deletion of copied data */
|
||||
image->ncolors = 0;
|
||||
image->colorTable = NULL;
|
||||
}
|
||||
/* 3.2 backward compatibility code */
|
||||
else if (attributes->valuemask & XpmReturnInfos) {
|
||||
int ErrorStatus;
|
||||
|
||||
ErrorStatus = CreateOldColorTable(image->colorTable, image->ncolors,
|
||||
(XpmColor ***)
|
||||
&attributes->colorTable);
|
||||
|
||||
/* if error just say we can't return requested data */
|
||||
if (ErrorStatus != XpmSuccess) {
|
||||
attributes->valuemask &= ~XpmReturnInfos;
|
||||
if (!(attributes->valuemask & XpmReturnPixels)) {
|
||||
XpmFree(attributes->pixels);
|
||||
attributes->pixels = NULL;
|
||||
attributes->npixels = 0;
|
||||
}
|
||||
attributes->ncolors = 0;
|
||||
} else {
|
||||
attributes->ncolors = image->ncolors;
|
||||
attributes->hints_cmt = info->hints_cmt;
|
||||
attributes->colors_cmt = info->colors_cmt;
|
||||
attributes->pixels_cmt = info->pixels_cmt;
|
||||
|
||||
/* avoid deletion of copied data */
|
||||
image->ncolors = 0;
|
||||
image->colorTable = NULL;
|
||||
info->hints_cmt = NULL;
|
||||
info->colors_cmt = NULL;
|
||||
info->pixels_cmt = NULL;
|
||||
}
|
||||
}
|
||||
/* end 3.2 bc */
|
||||
if (attributes->valuemask & XpmReturnExtensions) {
|
||||
attributes->extensions = info->extensions;
|
||||
attributes->nextensions = info->nextensions;
|
||||
|
||||
/* avoid deletion of copied data */
|
||||
info->extensions = NULL;
|
||||
info->nextensions = 0;
|
||||
}
|
||||
if (info->valuemask & XpmHotspot) {
|
||||
attributes->valuemask |= XpmHotspot;
|
||||
attributes->x_hotspot = info->x_hotspot;
|
||||
attributes->y_hotspot = info->y_hotspot;
|
||||
}
|
||||
attributes->valuemask |= XpmCharsPerPixel;
|
||||
attributes->cpp = image->cpp;
|
||||
attributes->valuemask |= XpmSize;
|
||||
attributes->width = image->width;
|
||||
attributes->height = image->height;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the XpmAttributes structure members
|
||||
* but the structure itself
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
void XpmFreeAttributes(XpmAttributes* attributes)
|
||||
#else
|
||||
void
|
||||
XpmFreeAttributes(attributes)
|
||||
XpmAttributes *attributes;
|
||||
#endif
|
||||
{
|
||||
if (attributes->valuemask & XpmReturnPixels && attributes->npixels) {
|
||||
XpmFree(attributes->pixels);
|
||||
attributes->pixels = NULL;
|
||||
attributes->npixels = 0;
|
||||
}
|
||||
if (attributes->valuemask & XpmReturnColorTable) {
|
||||
xpmFreeColorTable(attributes->colorTable, attributes->ncolors);
|
||||
attributes->colorTable = NULL;
|
||||
attributes->ncolors = 0;
|
||||
}
|
||||
/* 3.2 backward compatibility code */
|
||||
else if (attributes->valuemask & XpmInfos) {
|
||||
if (attributes->colorTable) {
|
||||
FreeOldColorTable((XpmColor **) attributes->colorTable,
|
||||
attributes->ncolors);
|
||||
attributes->colorTable = NULL;
|
||||
attributes->ncolors = 0;
|
||||
}
|
||||
if (attributes->hints_cmt) {
|
||||
XpmFree(attributes->hints_cmt);
|
||||
attributes->hints_cmt = NULL;
|
||||
}
|
||||
if (attributes->colors_cmt) {
|
||||
XpmFree(attributes->colors_cmt);
|
||||
attributes->colors_cmt = NULL;
|
||||
}
|
||||
if (attributes->pixels_cmt) {
|
||||
XpmFree(attributes->pixels_cmt);
|
||||
attributes->pixels_cmt = NULL;
|
||||
}
|
||||
if (attributes->pixels) {
|
||||
XpmFree(attributes->pixels);
|
||||
attributes->pixels = NULL;
|
||||
attributes->npixels = 0;
|
||||
}
|
||||
}
|
||||
/* end 3.2 bc */
|
||||
if (attributes->valuemask & XpmReturnExtensions
|
||||
&& attributes->nextensions) {
|
||||
XpmFreeExtensions(attributes->extensions, attributes->nextensions);
|
||||
attributes->extensions = NULL;
|
||||
attributes->nextensions = 0;
|
||||
}
|
||||
if (attributes->valuemask & XpmReturnAllocPixels
|
||||
&& attributes->nalloc_pixels) {
|
||||
XpmFree(attributes->alloc_pixels);
|
||||
attributes->alloc_pixels = NULL;
|
||||
attributes->nalloc_pixels = 0;
|
||||
}
|
||||
attributes->valuemask = 0;
|
||||
}
|
@@ -1,461 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* CrBufFrI.c: *
|
||||
* *
|
||||
* XPM library *
|
||||
* Scan an image and possibly its mask and create an XPM buffer *
|
||||
* *
|
||||
* Developed by Arnaud Le Hors *
|
||||
\*****************************************************************************/
|
||||
|
||||
#include "XpmI.h"
|
||||
|
||||
LFUNC(WriteColors, int, (char **dataptr, unsigned int *data_size,
|
||||
unsigned int *used_size, XpmColor *colors,
|
||||
unsigned int ncolors, unsigned int cpp));
|
||||
|
||||
LFUNC(WritePixels, void, (char *dataptr, unsigned int *used_size,
|
||||
unsigned int width, unsigned int height,
|
||||
unsigned int cpp, unsigned int *pixels,
|
||||
XpmColor *colors));
|
||||
|
||||
LFUNC(WriteExtensions, void, (char *dataptr, unsigned int *used_size,
|
||||
XpmExtension *ext, unsigned int num));
|
||||
|
||||
LFUNC(ExtensionsSize, int, (XpmExtension *ext, unsigned int num));
|
||||
LFUNC(CommentsSize, int, (XpmInfo *info));
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int XpmCreateBufferFromImage(
|
||||
Display* display
|
||||
, char** buffer_return
|
||||
, XImage* image
|
||||
, XImage* shapeimage
|
||||
, XpmAttributes* attributes
|
||||
)
|
||||
#else
|
||||
int
|
||||
XpmCreateBufferFromImage(display, buffer_return, image, shapeimage, attributes)
|
||||
Display *display;
|
||||
char **buffer_return;
|
||||
XImage *image;
|
||||
XImage *shapeimage;
|
||||
XpmAttributes *attributes;
|
||||
#endif
|
||||
{
|
||||
XpmImage xpmimage;
|
||||
XpmInfo info;
|
||||
int ErrorStatus;
|
||||
|
||||
/* initialize return value */
|
||||
if (buffer_return)
|
||||
*buffer_return = NULL;
|
||||
|
||||
/* create an XpmImage from the image */
|
||||
ErrorStatus = XpmCreateXpmImageFromImage(display, image, shapeimage,
|
||||
&xpmimage, attributes);
|
||||
if (ErrorStatus != XpmSuccess)
|
||||
return (ErrorStatus);
|
||||
|
||||
/* create the buffer from the XpmImage */
|
||||
if (attributes) {
|
||||
xpmSetInfo(&info, attributes);
|
||||
ErrorStatus =
|
||||
XpmCreateBufferFromXpmImage(buffer_return, &xpmimage, &info);
|
||||
} else
|
||||
ErrorStatus =
|
||||
XpmCreateBufferFromXpmImage(buffer_return, &xpmimage, NULL);
|
||||
|
||||
/* free the XpmImage */
|
||||
XpmFreeXpmImage(&xpmimage);
|
||||
|
||||
return (ErrorStatus);
|
||||
}
|
||||
|
||||
|
||||
#undef RETURN
|
||||
#define RETURN(status) \
|
||||
{ \
|
||||
ErrorStatus = status; \
|
||||
goto error; \
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int XpmCreateBufferFromXpmImage(char** buffer_return, XpmImage* image, XpmInfo* info)
|
||||
#else
|
||||
int
|
||||
XpmCreateBufferFromXpmImage(buffer_return, image, info)
|
||||
char **buffer_return;
|
||||
XpmImage *image;
|
||||
XpmInfo *info;
|
||||
#endif
|
||||
{
|
||||
/* calculation variables */
|
||||
int ErrorStatus;
|
||||
char buf[BUFSIZ];
|
||||
unsigned int cmts, extensions, ext_size = 0;
|
||||
unsigned int l, cmt_size = 0;
|
||||
char *ptr = NULL, *p;
|
||||
unsigned int ptr_size, used_size;
|
||||
|
||||
*buffer_return = NULL;
|
||||
|
||||
cmts = info && (info->valuemask & XpmComments);
|
||||
extensions = info && (info->valuemask & XpmExtensions)
|
||||
&& info->nextensions;
|
||||
|
||||
/* compute the extensions and comments size */
|
||||
if (extensions)
|
||||
ext_size = ExtensionsSize(info->extensions, info->nextensions);
|
||||
if (cmts)
|
||||
cmt_size = CommentsSize(info);
|
||||
|
||||
/* write the header line */
|
||||
#ifndef VOID_SPRINTF
|
||||
used_size =
|
||||
#endif
|
||||
sprintf(buf, "/* XPM */\nstatic char * image_name[] = {\n");
|
||||
#ifdef VOID_SPRINTF
|
||||
used_size = strlen(buf);
|
||||
#endif
|
||||
ptr_size = used_size + ext_size + cmt_size + 1;
|
||||
ptr = (char *) XpmMalloc(ptr_size);
|
||||
if (!ptr)
|
||||
return XpmNoMemory;
|
||||
strcpy(ptr, buf);
|
||||
|
||||
/* write the values line */
|
||||
if (cmts && info->hints_cmt) {
|
||||
#ifndef VOID_SPRINTF
|
||||
used_size +=
|
||||
#endif
|
||||
sprintf(ptr + used_size, "/*%s*/\n", info->hints_cmt);
|
||||
#ifdef VOID_SPRINTF
|
||||
used_size += strlen(info->hints_cmt) + 5;
|
||||
#endif
|
||||
}
|
||||
#ifndef VOID_SPRINTF
|
||||
l =
|
||||
#endif
|
||||
sprintf(buf, "\"%d %d %d %d", image->width, image->height,
|
||||
image->ncolors, image->cpp);
|
||||
#ifdef VOID_SPRINTF
|
||||
l = strlen(buf);
|
||||
#endif
|
||||
|
||||
if (info && (info->valuemask & XpmHotspot)) {
|
||||
#ifndef VOID_SPRINTF
|
||||
l +=
|
||||
#endif
|
||||
sprintf(buf + l, " %d %d", info->x_hotspot, info->y_hotspot);
|
||||
#ifdef VOID_SPRINTF
|
||||
l = strlen(buf);
|
||||
#endif
|
||||
}
|
||||
if (extensions) {
|
||||
#ifndef VOID_SPRINTF
|
||||
l +=
|
||||
#endif
|
||||
sprintf(buf + l, " XPMEXT");
|
||||
#ifdef VOID_SPRINTF
|
||||
l = strlen(buf);
|
||||
#endif
|
||||
}
|
||||
#ifndef VOID_SPRINTF
|
||||
l +=
|
||||
#endif
|
||||
sprintf(buf + l, "\",\n");
|
||||
#ifdef VOID_SPRINTF
|
||||
l = strlen(buf);
|
||||
#endif
|
||||
ptr_size += l;
|
||||
p = (char *) XpmRealloc(ptr, ptr_size);
|
||||
if (!p)
|
||||
RETURN(XpmNoMemory);
|
||||
ptr = p;
|
||||
strcpy(ptr + used_size, buf);
|
||||
used_size += l;
|
||||
|
||||
/* write colors */
|
||||
if (cmts && info->colors_cmt) {
|
||||
#ifndef VOID_SPRINTF
|
||||
used_size +=
|
||||
#endif
|
||||
sprintf(ptr + used_size, "/*%s*/\n", info->colors_cmt);
|
||||
#ifdef VOID_SPRINTF
|
||||
used_size += strlen(info->colors_cmt) + 5;
|
||||
#endif
|
||||
}
|
||||
ErrorStatus = WriteColors(&ptr, &ptr_size, &used_size,
|
||||
image->colorTable, image->ncolors, image->cpp);
|
||||
|
||||
if (ErrorStatus != XpmSuccess)
|
||||
RETURN(ErrorStatus);
|
||||
|
||||
/*
|
||||
* now we know the exact size we need, realloc the data
|
||||
* 4 = 1 (for '"') + 3 (for '",\n')
|
||||
* 1 = - 2 (because the last line does not end with ',\n') + 3 (for '};\n')
|
||||
*/
|
||||
ptr_size += image->height * (image->width * image->cpp + 4) + 1;
|
||||
|
||||
p = (char *) XpmRealloc(ptr, ptr_size);
|
||||
if (!p)
|
||||
RETURN(XpmNoMemory);
|
||||
ptr = p;
|
||||
|
||||
/* print pixels */
|
||||
if (cmts && info->pixels_cmt) {
|
||||
#ifndef VOID_SPRINTF
|
||||
used_size +=
|
||||
#endif
|
||||
sprintf(ptr + used_size, "/*%s*/\n", info->pixels_cmt);
|
||||
#ifdef VOID_SPRINTF
|
||||
used_size += strlen(info->pixels_cmt) + 5;
|
||||
#endif
|
||||
}
|
||||
WritePixels(ptr + used_size, &used_size, image->width, image->height,
|
||||
image->cpp, image->data, image->colorTable);
|
||||
|
||||
/* print extensions */
|
||||
if (extensions)
|
||||
WriteExtensions(ptr + used_size, &used_size,
|
||||
info->extensions, info->nextensions);
|
||||
|
||||
/* close the array */
|
||||
strcpy(ptr + used_size, "};\n");
|
||||
|
||||
*buffer_return = ptr;
|
||||
|
||||
return (XpmSuccess);
|
||||
|
||||
/* exit point in case of error, free only locally allocated variables */
|
||||
error:
|
||||
if (ptr)
|
||||
XpmFree(ptr);
|
||||
return (ErrorStatus);
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static int WriteColors(
|
||||
char** dataptr
|
||||
, unsigned int* data_size
|
||||
, unsigned int* used_size
|
||||
, XpmColor* colors
|
||||
, unsigned int ncolors
|
||||
, unsigned int cpp
|
||||
)
|
||||
#else
|
||||
static int
|
||||
WriteColors(dataptr, data_size, used_size, colors, ncolors, cpp)
|
||||
char **dataptr;
|
||||
unsigned int *data_size;
|
||||
unsigned int *used_size;
|
||||
XpmColor *colors;
|
||||
unsigned int ncolors;
|
||||
unsigned int cpp;
|
||||
#endif
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
unsigned int a, key, l;
|
||||
char *s, *s2;
|
||||
char **defaults;
|
||||
|
||||
*buf = '"';
|
||||
for (a = 0; a < ncolors; a++, colors++) {
|
||||
|
||||
defaults = (char **) colors;
|
||||
s = buf + 1;
|
||||
strncpy(s, *defaults++, cpp);
|
||||
s += cpp;
|
||||
|
||||
for (key = 1; key <= NKEYS; key++, defaults++) {
|
||||
if (s2 = *defaults) {
|
||||
#ifndef VOID_SPRINTF
|
||||
s +=
|
||||
#endif
|
||||
sprintf(s, "\t%s %s", xpmColorKeys[key - 1], s2);
|
||||
#ifdef VOID_SPRINTF
|
||||
s += strlen(s);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
strcpy(s, "\",\n");
|
||||
l = s + 3 - buf;
|
||||
s = (char *) XpmRealloc(*dataptr, *data_size + l);
|
||||
if (!s)
|
||||
return (XpmNoMemory);
|
||||
*data_size += l;
|
||||
strcpy(s + *used_size, buf);
|
||||
*used_size += l;
|
||||
*dataptr = s;
|
||||
}
|
||||
return (XpmSuccess);
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static void WritePixels(
|
||||
char* dataptr
|
||||
, unsigned int* used_size
|
||||
, unsigned int width
|
||||
, unsigned int height
|
||||
, unsigned int cpp
|
||||
, unsigned int* pixels
|
||||
, XpmColor* colors
|
||||
)
|
||||
#else
|
||||
static void
|
||||
WritePixels(dataptr, used_size, width, height, cpp, pixels, colors)
|
||||
char *dataptr;
|
||||
unsigned int *used_size;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int cpp;
|
||||
unsigned int *pixels;
|
||||
XpmColor *colors;
|
||||
#endif
|
||||
{
|
||||
char *s = dataptr;
|
||||
unsigned int x, y, h;
|
||||
|
||||
h = height - 1;
|
||||
for (y = 0; y < h; y++) {
|
||||
*s++ = '"';
|
||||
for (x = 0; x < width; x++, pixels++) {
|
||||
strncpy(s, colors[*pixels].string, cpp);
|
||||
s += cpp;
|
||||
}
|
||||
strcpy(s, "\",\n");
|
||||
s += 3;
|
||||
}
|
||||
/* duplicate some code to avoid a test in the loop */
|
||||
*s++ = '"';
|
||||
for (x = 0; x < width; x++, pixels++) {
|
||||
strncpy(s, colors[*pixels].string, cpp);
|
||||
s += cpp;
|
||||
}
|
||||
*s++ = '"';
|
||||
*used_size += s - dataptr;
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static int
|
||||
ExtensionsSize(XpmExtension* ext, unsigned int num)
|
||||
#else
|
||||
static int
|
||||
ExtensionsSize(ext, num)
|
||||
XpmExtension *ext;
|
||||
unsigned int num;
|
||||
#endif
|
||||
{
|
||||
unsigned int x, y, a, size;
|
||||
char **line;
|
||||
|
||||
size = 0;
|
||||
for (x = 0; x < num; x++, ext++) {
|
||||
/* 11 = 10 (for ',\n"XPMEXT ') + 1 (for '"') */
|
||||
size += strlen(ext->name) + 11;
|
||||
a = ext->nlines;
|
||||
for (y = 0, line = ext->lines; y < a; y++, line++)
|
||||
/* 4 = 3 (for ',\n"') + 1 (for '"') */
|
||||
size += strlen(*line) + 4;
|
||||
}
|
||||
/* 13 is for ',\n"XPMENDEXT"' */
|
||||
return size + 13;
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static void WriteExtensions(
|
||||
char* dataptr
|
||||
, unsigned int* used_size
|
||||
, XpmExtension* ext
|
||||
, unsigned int num
|
||||
)
|
||||
#else
|
||||
static void
|
||||
WriteExtensions(dataptr, used_size, ext, num)
|
||||
char *dataptr;
|
||||
unsigned int *used_size;
|
||||
XpmExtension *ext;
|
||||
unsigned int num;
|
||||
#endif
|
||||
{
|
||||
unsigned int x, y, a;
|
||||
char **line;
|
||||
char *s = dataptr;
|
||||
|
||||
for (x = 0; x < num; x++, ext++) {
|
||||
#ifndef VOID_SPRINTF
|
||||
s +=
|
||||
#endif
|
||||
sprintf(s, ",\n\"XPMEXT %s\"", ext->name);
|
||||
#ifdef VOID_SPRINTF
|
||||
s += strlen(ext->name) + 11;
|
||||
#endif
|
||||
a = ext->nlines;
|
||||
for (y = 0, line = ext->lines; y < a; y++, line++) {
|
||||
#ifndef VOID_SPRINTF
|
||||
s +=
|
||||
#endif
|
||||
sprintf(s, ",\n\"%s\"", *line);
|
||||
#ifdef VOID_SPRINTF
|
||||
s += strlen(*line) + 4;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
strcpy(s, ",\n\"XPMENDEXT\"");
|
||||
*used_size += s - dataptr + 13;
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static int CommentsSize(XpmInfo* info)
|
||||
#else
|
||||
static int CommentsSize(info)
|
||||
XpmInfo *info;
|
||||
#endif
|
||||
{
|
||||
int size = 0;
|
||||
|
||||
/* 5 = 2 (for "/_*") + 3 (for "*_/\n") */
|
||||
if (info->hints_cmt)
|
||||
size += 5 + strlen(info->hints_cmt);
|
||||
|
||||
if (info->colors_cmt)
|
||||
size += 5 + strlen(info->colors_cmt);
|
||||
|
||||
if (info->pixels_cmt)
|
||||
size += 5 + strlen(info->pixels_cmt);
|
||||
|
||||
return size;
|
||||
}
|
@@ -1,404 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* CrDataFI.c: *
|
||||
* *
|
||||
* XPM library *
|
||||
* Scan an image and possibly its mask and create an XPM array *
|
||||
* *
|
||||
* Developed by Arnaud Le Hors *
|
||||
\*****************************************************************************/
|
||||
|
||||
#include "XpmI.h"
|
||||
|
||||
LFUNC(CreateColors, int, (char **dataptr, unsigned int *data_size,
|
||||
XpmColor *colors, unsigned int ncolors,
|
||||
unsigned int cpp));
|
||||
|
||||
LFUNC(CreatePixels, void, (char **dataptr, unsigned int width,
|
||||
unsigned int height, unsigned int cpp,
|
||||
unsigned int *pixels, XpmColor *colors));
|
||||
|
||||
LFUNC(CountExtensions, void, (XpmExtension *ext, unsigned int num,
|
||||
unsigned int *ext_size,
|
||||
unsigned int *ext_nlines));
|
||||
|
||||
LFUNC(CreateExtensions, void, (char **dataptr, unsigned int offset,
|
||||
XpmExtension *ext, unsigned int num,
|
||||
unsigned int ext_nlines));
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int
|
||||
XpmCreateDataFromImage(
|
||||
Display* display
|
||||
, char*** data_return
|
||||
, XImage* image
|
||||
, XImage* shapeimage
|
||||
, XpmAttributes* attributes
|
||||
)
|
||||
#else
|
||||
int
|
||||
XpmCreateDataFromImage(display, data_return, image, shapeimage, attributes)
|
||||
Display *display;
|
||||
char ***data_return;
|
||||
XImage *image;
|
||||
XImage *shapeimage;
|
||||
XpmAttributes *attributes;
|
||||
#endif
|
||||
{
|
||||
XpmImage xpmimage;
|
||||
XpmInfo info;
|
||||
int ErrorStatus;
|
||||
|
||||
/* initialize return value */
|
||||
if (data_return)
|
||||
*data_return = NULL;
|
||||
|
||||
/* create an XpmImage from the image */
|
||||
ErrorStatus = XpmCreateXpmImageFromImage(display, image, shapeimage,
|
||||
&xpmimage, attributes);
|
||||
if (ErrorStatus != XpmSuccess)
|
||||
return (ErrorStatus);
|
||||
|
||||
/* create the data from the XpmImage */
|
||||
if (attributes) {
|
||||
xpmSetInfo(&info, attributes);
|
||||
ErrorStatus = XpmCreateDataFromXpmImage(data_return, &xpmimage, &info);
|
||||
} else
|
||||
ErrorStatus = XpmCreateDataFromXpmImage(data_return, &xpmimage, NULL);
|
||||
|
||||
/* free the XpmImage */
|
||||
XpmFreeXpmImage(&xpmimage);
|
||||
|
||||
return (ErrorStatus);
|
||||
}
|
||||
|
||||
#undef RETURN
|
||||
#define RETURN(status) \
|
||||
{ \
|
||||
ErrorStatus = status; \
|
||||
goto exit; \
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int
|
||||
XpmCreateDataFromXpmImage(char*** data_return, XpmImage* image, XpmInfo* info)
|
||||
#else
|
||||
int
|
||||
XpmCreateDataFromXpmImage(data_return, image, info)
|
||||
char ***data_return;
|
||||
XpmImage *image;
|
||||
XpmInfo *info;
|
||||
#endif
|
||||
{
|
||||
/* calculation variables */
|
||||
int ErrorStatus;
|
||||
char buf[BUFSIZ];
|
||||
char **header = NULL, **data, **sptr, **sptr2, *s;
|
||||
unsigned int header_size, header_nlines;
|
||||
unsigned int data_size, data_nlines;
|
||||
unsigned int extensions = 0, ext_size = 0, ext_nlines = 0;
|
||||
unsigned int offset, l, n;
|
||||
|
||||
*data_return = NULL;
|
||||
|
||||
extensions = info && (info->valuemask & XpmExtensions)
|
||||
&& info->nextensions;
|
||||
|
||||
/* compute the number of extensions lines and size */
|
||||
if (extensions)
|
||||
CountExtensions(info->extensions, info->nextensions,
|
||||
&ext_size, &ext_nlines);
|
||||
|
||||
/*
|
||||
* alloc a temporary array of char pointer for the header section which
|
||||
* is the hints line + the color table lines
|
||||
*/
|
||||
header_nlines = 1 + image->ncolors;
|
||||
header_size = sizeof(char *) * header_nlines;
|
||||
header = (char **) XpmCalloc(header_size, sizeof(char *));
|
||||
if (!header)
|
||||
return (XpmNoMemory);
|
||||
|
||||
/* print the hints line */
|
||||
s = buf;
|
||||
#ifndef VOID_SPRINTF
|
||||
s +=
|
||||
#endif
|
||||
sprintf(s, "%d %d %d %d", image->width, image->height,
|
||||
image->ncolors, image->cpp);
|
||||
#ifdef VOID_SPRINTF
|
||||
s += strlen(s);
|
||||
#endif
|
||||
|
||||
if (info && (info->valuemask & XpmHotspot)) {
|
||||
#ifndef VOID_SPRINTF
|
||||
s +=
|
||||
#endif
|
||||
sprintf(s, " %d %d", info->x_hotspot, info->y_hotspot);
|
||||
#ifdef VOID_SPRINTF
|
||||
s += strlen(s);
|
||||
#endif
|
||||
}
|
||||
if (extensions) {
|
||||
strcpy(s, " XPMEXT");
|
||||
s += 7;
|
||||
}
|
||||
l = s - buf + 1;
|
||||
*header = (char *) XpmMalloc(l);
|
||||
if (!*header)
|
||||
RETURN(XpmNoMemory);
|
||||
header_size += l;
|
||||
strcpy(*header, buf);
|
||||
|
||||
/* print colors */
|
||||
ErrorStatus = CreateColors(header + 1, &header_size,
|
||||
image->colorTable, image->ncolors, image->cpp);
|
||||
|
||||
if (ErrorStatus != XpmSuccess)
|
||||
RETURN(ErrorStatus);
|
||||
|
||||
/* now we know the size needed, alloc the data and copy the header lines */
|
||||
offset = image->width * image->cpp + 1;
|
||||
data_size = header_size + (image->height + ext_nlines) * sizeof(char *)
|
||||
+ image->height * offset + ext_size;
|
||||
|
||||
data = (char **) XpmMalloc(data_size);
|
||||
if (!data)
|
||||
RETURN(XpmNoMemory);
|
||||
|
||||
data_nlines = header_nlines + image->height + ext_nlines;
|
||||
*data = (char *) (data + data_nlines);
|
||||
n = image->ncolors;
|
||||
for (l = 0, sptr = data, sptr2 = header; l <= n; l++, sptr++, sptr2++) {
|
||||
strcpy(*sptr, *sptr2);
|
||||
*(sptr + 1) = *sptr + strlen(*sptr2) + 1;
|
||||
}
|
||||
|
||||
/* print pixels */
|
||||
data[header_nlines] = (char *) data + header_size
|
||||
+ (image->height + ext_nlines) * sizeof(char *);
|
||||
|
||||
CreatePixels(data + header_nlines, image->width, image->height,
|
||||
image->cpp, image->data, image->colorTable);
|
||||
|
||||
/* print extensions */
|
||||
if (extensions)
|
||||
CreateExtensions(data + header_nlines + image->height - 1, offset,
|
||||
info->extensions, info->nextensions,
|
||||
ext_nlines);
|
||||
|
||||
*data_return = data;
|
||||
ErrorStatus = XpmSuccess;
|
||||
|
||||
/* exit point, free only locally allocated variables */
|
||||
exit:
|
||||
if (header) {
|
||||
for (l = 0; l < header_nlines; l++)
|
||||
if (header[l])
|
||||
XpmFree(header[l]);
|
||||
XpmFree(header);
|
||||
}
|
||||
return(ErrorStatus);
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static int
|
||||
CreateColors(
|
||||
char** dataptr
|
||||
, unsigned int* data_size
|
||||
, XpmColor* colors
|
||||
, unsigned int ncolors
|
||||
, unsigned int cpp
|
||||
)
|
||||
#else
|
||||
static int
|
||||
CreateColors(dataptr, data_size, colors, ncolors, cpp)
|
||||
char **dataptr;
|
||||
unsigned int *data_size;
|
||||
XpmColor *colors;
|
||||
unsigned int ncolors;
|
||||
unsigned int cpp;
|
||||
#endif
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
unsigned int a, key, l;
|
||||
char *s, *s2;
|
||||
char **defaults;
|
||||
|
||||
for (a = 0; a < ncolors; a++, colors++, dataptr++) {
|
||||
|
||||
defaults = (char **) colors;
|
||||
strncpy(buf, *defaults++, cpp);
|
||||
s = buf + cpp;
|
||||
|
||||
for (key = 1; key <= NKEYS; key++, defaults++) {
|
||||
if (s2 = *defaults) {
|
||||
#ifndef VOID_SPRINTF
|
||||
s +=
|
||||
#endif
|
||||
sprintf(s, "\t%s %s", xpmColorKeys[key - 1], s2);
|
||||
#ifdef VOID_SPRINTF
|
||||
s += strlen(s);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
l = s - buf + 1;
|
||||
s = (char *) XpmMalloc(l);
|
||||
if (!s)
|
||||
return (XpmNoMemory);
|
||||
*data_size += l;
|
||||
*dataptr = strcpy(s, buf);
|
||||
}
|
||||
return (XpmSuccess);
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static void CreatePixels(
|
||||
char** dataptr
|
||||
, unsigned int width
|
||||
, unsigned int height
|
||||
, unsigned int cpp
|
||||
, unsigned int* pixels
|
||||
, XpmColor* colors
|
||||
)
|
||||
#else
|
||||
static void
|
||||
CreatePixels(dataptr, width, height, cpp, pixels, colors)
|
||||
char **dataptr;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int cpp;
|
||||
unsigned int *pixels;
|
||||
XpmColor *colors;
|
||||
#endif
|
||||
{
|
||||
char *s;
|
||||
unsigned int x, y, h, offset;
|
||||
|
||||
h = height - 1;
|
||||
offset = width * cpp + 1;
|
||||
for (y = 0; y < h; y++, dataptr++) {
|
||||
s = *dataptr;
|
||||
for (x = 0; x < width; x++, pixels++) {
|
||||
strncpy(s, colors[*pixels].string, cpp);
|
||||
s += cpp;
|
||||
}
|
||||
*s = '\0';
|
||||
*(dataptr + 1) = *dataptr + offset;
|
||||
}
|
||||
/* duplicate some code to avoid a test in the loop */
|
||||
s = *dataptr;
|
||||
for (x = 0; x < width; x++, pixels++) {
|
||||
strncpy(s, colors[*pixels].string, cpp);
|
||||
s += cpp;
|
||||
}
|
||||
*s = '\0';
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static void CountExtensions(
|
||||
XpmExtension* ext
|
||||
, unsigned int num
|
||||
, unsigned int* ext_size
|
||||
, unsigned int* ext_nlines
|
||||
)
|
||||
#else
|
||||
static void
|
||||
CountExtensions(ext, num, ext_size, ext_nlines)
|
||||
XpmExtension *ext;
|
||||
unsigned int num;
|
||||
unsigned int *ext_size;
|
||||
unsigned int *ext_nlines;
|
||||
#endif
|
||||
{
|
||||
unsigned int x, y, a, size, nlines;
|
||||
char **line;
|
||||
|
||||
size = 0;
|
||||
nlines = 0;
|
||||
for (x = 0; x < num; x++, ext++) {
|
||||
/* 1 for the name */
|
||||
nlines += ext->nlines + 1;
|
||||
/* 8 = 7 (for "XPMEXT ") + 1 (for 0) */
|
||||
size += strlen(ext->name) + 8;
|
||||
a = ext->nlines;
|
||||
for (y = 0, line = ext->lines; y < a; y++, line++)
|
||||
size += strlen(*line) + 1;
|
||||
}
|
||||
/* 10 and 1 are for the ending "XPMENDEXT" */
|
||||
*ext_size = size + 10;
|
||||
*ext_nlines = nlines + 1;
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static void
|
||||
CreateExtensions(
|
||||
char** dataptr
|
||||
, unsigned int offset
|
||||
, XpmExtension* ext
|
||||
, unsigned int num
|
||||
, unsigned int ext_nlines
|
||||
)
|
||||
#else
|
||||
static void
|
||||
CreateExtensions(dataptr, offset, ext, num, ext_nlines)
|
||||
char **dataptr;
|
||||
unsigned int offset;
|
||||
XpmExtension *ext;
|
||||
unsigned int num;
|
||||
unsigned int ext_nlines;
|
||||
#endif
|
||||
{
|
||||
unsigned int x, y, a, b;
|
||||
char **line;
|
||||
|
||||
*(dataptr + 1) = *dataptr + offset;
|
||||
dataptr++;
|
||||
a = 0;
|
||||
for (x = 0; x < num; x++, ext++) {
|
||||
sprintf(*dataptr, "XPMEXT %s", ext->name);
|
||||
a++;
|
||||
if (a < ext_nlines)
|
||||
*(dataptr + 1) = *dataptr + strlen(ext->name) + 8;
|
||||
dataptr++;
|
||||
b = ext->nlines;
|
||||
for (y = 0, line = ext->lines; y < b; y++, line++) {
|
||||
strcpy(*dataptr, *line);
|
||||
a++;
|
||||
if (a < ext_nlines)
|
||||
*(dataptr + 1) = *dataptr + strlen(*line) + 1;
|
||||
dataptr++;
|
||||
}
|
||||
}
|
||||
strcpy(*dataptr, "XPMENDEXT");
|
||||
}
|
@@ -1,140 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* CrIFrBuf.c: *
|
||||
* *
|
||||
* XPM library *
|
||||
* Parse an Xpm buffer (file in memory) and create the image and possibly its *
|
||||
* mask *
|
||||
* Developed by Arnaud Le Hors *
|
||||
\*****************************************************************************/
|
||||
|
||||
#include "XpmI.h"
|
||||
|
||||
LFUNC(OpenBuffer, void, (char *buffer, xpmData *mdata));
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int XpmCreateImageFromBuffer(
|
||||
Display* display
|
||||
, char* buffer
|
||||
, XImage** image_return
|
||||
, XImage** shapeimage_return
|
||||
, XpmAttributes* attributes
|
||||
)
|
||||
#else
|
||||
int
|
||||
XpmCreateImageFromBuffer(display, buffer, image_return,
|
||||
shapeimage_return, attributes)
|
||||
Display *display;
|
||||
char *buffer;
|
||||
XImage **image_return;
|
||||
XImage **shapeimage_return;
|
||||
XpmAttributes *attributes;
|
||||
#endif
|
||||
{
|
||||
XpmImage image;
|
||||
XpmInfo info;
|
||||
int ErrorStatus;
|
||||
xpmData mdata;
|
||||
|
||||
xpmInitXpmImage(&image);
|
||||
xpmInitXpmInfo(&info);
|
||||
|
||||
/* open buffer to read */
|
||||
OpenBuffer(buffer, &mdata);
|
||||
|
||||
/* create the XImage from the XpmData */
|
||||
if (attributes) {
|
||||
xpmInitAttributes(attributes);
|
||||
xpmSetInfoMask(&info, attributes);
|
||||
ErrorStatus = xpmParseDataAndCreate(display, &mdata,
|
||||
image_return, shapeimage_return,
|
||||
&image, &info, attributes);
|
||||
} else
|
||||
ErrorStatus = xpmParseDataAndCreate(display, &mdata,
|
||||
image_return, shapeimage_return,
|
||||
&image, NULL, attributes);
|
||||
if (attributes) {
|
||||
if (ErrorStatus >= 0) /* no fatal error */
|
||||
xpmSetAttributes(attributes, &image, &info);
|
||||
XpmFreeXpmInfo(&info);
|
||||
}
|
||||
|
||||
/* free the XpmImage */
|
||||
XpmFreeXpmImage(&image);
|
||||
|
||||
return (ErrorStatus);
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int XpmCreateXpmImageFromBuffer(
|
||||
char* buffer
|
||||
, XpmImage* image
|
||||
, XpmInfo* info
|
||||
)
|
||||
#else
|
||||
int
|
||||
XpmCreateXpmImageFromBuffer(buffer, image, info)
|
||||
char *buffer;
|
||||
XpmImage *image;
|
||||
XpmInfo *info;
|
||||
#endif
|
||||
{
|
||||
xpmData mdata;
|
||||
int ErrorStatus;
|
||||
|
||||
/* init returned values */
|
||||
xpmInitXpmImage(image);
|
||||
xpmInitXpmInfo(info);
|
||||
|
||||
/* open buffer to read */
|
||||
OpenBuffer(buffer, &mdata);
|
||||
|
||||
/* create the XpmImage from the XpmData */
|
||||
ErrorStatus = xpmParseData(&mdata, image, info);
|
||||
|
||||
return (ErrorStatus);
|
||||
}
|
||||
|
||||
/*
|
||||
* open the given buffer to be read or written as an xpmData which is returned
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static void OpenBuffer(char* buffer, xpmData* mdata)
|
||||
#else
|
||||
static void
|
||||
OpenBuffer(buffer, mdata)
|
||||
char *buffer;
|
||||
xpmData *mdata;
|
||||
#endif
|
||||
{
|
||||
mdata->type = XPMBUFFER;
|
||||
mdata->cptr = buffer;
|
||||
mdata->CommentLength = 0;
|
||||
}
|
@@ -1,146 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* CrIFrData.c: *
|
||||
* *
|
||||
* XPM library *
|
||||
* Parse an Xpm array and create the image and possibly its mask *
|
||||
* *
|
||||
* Developed by Arnaud Le Hors *
|
||||
\*****************************************************************************/
|
||||
|
||||
#include "XpmI.h"
|
||||
|
||||
LFUNC(OpenArray, void, (char **data, xpmData *mdata));
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int XpmCreateImageFromData(
|
||||
Display* display
|
||||
, char** data
|
||||
, XImage** image_return
|
||||
, XImage** shapeimage_return
|
||||
, XpmAttributes* attributes
|
||||
)
|
||||
#else
|
||||
int
|
||||
XpmCreateImageFromData(display, data, image_return,
|
||||
shapeimage_return, attributes)
|
||||
Display *display;
|
||||
char **data;
|
||||
XImage **image_return;
|
||||
XImage **shapeimage_return;
|
||||
XpmAttributes *attributes;
|
||||
#endif
|
||||
{
|
||||
XpmImage image;
|
||||
XpmInfo info;
|
||||
int ErrorStatus;
|
||||
xpmData mdata;
|
||||
|
||||
xpmInitXpmImage(&image);
|
||||
xpmInitXpmInfo(&info);
|
||||
|
||||
/* open data */
|
||||
OpenArray(data, &mdata);
|
||||
|
||||
/* create an XpmImage from the file */
|
||||
if (attributes) {
|
||||
xpmInitAttributes(attributes);
|
||||
xpmSetInfoMask(&info, attributes);
|
||||
ErrorStatus = xpmParseDataAndCreate(display, &mdata,
|
||||
image_return, shapeimage_return,
|
||||
&image, &info, attributes);
|
||||
} else
|
||||
ErrorStatus = xpmParseDataAndCreate(display, &mdata,
|
||||
image_return, shapeimage_return,
|
||||
&image, NULL, attributes);
|
||||
if (attributes) {
|
||||
if (ErrorStatus >= 0) /* no fatal error */
|
||||
xpmSetAttributes(attributes, &image, &info);
|
||||
XpmFreeXpmInfo(&info);
|
||||
}
|
||||
|
||||
/* free the XpmImage */
|
||||
XpmFreeXpmImage(&image);
|
||||
|
||||
return (ErrorStatus);
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int
|
||||
XpmCreateXpmImageFromData(
|
||||
char** data
|
||||
, XpmImage* image
|
||||
, XpmInfo* info
|
||||
)
|
||||
#else
|
||||
int
|
||||
XpmCreateXpmImageFromData(data, image, info)
|
||||
char **data;
|
||||
XpmImage *image;
|
||||
XpmInfo *info;
|
||||
#endif
|
||||
{
|
||||
xpmData mdata;
|
||||
int ErrorStatus;
|
||||
|
||||
/* init returned values */
|
||||
xpmInitXpmImage(image);
|
||||
xpmInitXpmInfo(info);
|
||||
|
||||
/* open data */
|
||||
OpenArray(data, &mdata);
|
||||
|
||||
/* create the XpmImage from the XpmData */
|
||||
ErrorStatus = xpmParseData(&mdata, image, info);
|
||||
|
||||
return (ErrorStatus);
|
||||
}
|
||||
|
||||
/*
|
||||
* open the given array to be read or written as an xpmData which is returned
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static void OpenArray(char** data, xpmData* mdata)
|
||||
#else
|
||||
static void
|
||||
OpenArray(data, mdata)
|
||||
char **data;
|
||||
xpmData *mdata;
|
||||
#endif
|
||||
{
|
||||
mdata->type = XPMARRAY;
|
||||
mdata->stream.data = data;
|
||||
mdata->cptr = *data;
|
||||
mdata->line = 0;
|
||||
mdata->CommentLength = 0;
|
||||
mdata->Bcmt = mdata->Ecmt = NULL;
|
||||
mdata->Bos = mdata->Eos = '\0';
|
||||
mdata->format = 0; /* this can only be Xpm 2 or 3 */
|
||||
}
|
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* Image.c: *
|
||||
* *
|
||||
* XPM library *
|
||||
* Functions to init and free the XpmImage structure. *
|
||||
* *
|
||||
* Developed by Arnaud Le Hors *
|
||||
\*****************************************************************************/
|
||||
|
||||
#include "XpmI.h"
|
||||
|
||||
/*
|
||||
* Init returned data to free safely later on
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
void
|
||||
xpmInitXpmImage(XpmImage* image)
|
||||
#else
|
||||
void
|
||||
xpmInitXpmImage(image)
|
||||
XpmImage *image;
|
||||
#endif
|
||||
{
|
||||
image->ncolors = 0;
|
||||
image->colorTable = NULL;
|
||||
image->data = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the XpmImage data which have been allocated
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
void
|
||||
XpmFreeXpmImage(XpmImage* image)
|
||||
#else
|
||||
void
|
||||
XpmFreeXpmImage(image)
|
||||
XpmImage *image;
|
||||
#endif
|
||||
{
|
||||
if (image->colorTable)
|
||||
xpmFreeColorTable(image->colorTable, image->ncolors);
|
||||
if (image->data)
|
||||
XpmFree(image->data);
|
||||
image->data = NULL;
|
||||
}
|
147
src/xpm/Info.c
147
src/xpm/Info.c
@@ -1,147 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* Info.c: *
|
||||
* *
|
||||
* XPM library *
|
||||
* Functions related to the XpmInfo structure. *
|
||||
* *
|
||||
* Developed by Arnaud Le Hors *
|
||||
\*****************************************************************************/
|
||||
|
||||
#include "XpmI.h"
|
||||
|
||||
/*
|
||||
* Init returned data to free safely later on
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
void
|
||||
xpmInitXpmInfo(XpmInfo* info)
|
||||
#else
|
||||
void
|
||||
xpmInitXpmInfo(info)
|
||||
XpmInfo *info;
|
||||
#endif
|
||||
{
|
||||
if (info) {
|
||||
info->hints_cmt = NULL;
|
||||
info->colors_cmt = NULL;
|
||||
info->pixels_cmt = NULL;
|
||||
info->extensions = NULL;
|
||||
info->nextensions = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the XpmInfo data which have been allocated
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
void
|
||||
XpmFreeXpmInfo(XpmInfo* info)
|
||||
#else
|
||||
void
|
||||
XpmFreeXpmInfo(info)
|
||||
XpmInfo *info;
|
||||
#endif
|
||||
{
|
||||
if (info) {
|
||||
if (info->valuemask & XpmComments) {
|
||||
if (info->hints_cmt) {
|
||||
XpmFree(info->hints_cmt);
|
||||
info->hints_cmt = NULL;
|
||||
}
|
||||
if (info->colors_cmt) {
|
||||
XpmFree(info->colors_cmt);
|
||||
info->colors_cmt = NULL;
|
||||
}
|
||||
if (info->pixels_cmt) {
|
||||
XpmFree(info->pixels_cmt);
|
||||
info->pixels_cmt = NULL;
|
||||
}
|
||||
}
|
||||
if (info->valuemask & XpmReturnExtensions && info->nextensions) {
|
||||
XpmFreeExtensions(info->extensions, info->nextensions);
|
||||
info->extensions = NULL;
|
||||
info->nextensions = 0;
|
||||
}
|
||||
info->valuemask = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the XpmInfo valuemask to retrieve required info
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
void xpmSetInfoMask(XpmInfo* info, XpmAttributes* attributes)
|
||||
#else
|
||||
void
|
||||
xpmSetInfoMask(info, attributes)
|
||||
XpmInfo *info;
|
||||
XpmAttributes *attributes;
|
||||
#endif
|
||||
{
|
||||
info->valuemask = 0;
|
||||
if (attributes->valuemask & XpmReturnInfos)
|
||||
info->valuemask |= XpmReturnComments;
|
||||
if (attributes->valuemask & XpmReturnExtensions)
|
||||
info->valuemask |= XpmReturnExtensions;
|
||||
}
|
||||
|
||||
/*
|
||||
* Fill in the XpmInfo with the XpmAttributes
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
void
|
||||
xpmSetInfo(XpmInfo* info, XpmAttributes* attributes)
|
||||
#else
|
||||
void
|
||||
xpmSetInfo(info, attributes)
|
||||
XpmInfo *info;
|
||||
XpmAttributes *attributes;
|
||||
#endif
|
||||
{
|
||||
info->valuemask = 0;
|
||||
if (attributes->valuemask & XpmInfos) {
|
||||
info->valuemask |= XpmComments | XpmColorTable;
|
||||
info->hints_cmt = attributes->hints_cmt;
|
||||
info->colors_cmt = attributes->colors_cmt;
|
||||
info->pixels_cmt = attributes->pixels_cmt;
|
||||
}
|
||||
if (attributes->valuemask & XpmExtensions) {
|
||||
info->valuemask |= XpmExtensions;
|
||||
info->extensions = attributes->extensions;
|
||||
info->nextensions = attributes->nextensions;
|
||||
}
|
||||
if (attributes->valuemask & XpmHotspot) {
|
||||
info->valuemask |= XpmHotspot;
|
||||
info->x_hotspot = attributes->x_hotspot;
|
||||
info->y_hotspot = attributes->y_hotspot;
|
||||
}
|
||||
}
|
@@ -1,185 +0,0 @@
|
||||
#
|
||||
# File: makefile.vc
|
||||
# Author: David Webster
|
||||
# Created: 1999
|
||||
# Updated:
|
||||
# Copyright: c) 1993, AIAI, University of Edinburgh
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile : Builds os2xpm.lib library for OS/2 3.0/4.0
|
||||
|
||||
# Suffixes
|
||||
OBJSUFF=obj
|
||||
SRCSUFF=cpp
|
||||
|
||||
OS2FLAGS=/c /W2 /DOS232 /D__VISAGECPP30__ /Dwx_msw /Q /N100
|
||||
OS2LINKFLAGS=/BASE:0x00010000 /PMTYPE:PM /NOE /NOD /ALIGN:16
|
||||
OS2LIBFLAGS=/NOL /NOE
|
||||
OS2LIBS=CPPOM30.lib CPPOOC3.LIB OS2386.LIB
|
||||
|
||||
!if "$(WXMAKINGDLL)" != "0"
|
||||
EXTRADLLFLAGS=/DWXMAKINGDLL=1 /Ge- /D__OS2DLL__
|
||||
EXTRALNKFLAGS=/DLL
|
||||
!endif
|
||||
|
||||
# Change WXDIR or WXWIN to wherever wxWindows is found
|
||||
WXDIR = $(WXWIN)
|
||||
|
||||
OS2XPMDIR=$(WXDIR)\src\xpm
|
||||
OS2XPMINC=$(WINXPMDIR)
|
||||
|
||||
!if "$(WXMAKINGDLL)" != "1"
|
||||
OS2XPMLIB=$(WXDIR)\lib\os2xpm.lib
|
||||
!else
|
||||
OS2XPMLIB=$(WXDIR)\lib\os2xpm.dll
|
||||
!endif
|
||||
INC=-I$(WXDIR)\src\xpm -I$(OS2XPMINC)
|
||||
|
||||
!ifndef FINAL
|
||||
FINAL=0
|
||||
!endif
|
||||
|
||||
!if "$(NOPCH)" == "1"
|
||||
PCH=
|
||||
PRECOMP=
|
||||
MAKEPRECOMP=
|
||||
!else
|
||||
PCH=$(WXLIBNAME).pch
|
||||
PRECOMP=/Si$(PCH)
|
||||
MAKEPRECOMP=/Fi$(PCH)
|
||||
!endif
|
||||
|
||||
!if "$(FINAL)" == "0"
|
||||
!if "$(WXMAKINGDLL)" == "1"
|
||||
D=DebugOS2DLL
|
||||
!else
|
||||
D=DebugOS2
|
||||
!endif
|
||||
OPT =
|
||||
DEBUG_FLAGS= /Ti /D__WXDEBUG__ #/Fb
|
||||
LINK_DEBUG_FLAGS=/DEBUG
|
||||
CRTFLAG=/Gm /Gd
|
||||
!else
|
||||
# /O1 - smallest code
|
||||
# /O2 - fastest code
|
||||
!if "$(WXMAKINGDLL)" == "1"
|
||||
D=RelseOS2DLL
|
||||
!else
|
||||
D=RelseOS2
|
||||
!endif
|
||||
OPT = /O+ /Oc /G5
|
||||
DEBUG_FLAGS=
|
||||
LINK_DEBUG_FLAGS=/RELEASE
|
||||
CRTFLAG=/Gm /Gd
|
||||
!endif
|
||||
|
||||
!if [md $(OS2XPMDIR)\$D]
|
||||
!endif
|
||||
|
||||
|
||||
CPPFLAGS=$(OS2FLAGS) $(EXTRADLLFLAGS) $(DEBUG_FLAGS) $(PRECOMP) $(INC) $(OPT) $(CRTFLAG)
|
||||
LINKFKAGS=$(OS2LINKFLAGS) $(EXTRALNKFLAGS)
|
||||
|
||||
{..\xpm}.c{..\xpm\$D}.obj:
|
||||
@echo $<
|
||||
icc @<<
|
||||
$(CPPFLAGS) /Fo$@ /Tp $<
|
||||
<<
|
||||
|
||||
OBJECTS = \
|
||||
..\xpm\$D\attrib.obj \
|
||||
..\xpm\$D\crbuffri.obj \
|
||||
..\xpm\$D\crdatfri.obj \
|
||||
..\xpm\$D\create.obj \
|
||||
..\xpm\$D\crifrbuf.obj \
|
||||
..\xpm\$D\crifrdat.obj \
|
||||
..\xpm\$D\data.obj \
|
||||
..\xpm\$D\image.obj \
|
||||
..\xpm\$D\info.obj \
|
||||
..\xpm\$D\hashtab.obj \
|
||||
..\xpm\$D\misc.obj \
|
||||
..\xpm\$D\parse.obj \
|
||||
..\xpm\$D\rdftodat.obj \
|
||||
..\xpm\$D\rdftoi.obj \
|
||||
..\xpm\$D\rgb.obj \
|
||||
..\xpm\$D\scan.obj \
|
||||
..\xpm\$D\simx.obj \
|
||||
..\xpm\$D\wrffrdat.obj \
|
||||
..\xpm\$D\wrffri.obj
|
||||
|
||||
LIBOBJECTS = \
|
||||
attrib.obj \
|
||||
crbuffri.obj \
|
||||
crdatfri.obj \
|
||||
create.obj \
|
||||
crifrbuf.obj \
|
||||
crifrdat.obj \
|
||||
data.obj \
|
||||
image.obj \
|
||||
info.obj \
|
||||
hashtab.obj \
|
||||
misc.obj \
|
||||
parse.obj \
|
||||
rdftodat.obj \
|
||||
rdftoi.obj \
|
||||
rgb.obj \
|
||||
scan.obj \
|
||||
simx.obj \
|
||||
wrffrdat.obj \
|
||||
wrffri.obj
|
||||
|
||||
all: $(OBJECTS) $(OS2XPMLIB)
|
||||
|
||||
!if "$(WXMAKINGDLL)" != "1"
|
||||
|
||||
$(WXDIR)\lib\os2xpm.lib: $(LIBOBJECTS)
|
||||
touch $(WXDIR)\lib\os2xpm.lib
|
||||
del $(WXDIR)\lib\os2xpm.lib
|
||||
ilib $(OS2LIBFLAGS) $@ @<<
|
||||
$**;
|
||||
<<
|
||||
del *.obj
|
||||
|
||||
!else
|
||||
|
||||
# Update the dynamic link library
|
||||
$(WXDIR)\lib\os2xpm.dll: $(OBJECTS)
|
||||
icc @<<
|
||||
/B" $(LINKFLAGS)" /Fe$@
|
||||
$(LIBS)
|
||||
$(OBJECTS)
|
||||
$(WXDIR)\src\os2\os2xpm.def
|
||||
<<
|
||||
implib $(WXDIR)\lib\os2xpmd.lib $(WXDIR)\src\os2\os2xpm.def
|
||||
|
||||
!endif
|
||||
|
||||
clean:
|
||||
del $(OS2XPMLIB)
|
||||
erase /N $(OS2XPMDIR)\$D
|
||||
rd $(OS2XPMDIR)\$D
|
||||
|
||||
cleanall: clean
|
||||
|
||||
$(LIBOBJECTS):
|
||||
copy ..\xpm\$D\attrib.obj
|
||||
copy ..\xpm\$D\crbuffri.obj
|
||||
copy ..\xpm\$D\crdatfri.obj
|
||||
copy ..\xpm\$D\create.obj
|
||||
copy ..\xpm\$D\crifrbuf.obj
|
||||
copy ..\xpm\$D\crifrdat.obj
|
||||
copy ..\xpm\$D\data.obj
|
||||
copy ..\xpm\$D\image.obj
|
||||
copy ..\xpm\$D\info.obj
|
||||
copy ..\xpm\$D\hashtab.obj
|
||||
copy ..\xpm\$D\misc.obj
|
||||
copy ..\xpm\$D\parse.obj
|
||||
copy ..\xpm\$D\rdftodat.obj
|
||||
copy ..\xpm\$D\rdftoi.obj
|
||||
copy ..\xpm\$D\rgb.obj
|
||||
copy ..\xpm\$D\scan.obj
|
||||
copy ..\xpm\$D\simx.obj
|
||||
copy ..\xpm\$D\wrffrdat.obj
|
||||
copy ..\xpm\$D\wrffri.obj
|
||||
|
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* RdFToDat.c: *
|
||||
* *
|
||||
* XPM library *
|
||||
* Parse an XPM file and create an array of strings corresponding to it. *
|
||||
* *
|
||||
* Developed by Dan Greening dgreen@cs.ucla.edu / dgreen@sti.com *
|
||||
\*****************************************************************************/
|
||||
|
||||
#include "XpmI.h"
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int XpmReadFileToData(char* filename, char*** data_return)
|
||||
#else
|
||||
int
|
||||
XpmReadFileToData(filename, data_return)
|
||||
char *filename;
|
||||
char ***data_return;
|
||||
#endif
|
||||
{
|
||||
XpmImage image;
|
||||
XpmInfo info;
|
||||
int ErrorStatus;
|
||||
|
||||
info.valuemask = XpmReturnComments | XpmReturnExtensions;
|
||||
|
||||
/*
|
||||
* initialize return value
|
||||
*/
|
||||
if (data_return)
|
||||
*data_return = NULL;
|
||||
|
||||
ErrorStatus = XpmReadFileToXpmImage(filename, &image, &info);
|
||||
if (ErrorStatus != XpmSuccess)
|
||||
return (ErrorStatus);
|
||||
|
||||
ErrorStatus =
|
||||
XpmCreateDataFromXpmImage(data_return, &image, &info);
|
||||
|
||||
XpmFreeXpmImage(&image);
|
||||
XpmFreeXpmInfo(&info);
|
||||
|
||||
return (ErrorStatus);
|
||||
}
|
256
src/xpm/RdFToI.c
256
src/xpm/RdFToI.c
@@ -1,256 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* RdFToI.c: *
|
||||
* *
|
||||
* XPM library *
|
||||
* Parse an XPM file and create the image and possibly its mask *
|
||||
* *
|
||||
* Developed by Arnaud Le Hors *
|
||||
\*****************************************************************************/
|
||||
|
||||
#include "XpmI.h"
|
||||
#include <sys/stat.h>
|
||||
#if !defined(NO_ZPIPE) && defined(WIN32)
|
||||
# define popen _popen
|
||||
# define pclose _pclose
|
||||
# if defined(STAT_ZFILE)
|
||||
# include <io.h>
|
||||
# define stat _stat
|
||||
# define fstat _fstat
|
||||
# endif
|
||||
#endif
|
||||
|
||||
LFUNC(OpenReadFile, int, (char *filename, xpmData *mdata));
|
||||
LFUNC(xpmDataClose, void, (xpmData *mdata));
|
||||
|
||||
#ifndef CXPMPROG
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int XpmReadFileToImage(
|
||||
Display* display
|
||||
, char* filename
|
||||
, XImage** image_return
|
||||
, XImage** shapeimage_return
|
||||
, XpmAttributes* attributes
|
||||
)
|
||||
#else
|
||||
int
|
||||
XpmReadFileToImage(display, filename,
|
||||
image_return, shapeimage_return, attributes)
|
||||
Display *display;
|
||||
char *filename;
|
||||
XImage **image_return;
|
||||
XImage **shapeimage_return;
|
||||
XpmAttributes *attributes;
|
||||
#endif
|
||||
{
|
||||
XpmImage image;
|
||||
XpmInfo info;
|
||||
int ErrorStatus;
|
||||
xpmData mdata;
|
||||
|
||||
xpmInitXpmImage(&image);
|
||||
xpmInitXpmInfo(&info);
|
||||
|
||||
/* open file to read */
|
||||
if ((ErrorStatus = OpenReadFile(filename, &mdata)) != XpmSuccess)
|
||||
return (ErrorStatus);
|
||||
|
||||
/* create the XImage from the XpmData */
|
||||
if (attributes) {
|
||||
xpmInitAttributes(attributes);
|
||||
xpmSetInfoMask(&info, attributes);
|
||||
ErrorStatus = xpmParseDataAndCreate(display, &mdata,
|
||||
image_return, shapeimage_return,
|
||||
&image, &info, attributes);
|
||||
} else
|
||||
ErrorStatus = xpmParseDataAndCreate(display, &mdata,
|
||||
image_return, shapeimage_return,
|
||||
&image, NULL, attributes);
|
||||
if (attributes) {
|
||||
if (ErrorStatus >= 0) /* no fatal error */
|
||||
xpmSetAttributes(attributes, &image, &info);
|
||||
XpmFreeXpmInfo(&info);
|
||||
}
|
||||
|
||||
xpmDataClose(&mdata);
|
||||
/* free the XpmImage */
|
||||
XpmFreeXpmImage(&image);
|
||||
|
||||
return (ErrorStatus);
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
#define popen fopen
|
||||
#define pclose fclose
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int XpmReadFileToXpmImage(
|
||||
char* filename
|
||||
, XpmImage* image
|
||||
, XpmInfo* info
|
||||
)
|
||||
#else
|
||||
int
|
||||
XpmReadFileToXpmImage(filename, image, info)
|
||||
char *filename;
|
||||
XpmImage *image;
|
||||
XpmInfo *info;
|
||||
#endif
|
||||
{
|
||||
xpmData mdata;
|
||||
int ErrorStatus;
|
||||
|
||||
/* init returned values */
|
||||
xpmInitXpmImage(image);
|
||||
xpmInitXpmInfo(info);
|
||||
|
||||
/* open file to read */
|
||||
if ((ErrorStatus = OpenReadFile(filename, &mdata)) != XpmSuccess)
|
||||
return (ErrorStatus);
|
||||
|
||||
/* create the XpmImage from the XpmData */
|
||||
ErrorStatus = xpmParseData(&mdata, image, info);
|
||||
|
||||
xpmDataClose(&mdata);
|
||||
|
||||
return (ErrorStatus);
|
||||
}
|
||||
#endif /* CXPMPROG */
|
||||
|
||||
/*
|
||||
* open the given file to be read as an xpmData which is returned.
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static int OpenReadFile(char* filename, xpmData* mdata)
|
||||
#else
|
||||
static int
|
||||
OpenReadFile(filename, mdata)
|
||||
char *filename;
|
||||
xpmData *mdata;
|
||||
#endif
|
||||
{
|
||||
#ifndef NO_ZPIPE
|
||||
char buf[BUFSIZ];
|
||||
# ifdef STAT_ZFILE
|
||||
char *compressfile;
|
||||
struct stat status;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
if (!filename) {
|
||||
mdata->stream.file = (stdin);
|
||||
mdata->type = XPMFILE;
|
||||
} else {
|
||||
#ifndef NO_ZPIPE
|
||||
int len = strlen(filename);
|
||||
if ((len > 2) && !strcmp(".Z", filename + (len - 2))) {
|
||||
mdata->type = XPMPIPE;
|
||||
sprintf(buf, "uncompress -c \"%s\"", filename);
|
||||
if (!(mdata->stream.file = popen(buf, "r")))
|
||||
return (XpmOpenFailed);
|
||||
|
||||
} else if ((len > 3) && !strcmp(".gz", filename + (len - 3))) {
|
||||
mdata->type = XPMPIPE;
|
||||
sprintf(buf, "gunzip -qc \"%s\"", filename);
|
||||
if (!(mdata->stream.file = popen(buf, "r")))
|
||||
return (XpmOpenFailed);
|
||||
|
||||
} else {
|
||||
# ifdef STAT_ZFILE
|
||||
if (!(compressfile = (char *) XpmMalloc(len + 4)))
|
||||
return (XpmNoMemory);
|
||||
|
||||
sprintf(compressfile, "%s.Z", filename);
|
||||
if (!stat(compressfile, &status)) {
|
||||
sprintf(buf, "uncompress -c \"%s\"", compressfile);
|
||||
if (!(mdata->stream.file = popen(buf, "r"))) {
|
||||
XpmFree(compressfile);
|
||||
return (XpmOpenFailed);
|
||||
}
|
||||
mdata->type = XPMPIPE;
|
||||
} else {
|
||||
sprintf(compressfile, "%s.gz", filename);
|
||||
if (!stat(compressfile, &status)) {
|
||||
sprintf(buf, "gunzip -c \"%s\"", compressfile);
|
||||
if (!(mdata->stream.file = popen(buf, "r"))) {
|
||||
XpmFree(compressfile);
|
||||
return (XpmOpenFailed);
|
||||
}
|
||||
mdata->type = XPMPIPE;
|
||||
} else {
|
||||
# endif
|
||||
#endif
|
||||
if (!(mdata->stream.file = fopen(filename, "r"))) {
|
||||
#if !defined(NO_ZPIPE) && defined(STAT_ZFILE)
|
||||
XpmFree(compressfile);
|
||||
#endif
|
||||
return (XpmOpenFailed);
|
||||
}
|
||||
mdata->type = XPMFILE;
|
||||
#ifndef NO_ZPIPE
|
||||
# ifdef STAT_ZFILE
|
||||
}
|
||||
}
|
||||
XpmFree(compressfile);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
mdata->CommentLength = 0;
|
||||
#ifdef CXPMPROG
|
||||
mdata->lineNum = 0;
|
||||
mdata->charNum = 0;
|
||||
#endif
|
||||
return (XpmSuccess);
|
||||
}
|
||||
|
||||
/*
|
||||
* close the file related to the xpmData if any
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static void
|
||||
xpmDataClose(xpmData* mdata)
|
||||
#else
|
||||
static void
|
||||
xpmDataClose(mdata)
|
||||
xpmData *mdata;
|
||||
#endif
|
||||
{
|
||||
switch (mdata->type) {
|
||||
case XPMFILE:
|
||||
if (mdata->stream.file != (stdin))
|
||||
fclose(mdata->stream.file);
|
||||
break;
|
||||
#ifndef NO_ZPIPE
|
||||
case XPMPIPE:
|
||||
pclose(mdata->stream.file);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* WrFFrData.c: *
|
||||
* *
|
||||
* XPM library *
|
||||
* Parse an Xpm array and write a file that corresponds to it. *
|
||||
* *
|
||||
* Developed by Dan Greening dgreen@cs.ucla.edu / dgreen@sti.com *
|
||||
\*****************************************************************************/
|
||||
|
||||
#include "XpmI.h"
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int XpmWriteFileFromData(char* filename, char** data)
|
||||
#else
|
||||
int
|
||||
XpmWriteFileFromData(filename, data)
|
||||
char *filename;
|
||||
char **data;
|
||||
#endif
|
||||
{
|
||||
XpmImage image;
|
||||
XpmInfo info;
|
||||
int ErrorStatus;
|
||||
|
||||
info.valuemask = XpmReturnComments | XpmReturnExtensions;
|
||||
|
||||
ErrorStatus = XpmCreateXpmImageFromData(data, &image, &info);
|
||||
|
||||
if (ErrorStatus != XpmSuccess)
|
||||
return (ErrorStatus);
|
||||
|
||||
ErrorStatus = XpmWriteFileFromXpmImage(filename, &image, &info);
|
||||
|
||||
XpmFreeXpmImage(&image);
|
||||
XpmFreeXpmInfo(&info);
|
||||
|
||||
return (ErrorStatus);
|
||||
}
|
435
src/xpm/WrFFrI.c
435
src/xpm/WrFFrI.c
@@ -1,435 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* WrFFrI.c: *
|
||||
* *
|
||||
* XPM library *
|
||||
* Write an image and possibly its mask to an XPM file *
|
||||
* *
|
||||
* Developed by Arnaud Le Hors *
|
||||
\*****************************************************************************/
|
||||
|
||||
/*
|
||||
* The code related to AMIGA has been added by
|
||||
* Lorens Younes (d93-hyo@nada.kth.se) 4/96
|
||||
*/
|
||||
|
||||
#include "XpmI.h"
|
||||
#if !defined(NO_ZPIPE) && defined(WIN32)
|
||||
# define popen _popen
|
||||
# define pclose _pclose
|
||||
#endif
|
||||
|
||||
/* MS Windows define a function called WriteFile @#%#&!!! */
|
||||
LFUNC(xpmWriteFile, int, (FILE *file, XpmImage *image, char *name,
|
||||
XpmInfo *info));
|
||||
|
||||
LFUNC(WriteColors, void, (FILE *file, XpmColor *colors, unsigned int ncolors));
|
||||
|
||||
LFUNC(WritePixels, int, (FILE *file, unsigned int width, unsigned int height,
|
||||
unsigned int cpp, unsigned int *pixels,
|
||||
XpmColor *colors));
|
||||
|
||||
LFUNC(WriteExtensions, void, (FILE *file, XpmExtension *ext,
|
||||
unsigned int num));
|
||||
|
||||
LFUNC(OpenWriteFile, int, (char *filename, xpmData *mdata));
|
||||
LFUNC(xpmDataClose, void, (xpmData *mdata));
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int XpmWriteFileFromImage(
|
||||
Display* display
|
||||
, char* filename
|
||||
, XImage* image
|
||||
, XImage* shapeimage
|
||||
, XpmAttributes* attributes
|
||||
)
|
||||
#else
|
||||
int
|
||||
XpmWriteFileFromImage(display, filename, image, shapeimage, attributes)
|
||||
Display *display;
|
||||
char *filename;
|
||||
XImage *image;
|
||||
XImage *shapeimage;
|
||||
XpmAttributes *attributes;
|
||||
#endif
|
||||
{
|
||||
XpmImage xpmimage;
|
||||
XpmInfo info;
|
||||
int ErrorStatus;
|
||||
|
||||
/* create an XpmImage from the image */
|
||||
ErrorStatus = XpmCreateXpmImageFromImage(display, image, shapeimage,
|
||||
&xpmimage, attributes);
|
||||
if (ErrorStatus != XpmSuccess)
|
||||
return (ErrorStatus);
|
||||
|
||||
/* write the file from the XpmImage */
|
||||
if (attributes) {
|
||||
xpmSetInfo(&info, attributes);
|
||||
ErrorStatus = XpmWriteFileFromXpmImage(filename, &xpmimage, &info);
|
||||
} else
|
||||
ErrorStatus = XpmWriteFileFromXpmImage(filename, &xpmimage, NULL);
|
||||
|
||||
/* free the XpmImage */
|
||||
XpmFreeXpmImage(&xpmimage);
|
||||
|
||||
return (ErrorStatus);
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int XpmWriteFileFromXpmImage(
|
||||
char* filename
|
||||
, XpmImage* image
|
||||
, XpmInfo* info
|
||||
)
|
||||
#else
|
||||
int
|
||||
XpmWriteFileFromXpmImage(filename, image, info)
|
||||
char *filename;
|
||||
XpmImage *image;
|
||||
XpmInfo *info;
|
||||
#endif
|
||||
{
|
||||
xpmData mdata;
|
||||
char *name, *dot, *s, new_name[BUFSIZ];
|
||||
int ErrorStatus;
|
||||
|
||||
/* open file to write */
|
||||
if ((ErrorStatus = OpenWriteFile(filename, &mdata)) != XpmSuccess)
|
||||
return (ErrorStatus);
|
||||
|
||||
/* figure out a name */
|
||||
if (filename) {
|
||||
#ifdef VMS
|
||||
name = filename;
|
||||
#else
|
||||
if (!(name = rindex(filename, '/'))
|
||||
#ifdef AMIGA
|
||||
&& !(name = rindex(filename, ':'))
|
||||
#endif
|
||||
)
|
||||
name = filename;
|
||||
else
|
||||
name++;
|
||||
#endif
|
||||
/* let's try to make a valid C syntax name */
|
||||
if (dot = index(name, '.')) {
|
||||
strcpy(new_name, name);
|
||||
/* change '.' to '_' */
|
||||
name = s = new_name;
|
||||
while (dot = index(s, '.')) {
|
||||
*dot = '_';
|
||||
s = dot;
|
||||
}
|
||||
}
|
||||
if (dot = index(name, '-')) {
|
||||
if (name != new_name) {
|
||||
strcpy(new_name, name);
|
||||
name = new_name;
|
||||
}
|
||||
/* change '-' to '_' */
|
||||
s = name;
|
||||
while (dot = index(s, '-')) {
|
||||
*dot = '_';
|
||||
s = dot;
|
||||
}
|
||||
}
|
||||
} else
|
||||
name = "image_name";
|
||||
|
||||
/* write the XpmData from the XpmImage */
|
||||
if (ErrorStatus == XpmSuccess)
|
||||
ErrorStatus = xpmWriteFile(mdata.stream.file, image, name, info);
|
||||
|
||||
xpmDataClose(&mdata);
|
||||
|
||||
return (ErrorStatus);
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static int
|
||||
xpmWriteFile(
|
||||
FILE* file
|
||||
, XpmImage* image
|
||||
, char* name
|
||||
, XpmInfo* info
|
||||
)
|
||||
#else
|
||||
static int
|
||||
xpmWriteFile(file, image, name, info)
|
||||
FILE *file;
|
||||
XpmImage *image;
|
||||
char *name;
|
||||
XpmInfo *info;
|
||||
#endif
|
||||
{
|
||||
/* calculation variables */
|
||||
unsigned int cmts, extensions;
|
||||
int ErrorStatus;
|
||||
|
||||
cmts = info && (info->valuemask & XpmComments);
|
||||
extensions = info && (info->valuemask & XpmExtensions)
|
||||
&& info->nextensions;
|
||||
|
||||
/* print the header line */
|
||||
fprintf(file, "/* XPM */\nstatic char * %s[] = {\n", name);
|
||||
|
||||
/* print the hints line */
|
||||
if (cmts && info->hints_cmt)
|
||||
fprintf(file, "/*%s*/\n", info->hints_cmt);
|
||||
|
||||
fprintf(file, "\"%d %d %d %d", image->width, image->height,
|
||||
image->ncolors, image->cpp);
|
||||
|
||||
if (info && (info->valuemask & XpmHotspot))
|
||||
fprintf(file, " %d %d", info->x_hotspot, info->y_hotspot);
|
||||
|
||||
if (extensions)
|
||||
fprintf(file, " XPMEXT");
|
||||
|
||||
fprintf(file, "\",\n");
|
||||
|
||||
/* print colors */
|
||||
if (cmts && info->colors_cmt)
|
||||
fprintf(file, "/*%s*/\n", info->colors_cmt);
|
||||
|
||||
WriteColors(file, image->colorTable, image->ncolors);
|
||||
|
||||
/* print pixels */
|
||||
if (cmts && info->pixels_cmt)
|
||||
fprintf(file, "/*%s*/\n", info->pixels_cmt);
|
||||
|
||||
ErrorStatus = WritePixels(file, image->width, image->height, image->cpp,
|
||||
image->data, image->colorTable);
|
||||
if (ErrorStatus != XpmSuccess)
|
||||
return (ErrorStatus);
|
||||
|
||||
/* print extensions */
|
||||
if (extensions)
|
||||
WriteExtensions(file, info->extensions, info->nextensions);
|
||||
|
||||
/* close the array */
|
||||
fprintf(file, "};\n");
|
||||
|
||||
return (XpmSuccess);
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static void
|
||||
WriteColors(
|
||||
FILE* file
|
||||
, XpmColor* colors
|
||||
, unsigned int ncolors
|
||||
)
|
||||
#else
|
||||
static void
|
||||
WriteColors(file, colors, ncolors)
|
||||
FILE *file;
|
||||
XpmColor *colors;
|
||||
unsigned int ncolors;
|
||||
#endif
|
||||
{
|
||||
unsigned int a, key;
|
||||
char *s;
|
||||
char **defaults;
|
||||
|
||||
for (a = 0; a < ncolors; a++, colors++) {
|
||||
|
||||
defaults = (char **) colors;
|
||||
fprintf(file, "\"%s", *defaults++);
|
||||
|
||||
for (key = 1; key <= NKEYS; key++, defaults++) {
|
||||
if (s = *defaults)
|
||||
fprintf(file, "\t%s %s", xpmColorKeys[key - 1], s);
|
||||
}
|
||||
fprintf(file, "\",\n");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static int WritePixels(
|
||||
FILE* file
|
||||
, unsigned int width
|
||||
, unsigned int height
|
||||
, unsigned int cpp
|
||||
, unsigned int* pixels
|
||||
, XpmColor* colors
|
||||
)
|
||||
#else
|
||||
static int
|
||||
WritePixels(file, width, height, cpp, pixels, colors)
|
||||
FILE *file;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int cpp;
|
||||
unsigned int *pixels;
|
||||
XpmColor *colors;
|
||||
#endif
|
||||
{
|
||||
char *s, *p, *buf;
|
||||
unsigned int x, y, h;
|
||||
|
||||
h = height - 1;
|
||||
p = buf = (char *) XpmMalloc(width * cpp + 3);
|
||||
if (!buf)
|
||||
return (XpmNoMemory);
|
||||
*buf = '"';
|
||||
p++;
|
||||
for (y = 0; y < h; y++) {
|
||||
s = p;
|
||||
for (x = 0; x < width; x++, pixels++) {
|
||||
strncpy(s, colors[*pixels].string, cpp);
|
||||
s += cpp;
|
||||
}
|
||||
*s++ = '"';
|
||||
*s = '\0';
|
||||
fprintf(file, "%s,\n", buf);
|
||||
}
|
||||
/* duplicate some code to avoid a test in the loop */
|
||||
s = p;
|
||||
for (x = 0; x < width; x++, pixels++) {
|
||||
strncpy(s, colors[*pixels].string, cpp);
|
||||
s += cpp;
|
||||
}
|
||||
*s++ = '"';
|
||||
*s = '\0';
|
||||
fprintf(file, "%s", buf);
|
||||
|
||||
XpmFree(buf);
|
||||
return (XpmSuccess);
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static void WriteExtensions(
|
||||
FILE* file
|
||||
, XpmExtension* ext
|
||||
, unsigned int num
|
||||
)
|
||||
#else
|
||||
static void
|
||||
WriteExtensions(file, ext, num)
|
||||
FILE *file;
|
||||
XpmExtension *ext;
|
||||
unsigned int num;
|
||||
#endif
|
||||
{
|
||||
unsigned int x, y, n;
|
||||
char **line;
|
||||
|
||||
for (x = 0; x < num; x++, ext++) {
|
||||
fprintf(file, ",\n\"XPMEXT %s\"", ext->name);
|
||||
n = ext->nlines;
|
||||
for (y = 0, line = ext->lines; y < n; y++, line++)
|
||||
fprintf(file, ",\n\"%s\"", *line);
|
||||
}
|
||||
fprintf(file, ",\n\"XPMENDEXT\"");
|
||||
}
|
||||
|
||||
/*
|
||||
* open the given file to be written as an xpmData which is returned
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
#define popen fopen
|
||||
#define pclose fclose
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static int OpenWriteFile(
|
||||
char* filename
|
||||
, xpmData* mdata
|
||||
)
|
||||
#else
|
||||
static int
|
||||
OpenWriteFile(filename, mdata)
|
||||
char *filename;
|
||||
xpmData *mdata;
|
||||
#endif
|
||||
{
|
||||
#ifndef NO_ZPIPE
|
||||
char buf[BUFSIZ];
|
||||
|
||||
#endif
|
||||
|
||||
if (!filename) {
|
||||
mdata->stream.file = (stdout);
|
||||
mdata->type = XPMFILE;
|
||||
} else {
|
||||
#ifndef NO_ZPIPE
|
||||
int len = strlen(filename);
|
||||
if (len > 2 && !strcmp(".Z", filename + (len - 2))) {
|
||||
sprintf(buf, "compress > \"%s\"", filename);
|
||||
if (!(mdata->stream.file = popen(buf, "w")))
|
||||
return (XpmOpenFailed);
|
||||
|
||||
mdata->type = XPMPIPE;
|
||||
} else if (len > 3 && !strcmp(".gz", filename + (len - 3))) {
|
||||
sprintf(buf, "gzip -q > \"%s\"", filename);
|
||||
if (!(mdata->stream.file = popen(buf, "w")))
|
||||
return (XpmOpenFailed);
|
||||
|
||||
mdata->type = XPMPIPE;
|
||||
} else {
|
||||
#endif
|
||||
if (!(mdata->stream.file = fopen(filename, "w")))
|
||||
return (XpmOpenFailed);
|
||||
|
||||
mdata->type = XPMFILE;
|
||||
#ifndef NO_ZPIPE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return (XpmSuccess);
|
||||
}
|
||||
|
||||
/*
|
||||
* close the file related to the xpmData if any
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static void xpmDataClose(xpmData* mdata)
|
||||
#else
|
||||
static void
|
||||
xpmDataClose(mdata)
|
||||
xpmData *mdata;
|
||||
#endif
|
||||
{
|
||||
switch (mdata->type) {
|
||||
case XPMFILE:
|
||||
if (mdata->stream.file != (stdout))
|
||||
fclose(mdata->stream.file);
|
||||
break;
|
||||
#ifndef NO_ZPIPE
|
||||
case XPMPIPE:
|
||||
pclose(mdata->stream.file);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
348
src/xpm/XpmI.h
348
src/xpm/XpmI.h
@@ -1,348 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* XpmI.h: *
|
||||
* *
|
||||
* XPM library *
|
||||
* Internal Include file *
|
||||
* *
|
||||
* ** Everything defined here is subject to changes any time. ** *
|
||||
* *
|
||||
* Developed by Arnaud Le Hors *
|
||||
\*****************************************************************************/
|
||||
|
||||
/*
|
||||
* The code related to FOR_MSW has been added by
|
||||
* HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
|
||||
*/
|
||||
|
||||
#ifndef XPMI_h
|
||||
#define XPMI_h
|
||||
|
||||
#include "xpm.h"
|
||||
|
||||
// Added by JACS for some compilers (no popen/pclose functions)
|
||||
#if defined(__WATCOMC__) || (!defined(WIN32) && defined(_MSC_VER)) || (!defined(WIN32) && defined(__BORLANDC__))
|
||||
#define NO_ZPIPE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* lets try to solve include files
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
/* stdio.h doesn't declare popen on a Sequent DYNIX OS */
|
||||
#ifdef sequent
|
||||
extern FILE *popen();
|
||||
#endif
|
||||
|
||||
#if defined(SYSV) || defined(SVR4) || defined(VMS) || defined(WIN32)
|
||||
#include <string.h>
|
||||
|
||||
#ifndef index
|
||||
#define index strchr
|
||||
#endif
|
||||
|
||||
#ifndef rindex
|
||||
#define rindex strrchr
|
||||
#endif
|
||||
|
||||
#else /* defined(SYSV) || defined(SVR4) || defined(VMS) */
|
||||
#include <strings.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(SYSV) || defined(SVR4) || defined(VMS) || defined(WIN32)
|
||||
#ifndef bcopy
|
||||
#define bcopy(source, dest, count) memcpy(dest, source, count)
|
||||
#endif
|
||||
#ifndef bzero
|
||||
#define bzero(b, len) memset(b, 0, len)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* the following is defined in X11R6 but not in previous versions */
|
||||
#ifdef __alpha
|
||||
#ifndef LONG64
|
||||
#define LONG64
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef VMS
|
||||
#include <unixio.h>
|
||||
#include <file.h>
|
||||
#endif
|
||||
|
||||
/* The following should help people wanting to use their own memory allocation
|
||||
* functions. To avoid the overhead of a function call when the standard
|
||||
* functions are used these are all macros, even the XpmFree function which
|
||||
* needs to be a real function for the outside world though.
|
||||
* So if change these be sure to change the XpmFree function in misc.c
|
||||
* accordingly.
|
||||
*/
|
||||
#define XpmFree(ptr) free(ptr)
|
||||
|
||||
#ifndef FOR_MSW
|
||||
#define XpmMalloc(size) malloc((size))
|
||||
#define XpmRealloc(ptr, size) realloc((ptr), (size))
|
||||
#define XpmCalloc(nelem, elsize) calloc((nelem), (elsize))
|
||||
#else
|
||||
/* checks for mallocs bigger than 64K */
|
||||
#define XpmMalloc(size) boundCheckingMalloc((long)(size))/* in simx.[ch] */
|
||||
#define XpmRealloc(ptr, size) boundCheckingRealloc((ptr),(long)(size))
|
||||
#define XpmCalloc(nelem, elsize) \
|
||||
boundCheckingCalloc((long)(nelem),(long) (elsize))
|
||||
#endif
|
||||
|
||||
#define XPMMAXCMTLEN BUFSIZ
|
||||
typedef struct {
|
||||
unsigned int type;
|
||||
union {
|
||||
FILE *file;
|
||||
char **data;
|
||||
} stream;
|
||||
char *cptr;
|
||||
unsigned int line;
|
||||
int CommentLength;
|
||||
char Comment[XPMMAXCMTLEN];
|
||||
char *Bcmt, *Ecmt, Bos, Eos;
|
||||
int format; /* 1 if XPM1, 0 otherwise */
|
||||
#ifdef CXPMPROG
|
||||
int lineNum;
|
||||
int charNum;
|
||||
#endif
|
||||
} xpmData;
|
||||
|
||||
#define XPMARRAY 0
|
||||
#define XPMFILE 1
|
||||
#define XPMPIPE 2
|
||||
#define XPMBUFFER 3
|
||||
|
||||
#define EOL '\n'
|
||||
#define TAB '\t'
|
||||
#define SPC ' '
|
||||
|
||||
typedef struct {
|
||||
char *type; /* key word */
|
||||
char *Bcmt; /* string beginning comments */
|
||||
char *Ecmt; /* string ending comments */
|
||||
char Bos; /* character beginning strings */
|
||||
char Eos; /* character ending strings */
|
||||
char *Strs; /* strings separator */
|
||||
char *Dec; /* data declaration string */
|
||||
char *Boa; /* string beginning assignment */
|
||||
char *Eoa; /* string ending assignment */
|
||||
} xpmDataType;
|
||||
|
||||
extern xpmDataType xpmDataTypes[];
|
||||
|
||||
/*
|
||||
* rgb values and ascii names (from rgb text file) rgb values,
|
||||
* range of 0 -> 65535 color mnemonic of rgb value
|
||||
*/
|
||||
typedef struct {
|
||||
int r, g, b;
|
||||
char *name;
|
||||
} xpmRgbName;
|
||||
|
||||
/* Maximum number of rgb mnemonics allowed in rgb text file. */
|
||||
#define MAX_RGBNAMES 1024
|
||||
|
||||
extern char *xpmColorKeys[];
|
||||
|
||||
#define TRANSPARENT_COLOR "None" /* this must be a string! */
|
||||
|
||||
/* number of xpmColorKeys */
|
||||
#define NKEYS 5
|
||||
|
||||
/* XPM internal routines */
|
||||
|
||||
FUNC(xpmParseData, int, (xpmData *data, XpmImage *image, XpmInfo *info));
|
||||
FUNC(xpmParseDataAndCreate, int, (Display *display, xpmData *data,
|
||||
XImage **image_return,
|
||||
XImage **shapeimage_return,
|
||||
XpmImage *image, XpmInfo *info,
|
||||
XpmAttributes *attributes));
|
||||
|
||||
FUNC(xpmFreeColorTable, void, (XpmColor *colorTable, int ncolors));
|
||||
|
||||
FUNC(xpmInitAttributes, void, (XpmAttributes *attributes));
|
||||
|
||||
FUNC(xpmInitXpmImage, void, (XpmImage *image));
|
||||
|
||||
FUNC(xpmInitXpmInfo, void, (XpmInfo *info));
|
||||
|
||||
FUNC(xpmSetInfoMask, void, (XpmInfo *info, XpmAttributes *attributes));
|
||||
FUNC(xpmSetInfo, void, (XpmInfo *info, XpmAttributes *attributes));
|
||||
FUNC(xpmSetAttributes, void, (XpmAttributes *attributes, XpmImage *image,
|
||||
XpmInfo *info));
|
||||
|
||||
#if !defined(FOR_MSW) && !defined(AMIGA)
|
||||
FUNC(xpmCreatePixmapFromImage, void, (Display *display, Drawable d,
|
||||
XImage *ximage, Pixmap *pixmap_return));
|
||||
|
||||
FUNC(xpmCreateImageFromPixmap, void, (Display *display, Pixmap pixmap,
|
||||
XImage **ximage_return,
|
||||
unsigned int *width,
|
||||
unsigned int *height));
|
||||
#endif
|
||||
|
||||
/* structures and functions related to hastable code */
|
||||
|
||||
typedef struct _xpmHashAtom {
|
||||
char *name;
|
||||
void *data;
|
||||
} *xpmHashAtom;
|
||||
|
||||
typedef struct {
|
||||
int size;
|
||||
int limit;
|
||||
int used;
|
||||
xpmHashAtom *atomTable;
|
||||
} xpmHashTable;
|
||||
|
||||
FUNC(xpmHashTableInit, int, (xpmHashTable *table));
|
||||
FUNC(xpmHashTableFree, void, (xpmHashTable *table));
|
||||
FUNC(xpmHashSlot, xpmHashAtom *, (xpmHashTable *table, char *s));
|
||||
FUNC(xpmHashIntern, int, (xpmHashTable *table, char *tag, void *data));
|
||||
|
||||
#define HashAtomData(i) ((void *)i)
|
||||
#define HashColorIndex(slot) ((unsigned int)((*slot)->data))
|
||||
#define USE_HASHTABLE (cpp > 2 && ncolors > 4)
|
||||
|
||||
/* I/O utility */
|
||||
|
||||
FUNC(xpmNextString, int, (xpmData *mdata));
|
||||
FUNC(xpmNextUI, int, (xpmData *mdata, unsigned int *ui_return));
|
||||
FUNC(xpmGetString, int, (xpmData *mdata, char **sptr, unsigned int *l));
|
||||
|
||||
#define xpmGetC(mdata) \
|
||||
((!mdata->type || mdata->type == XPMBUFFER) ? \
|
||||
(*mdata->cptr++) : (getc(mdata->stream.file)))
|
||||
|
||||
FUNC(xpmNextWord, unsigned int,
|
||||
(xpmData *mdata, char *buf, unsigned int buflen));
|
||||
FUNC(xpmGetCmt, int, (xpmData *mdata, char **cmt));
|
||||
FUNC(xpmParseHeader, int, (xpmData *mdata));
|
||||
FUNC(xpmParseValues, int, (xpmData *data, unsigned int *width,
|
||||
unsigned int *height, unsigned int *ncolors,
|
||||
unsigned int *cpp, unsigned int *x_hotspot,
|
||||
unsigned int *y_hotspot, unsigned int *hotspot,
|
||||
unsigned int *extensions));
|
||||
|
||||
FUNC(xpmParseColors, int, (xpmData *data, unsigned int ncolors,
|
||||
unsigned int cpp, XpmColor **colorTablePtr,
|
||||
xpmHashTable *hashtable));
|
||||
|
||||
FUNC(xpmParseExtensions, int, (xpmData *data, XpmExtension **extensions,
|
||||
unsigned int *nextensions));
|
||||
|
||||
/* RGB utility */
|
||||
|
||||
FUNC(xpmReadRgbNames, int, (char *rgb_fname, xpmRgbName *rgbn));
|
||||
FUNC(xpmGetRgbName, char *, (xpmRgbName *rgbn, int rgbn_max,
|
||||
int red, int green, int blue));
|
||||
FUNC(xpmFreeRgbNames, void, (xpmRgbName *rgbn, int rgbn_max));
|
||||
#ifdef FOR_MSW
|
||||
FUNC(xpmGetRGBfromName,int, (char *name, int *r, int *g, int *b));
|
||||
#endif
|
||||
|
||||
#ifndef AMIGA
|
||||
FUNC(xpm_xynormalizeimagebits, void, (register unsigned char *bp,
|
||||
register XImage *img));
|
||||
FUNC(xpm_znormalizeimagebits, void, (register unsigned char *bp,
|
||||
register XImage *img));
|
||||
|
||||
/*
|
||||
* Macros
|
||||
*
|
||||
* The XYNORMALIZE macro determines whether XY format data requires
|
||||
* normalization and calls a routine to do so if needed. The logic in
|
||||
* this module is designed for LSBFirst byte and bit order, so
|
||||
* normalization is done as required to present the data in this order.
|
||||
*
|
||||
* The ZNORMALIZE macro performs byte and nibble order normalization if
|
||||
* required for Z format data.
|
||||
*
|
||||
* The XYINDEX macro computes the index to the starting byte (char) boundary
|
||||
* for a bitmap_unit containing a pixel with coordinates x and y for image
|
||||
* data in XY format.
|
||||
*
|
||||
* The ZINDEX* macros compute the index to the starting byte (char) boundary
|
||||
* for a pixel with coordinates x and y for image data in ZPixmap format.
|
||||
*
|
||||
*/
|
||||
|
||||
#define XYNORMALIZE(bp, img) \
|
||||
if ((img->byte_order == MSBFirst) || (img->bitmap_bit_order == MSBFirst)) \
|
||||
xpm_xynormalizeimagebits((unsigned char *)(bp), img)
|
||||
|
||||
#define ZNORMALIZE(bp, img) \
|
||||
if (img->byte_order == MSBFirst) \
|
||||
xpm_znormalizeimagebits((unsigned char *)(bp), img)
|
||||
|
||||
#define XYINDEX(x, y, img) \
|
||||
((y) * img->bytes_per_line) + \
|
||||
(((x) + img->xoffset) / img->bitmap_unit) * (img->bitmap_unit >> 3)
|
||||
|
||||
#define ZINDEX(x, y, img) ((y) * img->bytes_per_line) + \
|
||||
(((x) * img->bits_per_pixel) >> 3)
|
||||
|
||||
#define ZINDEX32(x, y, img) ((y) * img->bytes_per_line) + ((x) << 2)
|
||||
|
||||
#define ZINDEX16(x, y, img) ((y) * img->bytes_per_line) + ((x) << 1)
|
||||
|
||||
#define ZINDEX8(x, y, img) ((y) * img->bytes_per_line) + (x)
|
||||
|
||||
#define ZINDEX1(x, y, img) ((y) * img->bytes_per_line) + ((x) >> 3)
|
||||
#endif /* not AMIGA */
|
||||
|
||||
#ifdef __STDC__
|
||||
#define Const const
|
||||
#else
|
||||
#define Const /**/
|
||||
#endif
|
||||
|
||||
#ifdef NEED_STRDUP
|
||||
FUNC(xpmstrdup, char *, (char *s1));
|
||||
#else
|
||||
#undef xpmstrdup
|
||||
#define xpmstrdup strdup
|
||||
#endif
|
||||
|
||||
#ifdef NEED_STRCASECMP
|
||||
FUNC(xpmstrcasecmp, int, (char *s1, char *s2));
|
||||
#else
|
||||
#undef xpmstrcasecmp
|
||||
#define xpmstrcasecmp strcasecmp
|
||||
#endif
|
||||
|
||||
FUNC(xpmatoui, unsigned int,
|
||||
(char *p, unsigned int l, unsigned int *ui_return));
|
||||
|
||||
#endif
|
957
src/xpm/changes
957
src/xpm/changes
@@ -1,957 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/**************************************************************************\
|
||||
* *
|
||||
* HISTORY of user-visible changes *
|
||||
* *
|
||||
\**************************************************************************/
|
||||
|
||||
3.4k (98/03/18)
|
||||
|
||||
ENHANCEMENTS:
|
||||
- A new program called cxpm is provided to check on XPM files and help
|
||||
figuring out where the file might be invalid.
|
||||
- The FAQ and README are now in HTML.
|
||||
|
||||
BUGS CORRECTED:
|
||||
- A bug in writing pixmaps out on an 32 bit depth visual and MSBFirst
|
||||
machine.
|
||||
- patch from Uwe Langenkamp <Uwe.Langenkamp@t-online.de>
|
||||
- A severe bug in parsing the pixels section when an unknown character
|
||||
is encountered.
|
||||
|
||||
3.4j (96/12/31)
|
||||
|
||||
ENHANCEMENTS:
|
||||
- The XPM library can now be built under Amiga DOS. This entirely comes
|
||||
from: Lorens Younes <d93-hyo@nada.kth.se>
|
||||
See the README.AMIGA file for details.
|
||||
- Changes for MSW: big performance improvement in ParseAndPutPixels(),
|
||||
fixed creation of the mask in SetColor()
|
||||
- patch from Jan Wielemaker <jan@swi.psy.uva.nl>
|
||||
- makefiles are provided for VMS
|
||||
- given by Martin P.J. Zinser m.zinser@gsi.de
|
||||
- Imakefiles reworked to get smoother builds and fixes from:
|
||||
- Paul DuBois dubois@primate.wisc.edu
|
||||
- Larry Schwimmer schwim@cyclone.stanford.edu
|
||||
- thanks to some code rearrangement the library is smaller (the size
|
||||
reduction goes from 4 to 7% depending on the system)
|
||||
|
||||
BUGS CORRECTED:
|
||||
- A severe bug (introduced in 3.4i as part of the sprintf
|
||||
optimization) in code writing XPM extensions to a buffer
|
||||
XpmCreateBufferFromImage/Pixmap.
|
||||
- The XpmAttributes definition in xpm.h was declaring nalloc_colors to
|
||||
be Bool, it's an int.
|
||||
|
||||
3.4i (96/09/13)
|
||||
|
||||
NEW FEATURES:
|
||||
- The XPM library now allows the application to pass its own color
|
||||
allocation/free functions. For this matter the following was done:
|
||||
The XpmAttributes structure has three new fields alloc_color,
|
||||
free_color, and color_closure. The following new valuemasks were
|
||||
added XpmAllocColorFunc, XpmFreeColorsFunc, XpmColorClosure. And
|
||||
two new types were defined XpmAllocColorFunc and XpmFreeColorsFunc.
|
||||
See documentation for details.
|
||||
|
||||
ENHANCEMENTS:
|
||||
- Windows NT support. It should compile and run fine based on the X
|
||||
Consortium X11R6 distribution.
|
||||
- The README file contains information to compile on Solaris with gcc.
|
||||
- Part of the code has been optimized by using the value returned by
|
||||
sprintf instead of calling strlen. Add the flag -DVOID_SPRINTF
|
||||
if on your system sprintf returns void.
|
||||
- patch from Thomas Ott thommy@rz.fh-augsburg.de
|
||||
|
||||
BUGS CORRECTED:
|
||||
- XpmFree is now a real function (simply calling free by default).
|
||||
|
||||
CHANGES TO THE DOC:
|
||||
- The documentation describes the new XpmAttributes fields and their
|
||||
use.
|
||||
|
||||
3.4h (96/02/01)
|
||||
|
||||
NEW FEATURES:
|
||||
- The XpmAttributes has a new member called 'alloc_close_colors' which
|
||||
lets the caller specify whether close colors should be allocated
|
||||
using XAllocColor or not. This is especially useful when one uses a
|
||||
private colormap full of read/write cells.
|
||||
The xpm.h header file define a new bitmap flag called
|
||||
XpmAllocCloseColors to use along with this new slot.
|
||||
- Dale Pease peased@bigbird.cso.gtegsc.com
|
||||
- The XpmAttributes has a new member called 'bitmap_format' which lets
|
||||
the caller specify the format of 1 bit depth images (XYBitmap or
|
||||
ZPixmap). The xpm.h header file define a new bitmap flag called
|
||||
XpmBitmapFormat to use along with this new field.
|
||||
|
||||
ENHANCEMENTS:
|
||||
- XpmReadFileTo[Image/Pixmap], XpmCreate[Image/Pixmap]FromData,
|
||||
XpmCreateImageFromDataFromBuffer functions do no longer use a
|
||||
temporary XpmImage object, which reduces a lot the amount of memory
|
||||
used. On the other hand it can take a little more time, but given the
|
||||
following figures (based on sxpm) it is a real good trade-off.
|
||||
|
||||
Reading a 22x22 pixmap with 5 colors no time change is detected
|
||||
using time:
|
||||
real 0.3
|
||||
user 0.1
|
||||
sys 0.1
|
||||
|
||||
Reading a 1279x1023 pixmap with 14 colors (quite extreme case for
|
||||
XPM!) the time goes from:
|
||||
real 1.9
|
||||
user 0.8
|
||||
sys 0.8
|
||||
|
||||
to:
|
||||
real 2.2
|
||||
user 1.8
|
||||
sys 0.3
|
||||
|
||||
Reading the 22x22 pixmap with 5 colors the memory usage (under
|
||||
purify) goes from:
|
||||
255256 code
|
||||
55496 data/bss
|
||||
163848 heap (peak use)
|
||||
4248 stack
|
||||
to:
|
||||
271240 code
|
||||
55472 data/bss
|
||||
159752 heap (peak use)
|
||||
4224 stack
|
||||
|
||||
And reading the 1279x1023 pixmap with 14 colors it goes from:
|
||||
255256 code
|
||||
55496 data/bss
|
||||
6705160 heap (peak use)
|
||||
4280 stack
|
||||
to:
|
||||
271240 code
|
||||
55472 data/bss
|
||||
1732616 heap (peak use)
|
||||
4264 stack
|
||||
|
||||
This clearly shows that while for small pixmaps there is no real
|
||||
difference on both sides, for large pixmaps this makes a huge
|
||||
difference about the amount of memory used and it is not much
|
||||
slower.
|
||||
|
||||
Note that you can still get the old behavior using both
|
||||
XpmReadFileToXpmImage and XpmCreate[Image/Pixmap]FromXpmImage instead
|
||||
of XpmReadFileTo[Image/Pixmap]. Once more XPM gives you the choice!
|
||||
|
||||
BUGS CORRECTED:
|
||||
- when defined locally the global symbols strcasecmp and strdup are
|
||||
now called xpmstrcasecmp and xpmstrdup to avoid any possible
|
||||
conflict.
|
||||
- VMS has a bogus file system which requires a work around in
|
||||
XpmReadFileToBuffer.
|
||||
- patch from Bob.Deen@jpl.nasa.gov
|
||||
- the type of the exactColors attribute has been changed from unsigned
|
||||
int to Bool.
|
||||
|
||||
CHANGES TO THE DOC:
|
||||
- the documentation describes the new XpmAttributes fields
|
||||
alloc_close_colors and bitmap_format.
|
||||
|
||||
3.4g (95/10/08)
|
||||
|
||||
ENHANCEMENTS:
|
||||
- The XpmAttributes structure has now two new slots: alloc_pixels and
|
||||
nalloc_pixels in order to provide an easy way to free allocated
|
||||
colors. The new bitmask XpmReturnAllocPixels should be used to
|
||||
request this data through the valuemask. Unless you really know why,
|
||||
you should use this instead of XpmReturnPixels, pixels, and npixels.
|
||||
- the XPM1 format parsing has been improved.
|
||||
- patch from Chuck Thompson <cthomp@cs.uiuc.edu>
|
||||
- compilers defining _STDC_ to something different from 1 are now
|
||||
considered as ANSI compilers.
|
||||
- the README file provides now more info on how to build XPM depending
|
||||
on the system.
|
||||
|
||||
BUGS CORRECTED:
|
||||
- a bug introduced in 3.4f in the XPM1 format parsing function.
|
||||
- fix from Chuck Thompson <cthomp@cs.uiuc.edu>
|
||||
- the hashtable was not free when the color parsing failed.
|
||||
- patch from ackley@cs.unm.edu (David Ackley)
|
||||
- the close color mechanism wasn't used if one of the closeness
|
||||
parameter was null. Now only one needs to be different from 0.
|
||||
Lorens Younes d93-hyo@nada.kth.se
|
||||
- parsing of long comments failed with a segmentation fault.
|
||||
|
||||
CHANGES TO THE DOC:
|
||||
- the documentation describes the new XpmAttributes fields
|
||||
alloc_pixels and nalloc_pixels and how they are used.
|
||||
|
||||
3.4f (95/05/29)
|
||||
|
||||
ENHANCEMENTS:
|
||||
- Defines IMAKE_DEFINES in the top Imakefile so one can easily avoid
|
||||
building the shared library.
|
||||
- Add some information about the installation process in the README.
|
||||
- filenames are surrounded with quotes when calling gzip or compress in
|
||||
order to allow spaces within filenames.
|
||||
- William Parn <parn@fgm.com>
|
||||
- the compilation and the shared library building should be smoother
|
||||
on Alpha OSF/1.
|
||||
- patch from Dale Moore <Dale.Moore@CS.cmu.edu>
|
||||
|
||||
BUGS CORRECTED:
|
||||
- a segmentation fault occurring in some weird case.
|
||||
|
||||
3.4e (95/03/01)
|
||||
|
||||
ENHANCEMENTS:
|
||||
- The top Imakefile passes CDEBUGFLAGS and DEFINES to subdirs. Thus
|
||||
only this Imakefile should need to be edited by users.
|
||||
- FAQ includes the answer to the question "How can I get a non
|
||||
rectangular icon using XPM ?"
|
||||
- VMS support updated
|
||||
- patch from Martin P.J. Zinser m.zinser@gsi.de
|
||||
|
||||
BUGS CORRECTED:
|
||||
- XpmCreateImageFromXpmImage() called from XpmReadFileToPixmap() could
|
||||
lead to a segmentation fault since free was called on a memory block
|
||||
size variable instead of the block itself. Note: this bug has been
|
||||
introduced in 3.4d.
|
||||
|
||||
3.4d (95/01/31)
|
||||
|
||||
ENHANCEMENTS:
|
||||
- sxpm now supports a -version option command.
|
||||
|
||||
BUGS CORRECTED:
|
||||
- the list of pixels returned in XpmAttributes was wrong when two
|
||||
colors were defined as None in the read XPM
|
||||
- Lionel.Mallet@sophia.inria.fr
|
||||
- the parser was skipping whitespace reading extensions strings. This
|
||||
has been fixed so extensions lines are now returned exactly as they
|
||||
are.
|
||||
- some compilation control added for the dec alpha with X11R5 (LONG64)
|
||||
- patch from Fredrik Lundh <Fredrik_Lundh@ivab.se>
|
||||
- when writing an XPM file, '-' characters are replaced with '_'
|
||||
characters in the array name, in order to get a valid C syntax name.
|
||||
- XYPixmap format images were not correctly handled.
|
||||
- XPM1 file with names using multiple '_' characters are now handled
|
||||
correctly.
|
||||
- todd@erda.rl.af.mil (Todd Gleason)
|
||||
|
||||
3.4c (94/06/06)
|
||||
|
||||
Yes, this is kind of quick. But this is because no code has been modified,
|
||||
this is just a new packaging to make the whole stuff more suitable to the
|
||||
X development team's requests for inclusion in the R6 contrib.
|
||||
|
||||
ENHANCEMENTS:
|
||||
- Several filenames were too long to fit without any conflict on DOS
|
||||
and CD-ROM filesystems. They have been renamed.
|
||||
- Imakefiles use XCOMM for comments instead of the # character.
|
||||
- the Postscript documentation file doc/xpm.ps is now distributed as
|
||||
doc/xpm.PS.gz and allows browsing with tools such as ghostview.
|
||||
- Besides, parts of lib/misc.c have been moved to several new files,
|
||||
and some functions of data.c have been moved to other files in
|
||||
order to get a better link profile.
|
||||
- I've also added a FAQ hoping this will prevent people from
|
||||
continuously filling my mailbox with the same questions.
|
||||
- sxpm.c includes <X11/xpm.h> instead of "xpm.h" and BUILDINCTOP is
|
||||
used in Makefiles as expected.
|
||||
- Everything can be done simply using "xmkmf -a" and "make".
|
||||
|
||||
3.4b (94/05/24)
|
||||
|
||||
ENHANCEMENTS:
|
||||
- XPM can now be built under MS Windows. Yes, this is possible and this
|
||||
entirely comes from:
|
||||
- Hermann Dunkel <hedu@cul-ipn.uni-kiel.de>
|
||||
See the README.MSW file for details.
|
||||
|
||||
- building the shared library now depends on the SharedLibXpm variable
|
||||
and no longer on the SharedLibX variable which is private to the X
|
||||
Window System project.
|
||||
- patch from Stephen Gildea <gildea@x.org>
|
||||
Other variables can now be set for the various locations needed.
|
||||
|
||||
- lib/parse.c does no longer use a 256x256 array in the stack but
|
||||
malloc it instead.
|
||||
|
||||
- The Copyright notice which has been re-written from the X11R6's one
|
||||
should be clearer and is now present in every file.
|
||||
|
||||
BUGS CORRECTED:
|
||||
- lib/xpmP.h does no longer define a Boolean type which conflicts with
|
||||
the Intrinsic definition. Instead the type Bool defined in Xlib is
|
||||
used.
|
||||
- neumann@watson.ibm.com (Gustaf Neumann)
|
||||
|
||||
3.4a (94/03/29)
|
||||
|
||||
BUGS CORRECTED:
|
||||
- passing NULL as shapemask_return to XpmReadFileToPixmap and similar
|
||||
functions was leading to a bus error.
|
||||
- Dean Luick <dean@falcon.natinst.com>
|
||||
|
||||
3.4 (94/03/14)
|
||||
|
||||
IMPORTANT NOTE:
|
||||
This version is not compatible with 3.3. Fortunately most people should
|
||||
only need to recompile.
|
||||
I apology for this but CDE/Motif have put heavy pressure to go that
|
||||
way. The point is that I designed and released Xpm 3.3 in order to let
|
||||
OSF include a clean version of Xpm in Motif 2.0. This new version was
|
||||
not fully compatible with 3.2 but I thought it didn't matter since this
|
||||
was going to be the first version used within Motif. Unfortunately CDE
|
||||
was already using xpm-3.2 internally and requires both source and
|
||||
binary backward compatibility. By the way I must say they didn't drop
|
||||
us a single line to let us know they were using it and thus were
|
||||
expecting stability. All this could have been avoided...
|
||||
|
||||
However, since I had to go for a not compatible version I took this as
|
||||
an opportunity to modify the lower level API, which was new in 3.3 and
|
||||
which was somewhat clumsy, in order to provide yet a better API.
|
||||
|
||||
The library has been modified to have both source and binary backward
|
||||
compatibility with xpm-3.2. This implies it is not either source or
|
||||
binary compatible with 3.3. The fields related to the 3.2 XpmInfos
|
||||
mechanism have been put back into the XpmAttributes structure. The new
|
||||
3.3 XpmInfos struct has been renamed as XpmInfo to avoid conflict with
|
||||
the old 3.2 flag which is back too. All the semantic related to the
|
||||
XpmAttributes infos fields is back as well.
|
||||
|
||||
So this new version provides a high level API which is fully
|
||||
compatible with 3.2 and still provides the 3.3 lower level API
|
||||
(XpmImage) with the XpmInfos struct renamed as XpmInfo. This leads to
|
||||
some redundancy but this was the best I could do to satisfy both
|
||||
CDE/Motif people who needed the backward compatibility and myself (who
|
||||
always tries to provide you with the best ;-).
|
||||
|
||||
Tests have been successfully performed with pixmap-2.1, pixmap-2.4, and
|
||||
sxpm.
|
||||
|
||||
ENHANCEMENTS:
|
||||
- The colorTable member of the XpmAttributes structure is now an
|
||||
(XpmColor*) in order to be compatible with an XpmImage colorTable.
|
||||
However in order to be backward compatible this field is cast to
|
||||
(XpmColor **), which is equivalent to (char ***), when it is used
|
||||
with the old flags XpmInfos and XpmReturnInfos. To handle the new
|
||||
type the new flags XpmColorTable and XpmReturnColorTable have been
|
||||
defined.
|
||||
- The XpmInfo struct has been extended to avoid having to deal with an
|
||||
XpmAttributes at the lower level. The idea is that all the data
|
||||
stored in an Xpm file can be retrieve through both an XpmImage and
|
||||
an XpmInfo struct. See the documentation for details.
|
||||
- XpmUndefPixel is defined and exported by xpm.h in order to let
|
||||
clients providing their own colorTable when writing out an Xpm file.
|
||||
See the documentation for details.
|
||||
- in sxpm/sxpm.c, set attribute XtNinput to True on toplevel widget.
|
||||
Windows that don't "take" input, never get focus, as mandated by
|
||||
the ICCM.
|
||||
patch from Henrique Martins <martins@hplhasm.hpl.hp.com>
|
||||
- lib/Imakefile modified to build the shared library under IRIX 5.
|
||||
patch from simon@lia.di.epfl.ch (Simon Leinen)
|
||||
|
||||
NEW FEATURES:
|
||||
- a new function and a new define should help client figuring out with
|
||||
which Xpm library version they are working. These are
|
||||
XpmIncludeVersion and XpmLibraryVersion().
|
||||
|
||||
3.3 (93/12/20)
|
||||
|
||||
NEW FEATURES:
|
||||
- XPM1 files are now supported.
|
||||
- a new function is provided to get an error string related to the
|
||||
returned error code.
|
||||
- suggested by Detlef Schmier <detlef@mfr.dec.com>
|
||||
|
||||
ENHANCEMENTS:
|
||||
- gzip and gunzip are called with the -q option (quiet)
|
||||
- patch from Chris P. Ross <cross@eng.umd.edu>
|
||||
- the parser is again more flexible about the way the strings are
|
||||
distributed on lines. Actually a single line XPM file can be read.
|
||||
- the documentation should be clearer about shapemask generation and
|
||||
XpmAttributes valuemask.
|
||||
|
||||
BUGS CORRECTED:
|
||||
- reading some binary file was leading to a bus error.
|
||||
- patch from Detlef Schmier <detlef@mfr.dec.com>
|
||||
- the ? character is no longer used when writing an XPM file in order
|
||||
to avoid possible ANSI trigraphs.
|
||||
|
||||
3.3alpha (93/08/13)
|
||||
|
||||
NEW FEATURES:
|
||||
- a new level interface is provided to allow applications to do either
|
||||
icon editing or data caching.
|
||||
The XpmAttributes has been changed but most applications will just
|
||||
need to be recompiled.
|
||||
- new structures are provided to deal with the new lower level:
|
||||
XpmImage, XpmColor, XpmInfos.
|
||||
|
||||
- a separate distribution called xpm-contrib is available. This
|
||||
includes the converters which used to be part of this distribution
|
||||
plus:
|
||||
two new applications:
|
||||
* nexpm to draw a pixmap in *any* existing window from
|
||||
Ralph Betza <gnohmon@ssiny.com>
|
||||
* xpmview to display a list of Xpm files from
|
||||
Jean Michel Leon <leon@sophia.inria.fr>
|
||||
|
||||
a hacky string to pixmap converter, provided by
|
||||
Robert H. Forsman Jr. <thoth@manatee.cis.ufl.edu>
|
||||
|
||||
The Xpm editor called pixmap will also be part of this contrib.
|
||||
This does not mean it is the best pixmap editor one can find
|
||||
but it is the only one that I know of which tries to handle
|
||||
all the features of this format.
|
||||
|
||||
ENHANCEMENTS:
|
||||
- the code to build XImage data has been optimized by
|
||||
jules@x.co.uk (Julian Gosnell)
|
||||
the old code is still available when compiling with the
|
||||
-DWITHOUT_SPEEDUPS flag.
|
||||
|
||||
- closecolor code was not re-entrant
|
||||
- dbl@visual.com (David B. Lewis)
|
||||
- fix gzip filename (*.gz and no longer *.z).
|
||||
- Jason Patterson <jasonp@fitmail.fit.qut.edu.au>
|
||||
- sxpm has 2 new options:
|
||||
-nom to do not display the mask if there is one
|
||||
-cp <color> <pixel> to override a color value with a given
|
||||
pixel, i.e. sxpm plaid.xpm -cp red 4
|
||||
|
||||
also the '-s' adn '-p' options have been renamed to '-sc' and '-sp'.
|
||||
|
||||
- xpm.h defines XpmFormat, XpmVersion, and XpmRevision numbers.
|
||||
|
||||
BUGS CORRECTED:
|
||||
- closecolor minor fix
|
||||
- Jason Patterson <jasonp@fitmail.fit.qut.edu.au>
|
||||
|
||||
3.2g (93/04/26)
|
||||
|
||||
ENHANCEMENTS:
|
||||
- much faster close colors
|
||||
- piping from/to compressed files now handles GNU's gzip (.z) format
|
||||
- added XpmColorKey attribute - ability to specify which visual's
|
||||
colors to use (ie: now it's possible to read in a pixmap in a
|
||||
color visual, but use the colors specified for monochrome).
|
||||
- added -mono, -grey4, -grey and -color options to sxpm to demonstrate
|
||||
the XpmColorKey attribute.
|
||||
- Jason Patterson <jasonp@fitmail.qut.edu.au>
|
||||
|
||||
BUGS CORRECTED:
|
||||
- fixed bug where redefining "None" as a pixel stopped mask generation
|
||||
- minor SVR4 defines for <string.h>
|
||||
- fixed annoying closecolor bug related to read/write color cells
|
||||
- fixed minor bug in color value -> pixel overloading
|
||||
- manual updated to include new red/green/blue closeness attributes
|
||||
- Jason Patterson <jasonp@fitmail.qut.edu.au>
|
||||
|
||||
- the top Imakefile was missing the depend target
|
||||
- sxpm/Imakefile fixed so that -L../lib is set before the standard
|
||||
library location.
|
||||
- Vivek Khera <khera@cs.duke.edu>
|
||||
|
||||
- lib/xpmP.h now defines bcopy as memcpy for VMS (required by recent
|
||||
versions of VMS)
|
||||
- J. Daniel Smith <dsmith@ann-arbor.applicon.slb.com>
|
||||
|
||||
- the lib/Imakefile didn't work with X11R4.
|
||||
|
||||
|
||||
3.2f (93/03/17)
|
||||
|
||||
NEW FEATURES:
|
||||
- the library provides four new functions to deal with Xpm files
|
||||
loaded in memory as single character strings buffers:
|
||||
|
||||
XpmCreateImageFromBuffer
|
||||
XpmCreatePixmapFromBuffer
|
||||
XpmCreateBufferFromImage
|
||||
XpmCreateBufferFromPixmap
|
||||
|
||||
- in addition, as a convenience, two functions are provided to copy a
|
||||
file in a buffer and to write a file from a buffer:
|
||||
|
||||
XpmReadFileToBuffer
|
||||
XpmWriteFileFromBuffer
|
||||
|
||||
ENHANCEMENTS:
|
||||
- Files are now dispatched in the following sub-directories:
|
||||
lib, sxpm, and doc.
|
||||
- Imakefiles will let you build a shared library as well as the static
|
||||
one (with either X11R4 or X11R5).
|
||||
- The documentation has been ported from LaTeX to FrameMaker and is
|
||||
now included in the distribution in its PostScript form (doc/xpm.ps).
|
||||
Source files are available on request.
|
||||
Also the documentation has been reorganized and includes a table of
|
||||
contents and an index of the functions (the number of functions
|
||||
increasing this became a requisite).
|
||||
|
||||
BUGS CORRECTED:
|
||||
- Many warnings have been fixed - patch from Daniel Dardailler
|
||||
daniel@osf.org
|
||||
|
||||
3.2e (93/02/05)
|
||||
|
||||
ENHANCEMENTS:
|
||||
- use XpmMalloc, XpmRealloc, XpmCalloc, and XpmFree which are defines
|
||||
in xpmP.h. This should help people wanting to use their own functions.
|
||||
|
||||
BUGS CORRECTED:
|
||||
- Intrinsic.h is no longer included.
|
||||
- bzero is defined as memset on SYSV and SVR4.
|
||||
- some memory initialization bug concerning XpmAttributes.
|
||||
|
||||
3.2d (93/01/27)
|
||||
|
||||
ENHANCEMENTS:
|
||||
- compile on Solaris 2.0
|
||||
- patch from Clint Jeffery <cjeffery@cs.arizona.edu>
|
||||
|
||||
BUGS CORRECTED:
|
||||
- shape masks are now set correctly for LSBFirst (Decs).
|
||||
- pixmaps are now set correctly for 2 bit displays (Nexts).
|
||||
- patch from Josef Leherbauer <joe@takeFive.co.at>
|
||||
- isspace was called on getc which fails when EOF is returned.
|
||||
- Marelli Paolo <marelli@colos3.usr.dsi.unimi.it>
|
||||
|
||||
3.2c (92/12/29)
|
||||
|
||||
ENHANCEMENTS:
|
||||
- parsing optimized for single and double characters color
|
||||
- patch originally from Martin Brunecky
|
||||
marbru@build1.auto-trol.com
|
||||
|
||||
BUGS CORRECTED:
|
||||
- XpmFreeExtensions was calling free on some argument without checking
|
||||
it was not NULL.
|
||||
- strdup was not correctly defined for systems which do not provide
|
||||
it. - Hans-Peter Lichtin <lich@zellweger.ch>
|
||||
- some bug in XpmCrDataFI.c
|
||||
- Sven Delmas garfield@avalanche.cs.tu-berlin.de
|
||||
|
||||
NOTE:
|
||||
- there is still a bug with the creation of the clipmask on display of
|
||||
depth 2 but I can't find a fix because unfortunately I don't have such
|
||||
a rendering system and nobody gets the time to investigate for me.
|
||||
|
||||
3.2b (92/10/19)
|
||||
|
||||
ENHANCEMENTS:
|
||||
- Create XpmReadFileToData and XpmWriteFileFromData
|
||||
- Dan Greening <dgreen@sti.com>
|
||||
- added "close colors" support and ability to redefine color values
|
||||
as pixels at load time, as well as color names
|
||||
- Jason Patterson <jasonp@fitmail.qut.edu.au>
|
||||
- errors while parsing or allocating colors now revert to other
|
||||
visual defaults, creating pixmap/image as expected, and returning
|
||||
XpmSuccess. The old behavior of XpmColorError being returned and no
|
||||
pixmap/image being created can be retained by setting the
|
||||
exactColors attribute.
|
||||
- Jason Patterson <jasonp@fitmail.qut.edu.au>
|
||||
|
||||
BUGS CORRECTED:
|
||||
- SVR4 defines for including <string.h> instead of <strings.h>
|
||||
- Jason Patterson <jasonp@fitmail.qut.edu.au>
|
||||
- attributes->extensions and attributes->nextensions fields were not
|
||||
set correctly when no extensions present in file.
|
||||
- Simon_Scott Cornish <cornish@ecr.mu.oz.au>
|
||||
|
||||
3.2a (92/08/17)
|
||||
|
||||
ENHANCEMENTS:
|
||||
- use the mock lisp hashing function instead of the gnu emacs one,
|
||||
it is faster in some cases and never slower (I've not found any case).
|
||||
|
||||
BUGS CORRECTED:
|
||||
- function prototypes for ansi compilers.
|
||||
- some memory initialization bugs (purify is just great for this).
|
||||
- empty strings in extensions are now correctly handled.
|
||||
|
||||
3.2 (92/07/06)
|
||||
|
||||
NEW FEATURES:
|
||||
- both format and functions handle extensions data. This allow people
|
||||
to store additional data related to a pixmap. See documentation for
|
||||
detail.
|
||||
- sxpm supports the new option '-c' to use a private colormap. This is
|
||||
useful when displaying pixmaps using a lot of colors.
|
||||
- sxpm supports the new option '-v' (verbose) to get possible
|
||||
extensions print out on standard error.
|
||||
|
||||
ENHANCEMENTS:
|
||||
- most of the code has been reworked to be improved and thus almost
|
||||
every function is faster. It takes less than 6 seconds of real time on
|
||||
a sun4 to display, with sxpm, a 487x635 pixmap using 213 colors, while
|
||||
it takes 32 seconds with the old library! It takes 18 seconds to
|
||||
display a 1279x1023 screen dump using 14 colors while xwud takes 10
|
||||
seconds.
|
||||
Of course performance improvements are not always that great, they
|
||||
depend on the size and number of colors but I'm sure everybody will
|
||||
appreciate ;-)
|
||||
I know how to improve it more but this will require changes in the
|
||||
architecture so this is not for now. Some optimizations have been
|
||||
contributed by gregor@kafka.saic.com (gregg hanna) and
|
||||
jnc@csl.biosci.arizona.edu (John N. Calley).
|
||||
- the Imakefile is modified to let you install sxpm - Rainer Klute
|
||||
<klute@irb.informatik.uni-dortmund.de>
|
||||
- xpmP.h declares popen for Sequent platforms - Clinton Jeffery
|
||||
<cjeffery@cs.arizona.edu>
|
||||
- XpmWriteFileFromImage/Pixmap rather than truncating the pixmap name
|
||||
to the first dot changes dots to underscores to get a valid C syntax
|
||||
name.
|
||||
|
||||
|
||||
BUGS CORRECTED:
|
||||
- there was a bug in the image creation function for some 24 bits
|
||||
displays. It is fixed.
|
||||
- allocated color pixels are now freed when an error occurs -
|
||||
nusser@dec1.wu-wien.ac.at (Stefan Nusser)
|
||||
|
||||
CHANGES TO THE DOC:
|
||||
- the documentation describes the new XpmExtension structure and how
|
||||
to use it with read and write functions.
|
||||
|
||||
3.1 (92/02/03)
|
||||
|
||||
ENHANCEMENTS:
|
||||
- sxpm now have more standard options (mainly suggested by
|
||||
Rainer Sinkwitz <sinkwitz@ifi.unizh.ch>):
|
||||
|
||||
Usage: sxpm [options...]
|
||||
Where options are:
|
||||
|
||||
[-d host:display] Display to connect to.
|
||||
[-g geom] Geometry of window.
|
||||
[-hints] Set ResizeInc for window.
|
||||
[-icon filename] Set pixmap for iconWindow.
|
||||
[-s symbol_name color_name] Overwrite color defaults.
|
||||
[-p symbol_name pixel_value] Overwrite color defaults.
|
||||
[-plaid] Read the included plaid pixmap.
|
||||
[filename] Read from file 'filename', and from
|
||||
standard input if 'filename' is '-'.
|
||||
[-o filename] Write to file 'filename', and to standard
|
||||
output if 'filename' is '-'.
|
||||
[-nod] Don't display in window.
|
||||
[-rgb filename] Search color names in the rgb text file
|
||||
'filename'.
|
||||
|
||||
if no input is specified sxpm reads from standard input.
|
||||
|
||||
|
||||
- Xpm functions and Ppm converters now deal with multiword colornames.
|
||||
patches from Rainer Sinkwitz <sinkwitz@ifi.unizh.ch>.
|
||||
|
||||
|
||||
3.0 (91/10/03)
|
||||
|
||||
Functions name and defines have been modified again (sorry for that)
|
||||
as follows:
|
||||
|
||||
XpmReadPixmapFile XpmReadFileToPixmap
|
||||
XpmWritePixmapFile XpmWriteFileFromPixmap
|
||||
|
||||
XpmPixmapColorError XpmColorError
|
||||
XpmPixmapSuccess XpmSuccess
|
||||
XpmPixmapOpenFailed XpmOpenFailed
|
||||
XpmPixmapFileInvalid XpmFileInvalid
|
||||
XpmPixmapNoMemory XpmNoMemory
|
||||
XpmPixmapColorFailed XpmColorFailed
|
||||
|
||||
To update code using Xpm you can use the included shell script called
|
||||
rename with the sed commands files name-3.0b-3.0c and name-3.0c-3.0.
|
||||
Old names still valid though.
|
||||
|
||||
NEW FEATURES:
|
||||
- four new functions to work with images instead of pixmaps:
|
||||
|
||||
XpmReadFileToImage
|
||||
XpmWriteFileFromImage
|
||||
XpmCreateImageFromData
|
||||
XpmCreateDataFromImage
|
||||
|
||||
ENHANCEMENTS:
|
||||
Algorithms to create and scan images and pixmaps are based on the
|
||||
MIT's R5 code, thus they are much cleaner than old ones and should
|
||||
avoid any problem with any visual (yes, I trust MIT folks :-)
|
||||
|
||||
BUGS CORRECTED:
|
||||
Imakefile use INCDIR instead of ROOTDIR.
|
||||
|
||||
CHANGES TO THE DOC:
|
||||
- the documentation presents the four new functions.
|
||||
|
||||
3.0c (91/09/18)
|
||||
|
||||
In answer to request of people functions, types and defines names have
|
||||
been changed as follows:
|
||||
|
||||
XCreatePixmapFromData XpmCreatePixmapFromData
|
||||
XCreateDataFromPixmap XpmCreateDataFromPixmap
|
||||
XReadPixmapFile XpmReadPixmapFile
|
||||
XWritePixmapFile XpmWritePixmapFile
|
||||
XFreeXpmAttributes XpmFreeAttributes
|
||||
|
||||
PixmapColorError XpmPixmapColorError
|
||||
PixmapSuccess XpmPixmapSuccess
|
||||
PixmapOpenFailed XpmPixmapOpenFailed
|
||||
PixmapFileInvalid XpmPixmapFileInvalid
|
||||
PixmapNoMemory XpmPixmapNoMemory
|
||||
PixmapColorFailed XpmPixmapColorFailed
|
||||
|
||||
ColorSymbol XpmColorSymbol
|
||||
|
||||
Generally speaking every public name begins with 'Xpm' and every
|
||||
private one with 'xpm'. This should avoid any possible conflict.
|
||||
|
||||
Some files have also be renamed accordingly.
|
||||
|
||||
NEW FEATURES:
|
||||
- support for VMS and two new options for sxpm: icon and hints (see
|
||||
manual for details) Richard Hess <rhess%pleione%cimshop@uunet.UU.NET>
|
||||
- DEFINES in Imakefile and Makefile.noXtree allows you to set the
|
||||
following:
|
||||
|
||||
ZPIPE for un/compressing piped feature (default is on)
|
||||
NEED_STRCASECMP for system which doesn't provide one (default
|
||||
is off)
|
||||
|
||||
- xpmtoppm.c has is own strstr function which is used if NEED_STRSTR
|
||||
is defined when compiling - Hugues.Leroy@irisa.fr (Hugues Leroy).
|
||||
|
||||
BUGS CORRECTED:
|
||||
- many bugs have been fixed, especially for ansi compilers -
|
||||
Doyle C. Davidson (doyle@doyled.b23b.ingr.com) and
|
||||
Clifford D. Morrison (cdm%bigdaddy%edsr@uunet.UU.NET)
|
||||
- parser is again a little more improved
|
||||
|
||||
3.0b (91/09/12)
|
||||
|
||||
This is a complete new version with a new API and where files and
|
||||
structures have been renamed. So this should be taken as a new
|
||||
starting release.
|
||||
This release should be quickly followed by the 3.0 because I'm planning
|
||||
to send it for X11R5 contrib which ends October 5th.
|
||||
|
||||
NEW FEATURES:
|
||||
- support for transparent color.
|
||||
- support for hotspot.
|
||||
- a new function: XCreateDataFromPixmap to create an XPM data from a
|
||||
pixmap in order to be able to create a new pixmap from this data using
|
||||
the XCreatePixmapFromData function later on.
|
||||
- a new structure: XpmAttributes which replace the XpmInfo structure
|
||||
and which leads to a much simpler API with less arguments.
|
||||
- arguments such as visual, colormap and depth are optional, default
|
||||
values are taken if omitted.
|
||||
- parsing and allocating color failures don't simply break anymore. If
|
||||
another default color can be found it is used and a PixmapColorError
|
||||
is returned. In case no color can be found then it breaks and returns
|
||||
PixmapColorFailed.
|
||||
- for this reason the ErrorStatus codes are redefined as follows:
|
||||
|
||||
null if full success
|
||||
positive if partial success
|
||||
negative if failure
|
||||
|
||||
with:
|
||||
#define PixmapColorError 1
|
||||
#define PixmapSuccess 0
|
||||
#define PixmapOpenFailed -1
|
||||
#define PixmapFileInvalid -2
|
||||
#define PixmapNoMemory -3
|
||||
#define PixmapColorFailed -4
|
||||
|
||||
- sxpm prints out a warning when a requested color could not be parsed
|
||||
or alloc'ed, and an error when none has been found.
|
||||
- sxpm handles pixmap with transparent color. For this purpose the
|
||||
plaid_mask.xpm is added to the distribution.
|
||||
|
||||
BUGS CORRECTED:
|
||||
- I've again improved the memory management.
|
||||
- the parser is also improved.
|
||||
- when writing a pixmap to a file the variable name could be
|
||||
"plaid.xpm" which is not valid in C. Now the extension name is cut off
|
||||
to give "plaid" as variable name.
|
||||
- reading multiple words colornames such as "peach puff" where leading
|
||||
to non readable Xpm files. They are now skipped to have only single
|
||||
word colorname. Lionel Mallet (mallet@ipvpel.unipv.it).
|
||||
- parser was triggered by the "/" character inside string.
|
||||
Doyle C. Davidson (doyle@doyled.b23b.ingr.com). This is corrected.
|
||||
- sxpm maps the window only if the option "-nod" is not selected.
|
||||
|
||||
CHANGES TO THE DOC:
|
||||
- the documentation presents the new API and features.
|
||||
|
||||
3.0a (91/04/10)
|
||||
|
||||
This is an alpha version because it supports the new version of XPM,
|
||||
but the library interface is still the same. Indeed it will change in
|
||||
future release to get rid of obsolete stuff such as the type argument
|
||||
of the XWritePixmapFile function.
|
||||
|
||||
******************************* WARNING *********************************
|
||||
The format is not anymore XPM2, it is XPM version 3 which is XPM2
|
||||
limited to the C syntax with the key word "XPM" in place of "XPM2 C".
|
||||
The interface library has not changed yet but the type argument of
|
||||
XWritePixmapFile and the type member of XpmInfo are not used anymore.
|
||||
Meanwhile the library which is now called libXpm.a is backward
|
||||
compatible as XPM2 files can be read. But the XWritePixmapFile
|
||||
function only writes out XPM version 3 files.
|
||||
*************************************************************************
|
||||
|
||||
NEW FEATURES:
|
||||
- the library doesn't use global variables anymore, thus it should be
|
||||
able to share it.
|
||||
- sxpm has been rewritten on top of Xt, it can be used to convert
|
||||
files from XPM2 to XPM version 3.
|
||||
- xpm1to2c.perl has been upgraded to the new XPM version and renamed
|
||||
as xpm1to3.perl
|
||||
- ppmtoxpm2.c and ppmtoxpm2.1 have been upgraded too and renamed
|
||||
ppmtoxpm.c and ppmtoxpm.1. In addition the xpmtoppm.c and xpmtoppm.1
|
||||
of the pbmplus package have been upgraded too. xpmtoppm can thus
|
||||
convert XPM version 1 and 3 to a portable pixmap. These files should
|
||||
replace the original ones which are part of the pbmplus package. See
|
||||
the ppm.README file for more details.
|
||||
- the library contains RCS variables which allows you to get revision
|
||||
numbers with ident (which is part of the RCS package). The Id number
|
||||
is an internal rcs number for my eyes only. The official one is found
|
||||
in Version.
|
||||
|
||||
BUGS CORRECTED:
|
||||
- the memory management has been much improved in order to avoid
|
||||
memory leaks.
|
||||
- the XImage building algorithm has been changed to support correctly
|
||||
different visual depths. There is special code to handle depths 1, 4,
|
||||
6, 8, 24, and 32 to build the image and send it in one whack, and
|
||||
other depths are supported by building the image with XPutPixel which
|
||||
is slow but sure.
|
||||
- similar algorithms are used to read pixmaps and write them out.
|
||||
|
||||
CHANGES TO THE DOC:
|
||||
- the documentation presents the new XPM format.
|
||||
|
||||
|
||||
2.8 (90/12/19)
|
||||
|
||||
******************************* WARNING *********************************
|
||||
Since the last release two structures have been modified and have now
|
||||
bigger sizes, so ANY CODE USING THE libXPM2 NEEDS TO BE RECOMPILED.
|
||||
*************************************************************************
|
||||
|
||||
NEW FEATURES:
|
||||
- the ColorSymbol struct contains the new member 'pixel' which allow
|
||||
to override default colors by giving a pixel value (in such a case
|
||||
symbol value must be set to NULL),
|
||||
- the XpmInfo struct contains the new member 'rgb_fname' in which one
|
||||
can specify an rgb text file name while writing a pixmap with the
|
||||
XWritePixmapFile function (otherwise this member should be set to
|
||||
NULL). This way colorname will be searched and written out if found
|
||||
instead of the RGB value,
|
||||
- Imakefile originally provided by stolcke@ICSI.Berkeley.EDU,
|
||||
- the old Makefile is now distributed as Makefile.noXtree and presents
|
||||
install targets,
|
||||
- the demo application is renamed sxpm (Show XPM), creates a window of
|
||||
the size of the pixmap if no geometry is specified, prints out
|
||||
messages instead of status when an error occurs, handles the new
|
||||
option -p for overriding colors by giving a pixel value (not really
|
||||
useful but is just here to show this new feature), handles the new
|
||||
option -rgb for specifying an rgb text file, and ends on
|
||||
keypress as buttonpress,
|
||||
- defines for SYSV have been provided by Paul Breslaw
|
||||
<paul@mecazh.uucp>,
|
||||
- the distribution includes a new directory called converters which
|
||||
contains xpm1to2 and xpm1to2c perl converters and a ppmtoxpm2
|
||||
converter provided by Paul Breslaw who upgraded the original ppmtoxpm
|
||||
written by Mark W. Snitily <mark@zok.uucp>.
|
||||
|
||||
CHANGES TO THE DOC:
|
||||
- this file is created and will give old users a quick reference to
|
||||
changes made from one release to the next one,
|
||||
- documentation is changed to present the new ColorSymbol structure
|
||||
and the way to override colors by giving a pixel value, and to present
|
||||
the new XpmInfo structure and how to use it,
|
||||
- a man page for sxpm is added to the distrib,
|
||||
- the README file talks about sxpm and no more demo, and have
|
||||
reference to the different converters.
|
||||
|
||||
2.7 (90/11/12)
|
||||
|
||||
NEW FEATURES:
|
||||
- XReadPixmapFile reads from stdin if filename is NULL,
|
||||
- XWritePixmapFile writes to stdin if filename is NULL,
|
||||
- the demo application handles the new option -nod for no displaying
|
||||
the pixmap in a window (useful when used as converter).
|
||||
|
||||
CHANGES TO THE DOC:
|
||||
- documentation about the new feature.
|
||||
|
||||
2.6 (90/10/29)
|
||||
|
||||
NEW FEATURES:
|
||||
- from nazgul@alphalpha.com (Kee Hinckley): changes to make the
|
||||
library usable as C++ code, and on Apollo without any warning.
|
||||
|
||||
BUGS CORRECTED:
|
||||
- from nazgul@alphalpha.com (Kee Hinckley): the xpm include files was
|
||||
declaring XWritePixmapFile as taking in arg a Pixmap pointer instead
|
||||
of a Pixmap.
|
||||
|
||||
2.5 (90/10/17)
|
||||
|
||||
BUGS CORRECTED:
|
||||
- XWritePixmapFile was not closing the file while ending normally.
|
||||
|
||||
2.4 (90/09/06)
|
||||
|
||||
NEW FEATURES:
|
||||
- XReadPixmapFile reads from a piped uncompress if the given filename
|
||||
ends by .Z or if filename.Z exists,
|
||||
- XWritePixmapFile writes to a piped compress if the given filename
|
||||
ends by .Z.
|
||||
|
||||
BUGS CORRECTED:
|
||||
- demo now deals with window manager.
|
||||
|
||||
CHANGES TO THE DOC:
|
||||
- documentation about compressed files management.
|
||||
|
||||
2.3 (90/08/30)
|
||||
|
||||
BUGS CORRECTED:
|
||||
- handle monochrome display correctly,
|
||||
- comments can be empty.
|
||||
|
||||
2.2 (90/08/27)
|
||||
|
||||
BUGS CORRECTED:
|
||||
- when reading some invalid free was dumping core on some machine.
|
||||
|
||||
2.1 (90/08/24)
|
||||
|
||||
First distribution of XPM2.
|
||||
|
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
Arnaud LE HORS BULL Research FRANCE -- Koala Project
|
||||
(XPM - X PixMap format version 2 & 3)
|
||||
Internet: lehors@sophia.inria.fr
|
||||
Surface Mail: Arnaud LE HORS, INRIA - Sophia Antipolis,
|
||||
2004, route des Lucioles, 06565 Valbonne Cedex -- FRANCE
|
||||
Voice phone: (33) 93.65.77.71, Fax: (33) 93 65 77 66, Telex: 97 00 50 F
|
2865
src/xpm/create.c
2865
src/xpm/create.c
File diff suppressed because it is too large
Load Diff
514
src/xpm/data.c
514
src/xpm/data.c
@@ -1,514 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* data.c: *
|
||||
* *
|
||||
* XPM library *
|
||||
* IO utilities *
|
||||
* *
|
||||
* Developed by Arnaud Le Hors *
|
||||
\*****************************************************************************/
|
||||
|
||||
#ifndef CXPMPROG
|
||||
#include "XpmI.h"
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef CXPMPROG
|
||||
#define Getc(data, file) getc(file)
|
||||
#define Ungetc(data, c, file) ungetc(c, file)
|
||||
#endif
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static int
|
||||
ParseComment(xpmData* data)
|
||||
#else
|
||||
static int
|
||||
ParseComment(data)
|
||||
xpmData *data;
|
||||
#endif
|
||||
{
|
||||
if (data->type == XPMBUFFER) {
|
||||
register char c;
|
||||
register unsigned int n = 0;
|
||||
unsigned int notend;
|
||||
char *s, *s2;
|
||||
|
||||
s = data->Comment;
|
||||
*s = data->Bcmt[0];
|
||||
|
||||
/* skip the string beginning comment */
|
||||
s2 = data->Bcmt;
|
||||
do {
|
||||
c = *data->cptr++;
|
||||
*++s = c;
|
||||
n++;
|
||||
s2++;
|
||||
} while (c == *s2 && *s2 != '\0' && c);
|
||||
|
||||
if (*s2 != '\0') {
|
||||
/* this wasn't the beginning of a comment */
|
||||
data->cptr -= n;
|
||||
return 0;
|
||||
}
|
||||
/* store comment */
|
||||
data->Comment[0] = *s;
|
||||
s = data->Comment;
|
||||
notend = 1;
|
||||
n = 0;
|
||||
while (notend) {
|
||||
s2 = data->Ecmt;
|
||||
while (*s != *s2 && c) {
|
||||
c = *data->cptr++;
|
||||
if (n == XPMMAXCMTLEN - 1) { /* forget it */
|
||||
s = data->Comment;
|
||||
n = 0;
|
||||
}
|
||||
*++s = c;
|
||||
n++;
|
||||
}
|
||||
data->CommentLength = n;
|
||||
do {
|
||||
c = *data->cptr++;
|
||||
if (n == XPMMAXCMTLEN - 1) { /* forget it */
|
||||
s = data->Comment;
|
||||
n = 0;
|
||||
}
|
||||
*++s = c;
|
||||
n++;
|
||||
s2++;
|
||||
} while (c == *s2 && *s2 != '\0' && c);
|
||||
if (*s2 == '\0') {
|
||||
/* this is the end of the comment */
|
||||
notend = 0;
|
||||
data->cptr--;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
FILE *file = data->stream.file;
|
||||
register int c;
|
||||
register unsigned int n = 0, a;
|
||||
unsigned int notend;
|
||||
char *s, *s2;
|
||||
|
||||
s = data->Comment;
|
||||
*s = data->Bcmt[0];
|
||||
|
||||
/* skip the string beginning comment */
|
||||
s2 = data->Bcmt;
|
||||
do {
|
||||
c = Getc(data, file);
|
||||
*++s = c;
|
||||
n++;
|
||||
s2++;
|
||||
} while (c == *s2 && *s2 != '\0' && c != EOF);
|
||||
|
||||
if (*s2 != '\0') {
|
||||
/* this wasn't the beginning of a comment */
|
||||
/* put characters back in the order that we got them */
|
||||
for (a = n; a > 0; a--, s--)
|
||||
Ungetc(data, *s, file);
|
||||
return 0;
|
||||
}
|
||||
/* store comment */
|
||||
data->Comment[0] = *s;
|
||||
s = data->Comment;
|
||||
notend = 1;
|
||||
n = 0;
|
||||
while (notend) {
|
||||
s2 = data->Ecmt;
|
||||
while (*s != *s2 && c != EOF) {
|
||||
c = Getc(data, file);
|
||||
if (n == XPMMAXCMTLEN - 1) { /* forget it */
|
||||
s = data->Comment;
|
||||
n = 0;
|
||||
}
|
||||
*++s = c;
|
||||
n++;
|
||||
}
|
||||
data->CommentLength = n;
|
||||
do {
|
||||
c = Getc(data, file);
|
||||
if (n == XPMMAXCMTLEN - 1) { /* forget it */
|
||||
s = data->Comment;
|
||||
n = 0;
|
||||
}
|
||||
*++s = c;
|
||||
n++;
|
||||
s2++;
|
||||
} while (c == *s2 && *s2 != '\0' && c != EOF);
|
||||
if (*s2 == '\0') {
|
||||
/* this is the end of the comment */
|
||||
notend = 0;
|
||||
Ungetc(data, *s, file);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* skip to the end of the current string and the beginning of the next one
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int xpmNextString(xpmData* data)
|
||||
#else
|
||||
int
|
||||
xpmNextString(data)
|
||||
xpmData *data;
|
||||
#endif
|
||||
{
|
||||
if (!data->type)
|
||||
data->cptr = (data->stream.data)[++data->line];
|
||||
else if (data->type == XPMBUFFER) {
|
||||
register char c;
|
||||
|
||||
/* get to the end of the current string */
|
||||
if (data->Eos)
|
||||
while ((c = *data->cptr++) && c != data->Eos);
|
||||
|
||||
/*
|
||||
* then get to the beginning of the next string looking for possible
|
||||
* comment
|
||||
*/
|
||||
if (data->Bos) {
|
||||
while ((c = *data->cptr++) && c != data->Bos)
|
||||
if (data->Bcmt && c == data->Bcmt[0])
|
||||
ParseComment(data);
|
||||
} else if (data->Bcmt) { /* XPM2 natural */
|
||||
while ((c = *data->cptr++) == data->Bcmt[0])
|
||||
ParseComment(data);
|
||||
data->cptr--;
|
||||
}
|
||||
} else {
|
||||
register int c;
|
||||
FILE *file = data->stream.file;
|
||||
|
||||
/* get to the end of the current string */
|
||||
if (data->Eos)
|
||||
while ((c = Getc(data, file)) != data->Eos && c != EOF);
|
||||
|
||||
/*
|
||||
* then get to the beginning of the next string looking for possible
|
||||
* comment
|
||||
*/
|
||||
if (data->Bos) {
|
||||
while ((c = Getc(data, file)) != data->Bos && c != EOF)
|
||||
if (data->Bcmt && c == data->Bcmt[0])
|
||||
ParseComment(data);
|
||||
|
||||
} else if (data->Bcmt) { /* XPM2 natural */
|
||||
while ((c = Getc(data, file)) == data->Bcmt[0])
|
||||
ParseComment(data);
|
||||
Ungetc(data, c, file);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* skip whitespace and return the following word
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
unsigned int xpmNextWord(
|
||||
xpmData* data
|
||||
, char* buf
|
||||
, unsigned int buflen
|
||||
)
|
||||
#else
|
||||
unsigned int
|
||||
xpmNextWord(data, buf, buflen)
|
||||
xpmData *data;
|
||||
char *buf;
|
||||
unsigned int buflen;
|
||||
#endif
|
||||
{
|
||||
register unsigned int n = 0;
|
||||
int c;
|
||||
|
||||
if (!data->type || data->type == XPMBUFFER) {
|
||||
while (isspace(c = *data->cptr) && c != data->Eos)
|
||||
data->cptr++;
|
||||
do {
|
||||
c = *data->cptr++;
|
||||
*buf++ = c;
|
||||
n++;
|
||||
} while (!isspace(c) && c != data->Eos && n < buflen);
|
||||
n--;
|
||||
data->cptr--;
|
||||
} else {
|
||||
FILE *file = data->stream.file;
|
||||
|
||||
while ((c = Getc(data, file)) != EOF && isspace(c) && c != data->Eos);
|
||||
while (!isspace(c) && c != data->Eos && c != EOF && n < buflen) {
|
||||
*buf++ = c;
|
||||
n++;
|
||||
c = Getc(data, file);
|
||||
}
|
||||
Ungetc(data, c, file);
|
||||
}
|
||||
return (n);
|
||||
}
|
||||
|
||||
/*
|
||||
* skip whitespace and compute the following unsigned int,
|
||||
* returns 1 if one is found and 0 if not
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int
|
||||
xpmNextUI(xpmData* data, unsigned int* ui_return)
|
||||
#else
|
||||
int
|
||||
xpmNextUI(data, ui_return)
|
||||
xpmData *data;
|
||||
unsigned int *ui_return;
|
||||
#endif
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
int l;
|
||||
|
||||
l = xpmNextWord(data, buf, BUFSIZ);
|
||||
return xpmatoui(buf, l, ui_return);
|
||||
}
|
||||
|
||||
/*
|
||||
* return end of string - WARNING: malloc!
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int xpmGetString(xpmData* data, char** sptr, unsigned int* l)
|
||||
#else
|
||||
int
|
||||
xpmGetString(data, sptr, l)
|
||||
xpmData *data;
|
||||
char **sptr;
|
||||
unsigned int *l;
|
||||
#endif
|
||||
{
|
||||
unsigned int i, n = 0;
|
||||
int c;
|
||||
char *p = NULL, *q, buf[BUFSIZ];
|
||||
|
||||
if (!data->type || data->type == XPMBUFFER) {
|
||||
if (data->cptr) {
|
||||
char *start = data->cptr;
|
||||
while ((c = *data->cptr) && c != data->Eos)
|
||||
data->cptr++;
|
||||
n = data->cptr - start + 1;
|
||||
p = (char *) XpmMalloc(n);
|
||||
if (!p)
|
||||
return (XpmNoMemory);
|
||||
strncpy(p, start, n);
|
||||
if (data->type) /* XPMBUFFER */
|
||||
p[n - 1] = '\0';
|
||||
}
|
||||
} else {
|
||||
FILE *file = data->stream.file;
|
||||
|
||||
if ((c = Getc(data, file)) == EOF)
|
||||
return (XpmFileInvalid);
|
||||
|
||||
i = 0;
|
||||
q = buf;
|
||||
p = (char *) XpmMalloc(1);
|
||||
while (c != data->Eos && c != EOF) {
|
||||
if (i == BUFSIZ) {
|
||||
/* get to the end of the buffer */
|
||||
/* malloc needed memory */
|
||||
q = (char *) XpmRealloc(p, n + i);
|
||||
if (!q) {
|
||||
XpmFree(p);
|
||||
return (XpmNoMemory);
|
||||
}
|
||||
p = q;
|
||||
q += n;
|
||||
/* and copy what we already have */
|
||||
strncpy(q, buf, i);
|
||||
n += i;
|
||||
i = 0;
|
||||
q = buf;
|
||||
}
|
||||
*q++ = c;
|
||||
i++;
|
||||
c = Getc(data, file);
|
||||
}
|
||||
if (c == EOF) {
|
||||
XpmFree(p);
|
||||
return (XpmFileInvalid);
|
||||
}
|
||||
if (n + i != 0) {
|
||||
/* malloc needed memory */
|
||||
q = (char *) XpmRealloc(p, n + i + 1);
|
||||
if (!q) {
|
||||
XpmFree(p);
|
||||
return (XpmNoMemory);
|
||||
}
|
||||
p = q;
|
||||
q += n;
|
||||
/* and copy the buffer */
|
||||
strncpy(q, buf, i);
|
||||
n += i;
|
||||
p[n++] = '\0';
|
||||
} else {
|
||||
*p = '\0';
|
||||
n = 1;
|
||||
}
|
||||
Ungetc(data, c, file);
|
||||
}
|
||||
*sptr = p;
|
||||
*l = n;
|
||||
return (XpmSuccess);
|
||||
}
|
||||
|
||||
/*
|
||||
* get the current comment line
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int xpmGetCmt(xpmData* data, char** cmt)
|
||||
#else
|
||||
int
|
||||
xpmGetCmt(data, cmt)
|
||||
xpmData *data;
|
||||
char **cmt;
|
||||
#endif
|
||||
{
|
||||
if (!data->type)
|
||||
*cmt = NULL;
|
||||
else if (data->CommentLength) {
|
||||
*cmt = (char *) XpmMalloc(data->CommentLength + 1);
|
||||
strncpy(*cmt, data->Comment, data->CommentLength);
|
||||
(*cmt)[data->CommentLength] = '\0';
|
||||
data->CommentLength = 0;
|
||||
} else
|
||||
*cmt = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
xpmDataType xpmDataTypes[] =
|
||||
{
|
||||
"", "!", "\n", '\0', '\n', "", "", "", "", /* Natural type */
|
||||
"C", "/*", "*/", '"', '"', ",\n", "static char *", "[] = {\n", "};\n",
|
||||
"Lisp", ";", "\n", '"', '"', "\n", "(setq ", " '(\n", "))\n",
|
||||
#ifdef VMS
|
||||
NULL
|
||||
#else
|
||||
NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* parse xpm header
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int xpmParseHeader(xpmData* data)
|
||||
#else
|
||||
int
|
||||
xpmParseHeader(data)
|
||||
xpmData *data;
|
||||
#endif
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
int l, n = 0;
|
||||
|
||||
if (data->type) {
|
||||
data->Bos = '\0';
|
||||
data->Eos = '\n';
|
||||
data->Bcmt = data->Ecmt = NULL;
|
||||
l = xpmNextWord(data, buf, BUFSIZ);
|
||||
if (l == 7 && !strncmp("#define", buf, 7)) {
|
||||
/* this maybe an XPM 1 file */
|
||||
char *ptr;
|
||||
|
||||
l = xpmNextWord(data, buf, BUFSIZ);
|
||||
if (!l)
|
||||
return (XpmFileInvalid);
|
||||
buf[l] = '\0';
|
||||
ptr = rindex(buf, '_');
|
||||
if (!ptr || strncmp("_format", ptr, l - (ptr - buf)))
|
||||
return XpmFileInvalid;
|
||||
/* this is definitely an XPM 1 file */
|
||||
data->format = 1;
|
||||
n = 1; /* handle XPM1 as mainly XPM2 C */
|
||||
} else {
|
||||
|
||||
/*
|
||||
* skip the first word, get the second one, and see if this is
|
||||
* XPM 2 or 3
|
||||
*/
|
||||
l = xpmNextWord(data, buf, BUFSIZ);
|
||||
if ((l == 3 && !strncmp("XPM", buf, 3)) ||
|
||||
(l == 4 && !strncmp("XPM2", buf, 4))) {
|
||||
if (l == 3)
|
||||
n = 1; /* handle XPM as XPM2 C */
|
||||
else {
|
||||
/* get the type key word */
|
||||
l = xpmNextWord(data, buf, BUFSIZ);
|
||||
|
||||
/*
|
||||
* get infos about this type
|
||||
*/
|
||||
while (xpmDataTypes[n].type
|
||||
&& strncmp(xpmDataTypes[n].type, buf, l))
|
||||
n++;
|
||||
}
|
||||
data->format = 0;
|
||||
} else
|
||||
/* nope this is not an XPM file */
|
||||
return XpmFileInvalid;
|
||||
}
|
||||
if (xpmDataTypes[n].type) {
|
||||
if (n == 0) { /* natural type */
|
||||
data->Bcmt = xpmDataTypes[n].Bcmt;
|
||||
data->Ecmt = xpmDataTypes[n].Ecmt;
|
||||
xpmNextString(data); /* skip the end of the headerline */
|
||||
data->Bos = xpmDataTypes[n].Bos;
|
||||
data->Eos = xpmDataTypes[n].Eos;
|
||||
} else {
|
||||
data->Bcmt = xpmDataTypes[n].Bcmt;
|
||||
data->Ecmt = xpmDataTypes[n].Ecmt;
|
||||
if (!data->format) { /* XPM 2 or 3 */
|
||||
data->Bos = xpmDataTypes[n].Bos;
|
||||
data->Eos = '\0';
|
||||
/* get to the beginning of the first string */
|
||||
xpmNextString(data);
|
||||
data->Eos = xpmDataTypes[n].Eos;
|
||||
} else /* XPM 1 skip end of line */
|
||||
xpmNextString(data);
|
||||
}
|
||||
} else
|
||||
/* we don't know about that type of XPM file... */
|
||||
return XpmFileInvalid;
|
||||
}
|
||||
return XpmSuccess;
|
||||
}
|
@@ -1,479 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* data.c: *
|
||||
* *
|
||||
* XPM library *
|
||||
* IO utilities *
|
||||
* *
|
||||
* Developed by Arnaud Le Hors *
|
||||
\*****************************************************************************/
|
||||
|
||||
#ifndef CXPMPROG
|
||||
/* Official version number */
|
||||
static char *RCS_Version = "$XpmVersion: 3.4k $";
|
||||
|
||||
/* Internal version number */
|
||||
static char *RCS_Id = "$Id$";
|
||||
|
||||
#include "XpmI.h"
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef CXPMPROG
|
||||
#define Getc(data, file) getc(file)
|
||||
#define Ungetc(data, c, file) ungetc(c, file)
|
||||
#endif
|
||||
|
||||
static int
|
||||
ParseComment(data)
|
||||
xpmData *data;
|
||||
{
|
||||
if (data->type == XPMBUFFER) {
|
||||
register char c;
|
||||
register unsigned int n = 0;
|
||||
unsigned int notend;
|
||||
char *s, *s2;
|
||||
|
||||
s = data->Comment;
|
||||
*s = data->Bcmt[0];
|
||||
|
||||
/* skip the string beginning comment */
|
||||
s2 = data->Bcmt;
|
||||
do {
|
||||
c = *data->cptr++;
|
||||
*++s = c;
|
||||
n++;
|
||||
s2++;
|
||||
} while (c == *s2 && *s2 != '\0' && c);
|
||||
|
||||
if (*s2 != '\0') {
|
||||
/* this wasn't the beginning of a comment */
|
||||
data->cptr -= n;
|
||||
return 0;
|
||||
}
|
||||
/* store comment */
|
||||
data->Comment[0] = *s;
|
||||
s = data->Comment;
|
||||
notend = 1;
|
||||
n = 0;
|
||||
while (notend) {
|
||||
s2 = data->Ecmt;
|
||||
while (*s != *s2 && c) {
|
||||
c = *data->cptr++;
|
||||
if (n == XPMMAXCMTLEN - 1) { /* forget it */
|
||||
s = data->Comment;
|
||||
n = 0;
|
||||
}
|
||||
*++s = c;
|
||||
n++;
|
||||
}
|
||||
data->CommentLength = n;
|
||||
do {
|
||||
c = *data->cptr++;
|
||||
if (n == XPMMAXCMTLEN - 1) { /* forget it */
|
||||
s = data->Comment;
|
||||
n = 0;
|
||||
}
|
||||
*++s = c;
|
||||
n++;
|
||||
s2++;
|
||||
} while (c == *s2 && *s2 != '\0' && c);
|
||||
if (*s2 == '\0') {
|
||||
/* this is the end of the comment */
|
||||
notend = 0;
|
||||
data->cptr--;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
FILE *file = data->stream.file;
|
||||
register int c;
|
||||
register unsigned int n = 0, a;
|
||||
unsigned int notend;
|
||||
char *s, *s2;
|
||||
|
||||
s = data->Comment;
|
||||
*s = data->Bcmt[0];
|
||||
|
||||
/* skip the string beginning comment */
|
||||
s2 = data->Bcmt;
|
||||
do {
|
||||
c = Getc(data, file);
|
||||
*++s = c;
|
||||
n++;
|
||||
s2++;
|
||||
} while (c == *s2 && *s2 != '\0' && c != EOF);
|
||||
|
||||
if (*s2 != '\0') {
|
||||
/* this wasn't the beginning of a comment */
|
||||
/* put characters back in the order that we got them */
|
||||
for (a = n; a > 0; a--, s--)
|
||||
Ungetc(data, *s, file);
|
||||
return 0;
|
||||
}
|
||||
/* store comment */
|
||||
data->Comment[0] = *s;
|
||||
s = data->Comment;
|
||||
notend = 1;
|
||||
n = 0;
|
||||
while (notend) {
|
||||
s2 = data->Ecmt;
|
||||
while (*s != *s2 && c != EOF) {
|
||||
c = Getc(data, file);
|
||||
if (n == XPMMAXCMTLEN - 1) { /* forget it */
|
||||
s = data->Comment;
|
||||
n = 0;
|
||||
}
|
||||
*++s = c;
|
||||
n++;
|
||||
}
|
||||
data->CommentLength = n;
|
||||
do {
|
||||
c = Getc(data, file);
|
||||
if (n == XPMMAXCMTLEN - 1) { /* forget it */
|
||||
s = data->Comment;
|
||||
n = 0;
|
||||
}
|
||||
*++s = c;
|
||||
n++;
|
||||
s2++;
|
||||
} while (c == *s2 && *s2 != '\0' && c != EOF);
|
||||
if (*s2 == '\0') {
|
||||
/* this is the end of the comment */
|
||||
notend = 0;
|
||||
Ungetc(data, *s, file);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* skip to the end of the current string and the beginning of the next one
|
||||
*/
|
||||
int
|
||||
xpmNextString(data)
|
||||
xpmData *data;
|
||||
{
|
||||
if (!data->type)
|
||||
data->cptr = (data->stream.data)[++data->line];
|
||||
else if (data->type == XPMBUFFER) {
|
||||
register char c;
|
||||
|
||||
/* get to the end of the current string */
|
||||
if (data->Eos)
|
||||
while ((c = *data->cptr++) && c != data->Eos);
|
||||
|
||||
/*
|
||||
* then get to the beginning of the next string looking for possible
|
||||
* comment
|
||||
*/
|
||||
if (data->Bos) {
|
||||
while ((c = *data->cptr++) && c != data->Bos)
|
||||
if (data->Bcmt && c == data->Bcmt[0])
|
||||
ParseComment(data);
|
||||
} else if (data->Bcmt) { /* XPM2 natural */
|
||||
while ((c = *data->cptr++) == data->Bcmt[0])
|
||||
ParseComment(data);
|
||||
data->cptr--;
|
||||
}
|
||||
} else {
|
||||
register int c;
|
||||
FILE *file = data->stream.file;
|
||||
|
||||
/* get to the end of the current string */
|
||||
if (data->Eos)
|
||||
while ((c = Getc(data, file)) != data->Eos && c != EOF);
|
||||
|
||||
/*
|
||||
* then get to the beginning of the next string looking for possible
|
||||
* comment
|
||||
*/
|
||||
if (data->Bos) {
|
||||
while ((c = Getc(data, file)) != data->Bos && c != EOF)
|
||||
if (data->Bcmt && c == data->Bcmt[0])
|
||||
ParseComment(data);
|
||||
|
||||
} else if (data->Bcmt) { /* XPM2 natural */
|
||||
while ((c = Getc(data, file)) == data->Bcmt[0])
|
||||
ParseComment(data);
|
||||
Ungetc(data, c, file);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* skip whitespace and return the following word
|
||||
*/
|
||||
unsigned int
|
||||
xpmNextWord(data, buf, buflen)
|
||||
xpmData *data;
|
||||
char *buf;
|
||||
unsigned int buflen;
|
||||
{
|
||||
register unsigned int n = 0;
|
||||
int c;
|
||||
|
||||
if (!data->type || data->type == XPMBUFFER) {
|
||||
while (isspace(c = *data->cptr) && c != data->Eos)
|
||||
data->cptr++;
|
||||
do {
|
||||
c = *data->cptr++;
|
||||
*buf++ = c;
|
||||
n++;
|
||||
} while (!isspace(c) && c != data->Eos && n < buflen);
|
||||
n--;
|
||||
data->cptr--;
|
||||
} else {
|
||||
FILE *file = data->stream.file;
|
||||
|
||||
while ((c = Getc(data, file)) != EOF && isspace(c) && c != data->Eos);
|
||||
while (!isspace(c) && c != data->Eos && c != EOF && n < buflen) {
|
||||
*buf++ = c;
|
||||
n++;
|
||||
c = Getc(data, file);
|
||||
}
|
||||
Ungetc(data, c, file);
|
||||
}
|
||||
return (n);
|
||||
}
|
||||
|
||||
/*
|
||||
* skip whitespace and compute the following unsigned int,
|
||||
* returns 1 if one is found and 0 if not
|
||||
*/
|
||||
int
|
||||
xpmNextUI(data, ui_return)
|
||||
xpmData *data;
|
||||
unsigned int *ui_return;
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
int l;
|
||||
|
||||
l = xpmNextWord(data, buf, BUFSIZ);
|
||||
return xpmatoui(buf, l, ui_return);
|
||||
}
|
||||
|
||||
/*
|
||||
* return end of string - WARNING: malloc!
|
||||
*/
|
||||
int
|
||||
xpmGetString(data, sptr, l)
|
||||
xpmData *data;
|
||||
char **sptr;
|
||||
unsigned int *l;
|
||||
{
|
||||
unsigned int i, n = 0;
|
||||
int c;
|
||||
char *p = NULL, *q, buf[BUFSIZ];
|
||||
|
||||
if (!data->type || data->type == XPMBUFFER) {
|
||||
if (data->cptr) {
|
||||
char *start = data->cptr;
|
||||
while ((c = *data->cptr) && c != data->Eos)
|
||||
data->cptr++;
|
||||
n = data->cptr - start + 1;
|
||||
p = (char *) XpmMalloc(n);
|
||||
if (!p)
|
||||
return (XpmNoMemory);
|
||||
strncpy(p, start, n);
|
||||
if (data->type) /* XPMBUFFER */
|
||||
p[n - 1] = '\0';
|
||||
}
|
||||
} else {
|
||||
FILE *file = data->stream.file;
|
||||
|
||||
if ((c = Getc(data, file)) == EOF)
|
||||
return (XpmFileInvalid);
|
||||
|
||||
i = 0;
|
||||
q = buf;
|
||||
p = (char *) XpmMalloc(1);
|
||||
while (c != data->Eos && c != EOF) {
|
||||
if (i == BUFSIZ) {
|
||||
/* get to the end of the buffer */
|
||||
/* malloc needed memory */
|
||||
q = (char *) XpmRealloc(p, n + i);
|
||||
if (!q) {
|
||||
XpmFree(p);
|
||||
return (XpmNoMemory);
|
||||
}
|
||||
p = q;
|
||||
q += n;
|
||||
/* and copy what we already have */
|
||||
strncpy(q, buf, i);
|
||||
n += i;
|
||||
i = 0;
|
||||
q = buf;
|
||||
}
|
||||
*q++ = c;
|
||||
i++;
|
||||
c = Getc(data, file);
|
||||
}
|
||||
if (c == EOF) {
|
||||
XpmFree(p);
|
||||
return (XpmFileInvalid);
|
||||
}
|
||||
if (n + i != 0) {
|
||||
/* malloc needed memory */
|
||||
q = (char *) XpmRealloc(p, n + i + 1);
|
||||
if (!q) {
|
||||
XpmFree(p);
|
||||
return (XpmNoMemory);
|
||||
}
|
||||
p = q;
|
||||
q += n;
|
||||
/* and copy the buffer */
|
||||
strncpy(q, buf, i);
|
||||
n += i;
|
||||
p[n++] = '\0';
|
||||
} else {
|
||||
*p = '\0';
|
||||
n = 1;
|
||||
}
|
||||
Ungetc(data, c, file);
|
||||
}
|
||||
*sptr = p;
|
||||
*l = n;
|
||||
return (XpmSuccess);
|
||||
}
|
||||
|
||||
/*
|
||||
* get the current comment line
|
||||
*/
|
||||
int
|
||||
xpmGetCmt(data, cmt)
|
||||
xpmData *data;
|
||||
char **cmt;
|
||||
{
|
||||
if (!data->type)
|
||||
*cmt = NULL;
|
||||
else if (data->CommentLength) {
|
||||
*cmt = (char *) XpmMalloc(data->CommentLength + 1);
|
||||
strncpy(*cmt, data->Comment, data->CommentLength);
|
||||
(*cmt)[data->CommentLength] = '\0';
|
||||
data->CommentLength = 0;
|
||||
} else
|
||||
*cmt = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
xpmDataType xpmDataTypes[] =
|
||||
{
|
||||
"", "!", "\n", '\0', '\n', "", "", "", "", /* Natural type */
|
||||
"C", "/*", "*/", '"', '"', ",\n", "static char *", "[] = {\n", "};\n",
|
||||
"Lisp", ";", "\n", '"', '"', "\n", "(setq ", " '(\n", "))\n",
|
||||
#ifdef VMS
|
||||
NULL
|
||||
#else
|
||||
NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
* parse xpm header
|
||||
*/
|
||||
int
|
||||
xpmParseHeader(data)
|
||||
xpmData *data;
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
int l, n = 0;
|
||||
|
||||
if (data->type) {
|
||||
data->Bos = '\0';
|
||||
data->Eos = '\n';
|
||||
data->Bcmt = data->Ecmt = NULL;
|
||||
l = xpmNextWord(data, buf, BUFSIZ);
|
||||
if (l == 7 && !strncmp("#define", buf, 7)) {
|
||||
/* this maybe an XPM 1 file */
|
||||
char *ptr;
|
||||
|
||||
l = xpmNextWord(data, buf, BUFSIZ);
|
||||
if (!l)
|
||||
return (XpmFileInvalid);
|
||||
buf[l] = '\0';
|
||||
ptr = rindex(buf, '_');
|
||||
if (!ptr || strncmp("_format", ptr, l - (ptr - buf)))
|
||||
return XpmFileInvalid;
|
||||
/* this is definitely an XPM 1 file */
|
||||
data->format = 1;
|
||||
n = 1; /* handle XPM1 as mainly XPM2 C */
|
||||
} else {
|
||||
|
||||
/*
|
||||
* skip the first word, get the second one, and see if this is
|
||||
* XPM 2 or 3
|
||||
*/
|
||||
l = xpmNextWord(data, buf, BUFSIZ);
|
||||
if ((l == 3 && !strncmp("XPM", buf, 3)) ||
|
||||
(l == 4 && !strncmp("XPM2", buf, 4))) {
|
||||
if (l == 3)
|
||||
n = 1; /* handle XPM as XPM2 C */
|
||||
else {
|
||||
/* get the type key word */
|
||||
l = xpmNextWord(data, buf, BUFSIZ);
|
||||
|
||||
/*
|
||||
* get infos about this type
|
||||
*/
|
||||
while (xpmDataTypes[n].type
|
||||
&& strncmp(xpmDataTypes[n].type, buf, l))
|
||||
n++;
|
||||
}
|
||||
data->format = 0;
|
||||
} else
|
||||
/* nope this is not an XPM file */
|
||||
return XpmFileInvalid;
|
||||
}
|
||||
if (xpmDataTypes[n].type) {
|
||||
if (n == 0) { /* natural type */
|
||||
data->Bcmt = xpmDataTypes[n].Bcmt;
|
||||
data->Ecmt = xpmDataTypes[n].Ecmt;
|
||||
xpmNextString(data); /* skip the end of the headerline */
|
||||
data->Bos = xpmDataTypes[n].Bos;
|
||||
data->Eos = xpmDataTypes[n].Eos;
|
||||
} else {
|
||||
data->Bcmt = xpmDataTypes[n].Bcmt;
|
||||
data->Ecmt = xpmDataTypes[n].Ecmt;
|
||||
if (!data->format) { /* XPM 2 or 3 */
|
||||
data->Bos = xpmDataTypes[n].Bos;
|
||||
data->Eos = '\0';
|
||||
/* get to the beginning of the first string */
|
||||
xpmNextString(data);
|
||||
data->Eos = xpmDataTypes[n].Eos;
|
||||
} else /* XPM 1 skip end of line */
|
||||
xpmNextString(data);
|
||||
}
|
||||
} else
|
||||
/* we don't know about that type of XPM file... */
|
||||
return XpmFileInvalid;
|
||||
}
|
||||
return XpmSuccess;
|
||||
}
|
@@ -1,68 +0,0 @@
|
||||
CHANGES
|
||||
COPYRIGHT
|
||||
FAQ.html
|
||||
FILES
|
||||
Imakefile
|
||||
Makefile.noX
|
||||
README.html
|
||||
README.AMIGA
|
||||
README.MSW
|
||||
namecvt
|
||||
lib
|
||||
lib/Imakefile
|
||||
lib/Makefile.noX
|
||||
lib/Makefile.AmigaGCC
|
||||
lib/Smakefile
|
||||
lib/Attrib.c
|
||||
lib/CrBufFrI.c
|
||||
lib/CrBufFrP.c
|
||||
lib/CrDatFrI.c
|
||||
lib/CrDatFrP.c
|
||||
lib/CrIFrBuf.c
|
||||
lib/CrIFrDat.c
|
||||
lib/CrIFrP.c
|
||||
lib/CrPFrBuf.c
|
||||
lib/CrPFrDat.c
|
||||
lib/CrPFrI.c
|
||||
lib/Image.c
|
||||
lib/Info.c
|
||||
lib/RdFToBuf.c
|
||||
lib/RdFToDat.c
|
||||
lib/RdFToI.c
|
||||
lib/RdFToP.c
|
||||
lib/WrFFrBuf.c
|
||||
lib/WrFFrDat.c
|
||||
lib/WrFFrI.c
|
||||
lib/WrFFrP.c
|
||||
lib/amigax.h
|
||||
lib/amigax.c
|
||||
lib/create.c
|
||||
lib/data.c
|
||||
lib/descrip.mms
|
||||
lib/hashtab.c
|
||||
lib/make.com
|
||||
lib/misc.c
|
||||
lib/parse.c
|
||||
lib/rgb.c
|
||||
lib/rgbtab.h
|
||||
lib/scan.c
|
||||
lib/simx.h
|
||||
lib/simx.c
|
||||
lib/xpm.h
|
||||
lib/XpmI.h
|
||||
lib/Xpm-def.cpp
|
||||
doc
|
||||
doc/xpm.PS
|
||||
sxpm
|
||||
sxpm/Imakefile
|
||||
sxpm/Makefile.noX
|
||||
sxpm/plaid.xpm
|
||||
sxpm/plaid_ext.xpm
|
||||
sxpm/plaid_mask.xpm
|
||||
sxpm/sxpm.c
|
||||
sxpm/sxpm.man
|
||||
cxpm
|
||||
cxpm/Imakefile
|
||||
cxpm/Makefile.noX
|
||||
cxpm/cxpm.c
|
||||
cxpm/cxpm.man
|
@@ -1,266 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* hashtab.c: *
|
||||
* *
|
||||
* XPM library *
|
||||
* *
|
||||
* Developed by Arnaud Le Hors *
|
||||
* this originaly comes from Colas Nahaboo as a part of Wool *
|
||||
* *
|
||||
\*****************************************************************************/
|
||||
|
||||
#include "XpmI.h"
|
||||
|
||||
LFUNC(AtomMake, xpmHashAtom, (char *name, void *data));
|
||||
LFUNC(HashTableGrows, int, (xpmHashTable * table));
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static xpmHashAtom
|
||||
AtomMake(char* name, void* data) /* makes an atom */
|
||||
#else
|
||||
static xpmHashAtom
|
||||
AtomMake(name, data) /* makes an atom */
|
||||
char *name; /* WARNING: is just pointed to */
|
||||
void *data;
|
||||
#endif
|
||||
{
|
||||
xpmHashAtom object = (xpmHashAtom) XpmMalloc(sizeof(struct _xpmHashAtom));
|
||||
|
||||
if (object) {
|
||||
object->name = name;
|
||||
object->data = data;
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
/************************\
|
||||
* *
|
||||
* hash table routines *
|
||||
* *
|
||||
\************************/
|
||||
|
||||
/*
|
||||
* Hash function definition:
|
||||
* HASH_FUNCTION: hash function, hash = hashcode, hp = pointer on char,
|
||||
* hash2 = temporary for hashcode.
|
||||
* INITIAL_TABLE_SIZE in slots
|
||||
* HASH_TABLE_GROWS how hash table grows.
|
||||
*/
|
||||
|
||||
/* Mock lisp function */
|
||||
#define HASH_FUNCTION hash = (hash << 5) - hash + *hp++;
|
||||
/* #define INITIAL_HASH_SIZE 2017 */
|
||||
#define INITIAL_HASH_SIZE 256 /* should be enough for colors */
|
||||
#define HASH_TABLE_GROWS size = size * 2;
|
||||
|
||||
/* aho-sethi-ullman's HPJ (sizes should be primes)*/
|
||||
#ifdef notdef
|
||||
#define HASH_FUNCTION hash <<= 4; hash += *hp++; \
|
||||
if(hash2 = hash & 0xf0000000) hash ^= (hash2 >> 24) ^ hash2;
|
||||
#define INITIAL_HASH_SIZE 4095 /* should be 2^n - 1 */
|
||||
#define HASH_TABLE_GROWS size = size << 1 + 1;
|
||||
#endif
|
||||
|
||||
/* GNU emacs function */
|
||||
/*
|
||||
#define HASH_FUNCTION hash = (hash << 3) + (hash >> 28) + *hp++;
|
||||
#define INITIAL_HASH_SIZE 2017
|
||||
#define HASH_TABLE_GROWS size = size * 2;
|
||||
*/
|
||||
|
||||
/* end of hash functions */
|
||||
|
||||
/*
|
||||
* The hash table is used to store atoms via their NAME:
|
||||
*
|
||||
* NAME --hash--> ATOM |--name--> "foo"
|
||||
* |--data--> any value which has to be stored
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* xpmHashSlot gives the slot (pointer to xpmHashAtom) of a name
|
||||
* (slot points to NULL if it is not defined)
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
xpmHashAtom* xpmHashSlot(xpmHashTable* table, char* s)
|
||||
#else
|
||||
xpmHashAtom *
|
||||
xpmHashSlot(table, s)
|
||||
xpmHashTable *table;
|
||||
char *s;
|
||||
#endif
|
||||
{
|
||||
xpmHashAtom *atomTable = table->atomTable;
|
||||
unsigned int hash;
|
||||
xpmHashAtom *p;
|
||||
char *hp = s;
|
||||
char *ns;
|
||||
|
||||
hash = 0;
|
||||
while (*hp) { /* computes hash function */
|
||||
HASH_FUNCTION
|
||||
}
|
||||
p = atomTable + hash % table->size;
|
||||
while (*p) {
|
||||
ns = (*p)->name;
|
||||
if (ns[0] == s[0] && strcmp(ns, s) == 0)
|
||||
break;
|
||||
p--;
|
||||
if (p < atomTable)
|
||||
p = atomTable + table->size - 1;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static int HashTableGrows(xpmHashTable* table)
|
||||
#else
|
||||
static int
|
||||
HashTableGrows(table)
|
||||
xpmHashTable *table;
|
||||
#endif
|
||||
{
|
||||
xpmHashAtom *atomTable = table->atomTable;
|
||||
int size = table->size;
|
||||
xpmHashAtom *t, *p;
|
||||
int i;
|
||||
int oldSize = size;
|
||||
|
||||
t = atomTable;
|
||||
HASH_TABLE_GROWS
|
||||
table->size = size;
|
||||
table->limit = size / 3;
|
||||
atomTable = (xpmHashAtom *) XpmMalloc(size * sizeof(*atomTable));
|
||||
if (!atomTable)
|
||||
return (XpmNoMemory);
|
||||
table->atomTable = atomTable;
|
||||
for (p = atomTable + size; p > atomTable;)
|
||||
*--p = NULL;
|
||||
for (i = 0, p = t; i < oldSize; i++, p++)
|
||||
if (*p) {
|
||||
xpmHashAtom *ps = xpmHashSlot(table, (*p)->name);
|
||||
|
||||
*ps = *p;
|
||||
}
|
||||
XpmFree(t);
|
||||
return (XpmSuccess);
|
||||
}
|
||||
|
||||
/*
|
||||
* xpmHashIntern(table, name, data)
|
||||
* an xpmHashAtom is created if name doesn't exist, with the given data.
|
||||
*/
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int xpmHashIntern(xpmHashTable* table, char* tag, void* data)
|
||||
#else
|
||||
int
|
||||
xpmHashIntern(table, tag, data)
|
||||
xpmHashTable *table;
|
||||
char *tag;
|
||||
void *data;
|
||||
#endif
|
||||
{
|
||||
xpmHashAtom *slot;
|
||||
|
||||
if (!*(slot = xpmHashSlot(table, tag))) {
|
||||
/* undefined, make a new atom with the given data */
|
||||
if (!(*slot = AtomMake(tag, data)))
|
||||
return (XpmNoMemory);
|
||||
if (table->used >= table->limit) {
|
||||
int ErrorStatus;
|
||||
|
||||
if ((ErrorStatus = HashTableGrows(table)) != XpmSuccess)
|
||||
return (ErrorStatus);
|
||||
table->used++;
|
||||
return (XpmSuccess);
|
||||
}
|
||||
table->used++;
|
||||
}
|
||||
return (XpmSuccess);
|
||||
}
|
||||
|
||||
/*
|
||||
* must be called before allocating any atom
|
||||
*/
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int xpmHashTableInit(xpmHashTable* table)
|
||||
#else
|
||||
int
|
||||
xpmHashTableInit(table)
|
||||
xpmHashTable *table;
|
||||
#endif
|
||||
{
|
||||
xpmHashAtom *p;
|
||||
xpmHashAtom *atomTable;
|
||||
|
||||
table->size = INITIAL_HASH_SIZE;
|
||||
table->limit = table->size / 3;
|
||||
table->used = 0;
|
||||
atomTable = (xpmHashAtom *) XpmMalloc(table->size * sizeof(*atomTable));
|
||||
if (!atomTable)
|
||||
return (XpmNoMemory);
|
||||
for (p = atomTable + table->size; p > atomTable;)
|
||||
*--p = NULL;
|
||||
table->atomTable = atomTable;
|
||||
return (XpmSuccess);
|
||||
}
|
||||
|
||||
/*
|
||||
* frees a hashtable and all the stored atoms
|
||||
*/
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
void
|
||||
xpmHashTableFree(xpmHashTable* table)
|
||||
#else
|
||||
void
|
||||
xpmHashTableFree(table)
|
||||
xpmHashTable *table;
|
||||
#endif
|
||||
{
|
||||
xpmHashAtom *p;
|
||||
xpmHashAtom *atomTable = table->atomTable;
|
||||
|
||||
if (!atomTable)
|
||||
return;
|
||||
for (p = atomTable + table->size; p > atomTable;)
|
||||
if (*--p)
|
||||
XpmFree(*p);
|
||||
XpmFree(atomTable);
|
||||
table->atomTable = NULL;
|
||||
}
|
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* Image.c: *
|
||||
* *
|
||||
* XPM library *
|
||||
* Functions to init and free the XpmImage structure. *
|
||||
* *
|
||||
* Developed by Arnaud Le Hors *
|
||||
\*****************************************************************************/
|
||||
|
||||
#include "XpmI.h"
|
||||
|
||||
/*
|
||||
* Init returned data to free safely later on
|
||||
*/
|
||||
void
|
||||
xpmInitXpmImage(image)
|
||||
XpmImage *image;
|
||||
{
|
||||
image->ncolors = 0;
|
||||
image->colorTable = NULL;
|
||||
image->data = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the XpmImage data which have been allocated
|
||||
*/
|
||||
void
|
||||
XpmFreeXpmImage(image)
|
||||
XpmImage *image;
|
||||
{
|
||||
if (image->colorTable)
|
||||
xpmFreeColorTable(image->colorTable, image->ncolors);
|
||||
if (image->data)
|
||||
XpmFree(image->data);
|
||||
image->data = NULL;
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
# Makefile for xpm
|
||||
# Borland C++
|
||||
|
||||
|
||||
LIBTARGET=$(WXDIR)\lib\xpm.lib
|
||||
|
||||
OBJECTS = attrib.obj crbuffri.obj crdatfri.obj create.obj crifrbuf.obj crifrdat.obj\
|
||||
data.obj image.obj info.obj hashtab.obj misc.obj parse.obj\
|
||||
rdftodat.obj rdftoi.obj rgb.obj scan.obj simx.obj wrffrdat.obj wrffri.obj
|
||||
|
||||
!include $(WXWIN)\src\makelib.b32
|
||||
|
||||
create.obj: create.c
|
||||
bcc32 $(CPPFLAGS) -Od -P- -c create.c
|
||||
|
||||
rgb.obj: rgb.c
|
||||
bcc32 $(CPPFLAGS) -Od -P- -c rgb.c
|
||||
|
@@ -1,11 +0,0 @@
|
||||
# Makefile for xpm
|
||||
# Borland C++
|
||||
|
||||
|
||||
LIBTARGET=$(WXDIR)\lib\xpm.lib
|
||||
|
||||
OBJECTS = attrib.obj crbuffri.obj crdatfri.obj create.obj crifrbuf.obj crifrdat.obj\
|
||||
data.obj image.obj info.obj hashtab.obj misc.obj parse.obj\
|
||||
rdftodat.obj rdftoi.obj rgb.obj scan.obj simx.obj wrffrdat.obj wrffri.obj
|
||||
|
||||
!include $(WXWIN)\src\makelib.bcc
|
@@ -1,155 +0,0 @@
|
||||
#
|
||||
# File: makefile.vc
|
||||
# Author: Julian Smart
|
||||
# Created: 1997
|
||||
# Updated:
|
||||
# Copyright: (c) 1997, Julian Smart
|
||||
#
|
||||
# "%W% %G%"
|
||||
#
|
||||
# Makefile : Builds xpm.lib for VC++ (16-bit)
|
||||
#
|
||||
!include <..\makemsc.env>
|
||||
|
||||
THISDIR=$(WXWIN)\src\xpm
|
||||
|
||||
LIBTARGET=$(WXDIR)\lib\xpm.lib
|
||||
|
||||
XPMDIR=$(WXDIR)\src\xpm
|
||||
|
||||
OBJECTS = $(XPMDIR)\attrib.obj\
|
||||
$(XPMDIR)\crbuffri.obj\
|
||||
$(XPMDIR)\crdatfri.obj\
|
||||
$(XPMDIR)\create.obj\
|
||||
$(XPMDIR)\crifrbuf.obj\
|
||||
$(XPMDIR)\crifrdat.obj\
|
||||
$(XPMDIR)\dataxpm.obj\
|
||||
$(XPMDIR)\imagexpm.obj\
|
||||
$(XPMDIR)\info.obj\
|
||||
$(XPMDIR)\hashtab.obj\
|
||||
$(XPMDIR)\misc.obj\
|
||||
$(XPMDIR)\parse.obj\
|
||||
$(XPMDIR)\rdftodat.obj\
|
||||
$(XPMDIR)\rdftoi.obj\
|
||||
$(XPMDIR)\rgb.obj\
|
||||
$(XPMDIR)\scan.obj\
|
||||
$(XPMDIR)\simx.obj\
|
||||
$(XPMDIR)\wrffrdat.obj\
|
||||
$(XPMDIR)\wrffri.obj
|
||||
|
||||
all: $(LIBTARGET)
|
||||
|
||||
$(LIBTARGET): $(OBJECTS)
|
||||
-erase $(LIBTARGET)
|
||||
lib /PAGESIZE:128 @<<
|
||||
$(LIBTARGET)
|
||||
y
|
||||
$(OBJECTS)
|
||||
nul
|
||||
;
|
||||
<<
|
||||
|
||||
$(XPMDIR)\attrib.obj: $(XPMDIR)\attrib.c
|
||||
cl @<<
|
||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||
<<
|
||||
|
||||
$(XPMDIR)\crbuffri.obj: $(XPMDIR)\crbuffri.c
|
||||
cl @<<
|
||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||
<<
|
||||
|
||||
$(XPMDIR)\crdatfri.obj: $(XPMDIR)\crdatfri.c
|
||||
cl @<<
|
||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||
<<
|
||||
|
||||
$(XPMDIR)\create.obj: $(XPMDIR)\create.c
|
||||
cl @<<
|
||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||
<<
|
||||
|
||||
$(XPMDIR)\crifrbuf.obj: $(XPMDIR)\crifrbuf.c
|
||||
cl @<<
|
||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||
<<
|
||||
|
||||
$(XPMDIR)\crifrdat.obj: $(XPMDIR)\crifrdat.c
|
||||
cl @<<
|
||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||
<<
|
||||
|
||||
$(XPMDIR)\dataxpm.obj: $(XPMDIR)\dataxpm.c
|
||||
cl @<<
|
||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||
<<
|
||||
|
||||
$(XPMDIR)\imagexpm.obj: $(XPMDIR)\imagexpm.c
|
||||
cl @<<
|
||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||
<<
|
||||
|
||||
$(XPMDIR)\info.obj: $(XPMDIR)\info.c
|
||||
cl @<<
|
||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||
<<
|
||||
|
||||
$(XPMDIR)\hashtab.obj: $(XPMDIR)\hashtab.c
|
||||
cl @<<
|
||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||
<<
|
||||
|
||||
$(XPMDIR)\misc.obj: $(XPMDIR)\misc.c
|
||||
cl @<<
|
||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||
<<
|
||||
|
||||
$(XPMDIR)\parse.obj: $(XPMDIR)\parse.c
|
||||
cl @<<
|
||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||
<<
|
||||
|
||||
$(XPMDIR)\rdftodat.obj: $(XPMDIR)\rdftodat.c
|
||||
cl @<<
|
||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||
<<
|
||||
|
||||
$(XPMDIR)\rdftoi.obj: $(XPMDIR)\rdftoi.c
|
||||
cl @<<
|
||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||
<<
|
||||
|
||||
$(XPMDIR)\rgb.obj: $(XPMDIR)\rgb.c
|
||||
cl @<<
|
||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||
<<
|
||||
|
||||
$(XPMDIR)\scan.obj: $(XPMDIR)\scan.c
|
||||
cl @<<
|
||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||
<<
|
||||
|
||||
$(XPMDIR)\simx.obj: $(XPMDIR)\simx.c
|
||||
cl @<<
|
||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||
<<
|
||||
|
||||
$(XPMDIR)\wrffrdat.obj: $(XPMDIR)\wrffrdat.c
|
||||
cl @<<
|
||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||
<<
|
||||
|
||||
$(XPMDIR)\wrffri.obj: $(XPMDIR)\wrffri.c
|
||||
cl @<<
|
||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||
<<
|
||||
|
||||
clean:
|
||||
-erase *.obj
|
||||
-erase $(LIBTARGET)
|
||||
-erase *.pdb
|
||||
-erase *.sbr
|
||||
-erase *.pch
|
||||
|
||||
cleanall: clean
|
||||
|
@@ -1,56 +0,0 @@
|
||||
#!/binb/wmake.exe
|
||||
#
|
||||
# File: makefile.wat
|
||||
# Author: Julian Smart
|
||||
# Created: 1998
|
||||
#
|
||||
# Makefile : Builds XPM library for Watcom C++, WIN32
|
||||
|
||||
WXDIR = ..\..
|
||||
|
||||
!include $(WXDIR)\src\makewat.env
|
||||
|
||||
WXLIB = $(WXDIR)\lib
|
||||
|
||||
LIBTARGET = $(WXLIB)\xpm.lib
|
||||
|
||||
OBJECTS = attrib.obj &
|
||||
crbuffri.obj &
|
||||
crdatfri.obj &
|
||||
create.obj &
|
||||
crifrbuf.obj &
|
||||
crifrdat.obj &
|
||||
data.obj &
|
||||
image.obj &
|
||||
info.obj &
|
||||
hashtab.obj &
|
||||
misc.obj &
|
||||
parse.obj &
|
||||
rdftodat.obj &
|
||||
rdftoi.obj &
|
||||
rgb.obj &
|
||||
scan.obj &
|
||||
simx.obj &
|
||||
wrffrdat.obj &
|
||||
wrffri.obj
|
||||
|
||||
all: $(OBJECTS) $(LIBTARGET)
|
||||
|
||||
$(LIBTARGET) : $(OBJECTS)
|
||||
%create tmp.lbc
|
||||
@for %i in ( $(OBJECTS) ) do @%append tmp.lbc +%i
|
||||
wlib /b /c /n /p=512 $^@ @tmp.lbc
|
||||
|
||||
clean: .SYMBOLIC
|
||||
-erase *.obj
|
||||
-erase $(LIBTARGET)
|
||||
-erase *.pch
|
||||
-erase *.err
|
||||
-erase *.lbc
|
||||
|
||||
cleanall: clean
|
||||
|
||||
#accel.obj: $(MSWDIR)\accel.cpp
|
||||
# *$(CCC) $(CPPFLAGS) $(IFLAGS) $<
|
||||
|
||||
|
150
src/xpm/misc.c
150
src/xpm/misc.c
@@ -1,150 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* misc.c: *
|
||||
* *
|
||||
* XPM library *
|
||||
* Miscellaneous utilities *
|
||||
* *
|
||||
* Developed by Arnaud Le Hors *
|
||||
\*****************************************************************************/
|
||||
|
||||
#include "XpmI.h"
|
||||
|
||||
#ifdef NEED_STRDUP
|
||||
/*
|
||||
* in case strdup is not provided by the system here is one
|
||||
* which does the trick
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
char* xpmstrdup(char* s1)
|
||||
#else
|
||||
char *
|
||||
xpmstrdup(s1)
|
||||
char *s1;
|
||||
#endif
|
||||
{
|
||||
char *s2;
|
||||
int l = strlen(s1) + 1;
|
||||
|
||||
if (s2 = (char *) XpmMalloc(l))
|
||||
strcpy(s2, s1);
|
||||
return s2;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
unsigned int
|
||||
xpmatoui(
|
||||
register char* p
|
||||
, unsigned int l
|
||||
, unsigned int* ui_return
|
||||
)
|
||||
#else
|
||||
unsigned int
|
||||
xpmatoui(p, l, ui_return)
|
||||
register char *p;
|
||||
unsigned int l;
|
||||
unsigned int *ui_return;
|
||||
#endif
|
||||
{
|
||||
register unsigned int n, i;
|
||||
|
||||
n = 0;
|
||||
for (i = 0; i < l; i++)
|
||||
if (*p >= '0' && *p <= '9')
|
||||
n = n * 10 + *p++ - '0';
|
||||
else
|
||||
break;
|
||||
|
||||
if (i != 0 && i == l) {
|
||||
*ui_return = n;
|
||||
return 1;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function returning a character string related to an error code.
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
char* XpmGetErrorString(int errcode)
|
||||
#else
|
||||
char *
|
||||
XpmGetErrorString(errcode)
|
||||
int errcode;
|
||||
#endif
|
||||
{
|
||||
switch (errcode) {
|
||||
case XpmColorError:
|
||||
return ("XpmColorError");
|
||||
case XpmSuccess:
|
||||
return ("XpmSuccess");
|
||||
case XpmOpenFailed:
|
||||
return ("XpmOpenFailed");
|
||||
case XpmFileInvalid:
|
||||
return ("XpmFileInvalid");
|
||||
case XpmNoMemory:
|
||||
return ("XpmNoMemory");
|
||||
case XpmColorFailed:
|
||||
return ("XpmColorFailed");
|
||||
default:
|
||||
return ("Invalid XpmError");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The following function provides a way to figure out if the linked library is
|
||||
* newer or older than the one with which a program has been first compiled.
|
||||
*/
|
||||
int
|
||||
XpmLibraryVersion()
|
||||
{
|
||||
return XpmIncludeVersion;
|
||||
}
|
||||
|
||||
|
||||
/* The following should help people wanting to use their own functions */
|
||||
#ifdef XpmFree
|
||||
#undef XpmFree
|
||||
#endif
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
void
|
||||
XpmFree(void* ptr)
|
||||
#else
|
||||
void
|
||||
XpmFree(ptr)
|
||||
void *ptr;
|
||||
#endif
|
||||
{
|
||||
free(ptr);
|
||||
}
|
804
src/xpm/parse.c
804
src/xpm/parse.c
@@ -1,804 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* parse.c: *
|
||||
* *
|
||||
* XPM library *
|
||||
* Parse an XPM file or array and store the found informations *
|
||||
* in the given XpmImage structure. *
|
||||
* *
|
||||
* Developed by Arnaud Le Hors *
|
||||
\*****************************************************************************/
|
||||
|
||||
/*
|
||||
* The code related to FOR_MSW has been added by
|
||||
* HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
|
||||
*/
|
||||
|
||||
#include "XpmI.h"
|
||||
#include <ctype.h>
|
||||
|
||||
LFUNC(ParsePixels, int, (xpmData *data, unsigned int width,
|
||||
unsigned int height, unsigned int ncolors,
|
||||
unsigned int cpp, XpmColor *colorTable,
|
||||
xpmHashTable *hashtable, unsigned int **pixels));
|
||||
|
||||
char *xpmColorKeys[] = {
|
||||
"s", /* key #1: symbol */
|
||||
"m", /* key #2: mono visual */
|
||||
"g4", /* key #3: 4 grays visual */
|
||||
"g", /* key #4: gray visual */
|
||||
"c", /* key #5: color visual */
|
||||
};
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int xpmParseValues(
|
||||
xpmData* data
|
||||
, unsigned int* width
|
||||
, unsigned int* height
|
||||
, unsigned int* ncolors
|
||||
, unsigned int* cpp
|
||||
, unsigned int* x_hotspot
|
||||
, unsigned int* y_hotspot
|
||||
, unsigned int* hotspot
|
||||
, unsigned int* extensions
|
||||
)
|
||||
#else
|
||||
int
|
||||
xpmParseValues(data, width, height, ncolors, cpp,
|
||||
x_hotspot, y_hotspot, hotspot, extensions)
|
||||
xpmData *data;
|
||||
unsigned int *width, *height, *ncolors, *cpp;
|
||||
unsigned int *x_hotspot, *y_hotspot, *hotspot;
|
||||
unsigned int *extensions;
|
||||
#endif
|
||||
{
|
||||
unsigned int l;
|
||||
char buf[BUFSIZ];
|
||||
|
||||
if (!data->format) { /* XPM 2 or 3 */
|
||||
|
||||
/*
|
||||
* read values: width, height, ncolors, chars_per_pixel
|
||||
*/
|
||||
if (!(xpmNextUI(data, width) && xpmNextUI(data, height)
|
||||
&& xpmNextUI(data, ncolors) && xpmNextUI(data, cpp)))
|
||||
return (XpmFileInvalid);
|
||||
|
||||
/*
|
||||
* read optional information (hotspot and/or XPMEXT) if any
|
||||
*/
|
||||
l = xpmNextWord(data, buf, BUFSIZ);
|
||||
if (l) {
|
||||
*extensions = (l == 6 && !strncmp("XPMEXT", buf, 6));
|
||||
if (*extensions)
|
||||
*hotspot = (xpmNextUI(data, x_hotspot)
|
||||
&& xpmNextUI(data, y_hotspot));
|
||||
else {
|
||||
*hotspot = (xpmatoui(buf, l, x_hotspot)
|
||||
&& xpmNextUI(data, y_hotspot));
|
||||
l = xpmNextWord(data, buf, BUFSIZ);
|
||||
*extensions = (l == 6 && !strncmp("XPMEXT", buf, 6));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
/*
|
||||
* XPM 1 file read values: width, height, ncolors, chars_per_pixel
|
||||
*/
|
||||
int i;
|
||||
char *ptr;
|
||||
Bool got_one, saw_width = False, saw_height = False;
|
||||
Bool saw_ncolors = False, saw_chars_per_pixel = False;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
l = xpmNextWord(data, buf, BUFSIZ);
|
||||
if (l != 7 || strncmp("#define", buf, 7))
|
||||
return (XpmFileInvalid);
|
||||
l = xpmNextWord(data, buf, BUFSIZ);
|
||||
if (!l)
|
||||
return (XpmFileInvalid);
|
||||
buf[l] = '\0';
|
||||
ptr = buf;
|
||||
got_one = False;
|
||||
while (!got_one) {
|
||||
ptr = index(ptr, '_');
|
||||
if (!ptr)
|
||||
return (XpmFileInvalid);
|
||||
switch (l - (ptr - buf)) {
|
||||
case 6:
|
||||
if (saw_width || strncmp("_width", ptr, 6)
|
||||
|| !xpmNextUI(data, width))
|
||||
return (XpmFileInvalid);
|
||||
else
|
||||
saw_width = True;
|
||||
got_one = True;
|
||||
break;
|
||||
case 7:
|
||||
if (saw_height || strncmp("_height", ptr, 7)
|
||||
|| !xpmNextUI(data, height))
|
||||
return (XpmFileInvalid);
|
||||
else
|
||||
saw_height = True;
|
||||
got_one = True;
|
||||
break;
|
||||
case 8:
|
||||
if (saw_ncolors || strncmp("_ncolors", ptr, 8)
|
||||
|| !xpmNextUI(data, ncolors))
|
||||
return (XpmFileInvalid);
|
||||
else
|
||||
saw_ncolors = True;
|
||||
got_one = True;
|
||||
break;
|
||||
case 16:
|
||||
if (saw_chars_per_pixel
|
||||
|| strncmp("_chars_per_pixel", ptr, 16)
|
||||
|| !xpmNextUI(data, cpp))
|
||||
return (XpmFileInvalid);
|
||||
else
|
||||
saw_chars_per_pixel = True;
|
||||
got_one = True;
|
||||
break;
|
||||
default:
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
/* skip the end of line */
|
||||
xpmNextString(data);
|
||||
}
|
||||
if (!saw_width || !saw_height || !saw_ncolors || !saw_chars_per_pixel)
|
||||
return (XpmFileInvalid);
|
||||
|
||||
*hotspot = 0;
|
||||
*extensions = 0;
|
||||
}
|
||||
return (XpmSuccess);
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int xpmParseColors(
|
||||
xpmData* data
|
||||
, unsigned int ncolors
|
||||
, unsigned int cpp
|
||||
, XpmColor** colorTablePtr
|
||||
, xpmHashTable* hashtable
|
||||
)
|
||||
#else
|
||||
int
|
||||
xpmParseColors(data, ncolors, cpp, colorTablePtr, hashtable)
|
||||
xpmData *data;
|
||||
unsigned int ncolors;
|
||||
unsigned int cpp;
|
||||
XpmColor **colorTablePtr;
|
||||
xpmHashTable *hashtable;
|
||||
#endif
|
||||
{
|
||||
unsigned int key, l, a, b;
|
||||
unsigned int curkey; /* current color key */
|
||||
unsigned int lastwaskey; /* key read */
|
||||
char buf[BUFSIZ];
|
||||
char curbuf[BUFSIZ]; /* current buffer */
|
||||
char **sptr, *s;
|
||||
XpmColor *color;
|
||||
XpmColor *colorTable;
|
||||
char **defaults;
|
||||
int ErrorStatus;
|
||||
|
||||
colorTable = (XpmColor *) XpmCalloc(ncolors, sizeof(XpmColor));
|
||||
if (!colorTable)
|
||||
return (XpmNoMemory);
|
||||
|
||||
if (!data->format) { /* XPM 2 or 3 */
|
||||
for (a = 0, color = colorTable; a < ncolors; a++, color++) {
|
||||
xpmNextString(data); /* skip the line */
|
||||
|
||||
/*
|
||||
* read pixel value
|
||||
*/
|
||||
color->string = (char *) XpmMalloc(cpp + 1);
|
||||
if (!color->string) {
|
||||
xpmFreeColorTable(colorTable, ncolors);
|
||||
return (XpmNoMemory);
|
||||
}
|
||||
for (b = 0, s = color->string; b < cpp; b++, s++)
|
||||
*s = xpmGetC(data);
|
||||
*s = '\0';
|
||||
|
||||
/*
|
||||
* store the string in the hashtable with its color index number
|
||||
*/
|
||||
if (USE_HASHTABLE) {
|
||||
ErrorStatus =
|
||||
xpmHashIntern(hashtable, color->string, HashAtomData(a));
|
||||
if (ErrorStatus != XpmSuccess) {
|
||||
xpmFreeColorTable(colorTable, ncolors);
|
||||
return (ErrorStatus);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* read color keys and values
|
||||
*/
|
||||
defaults = (char **) color;
|
||||
curkey = 0;
|
||||
lastwaskey = 0;
|
||||
*curbuf = '\0'; /* init curbuf */
|
||||
while (l = xpmNextWord(data, buf, BUFSIZ)) {
|
||||
if (!lastwaskey) {
|
||||
for (key = 0, sptr = xpmColorKeys; key < NKEYS; key++,
|
||||
sptr++)
|
||||
if ((strlen(*sptr) == l) && (!strncmp(*sptr, buf, l)))
|
||||
break;
|
||||
}
|
||||
if (!lastwaskey && key < NKEYS) { /* open new key */
|
||||
if (curkey) { /* flush string */
|
||||
s = (char *) XpmMalloc(strlen(curbuf) + 1);
|
||||
if (!s) {
|
||||
xpmFreeColorTable(colorTable, ncolors);
|
||||
return (XpmNoMemory);
|
||||
}
|
||||
defaults[curkey] = s;
|
||||
strcpy(s, curbuf);
|
||||
}
|
||||
curkey = key + 1; /* set new key */
|
||||
*curbuf = '\0'; /* reset curbuf */
|
||||
lastwaskey = 1;
|
||||
} else {
|
||||
if (!curkey) { /* key without value */
|
||||
xpmFreeColorTable(colorTable, ncolors);
|
||||
return (XpmFileInvalid);
|
||||
}
|
||||
if (!lastwaskey)
|
||||
strcat(curbuf, " "); /* append space */
|
||||
buf[l] = '\0';
|
||||
strcat(curbuf, buf);/* append buf */
|
||||
lastwaskey = 0;
|
||||
}
|
||||
}
|
||||
if (!curkey) { /* key without value */
|
||||
xpmFreeColorTable(colorTable, ncolors);
|
||||
return (XpmFileInvalid);
|
||||
}
|
||||
s = defaults[curkey] = (char *) XpmMalloc(strlen(curbuf) + 1);
|
||||
if (!s) {
|
||||
xpmFreeColorTable(colorTable, ncolors);
|
||||
return (XpmNoMemory);
|
||||
}
|
||||
strcpy(s, curbuf);
|
||||
}
|
||||
} else { /* XPM 1 */
|
||||
/* get to the beginning of the first string */
|
||||
data->Bos = '"';
|
||||
data->Eos = '\0';
|
||||
xpmNextString(data);
|
||||
data->Eos = '"';
|
||||
for (a = 0, color = colorTable; a < ncolors; a++, color++) {
|
||||
|
||||
/*
|
||||
* read pixel value
|
||||
*/
|
||||
color->string = (char *) XpmMalloc(cpp + 1);
|
||||
if (!color->string) {
|
||||
xpmFreeColorTable(colorTable, ncolors);
|
||||
return (XpmNoMemory);
|
||||
}
|
||||
for (b = 0, s = color->string; b < cpp; b++, s++)
|
||||
*s = xpmGetC(data);
|
||||
*s = '\0';
|
||||
|
||||
/*
|
||||
* store the string in the hashtable with its color index number
|
||||
*/
|
||||
if (USE_HASHTABLE) {
|
||||
ErrorStatus =
|
||||
xpmHashIntern(hashtable, color->string, HashAtomData(a));
|
||||
if (ErrorStatus != XpmSuccess) {
|
||||
xpmFreeColorTable(colorTable, ncolors);
|
||||
return (ErrorStatus);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* read color values
|
||||
*/
|
||||
xpmNextString(data); /* get to the next string */
|
||||
*curbuf = '\0'; /* init curbuf */
|
||||
while (l = xpmNextWord(data, buf, BUFSIZ)) {
|
||||
if (*curbuf != '\0')
|
||||
strcat(curbuf, " ");/* append space */
|
||||
buf[l] = '\0';
|
||||
strcat(curbuf, buf); /* append buf */
|
||||
}
|
||||
s = (char *) XpmMalloc(strlen(curbuf) + 1);
|
||||
if (!s) {
|
||||
xpmFreeColorTable(colorTable, ncolors);
|
||||
return (XpmNoMemory);
|
||||
}
|
||||
strcpy(s, curbuf);
|
||||
color->c_color = s;
|
||||
*curbuf = '\0'; /* reset curbuf */
|
||||
if (a < ncolors - 1)
|
||||
xpmNextString(data); /* get to the next string */
|
||||
}
|
||||
}
|
||||
*colorTablePtr = colorTable;
|
||||
return (XpmSuccess);
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
static int
|
||||
ParsePixels(
|
||||
xpmData* data
|
||||
, unsigned int width
|
||||
, unsigned int height
|
||||
, unsigned int ncolors
|
||||
, unsigned int cpp
|
||||
, XpmColor* colorTable
|
||||
, xpmHashTable* hashtable
|
||||
, unsigned int** pixels
|
||||
)
|
||||
#else
|
||||
static int
|
||||
ParsePixels(data, width, height, ncolors, cpp, colorTable, hashtable, pixels)
|
||||
xpmData *data;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int ncolors;
|
||||
unsigned int cpp;
|
||||
XpmColor *colorTable;
|
||||
xpmHashTable *hashtable;
|
||||
unsigned int **pixels;
|
||||
#endif
|
||||
{
|
||||
unsigned int *iptr, *iptr2;
|
||||
unsigned int a, x, y;
|
||||
|
||||
#ifndef FOR_MSW
|
||||
iptr2 = (unsigned int *) XpmMalloc(sizeof(unsigned int) * width * height);
|
||||
#else
|
||||
|
||||
/*
|
||||
* special treatment to trick DOS malloc(size_t) where size_t is 16 bit!!
|
||||
* XpmMalloc is defined to longMalloc(long) and checks the 16 bit boundary
|
||||
*/
|
||||
iptr2 = (unsigned int *)
|
||||
XpmMalloc((long) sizeof(unsigned int) * (long) width * (long) height);
|
||||
#endif
|
||||
if (!iptr2)
|
||||
return (XpmNoMemory);
|
||||
|
||||
iptr = iptr2;
|
||||
|
||||
switch (cpp) {
|
||||
|
||||
case (1): /* Optimize for single character
|
||||
* colors */
|
||||
{
|
||||
unsigned short colidx[256];
|
||||
|
||||
bzero((char *)colidx, 256 * sizeof(short));
|
||||
for (a = 0; a < ncolors; a++)
|
||||
colidx[(unsigned char)colorTable[a].string[0]] = a + 1;
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
xpmNextString(data);
|
||||
for (x = 0; x < width; x++, iptr++) {
|
||||
int c = xpmGetC(data);
|
||||
|
||||
if (c > 0 && c < 256 && colidx[c] != 0)
|
||||
*iptr = colidx[c] - 1;
|
||||
else {
|
||||
XpmFree(iptr2);
|
||||
return (XpmFileInvalid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case (2): /* Optimize for double character
|
||||
* colors */
|
||||
{
|
||||
|
||||
/* free all allocated pointers at all exits */
|
||||
#define FREE_CIDX {int f; for (f = 0; f < 256; f++) \
|
||||
if (cidx[f]) XpmFree(cidx[f]);}
|
||||
|
||||
/* array of pointers malloced by need */
|
||||
unsigned short *cidx[256];
|
||||
int char1;
|
||||
|
||||
bzero((char *)cidx, 256 * sizeof(unsigned short *)); /* init */
|
||||
for (a = 0; a < ncolors; a++) {
|
||||
char1 = colorTable[a].string[0];
|
||||
if (cidx[char1] == NULL) { /* get new memory */
|
||||
cidx[char1] = (unsigned short *)
|
||||
XpmCalloc(256, sizeof(unsigned short));
|
||||
if (cidx[char1] == NULL) { /* new block failed */
|
||||
FREE_CIDX;
|
||||
XpmFree(iptr2);
|
||||
return (XpmNoMemory);
|
||||
}
|
||||
}
|
||||
cidx[char1][(unsigned char)colorTable[a].string[1]] = a + 1;
|
||||
}
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
xpmNextString(data);
|
||||
for (x = 0; x < width; x++, iptr++) {
|
||||
int cc1 = xpmGetC(data);
|
||||
if (cc1 > 0 && cc1 < 256) {
|
||||
int cc2 = xpmGetC(data);
|
||||
if (cc2 > 0 && cc2 < 256 &&
|
||||
cidx[cc1] && cidx[cc1][cc2] != 0)
|
||||
*iptr = cidx[cc1][cc2] - 1;
|
||||
else {
|
||||
FREE_CIDX;
|
||||
XpmFree(iptr2);
|
||||
return (XpmFileInvalid);
|
||||
}
|
||||
} else {
|
||||
FREE_CIDX;
|
||||
XpmFree(iptr2);
|
||||
return (XpmFileInvalid);
|
||||
}
|
||||
}
|
||||
}
|
||||
FREE_CIDX;
|
||||
}
|
||||
break;
|
||||
|
||||
default: /* Non-optimized case of long color
|
||||
* names */
|
||||
{
|
||||
char *s;
|
||||
char buf[BUFSIZ];
|
||||
|
||||
buf[cpp] = '\0';
|
||||
if (USE_HASHTABLE) {
|
||||
xpmHashAtom *slot;
|
||||
|
||||
for (y = 0; y < height; y++) {
|
||||
xpmNextString(data);
|
||||
for (x = 0; x < width; x++, iptr++) {
|
||||
for (a = 0, s = buf; a < cpp; a++, s++)
|
||||
*s = xpmGetC(data);
|
||||
slot = xpmHashSlot(hashtable, buf);
|
||||
if (!*slot) { /* no color matches */
|
||||
XpmFree(iptr2);
|
||||
return (XpmFileInvalid);
|
||||
}
|
||||
*iptr = HashColorIndex(slot);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (y = 0; y < height; y++) {
|
||||
xpmNextString(data);
|
||||
for (x = 0; x < width; x++, iptr++) {
|
||||
for (a = 0, s = buf; a < cpp; a++, s++)
|
||||
*s = xpmGetC(data);
|
||||
for (a = 0; a < ncolors; a++)
|
||||
if (!strcmp(colorTable[a].string, buf))
|
||||
break;
|
||||
if (a == ncolors) { /* no color matches */
|
||||
XpmFree(iptr2);
|
||||
return (XpmFileInvalid);
|
||||
}
|
||||
*iptr = a;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
*pixels = iptr2;
|
||||
return (XpmSuccess);
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int xpmParseExtensions(
|
||||
xpmData* data
|
||||
, XpmExtension** extensions
|
||||
, unsigned int* nextensions
|
||||
)
|
||||
#else
|
||||
int
|
||||
xpmParseExtensions(data, extensions, nextensions)
|
||||
xpmData *data;
|
||||
XpmExtension **extensions;
|
||||
unsigned int *nextensions;
|
||||
#endif
|
||||
{
|
||||
XpmExtension *exts = NULL, *ext;
|
||||
unsigned int num = 0;
|
||||
unsigned int nlines, a, l, notstart, notend = 0;
|
||||
int status;
|
||||
char *string, *s, *s2, **sp;
|
||||
|
||||
xpmNextString(data);
|
||||
exts = (XpmExtension *) XpmMalloc(sizeof(XpmExtension));
|
||||
/* get the whole string */
|
||||
status = xpmGetString(data, &string, &l);
|
||||
if (status != XpmSuccess) {
|
||||
XpmFree(exts);
|
||||
return (status);
|
||||
}
|
||||
/* look for the key word XPMEXT, skip lines before this */
|
||||
while ((notstart = strncmp("XPMEXT", string, 6))
|
||||
&& (notend = strncmp("XPMENDEXT", string, 9))) {
|
||||
XpmFree(string);
|
||||
xpmNextString(data);
|
||||
status = xpmGetString(data, &string, &l);
|
||||
if (status != XpmSuccess) {
|
||||
XpmFree(exts);
|
||||
return (status);
|
||||
}
|
||||
}
|
||||
if (!notstart)
|
||||
notend = strncmp("XPMENDEXT", string, 9);
|
||||
while (!notstart && notend) {
|
||||
/* there starts an extension */
|
||||
ext = (XpmExtension *)
|
||||
XpmRealloc(exts, (num + 1) * sizeof(XpmExtension));
|
||||
if (!ext) {
|
||||
XpmFree(string);
|
||||
XpmFreeExtensions(exts, num);
|
||||
return (XpmNoMemory);
|
||||
}
|
||||
exts = ext;
|
||||
ext += num;
|
||||
/* skip whitespace and store its name */
|
||||
s2 = s = string + 6;
|
||||
while (isspace(*s2))
|
||||
s2++;
|
||||
a = s2 - s;
|
||||
ext->name = (char *) XpmMalloc(l - a - 6);
|
||||
if (!ext->name) {
|
||||
XpmFree(string);
|
||||
ext->lines = NULL;
|
||||
ext->nlines = 0;
|
||||
XpmFreeExtensions(exts, num + 1);
|
||||
return (XpmNoMemory);
|
||||
}
|
||||
strncpy(ext->name, s + a, l - a - 6);
|
||||
XpmFree(string);
|
||||
/* now store the related lines */
|
||||
xpmNextString(data);
|
||||
status = xpmGetString(data, &string, &l);
|
||||
if (status != XpmSuccess) {
|
||||
ext->lines = NULL;
|
||||
ext->nlines = 0;
|
||||
XpmFreeExtensions(exts, num + 1);
|
||||
return (status);
|
||||
}
|
||||
ext->lines = (char **) XpmMalloc(sizeof(char *));
|
||||
nlines = 0;
|
||||
while ((notstart = strncmp("XPMEXT", string, 6))
|
||||
&& (notend = strncmp("XPMENDEXT", string, 9))) {
|
||||
sp = (char **)
|
||||
XpmRealloc(ext->lines, (nlines + 1) * sizeof(char *));
|
||||
if (!sp) {
|
||||
XpmFree(string);
|
||||
ext->nlines = nlines;
|
||||
XpmFreeExtensions(exts, num + 1);
|
||||
return (XpmNoMemory);
|
||||
}
|
||||
ext->lines = sp;
|
||||
ext->lines[nlines] = string;
|
||||
nlines++;
|
||||
xpmNextString(data);
|
||||
status = xpmGetString(data, &string, &l);
|
||||
if (status != XpmSuccess) {
|
||||
ext->nlines = nlines;
|
||||
XpmFreeExtensions(exts, num + 1);
|
||||
return (status);
|
||||
}
|
||||
}
|
||||
if (!nlines) {
|
||||
XpmFree(ext->lines);
|
||||
ext->lines = NULL;
|
||||
}
|
||||
ext->nlines = nlines;
|
||||
num++;
|
||||
}
|
||||
if (!num) {
|
||||
XpmFree(string);
|
||||
XpmFree(exts);
|
||||
exts = NULL;
|
||||
} else if (!notend)
|
||||
XpmFree(string);
|
||||
*nextensions = num;
|
||||
*extensions = exts;
|
||||
return (XpmSuccess);
|
||||
}
|
||||
|
||||
|
||||
/* function call in case of error */
|
||||
#undef RETURN
|
||||
#define RETURN(status) \
|
||||
{ \
|
||||
goto error; \
|
||||
}
|
||||
|
||||
/*
|
||||
* This function parses an Xpm file or data and store the found informations
|
||||
* in an an XpmImage structure which is returned.
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int xpmParseData(
|
||||
xpmData* data
|
||||
, XpmImage* image
|
||||
, XpmInfo* info
|
||||
)
|
||||
#else
|
||||
int
|
||||
xpmParseData(data, image, info)
|
||||
xpmData *data;
|
||||
XpmImage *image;
|
||||
XpmInfo *info;
|
||||
#endif
|
||||
{
|
||||
/* variables to return */
|
||||
unsigned int width, height, ncolors, cpp;
|
||||
unsigned int x_hotspot, y_hotspot, hotspot = 0, extensions = 0;
|
||||
XpmColor *colorTable = NULL;
|
||||
unsigned int *pixelindex = NULL;
|
||||
char *hints_cmt = NULL;
|
||||
char *colors_cmt = NULL;
|
||||
char *pixels_cmt = NULL;
|
||||
|
||||
unsigned int cmts;
|
||||
int ErrorStatus;
|
||||
xpmHashTable hashtable;
|
||||
|
||||
cmts = info && (info->valuemask & XpmReturnComments);
|
||||
|
||||
/*
|
||||
* parse the header
|
||||
*/
|
||||
ErrorStatus = xpmParseHeader(data);
|
||||
if (ErrorStatus != XpmSuccess)
|
||||
return (ErrorStatus);
|
||||
|
||||
/*
|
||||
* read values
|
||||
*/
|
||||
ErrorStatus = xpmParseValues(data, &width, &height, &ncolors, &cpp,
|
||||
&x_hotspot, &y_hotspot, &hotspot,
|
||||
&extensions);
|
||||
if (ErrorStatus != XpmSuccess)
|
||||
return (ErrorStatus);
|
||||
|
||||
/*
|
||||
* store the hints comment line
|
||||
*/
|
||||
if (cmts)
|
||||
xpmGetCmt(data, &hints_cmt);
|
||||
|
||||
/*
|
||||
* init the hastable
|
||||
*/
|
||||
if (USE_HASHTABLE) {
|
||||
ErrorStatus = xpmHashTableInit(&hashtable);
|
||||
if (ErrorStatus != XpmSuccess)
|
||||
return (ErrorStatus);
|
||||
}
|
||||
|
||||
/*
|
||||
* read colors
|
||||
*/
|
||||
ErrorStatus = xpmParseColors(data, ncolors, cpp, &colorTable, &hashtable);
|
||||
if (ErrorStatus != XpmSuccess) {
|
||||
if (USE_HASHTABLE)
|
||||
xpmHashTableFree(&hashtable);
|
||||
RETURN(ErrorStatus);
|
||||
}
|
||||
|
||||
/*
|
||||
* store the colors comment line
|
||||
*/
|
||||
if (cmts)
|
||||
xpmGetCmt(data, &colors_cmt);
|
||||
|
||||
/*
|
||||
* read pixels and index them on color number
|
||||
*/
|
||||
ErrorStatus = ParsePixels(data, width, height, ncolors, cpp, colorTable,
|
||||
&hashtable, &pixelindex);
|
||||
|
||||
/*
|
||||
* free the hastable
|
||||
*/
|
||||
if (USE_HASHTABLE)
|
||||
xpmHashTableFree(&hashtable);
|
||||
|
||||
if (ErrorStatus != XpmSuccess)
|
||||
RETURN(ErrorStatus);
|
||||
|
||||
/*
|
||||
* store the pixels comment line
|
||||
*/
|
||||
if (cmts)
|
||||
xpmGetCmt(data, &pixels_cmt);
|
||||
|
||||
/*
|
||||
* parse extensions
|
||||
*/
|
||||
if (info && (info->valuemask & XpmReturnExtensions))
|
||||
if (extensions) {
|
||||
ErrorStatus = xpmParseExtensions(data, &info->extensions,
|
||||
&info->nextensions);
|
||||
if (ErrorStatus != XpmSuccess)
|
||||
RETURN(ErrorStatus);
|
||||
} else {
|
||||
info->extensions = NULL;
|
||||
info->nextensions = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* store found informations in the XpmImage structure
|
||||
*/
|
||||
image->width = width;
|
||||
image->height = height;
|
||||
image->cpp = cpp;
|
||||
image->ncolors = ncolors;
|
||||
image->colorTable = colorTable;
|
||||
image->data = pixelindex;
|
||||
|
||||
if (info) {
|
||||
if (cmts) {
|
||||
info->hints_cmt = hints_cmt;
|
||||
info->colors_cmt = colors_cmt;
|
||||
info->pixels_cmt = pixels_cmt;
|
||||
}
|
||||
if (hotspot) {
|
||||
info->x_hotspot = x_hotspot;
|
||||
info->y_hotspot = y_hotspot;
|
||||
info->valuemask |= XpmHotspot;
|
||||
}
|
||||
}
|
||||
return (XpmSuccess);
|
||||
|
||||
/* exit point in case of error, free only locally allocated variables */
|
||||
error:
|
||||
if (colorTable)
|
||||
xpmFreeColorTable(colorTable, ncolors);
|
||||
if (pixelindex)
|
||||
XpmFree(pixelindex);
|
||||
if (hints_cmt)
|
||||
XpmFree(hints_cmt);
|
||||
if (colors_cmt)
|
||||
XpmFree(colors_cmt);
|
||||
if (pixels_cmt)
|
||||
XpmFree(pixels_cmt);
|
||||
|
||||
return(ErrorStatus);
|
||||
}
|
@@ -1,303 +0,0 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html lang="en">
|
||||
<HEAD>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<TITLE>XPM README</TITLE>
|
||||
</HEAD>
|
||||
|
||||
<body>
|
||||
<h1 align="center">XPM README</h1>
|
||||
|
||||
<h2>Contents</h2>
|
||||
|
||||
<ol>
|
||||
<li><a href="#sec1">What Is XPM?</a>
|
||||
<li><a href="#sec2">Where to get XPM?</a>
|
||||
<li><a href="#sec3">Documentation</a>
|
||||
<li><a href="#sec4">Installation</a>
|
||||
<ol>
|
||||
<li><a href="#sec4.1">With imake</a>
|
||||
<li><a href="#sec4.2">Without imake</a>
|
||||
</ol>
|
||||
<li><a href="#sec5">SXPM</a>
|
||||
<li><a href="#sec6">CXPM</a>
|
||||
<li><a href="#sec7">Other Tools</a>
|
||||
<li><a href="#sec8">Discussion</a>
|
||||
<li><a href="#copy">Copyright</a>
|
||||
</ol>
|
||||
|
||||
|
||||
<h2><a name="sec1">1. What Is XPM?</a></h2>
|
||||
<p>
|
||||
XPM (X PixMap) is a format for storing/retrieving X pixmaps to/from files.
|
||||
<p>
|
||||
Here is provided a library containing a set of four functions, similar to the
|
||||
X bitmap functions as defined in the Xlib: <code>XpmCreatePixmapFromData</code>,
|
||||
<code>XpmCreateDataFromPixmap</code>, <code>XpmReadFileToPixmap</code> and <code>XpmWriteFileFromPixmap</code> for
|
||||
respectively including, storing, reading and writing this format, plus four
|
||||
other: <code>XpmCreateImageFromData</code>, <code>XpmCreateDataFromImage</code>, <code>XpmReadFileToImage</code> and
|
||||
<code>XpmWriteFileFromImage</code> for working with images instead of pixmaps.
|
||||
<p>
|
||||
This new version provides a C includable format, defaults for different types
|
||||
of display: monochrome/color/grayscale, hotspot coordinates and symbol names
|
||||
for colors for overriding default colors when creating the pixmap. It provides
|
||||
a mechanism for storing information while reading a file which is re-used
|
||||
while writing. This way comments, default colors and symbol names aren't lost.
|
||||
It also handles "transparent pixels" by returning a shape mask in addition to
|
||||
the created pixmap.
|
||||
<p>
|
||||
See the XPM Manual for details.
|
||||
|
||||
|
||||
<h2><a name="sec2">2. Where to get XPM?</a></h2>
|
||||
<p>
|
||||
New XPM updates are announced on the comp.windows.x newsgroup, and on the
|
||||
"xpm-talk" list and you can always consult the XPM Home page at <a
|
||||
href="http://www.inria.fr/koala/lehors/xpm.html">http://www.inria.fr/koala/lehors/xpm.html</a>
|
||||
<p>The latest "official" XPM release can always be found at:
|
||||
<br>Boston, USA: <a
|
||||
href="ftp://ftp.x.org/contrib">ftp://ftp.x.org/contrib</a>
|
||||
<br>Sophia Antipolis, France: <a
|
||||
href="ftp://koala.inria.fr/pub/xpm">ftp://koala.inria.fr/pub/xpm</a>
|
||||
|
||||
|
||||
<h2><a name="sec3">3. Documentation</a></h2>
|
||||
<p>
|
||||
Old users might read the <a href="CHANGES">CHANGES</a> file for a history
|
||||
of changes interesting the user.
|
||||
<p>
|
||||
Read the doc. The documentation is in PostScript format (<a
|
||||
href="doc/xpm.PS">doc/xpm.PS</a>) and has been produced with
|
||||
FrameMaker. The source files are available on request.
|
||||
<p>
|
||||
A <a href="FAQ.html">FAQ</a> (Frequently Asked Questions) is also provided,
|
||||
so if you experience any problem you should have a look at this file.
|
||||
|
||||
|
||||
<h2><a name="sec4">4. Installation</a></h2>
|
||||
<p>
|
||||
To obtain the XPM library, first uncompress and untar the compressed tar file
|
||||
in an appropriate directory.
|
||||
<p>
|
||||
Then you can either compile XPM via "imake" or in a stand-alone way.
|
||||
|
||||
<h3><a name="sec4.1">4.1. With imake</a></h3>
|
||||
<p>
|
||||
Imakefiles are provided to build both shared and unshared libraries.
|
||||
However, building a shared lib is very OS dependent and often requires
|
||||
specific files which are not available. Also config files are often not
|
||||
set correctly for this task. So if it fails you can avoid trying to
|
||||
build one and simply build the static library instead. In order to do
|
||||
so you should edit the top Imakefile to add -DSharedLibXpm=NO to the
|
||||
definition of IMAKE_DEFINES as described.
|
||||
<p>
|
||||
The compilation and installation of the library and the sxpm program
|
||||
should only require you to edit the top Imakefile. But you should do so
|
||||
in order to specify the locations where the various files should be
|
||||
installed and to set the DEFINES variable accordingly to your system.
|
||||
<p>
|
||||
On Solaris 2.* the compilation works only in the native svr4
|
||||
environment, avoid the bsd one or it won't compile. Especially you
|
||||
should be using /opt/SUNWspro/bin/cc and not /usr/ucb/cc.
|
||||
Also since the compiler is no longer part of the OS distribution a lot
|
||||
of people use gcc instead. This is fine, but be aware that the imake
|
||||
tool you get as part of the X Window System on a solaris box is
|
||||
configured for cc. Therefore the compilation using the generated
|
||||
Makefiles will not succeed unless you have changed the default
|
||||
configuration. An easy work around is to directly edit the generated
|
||||
lib/Makefile to change '-K pic' to '-fpic'. Fixing your imake
|
||||
configuration would be better though.
|
||||
<p>
|
||||
On Linux, if you do not use ELF yet you'd better get the binary
|
||||
distribution available from sunsite. Because it's really a pain to
|
||||
build a shared lib and the current XPM distribution doesn't contain
|
||||
the jump files you would need to do so. On the other hand people have
|
||||
had no problems building it using ELF.
|
||||
<p>
|
||||
Then execute the following command:
|
||||
<pre>
|
||||
xmkmf -a
|
||||
</pre>
|
||||
<p>
|
||||
or if this option is not supported by your version of xmkmf:
|
||||
<pre>
|
||||
xmkmf
|
||||
make Makefiles
|
||||
make includes
|
||||
make depend (optional)
|
||||
</pre>
|
||||
<p>
|
||||
Then simply execute:
|
||||
<pre>
|
||||
make
|
||||
</pre>
|
||||
<p>
|
||||
which will build the XPM library and the sxpm application.
|
||||
Then do:
|
||||
<pre>
|
||||
make install
|
||||
make install.man
|
||||
</pre>
|
||||
<p>
|
||||
which will install the library and the sxpm program and man page.
|
||||
<p>
|
||||
If it fails, be sure you have set the DEFINES correctly in the top
|
||||
Imakefile to suit your machine.
|
||||
|
||||
<h4>NOTE ON USING IMAKE:</h4>
|
||||
<p>
|
||||
Building the XPM distribution with imake requires to have imake
|
||||
<strong>correctly installed and configured</strong> on your
|
||||
system. I do my best at tweaking the Imakefiles so they work with
|
||||
as many imake flavors people might have as possible but there is
|
||||
nothing I can do against wrong imake configurations. So if your
|
||||
build fails using imake, don't send me email for advice. Get your
|
||||
imake configuration fixed or forget about it!
|
||||
|
||||
|
||||
<h3><a name="sec4.2">4.2. Without imake</a></h3>
|
||||
<p>
|
||||
A set of makefiles is provided for those who do not have imake
|
||||
available on their system. However, this is only provided as a
|
||||
convenience and you should be considered as a starting point and not as
|
||||
something ready to use. These makefiles, called Makefile.noX, will most
|
||||
likely require some editing in order be set accordingly to your system.
|
||||
<p>
|
||||
Once this setting is done, you should be able to compile XPM, by
|
||||
executing the following command:
|
||||
<pre>
|
||||
make -f Makefile.noX
|
||||
</pre>
|
||||
<p>
|
||||
Then to install it, do:
|
||||
<pre>
|
||||
make -f Makefile.noX install
|
||||
</pre>
|
||||
|
||||
|
||||
<h2><a name="sec5">5. SXPM</a></h2>
|
||||
<p>
|
||||
In addition to the library the sxpm tool is provided to show XPM file and
|
||||
convert them from XPM1 or XPM2 to XPM version 3. If you have previously done
|
||||
'make' or 'make all' you should already have it, otherwise just do:
|
||||
<pre>
|
||||
cd sxpm; make
|
||||
</pre>
|
||||
<p>
|
||||
This application shows you most of the features of XPM and its source can be
|
||||
used to quickly see how to use the provided functions.
|
||||
<p>
|
||||
By executing 'sxpm -help' you will get the usage.
|
||||
<p>
|
||||
Executing 'sxpm -plaid' will show a demo of the XpmCreatePixmapFromData
|
||||
function. The pixmap is created from the static variable plaid defined in the
|
||||
sxpm.c file. sxpm will end when you press the key 'q' in the created window.
|
||||
<p>
|
||||
Executing 'sxpm -plaid -sc lines_in_mix blue' will show the feature of
|
||||
overriding color symbols giving a colorname, executing 'sxpm -plaid -sp
|
||||
lines_in_mix 1' will show overriding giving a pixel value, and executing 'sxpm
|
||||
-plaid -cp red 0' will show overriding giving a color value.
|
||||
<p>
|
||||
Then you should try 'sxpm -plaid -o output' to get an output file using the
|
||||
XpmWriteFileFromPixmap function.
|
||||
<p>
|
||||
You can now try 'sxpm -plaid -o - -nod -rgb /usr/lib/X11/rgb.txt' to directly
|
||||
get the pixmap printed out on the standard output with colornames instead of
|
||||
rgb values.
|
||||
<p>
|
||||
Then you should try 'sxpm plaid.xpm' to use the XpmReadFileToPixmap function,
|
||||
and 'cat plaid_mask.xpm|sxpm' to see how "transparent pixels" are handled.
|
||||
<p>
|
||||
The XpmCreatePixmapFromData function is on purpose called without any XpmInfos
|
||||
flag to show the utility of this one. Indeed, compare the color section of the
|
||||
two files foo and bar obtained from 'sxpm -nod -plaid -o foo' and 'sxpm -nod
|
||||
plaid.xpm -o bar'. All the default colors and also the comments have been
|
||||
restored.
|
||||
<p>
|
||||
To end look at plaid_ext.xpm and try "sxpm -nod plaid_ext.xpm -v" to see how
|
||||
extensions are handled.
|
||||
<p>
|
||||
Of course, other combinations are allowed and should be tried. Thus, 'sxpm
|
||||
plaid.xpm -o output -nod' will show you how to convert a file from XPM1 or XPM2
|
||||
to a XPM version 3 using sxpm.
|
||||
<p>
|
||||
See the manual page for more detail.
|
||||
|
||||
|
||||
<h2><a name="sec6">6. CXPM</a></h2>
|
||||
<p>
|
||||
The cxpm tool is provided to help you figure out whether an XPM file is correct
|
||||
or not with regard to its format. If you have previously done 'make' or
|
||||
'make all' you should already have it, otherwise just do:
|
||||
<pre>
|
||||
cd cxpm; make
|
||||
</pre>
|
||||
<p>
|
||||
The related man page will tell you everything about it but here is a simple
|
||||
example of what it does:
|
||||
<pre>
|
||||
$ ./cxpm bogus_pixmap
|
||||
Xpm Error: Invalid XPM file.
|
||||
Error found line 3 near character 5
|
||||
</pre>
|
||||
<p>
|
||||
It is pretty limited but at least, unlike sxpm, it gives you some hint on where
|
||||
the error occured within the file.
|
||||
|
||||
|
||||
<h2><a name="sec7">7. Other Tools</a></h2>
|
||||
<p>
|
||||
Several converters dealing with XPM and a pixmap editor can be found in the
|
||||
xpm-contrib distribution. Also I recommend the use of netpbm to do any kind of
|
||||
general image operations such as scaling, resizing, dithering, and to convert
|
||||
from and to any other image format.
|
||||
|
||||
<h2><a name="sec8">8. Discussion</a></h2>
|
||||
<p>
|
||||
There is a mailing list to discuss about XPM which is <a
|
||||
href="mailto:xpm-talk@sophia.inria.fr">xpm-talk@sophia.inria.fr</a>.
|
||||
Any request to subscribe should be sent to <a
|
||||
href="mailto:xpm-talk-request@sophia.inria.fr">xpm-talk-request@sophia.inria.fr</a>.
|
||||
The archive of the xpm-talk list is available through the web at
|
||||
<a
|
||||
href="http://zenon.inria.fr/koala/xpm-talk-hypermail">http://zenon.inria.fr/koala/xpm-talk-hypermail</a>
|
||||
and through ftp at <a
|
||||
href="ftp://koala.inria.fr/pub/xpm/xpm-talk-archive">ftp://koala.inria.fr/pub/xpm/xpm-talk-archive</a>
|
||||
<p>
|
||||
Please mail any bug reports or modifications done, comments, suggestions,
|
||||
requests for updates or patches to port on another machine to:
|
||||
|
||||
<p>Email: <a href="lehors@sophia.inria.fr">lehors@sophia.inria.fr</a>
|
||||
<br>Phone: +33 (0)4 93 65 78 89
|
||||
<br>Surface Mail:<br>
|
||||
Arnaud Le Hors<br>
|
||||
Inria BP.93<br>
|
||||
2004, Route des lucioles<br>
|
||||
06902 Sophia Antipolis Cedex<br>
|
||||
FRANCE
|
||||
|
||||
|
||||
<hr>
|
||||
<h2><a name="copy">Copyright (C) 1989-95 GROUPE BULL</a></h2>
|
||||
<p>
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to
|
||||
deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
<p>
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
<p>
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
<p>
|
||||
Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
used in advertising or otherwise to promote the sale, use or other dealings
|
||||
in this Software without prior written authorization from GROUPE BULL.
|
||||
</body>
|
@@ -1,127 +0,0 @@
|
||||
|
||||
README.MSW hedu@cul-ipn.uni-kiel.de 5/94
|
||||
|
||||
The XPM library for MS-Windows
|
||||
|
||||
Motivated by the wxWindows library, which is a (freely available) toolkit
|
||||
for developing multi-platform, graphical applications from the same body
|
||||
of C++ code, I wanted to have XPM pixmaps for MS-windows. Instead of rewriting
|
||||
a XPM-parser I managed to port the XPM-library-code to MS-windows.
|
||||
Thanks to Anaud Le Hors this became a part of the official XPM-library.
|
||||
|
||||
Until now it's only used together with wxWindows. And even there it's more
|
||||
a kind of beta. But it should be possible to run it as a simple libxpm.a
|
||||
without wxWindows.
|
||||
|
||||
The key is a transformation of some X types plus some basic X functions.
|
||||
There is not yet a special MSW-API, so you should know the X types used.
|
||||
|
||||
The following is done in simx.h:
|
||||
|
||||
typedef HDC Display;
|
||||
typedef COLORREF Pixel;
|
||||
|
||||
typedef struct {
|
||||
Pixel pixel;
|
||||
BYTE red, green, blue;
|
||||
} XColor;
|
||||
|
||||
typedef struct {
|
||||
HBITMAP bitmap;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int depth;
|
||||
} XImage;
|
||||
|
||||
With these defines and the according functions from simx.c you can call
|
||||
XPM-functions the way it's done under X windows. It can look like this:
|
||||
|
||||
ErrorStatus=XpmCreateImageFromData(&dc, data,
|
||||
&ximage,(XImage **)NULL, &xpmAttr);
|
||||
ms_bitmap = ximage->bitmap;
|
||||
// releases the malloc,but do not destroy the bitmap
|
||||
XImageFree(ximage);
|
||||
|
||||
Supported functions are the Xpm*Image* but not the Xpm*Pixmap*.
|
||||
|
||||
DRAWBACKS:
|
||||
The main drawback is the missing support for Colormaps! There was nothing for
|
||||
it in wxWindows, so I did not know how to deal with Colormaps.
|
||||
|
||||
The size of the pixmaps is bounded by malloc() (width*height*2 < 64K).
|
||||
|
||||
Close colors do not look that close. But that seems to be the window system.
|
||||
|
||||
Neither a special API for MSW nor a special MSW documentation other than this.
|
||||
(I can only point you to wxxpm as an example , see below.)
|
||||
|
||||
INSTALLATION:
|
||||
There is not yet a makefile with it. Simply take all the *.c files
|
||||
into your project except the files related to Pixmap operations: *P*.c.
|
||||
!!!You MUST set FOR_MSW on the preprocessor options!!!
|
||||
(You might uncomment NEED_STRCASECMP in xpm.h if it's in your lib)
|
||||
This should compile into libxpm.a. Good luck...
|
||||
|
||||
FTP:
|
||||
wxWindows is currently available from the Artificial Intelligence
|
||||
Applications Institute (University of Edinburgh) by anonymous FTP.
|
||||
skye.aiai.ed.ac.uk pub/wxwin/
|
||||
or read http://burray.aiai.ed.ac.uk/aiai/aiai.html
|
||||
|
||||
wxxpm, XPM support for wxWindows, the latest version is available at
|
||||
yoda.cul-ipn.uni-kiel.de pub/wxxpm/
|
||||
and maybe in the contrib or tools of wxWindows
|
||||
|
||||
Please contact me if you have suggestions, comments or problems!
|
||||
|
||||
================================================================
|
||||
Some fixes and comments by Jan Wielemaker (jan@swi.psy.uva.nl),
|
||||
Oct 24, 1996:
|
||||
|
||||
* Please try not to disturb me on this, XPM is not my
|
||||
piece of cake.
|
||||
|
||||
* Hermann Dunkel has appearently moved in virtual space.
|
||||
|
||||
Changes:
|
||||
|
||||
* I've used the xpm package under NT 4.0 and MSVC++ 4.2.
|
||||
|
||||
* I've made a big performance improvement in
|
||||
ParseAndPutPixels(), fixed creation of the mask in
|
||||
SetColor() in create.c. I looked into XCreateImage()
|
||||
in simx.c, but commented out my improvement for reasons
|
||||
you'll find there. If you know what is going on, statement
|
||||
(1) does not apply to you.
|
||||
|
||||
Comments on installation:
|
||||
|
||||
* Donot include the to/from pixmap files into the project.
|
||||
These are the ones containing a capital P somewhere in their
|
||||
name. You can also first include all, and then remove all
|
||||
the files you get errors on :-)
|
||||
|
||||
* The DC that is requested should be a valid memory DC, thus
|
||||
CreateCompatibleDC(NULL) provides a good generic one, but
|
||||
GetDC(NULL) doesn't! This costed me some time.
|
||||
|
||||
* The real difficulty is using the mask, mostly due to the
|
||||
bad documentation. If 95 or NT is your target, use:
|
||||
|
||||
MaskBlt(context.hdc, // Destination DC
|
||||
x, y, w, h, // Destination area
|
||||
mhdc, // Memory DC with the image selected
|
||||
sx, sy, // Source X,Y
|
||||
msk, // HBITMAP of the mask
|
||||
sx, sy, // Mask X,Y
|
||||
MAKEROP4(SRCPAINT, SRCCOPY)); // The magic op code.
|
||||
================================================================
|
||||
|
||||
|
||||
--
|
||||
////|\\\\ \\\\\\ Hermann Dunkel
|
||||
O O ////// IPN Uni Kiel, Germany
|
||||
| \\\\\\ Tel: +49 431 / 880 3144
|
||||
\___/ ////// E-mail: hedu@cul-ipn.uni-kiel.de
|
||||
\_/ \\\\\\ X.400 : c=de;a=d400;p=uni-kiel;ou=nw-didaktik;s=dunkel
|
||||
|
300
src/xpm/rgb.c
300
src/xpm/rgb.c
@@ -1,300 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* rgb.c: *
|
||||
* *
|
||||
* XPM library *
|
||||
* Rgb file utilities *
|
||||
* *
|
||||
* Developed by Arnaud Le Hors *
|
||||
\*****************************************************************************/
|
||||
|
||||
/*
|
||||
* The code related to FOR_MSW has been added by
|
||||
* HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
|
||||
*/
|
||||
|
||||
/*
|
||||
* Part of this code has been taken from the ppmtoxpm.c file written by Mark
|
||||
* W. Snitily but has been modified for my special need
|
||||
*/
|
||||
|
||||
#include "XpmI.h"
|
||||
#include <ctype.h>
|
||||
|
||||
#ifndef FOR_MSW /* normal part first, MSW part at
|
||||
* the end, (huge ifdef!) */
|
||||
/*
|
||||
* Read a rgb text file. It stores the rgb values (0->65535)
|
||||
* and the rgb mnemonics (malloc'ed) into the "rgbn" array. Returns the
|
||||
* number of entries stored.
|
||||
*/
|
||||
int
|
||||
xpmReadRgbNames(rgb_fname, rgbn)
|
||||
char *rgb_fname;
|
||||
xpmRgbName rgbn[];
|
||||
|
||||
{
|
||||
FILE *rgbf;
|
||||
int n, items, red, green, blue;
|
||||
char line[512], name[512], *rgbname, *s1, *s2;
|
||||
xpmRgbName *rgb;
|
||||
|
||||
/* Open the rgb text file. Abort if error. */
|
||||
if ((rgbf = fopen(rgb_fname, "r")) == NULL)
|
||||
return 0;
|
||||
|
||||
/* Loop reading each line in the file. */
|
||||
n = 0;
|
||||
rgb = rgbn;
|
||||
/* Quit if rgb text file has too many entries. */
|
||||
while (fgets(line, sizeof(line), rgbf) && n < MAX_RGBNAMES) {
|
||||
|
||||
/* Skip silently if line is bad. */
|
||||
items = sscanf(line, "%d %d %d %[^\n]\n", &red, &green, &blue, name);
|
||||
if (items != 4)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Make sure rgb values are within 0->255 range. Skip silently if
|
||||
* bad.
|
||||
*/
|
||||
if (red < 0 || red > 0xFF ||
|
||||
green < 0 || green > 0xFF ||
|
||||
blue < 0 || blue > 0xFF)
|
||||
continue;
|
||||
|
||||
/* Allocate memory for ascii name. If error give up here. */
|
||||
if (!(rgbname = (char *) XpmMalloc(strlen(name) + 1)))
|
||||
break;
|
||||
|
||||
/* Copy string to ascii name and lowercase it. */
|
||||
for (s1 = name, s2 = rgbname; *s1; s1++)
|
||||
*s2++ = tolower(*s1);
|
||||
*s2 = '\0';
|
||||
|
||||
/* Save the rgb values and ascii name in the array. */
|
||||
rgb->r = red * 257; /* 65535/255 = 257 */
|
||||
rgb->g = green * 257;
|
||||
rgb->b = blue * 257;
|
||||
rgb->name = rgbname;
|
||||
rgb++;
|
||||
n++;
|
||||
}
|
||||
|
||||
fclose(rgbf);
|
||||
|
||||
/* Return the number of read rgb names. */
|
||||
return n < 0 ? 0 : n;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the color name corresponding to the given rgb values
|
||||
*/
|
||||
char *
|
||||
xpmGetRgbName(rgbn, rgbn_max, red, green, blue)
|
||||
xpmRgbName rgbn[]; /* rgb mnemonics from rgb text file */
|
||||
int rgbn_max; /* number of rgb mnemonics in table */
|
||||
int red, green, blue; /* rgb values */
|
||||
|
||||
{
|
||||
int i;
|
||||
xpmRgbName *rgb;
|
||||
|
||||
/*
|
||||
* Just perform a dumb linear search over the rgb values of the color
|
||||
* mnemonics. One could speed things up by sorting the rgb values and
|
||||
* using a binary search, or building a hash table, etc...
|
||||
*/
|
||||
for (i = 0, rgb = rgbn; i < rgbn_max; i++, rgb++)
|
||||
if (red == rgb->r && green == rgb->g && blue == rgb->b)
|
||||
return rgb->name;
|
||||
|
||||
/* if not found return NULL */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the strings which have been malloc'ed in xpmReadRgbNames
|
||||
*/
|
||||
void
|
||||
xpmFreeRgbNames(rgbn, rgbn_max)
|
||||
xpmRgbName rgbn[];
|
||||
int rgbn_max;
|
||||
|
||||
{
|
||||
int i;
|
||||
xpmRgbName *rgb;
|
||||
|
||||
for (i = 0, rgb = rgbn; i < rgbn_max; i++, rgb++)
|
||||
XpmFree(rgb->name);
|
||||
}
|
||||
|
||||
#else /* here comes the MSW part, the
|
||||
* second part of the huge ifdef */
|
||||
|
||||
#include "rgbtab.h" /* hard coded rgb.txt table */
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int xpmReadRgbNames(char* rgb_fname, xpmRgbName rgbn[])
|
||||
#else
|
||||
int
|
||||
xpmReadRgbNames(rgb_fname, rgbn)
|
||||
char *rgb_fname;
|
||||
xpmRgbName rgbn[];
|
||||
#endif
|
||||
{
|
||||
/*
|
||||
* check for consistency???
|
||||
* table has to be sorted for calls on strcasecmp
|
||||
*/
|
||||
return (numTheRGBRecords);
|
||||
}
|
||||
|
||||
/*
|
||||
* MSW rgb values are made from 3 BYTEs, this is different from X XColor.red,
|
||||
* which has something like #0303 for one color
|
||||
*/
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
char* xpmGetRgbName(xpmRgbName rgbn[], int rgbn_max, int red, int green, int blue)
|
||||
#else
|
||||
char *
|
||||
xpmGetRgbName(rgbn, rgbn_max, red, green, blue)
|
||||
xpmRgbName rgbn[]; /* rgb mnemonics from rgb text file
|
||||
* not used */
|
||||
int rgbn_max; /* not used */
|
||||
int red, green, blue; /* rgb values */
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
unsigned long rgbVal;
|
||||
|
||||
i = 0;
|
||||
while (i < numTheRGBRecords) {
|
||||
rgbVal = theRGBRecords[i].rgb;
|
||||
if (GetRValue(rgbVal) == red &&
|
||||
GetGValue(rgbVal) == green &&
|
||||
GetBValue(rgbVal) == blue)
|
||||
return (theRGBRecords[i].name);
|
||||
i++;
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* used in XParseColor in simx.c */
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
int xpmGetRGBfromName(char* inname, int* r, int* g, int* b)
|
||||
#else
|
||||
int
|
||||
xpmGetRGBfromName(inname, r, g, b)
|
||||
char *inname;
|
||||
int *r, *g, *b;
|
||||
#endif
|
||||
{
|
||||
int left, right, middle;
|
||||
int cmp;
|
||||
unsigned long rgbVal;
|
||||
char *name;
|
||||
char *grey, *p;
|
||||
|
||||
name = xpmstrdup(inname);
|
||||
|
||||
/*
|
||||
* the table in rgbtab.c has no names with spaces, and no grey, but a
|
||||
* lot of gray
|
||||
*/
|
||||
/* so first extract ' ' */
|
||||
while (p = strchr(name, ' ')) {
|
||||
while (*(p)) { /* till eof of string */
|
||||
*p = *(p + 1); /* copy to the left */
|
||||
p++;
|
||||
}
|
||||
}
|
||||
/* fold to lower case */
|
||||
p = name;
|
||||
while (*p) {
|
||||
*p = tolower(*p);
|
||||
p++;
|
||||
}
|
||||
|
||||
/*
|
||||
* substitute Grey with Gray, else rgbtab.h would have more than 100
|
||||
* 'duplicate' entries
|
||||
*/
|
||||
if (grey = strstr(name, "grey"))
|
||||
grey[2] = 'a';
|
||||
|
||||
/* binary search */
|
||||
left = 0;
|
||||
right = numTheRGBRecords - 1;
|
||||
do {
|
||||
middle = (left + right) / 2;
|
||||
cmp = xpmstrcasecmp(name, theRGBRecords[middle].name);
|
||||
if (cmp == 0) {
|
||||
rgbVal = theRGBRecords[middle].rgb;
|
||||
*r = GetRValue(rgbVal);
|
||||
*g = GetGValue(rgbVal);
|
||||
*b = GetBValue(rgbVal);
|
||||
free(name);
|
||||
return (1);
|
||||
} else if (cmp < 0) {
|
||||
right = middle - 1;
|
||||
} else { /* > 0 */
|
||||
left = middle + 1;
|
||||
}
|
||||
} while (left <= right);
|
||||
|
||||
/*
|
||||
* I don't like to run in a ColorInvalid error and to see no pixmap at
|
||||
* all, so simply return a red pixel. Should be wrapped in an #ifdef
|
||||
* HeDu
|
||||
*/
|
||||
|
||||
*r = 255;
|
||||
*g = 0;
|
||||
*b = 0; /* red error pixel */
|
||||
|
||||
free(name);
|
||||
return (1);
|
||||
}
|
||||
|
||||
#ifdef __OS2__
|
||||
/* Visual Age cannot deal with old, non-ansi, code */
|
||||
void xpmFreeRgbNames(xpmRgbName rgbn[], int rgbn_max)
|
||||
#else
|
||||
void
|
||||
xpmFreeRgbNames(rgbn, rgbn_max)
|
||||
xpmRgbName rgbn[];
|
||||
int rgbn_max;
|
||||
#endif
|
||||
{
|
||||
/* nothing to do */
|
||||
}
|
||||
|
||||
#endif /* MSW part */
|
295
src/xpm/rgbtab.h
295
src/xpm/rgbtab.h
@@ -1,295 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* rgbtab.h *
|
||||
* *
|
||||
* A hard coded rgb.txt. To keep it short I removed all colornames with *
|
||||
* trailing numbers, Blue3 etc, except the GrayXX. Sorry Grey-lovers I prefer *
|
||||
* Gray ;-). But Grey is recognized on lookups, only on save Gray will be *
|
||||
* used, maybe you want to do some substitue there too. *
|
||||
* *
|
||||
* To save memory the RGBs are coded in one long value, as done by the RGB *
|
||||
* macro. *
|
||||
* *
|
||||
* Developed by HeDu 3/94 (hedu@cul-ipn.uni-kiel.de) *
|
||||
\*****************************************************************************/
|
||||
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
COLORREF rgb; /* it's unsigned long */
|
||||
} rgbRecord;
|
||||
|
||||
/*
|
||||
#define myRGB(r,g,b) \
|
||||
((unsigned long)r<<16|(unsigned long)g<<8|(unsigned long)b)
|
||||
*/
|
||||
#ifndef __OS2__
|
||||
#define myRGB(r,g,b) RGB(r,g,b) /* MSW has this macro */
|
||||
#else
|
||||
#define myRGB(r,g,b) OS2RGB(r,g,b)
|
||||
#endif
|
||||
|
||||
static rgbRecord theRGBRecords[] =
|
||||
{
|
||||
{"AliceBlue", myRGB(240, 248, 255)},
|
||||
{"AntiqueWhite", myRGB(250, 235, 215)},
|
||||
{"Aquamarine", myRGB(50, 191, 193)},
|
||||
{"Azure", myRGB(240, 255, 255)},
|
||||
{"Beige", myRGB(245, 245, 220)},
|
||||
{"Bisque", myRGB(255, 228, 196)},
|
||||
{"Black", myRGB(0, 0, 0)},
|
||||
{"BlanchedAlmond", myRGB(255, 235, 205)},
|
||||
{"Blue", myRGB(0, 0, 255)},
|
||||
{"BlueViolet", myRGB(138, 43, 226)},
|
||||
{"Brown", myRGB(165, 42, 42)},
|
||||
{"burlywood", myRGB(222, 184, 135)},
|
||||
{"CadetBlue", myRGB(95, 146, 158)},
|
||||
{"chartreuse", myRGB(127, 255, 0)},
|
||||
{"chocolate", myRGB(210, 105, 30)},
|
||||
{"Coral", myRGB(255, 114, 86)},
|
||||
{"CornflowerBlue", myRGB(34, 34, 152)},
|
||||
{"cornsilk", myRGB(255, 248, 220)},
|
||||
{"Cyan", myRGB(0, 255, 255)},
|
||||
{"DarkGoldenrod", myRGB(184, 134, 11)},
|
||||
{"DarkGreen", myRGB(0, 86, 45)},
|
||||
{"DarkKhaki", myRGB(189, 183, 107)},
|
||||
{"DarkOliveGreen", myRGB(85, 86, 47)},
|
||||
{"DarkOrange", myRGB(255, 140, 0)},
|
||||
{"DarkOrchid", myRGB(139, 32, 139)},
|
||||
{"DarkSalmon", myRGB(233, 150, 122)},
|
||||
{"DarkSeaGreen", myRGB(143, 188, 143)},
|
||||
{"DarkSlateBlue", myRGB(56, 75, 102)},
|
||||
{"DarkSlateGray", myRGB(47, 79, 79)},
|
||||
{"DarkTurquoise", myRGB(0, 166, 166)},
|
||||
{"DarkViolet", myRGB(148, 0, 211)},
|
||||
{"DeepPink", myRGB(255, 20, 147)},
|
||||
{"DeepSkyBlue", myRGB(0, 191, 255)},
|
||||
{"DimGray", myRGB(84, 84, 84)},
|
||||
{"DodgerBlue", myRGB(30, 144, 255)},
|
||||
{"Firebrick", myRGB(142, 35, 35)},
|
||||
{"FloralWhite", myRGB(255, 250, 240)},
|
||||
{"ForestGreen", myRGB(80, 159, 105)},
|
||||
{"gainsboro", myRGB(220, 220, 220)},
|
||||
{"GhostWhite", myRGB(248, 248, 255)},
|
||||
{"Gold", myRGB(218, 170, 0)},
|
||||
{"Goldenrod", myRGB(239, 223, 132)},
|
||||
{"Gray", myRGB(126, 126, 126)},
|
||||
{"Gray0", myRGB(0, 0, 0)},
|
||||
{"Gray1", myRGB(3, 3, 3)},
|
||||
{"Gray10", myRGB(26, 26, 26)},
|
||||
{"Gray100", myRGB(255, 255, 255)},
|
||||
{"Gray11", myRGB(28, 28, 28)},
|
||||
{"Gray12", myRGB(31, 31, 31)},
|
||||
{"Gray13", myRGB(33, 33, 33)},
|
||||
{"Gray14", myRGB(36, 36, 36)},
|
||||
{"Gray15", myRGB(38, 38, 38)},
|
||||
{"Gray16", myRGB(41, 41, 41)},
|
||||
{"Gray17", myRGB(43, 43, 43)},
|
||||
{"Gray18", myRGB(46, 46, 46)},
|
||||
{"Gray19", myRGB(48, 48, 48)},
|
||||
{"Gray2", myRGB(5, 5, 5)},
|
||||
{"Gray20", myRGB(51, 51, 51)},
|
||||
{"Gray21", myRGB(54, 54, 54)},
|
||||
{"Gray22", myRGB(56, 56, 56)},
|
||||
{"Gray23", myRGB(59, 59, 59)},
|
||||
{"Gray24", myRGB(61, 61, 61)},
|
||||
{"Gray25", myRGB(64, 64, 64)},
|
||||
{"Gray26", myRGB(66, 66, 66)},
|
||||
{"Gray27", myRGB(69, 69, 69)},
|
||||
{"Gray28", myRGB(71, 71, 71)},
|
||||
{"Gray29", myRGB(74, 74, 74)},
|
||||
{"Gray3", myRGB(8, 8, 8)},
|
||||
{"Gray30", myRGB(77, 77, 77)},
|
||||
{"Gray31", myRGB(79, 79, 79)},
|
||||
{"Gray32", myRGB(82, 82, 82)},
|
||||
{"Gray33", myRGB(84, 84, 84)},
|
||||
{"Gray34", myRGB(87, 87, 87)},
|
||||
{"Gray35", myRGB(89, 89, 89)},
|
||||
{"Gray36", myRGB(92, 92, 92)},
|
||||
{"Gray37", myRGB(94, 94, 94)},
|
||||
{"Gray38", myRGB(97, 97, 97)},
|
||||
{"Gray39", myRGB(99, 99, 99)},
|
||||
{"Gray4", myRGB(10, 10, 10)},
|
||||
{"Gray40", myRGB(102, 102, 102)},
|
||||
{"Gray41", myRGB(105, 105, 105)},
|
||||
{"Gray42", myRGB(107, 107, 107)},
|
||||
{"Gray43", myRGB(110, 110, 110)},
|
||||
{"Gray44", myRGB(112, 112, 112)},
|
||||
{"Gray45", myRGB(115, 115, 115)},
|
||||
{"Gray46", myRGB(117, 117, 117)},
|
||||
{"Gray47", myRGB(120, 120, 120)},
|
||||
{"Gray48", myRGB(122, 122, 122)},
|
||||
{"Gray49", myRGB(125, 125, 125)},
|
||||
{"Gray5", myRGB(13, 13, 13)},
|
||||
{"Gray50", myRGB(127, 127, 127)},
|
||||
{"Gray51", myRGB(130, 130, 130)},
|
||||
{"Gray52", myRGB(133, 133, 133)},
|
||||
{"Gray53", myRGB(135, 135, 135)},
|
||||
{"Gray54", myRGB(138, 138, 138)},
|
||||
{"Gray55", myRGB(140, 140, 140)},
|
||||
{"Gray56", myRGB(143, 143, 143)},
|
||||
{"Gray57", myRGB(145, 145, 145)},
|
||||
{"Gray58", myRGB(148, 148, 148)},
|
||||
{"Gray59", myRGB(150, 150, 150)},
|
||||
{"Gray6", myRGB(15, 15, 15)},
|
||||
{"Gray60", myRGB(153, 153, 153)},
|
||||
{"Gray61", myRGB(156, 156, 156)},
|
||||
{"Gray62", myRGB(158, 158, 158)},
|
||||
{"Gray63", myRGB(161, 161, 161)},
|
||||
{"Gray64", myRGB(163, 163, 163)},
|
||||
{"Gray65", myRGB(166, 166, 166)},
|
||||
{"Gray66", myRGB(168, 168, 168)},
|
||||
{"Gray67", myRGB(171, 171, 171)},
|
||||
{"Gray68", myRGB(173, 173, 173)},
|
||||
{"Gray69", myRGB(176, 176, 176)},
|
||||
{"Gray7", myRGB(18, 18, 18)},
|
||||
{"Gray70", myRGB(179, 179, 179)},
|
||||
{"Gray71", myRGB(181, 181, 181)},
|
||||
{"Gray72", myRGB(184, 184, 184)},
|
||||
{"Gray73", myRGB(186, 186, 186)},
|
||||
{"Gray74", myRGB(189, 189, 189)},
|
||||
{"Gray75", myRGB(191, 191, 191)},
|
||||
{"Gray76", myRGB(194, 194, 194)},
|
||||
{"Gray77", myRGB(196, 196, 196)},
|
||||
{"Gray78", myRGB(199, 199, 199)},
|
||||
{"Gray79", myRGB(201, 201, 201)},
|
||||
{"Gray8", myRGB(20, 20, 20)},
|
||||
{"Gray80", myRGB(204, 204, 204)},
|
||||
{"Gray81", myRGB(207, 207, 207)},
|
||||
{"Gray82", myRGB(209, 209, 209)},
|
||||
{"Gray83", myRGB(212, 212, 212)},
|
||||
{"Gray84", myRGB(214, 214, 214)},
|
||||
{"Gray85", myRGB(217, 217, 217)},
|
||||
{"Gray86", myRGB(219, 219, 219)},
|
||||
{"Gray87", myRGB(222, 222, 222)},
|
||||
{"Gray88", myRGB(224, 224, 224)},
|
||||
{"Gray89", myRGB(227, 227, 227)},
|
||||
{"Gray9", myRGB(23, 23, 23)},
|
||||
{"Gray90", myRGB(229, 229, 229)},
|
||||
{"Gray91", myRGB(232, 232, 232)},
|
||||
{"Gray92", myRGB(235, 235, 235)},
|
||||
{"Gray93", myRGB(237, 237, 237)},
|
||||
{"Gray94", myRGB(240, 240, 240)},
|
||||
{"Gray95", myRGB(242, 242, 242)},
|
||||
{"Gray96", myRGB(245, 245, 245)},
|
||||
{"Gray97", myRGB(247, 247, 247)},
|
||||
{"Gray98", myRGB(250, 250, 250)},
|
||||
{"Gray99", myRGB(252, 252, 252)},
|
||||
{"Green", myRGB(0, 255, 0)},
|
||||
{"GreenYellow", myRGB(173, 255, 47)},
|
||||
{"honeydew", myRGB(240, 255, 240)},
|
||||
{"HotPink", myRGB(255, 105, 180)},
|
||||
{"IndianRed", myRGB(107, 57, 57)},
|
||||
{"ivory", myRGB(255, 255, 240)},
|
||||
{"Khaki", myRGB(179, 179, 126)},
|
||||
{"lavender", myRGB(230, 230, 250)},
|
||||
{"LavenderBlush", myRGB(255, 240, 245)},
|
||||
{"LawnGreen", myRGB(124, 252, 0)},
|
||||
{"LemonChiffon", myRGB(255, 250, 205)},
|
||||
{"LightBlue", myRGB(176, 226, 255)},
|
||||
{"LightCoral", myRGB(240, 128, 128)},
|
||||
{"LightCyan", myRGB(224, 255, 255)},
|
||||
{"LightGoldenrod", myRGB(238, 221, 130)},
|
||||
{"LightGoldenrodYellow", myRGB(250, 250, 210)},
|
||||
{"LightGray", myRGB(168, 168, 168)},
|
||||
{"LightPink", myRGB(255, 182, 193)},
|
||||
{"LightSalmon", myRGB(255, 160, 122)},
|
||||
{"LightSeaGreen", myRGB(32, 178, 170)},
|
||||
{"LightSkyBlue", myRGB(135, 206, 250)},
|
||||
{"LightSlateBlue", myRGB(132, 112, 255)},
|
||||
{"LightSlateGray", myRGB(119, 136, 153)},
|
||||
{"LightSteelBlue", myRGB(124, 152, 211)},
|
||||
{"LightYellow", myRGB(255, 255, 224)},
|
||||
{"LimeGreen", myRGB(0, 175, 20)},
|
||||
{"linen", myRGB(250, 240, 230)},
|
||||
{"Magenta", myRGB(255, 0, 255)},
|
||||
{"Maroon", myRGB(143, 0, 82)},
|
||||
{"MediumAquamarine", myRGB(0, 147, 143)},
|
||||
{"MediumBlue", myRGB(50, 50, 204)},
|
||||
{"MediumForestGreen", myRGB(50, 129, 75)},
|
||||
{"MediumGoldenrod", myRGB(209, 193, 102)},
|
||||
{"MediumOrchid", myRGB(189, 82, 189)},
|
||||
{"MediumPurple", myRGB(147, 112, 219)},
|
||||
{"MediumSeaGreen", myRGB(52, 119, 102)},
|
||||
{"MediumSlateBlue", myRGB(106, 106, 141)},
|
||||
{"MediumSpringGreen", myRGB(35, 142, 35)},
|
||||
{"MediumTurquoise", myRGB(0, 210, 210)},
|
||||
{"MediumVioletRed", myRGB(213, 32, 121)},
|
||||
{"MidnightBlue", myRGB(47, 47, 100)},
|
||||
{"MintCream", myRGB(245, 255, 250)},
|
||||
{"MistyRose", myRGB(255, 228, 225)},
|
||||
{"moccasin", myRGB(255, 228, 181)},
|
||||
{"NavajoWhite", myRGB(255, 222, 173)},
|
||||
{"Navy", myRGB(35, 35, 117)},
|
||||
{"NavyBlue", myRGB(35, 35, 117)},
|
||||
{"OldLace", myRGB(253, 245, 230)},
|
||||
{"OliveDrab", myRGB(107, 142, 35)},
|
||||
{"Orange", myRGB(255, 135, 0)},
|
||||
{"OrangeRed", myRGB(255, 69, 0)},
|
||||
{"Orchid", myRGB(239, 132, 239)},
|
||||
{"PaleGoldenrod", myRGB(238, 232, 170)},
|
||||
{"PaleGreen", myRGB(115, 222, 120)},
|
||||
{"PaleTurquoise", myRGB(175, 238, 238)},
|
||||
{"PaleVioletRed", myRGB(219, 112, 147)},
|
||||
{"PapayaWhip", myRGB(255, 239, 213)},
|
||||
{"PeachPuff", myRGB(255, 218, 185)},
|
||||
{"peru", myRGB(205, 133, 63)},
|
||||
{"Pink", myRGB(255, 181, 197)},
|
||||
{"Plum", myRGB(197, 72, 155)},
|
||||
{"PowderBlue", myRGB(176, 224, 230)},
|
||||
{"purple", myRGB(160, 32, 240)},
|
||||
{"Red", myRGB(255, 0, 0)},
|
||||
{"RosyBrown", myRGB(188, 143, 143)},
|
||||
{"RoyalBlue", myRGB(65, 105, 225)},
|
||||
{"SaddleBrown", myRGB(139, 69, 19)},
|
||||
{"Salmon", myRGB(233, 150, 122)},
|
||||
{"SandyBrown", myRGB(244, 164, 96)},
|
||||
{"SeaGreen", myRGB(82, 149, 132)},
|
||||
{"seashell", myRGB(255, 245, 238)},
|
||||
{"Sienna", myRGB(150, 82, 45)},
|
||||
{"SkyBlue", myRGB(114, 159, 255)},
|
||||
{"SlateBlue", myRGB(126, 136, 171)},
|
||||
{"SlateGray", myRGB(112, 128, 144)},
|
||||
{"snow", myRGB(255, 250, 250)},
|
||||
{"SpringGreen", myRGB(65, 172, 65)},
|
||||
{"SteelBlue", myRGB(84, 112, 170)},
|
||||
{"Tan", myRGB(222, 184, 135)},
|
||||
{"Thistle", myRGB(216, 191, 216)},
|
||||
{"tomato", myRGB(255, 99, 71)},
|
||||
{"Transparent", myRGB(0, 0, 1)},
|
||||
{"Turquoise", myRGB(25, 204, 223)},
|
||||
{"Violet", myRGB(156, 62, 206)},
|
||||
{"VioletRed", myRGB(243, 62, 150)},
|
||||
{"Wheat", myRGB(245, 222, 179)},
|
||||
{"White", myRGB(255, 255, 255)},
|
||||
{"WhiteSmoke", myRGB(245, 245, 245)},
|
||||
{"Yellow", myRGB(255, 255, 0)},
|
||||
{"YellowGreen", myRGB(50, 216, 56)},
|
||||
NULL
|
||||
};
|
||||
|
||||
static int numTheRGBRecords = 234;
|
1111
src/xpm/scan.c
1111
src/xpm/scan.c
File diff suppressed because it is too large
Load Diff
331
src/xpm/simx.c
331
src/xpm/simx.c
@@ -1,331 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* simx.c: 0.1a *
|
||||
* *
|
||||
* This emulates some Xlib functionality for MSW. It's not a general solution, *
|
||||
* it is close related to XPM-lib. It is only intended to satisfy what is need *
|
||||
* there. Thus allowing to read XPM files under MS windows. *
|
||||
* *
|
||||
* Developed by HeDu 3/94 (hedu@cul-ipn.uni-kiel.de) *
|
||||
\*****************************************************************************/
|
||||
|
||||
/* Moved here so that FOR_MSW gets defined if we are using wxWindows (GRG) */
|
||||
#include "xpm.h"
|
||||
|
||||
#ifdef FOR_MSW
|
||||
|
||||
#include "XpmI.h" /* for XpmMalloc */
|
||||
|
||||
/*
|
||||
* On DOS size_t is only 2 bytes, thus malloc(size_t s) can only malloc
|
||||
* 64K. BUT an expression data=malloc(width*height) may result in an
|
||||
* overflow. So this function takes a long as input, and returns NULL if the
|
||||
* request is larger than 64K, is size_t is only 2 bytes.
|
||||
*
|
||||
* This requires casts like XpmMalloc( (long)width*(long(height)), else it
|
||||
* might have no effect at all.
|
||||
*/
|
||||
|
||||
void *
|
||||
boundCheckingMalloc(long s)
|
||||
{
|
||||
if (sizeof(size_t) == sizeof(long)) { /* same size, just do it */
|
||||
return (malloc((size_t) s));
|
||||
} else {
|
||||
if (sizeof(size_t) == 2) {
|
||||
if (s > 0xFFFF)
|
||||
return (NULL); /* to large, size_t with 2 bytes
|
||||
* only allows 16 bits */
|
||||
else
|
||||
return (malloc((size_t) s));
|
||||
} else { /* it's not a long, not 2 bytes,
|
||||
* what is it ??? */
|
||||
return (malloc((size_t) s));
|
||||
}
|
||||
}
|
||||
}
|
||||
void *
|
||||
boundCheckingCalloc(long num, long s)
|
||||
{
|
||||
if (sizeof(size_t) == sizeof(long)) { /* same size, just do it */
|
||||
return (calloc((size_t) num, (size_t) s));
|
||||
} else {
|
||||
if (sizeof(size_t) == 2) {
|
||||
if (s > 0xFFFF || num * s > 0xFFFF)
|
||||
return (NULL); /* to large, size_t with 2 bytes
|
||||
* only allows 16 bits */
|
||||
else
|
||||
return (calloc((size_t) num, (size_t) s));
|
||||
} else { /* it's not a long, not 2 bytes,
|
||||
* what is it ??? */
|
||||
return (calloc((size_t) num, (size_t) s));
|
||||
}
|
||||
}
|
||||
}
|
||||
void *
|
||||
boundCheckingRealloc(void *p, long s)
|
||||
{
|
||||
if (sizeof(size_t) == sizeof(long)) { /* same size, just do it */
|
||||
return (realloc(p, (size_t) s));
|
||||
} else {
|
||||
if (sizeof(size_t) == 2) {
|
||||
if (s > 0xFFFF)
|
||||
return (NULL); /* to large, size_t with 2 bytes
|
||||
* only allows 16 bits */
|
||||
else
|
||||
return (realloc(p, (size_t) s));
|
||||
} else { /* it's not a long, not 2 bytes,
|
||||
* what is it ??? */
|
||||
return (realloc(p, (size_t) s));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* static Visual theVisual = { 0 }; */
|
||||
Visual *
|
||||
XDefaultVisual(Display *display, Screen *screen)
|
||||
{
|
||||
return (NULL); /* struct could contain info about
|
||||
* MONO, GRAY, COLOR */
|
||||
}
|
||||
|
||||
Screen *
|
||||
XDefaultScreen(Display *d)
|
||||
{
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* I get only 1 plane but 8 bits per pixel,
|
||||
so I think BITSPIXEL should be depth */
|
||||
int
|
||||
XDefaultDepth(Display *display, Screen *screen)
|
||||
{
|
||||
int d, b;
|
||||
#ifdef __OS2__
|
||||
HPS hpsScreen;
|
||||
HDC hdcScreen;
|
||||
LONG lPlanes;
|
||||
LONG lBitsPerPixel;
|
||||
LONG nDepth;
|
||||
|
||||
hpsScreen = WinGetScreenPS(HWND_DESKTOP);
|
||||
hdcScreen = GpiQueryDevice(hpsScreen);
|
||||
DevQueryCaps(hdcScreen, CAPS_COLOR_PLANES, 1L, &lPlanes);
|
||||
DevQueryCaps(hdcScreen, CAPS_COLOR_BITCOUNT, 1L, &lBitsPerPixel);
|
||||
b = (int)lBitsPerPixel;
|
||||
WinReleasePS(hpsScreen);
|
||||
#else
|
||||
b = GetDeviceCaps(*display, BITSPIXEL);
|
||||
d = GetDeviceCaps(*display, PLANES);
|
||||
#endif
|
||||
return (b);
|
||||
}
|
||||
|
||||
Colormap *
|
||||
XDefaultColormap(Display *display, Screen *screen)
|
||||
{
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* convert hex color names,
|
||||
wrong digits (not a-f,A-F,0-9) are treated as zero */
|
||||
static int
|
||||
hexCharToInt(char c)
|
||||
{
|
||||
int r;
|
||||
|
||||
if (c >= '0' && c <= '9')
|
||||
r = c - '0';
|
||||
else if (c >= 'a' && c <= 'f')
|
||||
r = c - 'a' + 10;
|
||||
else if (c >= 'A' && c <= 'F')
|
||||
r = c - 'A' + 10;
|
||||
else
|
||||
r = 0;
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
static int
|
||||
rgbFromHex(char *hex, int *r, int *g, int *b)
|
||||
{
|
||||
int len;
|
||||
|
||||
if (hex == NULL || hex[0] != '#')
|
||||
return (0);
|
||||
|
||||
len = strlen(hex);
|
||||
if (len == 3 + 1) {
|
||||
*r = hexCharToInt(hex[1]);
|
||||
*g = hexCharToInt(hex[2]);
|
||||
*b = hexCharToInt(hex[3]);
|
||||
} else if (len == 6 + 1) {
|
||||
*r = hexCharToInt(hex[1]) * 16 + hexCharToInt(hex[2]);
|
||||
*g = hexCharToInt(hex[3]) * 16 + hexCharToInt(hex[4]);
|
||||
*b = hexCharToInt(hex[5]) * 16 + hexCharToInt(hex[6]);
|
||||
} else if (len == 12 + 1) {
|
||||
/* it's like c #32329999CCCC */
|
||||
/* so for now only take two digits */
|
||||
*r = hexCharToInt(hex[1]) * 16 + hexCharToInt(hex[2]);
|
||||
*g = hexCharToInt(hex[5]) * 16 + hexCharToInt(hex[6]);
|
||||
*b = hexCharToInt(hex[9]) * 16 + hexCharToInt(hex[10]);
|
||||
} else
|
||||
return (0);
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Color related functions */
|
||||
int
|
||||
XParseColor(Display *d, Colormap *cmap, char *name, XColor *color)
|
||||
{
|
||||
int r, g, b; /* only 8 bit values used */
|
||||
int okay;
|
||||
|
||||
/* TODO: use colormap via PALETTE */
|
||||
/* parse name either in table or #RRGGBB #RGB */
|
||||
if (name == NULL)
|
||||
return (0);
|
||||
|
||||
if (name[0] == '#') { /* a hex string */
|
||||
okay = rgbFromHex(name, &r, &g, &b);
|
||||
} else {
|
||||
okay = xpmGetRGBfromName(name, &r, &g, &b);
|
||||
}
|
||||
|
||||
if (okay) {
|
||||
#ifdef __OS2__
|
||||
color->pixel = OS2RGB(r, g, b);
|
||||
#else
|
||||
color->pixel = RGB(r, g, b);
|
||||
#endif
|
||||
color->red = (BYTE) r;
|
||||
color->green = (BYTE) g;
|
||||
color->blue = (BYTE) b;
|
||||
return (1);
|
||||
} else
|
||||
return (0); /* --> ColorError */
|
||||
}
|
||||
|
||||
|
||||
/* GRG: 2nd arg is Colormap*, not Colormap */
|
||||
|
||||
int
|
||||
XAllocColor(Display *d, Colormap *cmap, XColor *color)
|
||||
{
|
||||
/* colormap not used yet so color->pixel is the real COLORREF (RBG) and not an
|
||||
index in some colormap as in X */
|
||||
return (1);
|
||||
}
|
||||
void
|
||||
XQueryColors(Display *display, Colormap *colormap,
|
||||
XColor *xcolors, int ncolors)
|
||||
{
|
||||
/* under X this fills the rgb values to given .pixel */
|
||||
/* since there no colormap use FOR_MSW (not yet!!), rgb is plain encoded */
|
||||
XColor *xc = xcolors;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ncolors; i++, xc++) {
|
||||
xc->red = GetRValue(xc->pixel);
|
||||
xc->green = GetGValue(xc->pixel);
|
||||
xc->blue = GetBValue(xc->pixel);
|
||||
}
|
||||
return;
|
||||
}
|
||||
int
|
||||
XFreeColors(Display *d, Colormap cmap,
|
||||
unsigned long pixels[], int npixels, unsigned long planes)
|
||||
{
|
||||
/* no colormap yet */
|
||||
return (0); /* correct ??? */
|
||||
}
|
||||
|
||||
/* XImage functions */
|
||||
XImage *
|
||||
XCreateImage(Display *d, Visual *v,
|
||||
int depth, int format,
|
||||
int x, int y, int width, int height,
|
||||
int pad, int foo)
|
||||
{
|
||||
XImage *img = (XImage *) XpmMalloc(sizeof(XImage));
|
||||
#ifdef __OS2__
|
||||
BITMAPINFOHEADER2 bmih;
|
||||
|
||||
memset(&bmih, 0, sizeof(BITMAPINFOHEADER2));
|
||||
bmih.cbFix = sizeof(BITMAPINFOHEADER2);
|
||||
bmih.cx = width;
|
||||
bmih.cy = height;
|
||||
bmih.cPlanes = 1;
|
||||
bmih.cBitCount = depth;
|
||||
#endif
|
||||
|
||||
if (img) {
|
||||
/*JW: This is what it should be, but the picture comes out
|
||||
just black!? It appears to be doing monochrome reduction,
|
||||
but I've got no clue why. Using CreateBitmap() is supposed
|
||||
to be slower, but otherwise ok
|
||||
if ( depth == GetDeviceCaps(*d, BITSPIXEL) ) {
|
||||
img->bitmap = CreateCompatibleBitmap(*d, width, height);
|
||||
} else*/ {
|
||||
#ifdef __OS2__
|
||||
img->bitmap = GpiCreateBitmap(*d, &bmih, 0L, NULL, NULL);
|
||||
WinReleasePS(*d);
|
||||
#else
|
||||
img->bitmap = CreateBitmap(width, height, 1 /* plane */ ,
|
||||
depth /* bits per pixel */ , NULL);
|
||||
#endif
|
||||
}
|
||||
img->width = width;
|
||||
img->height = height;
|
||||
img->depth = depth;
|
||||
}
|
||||
return (img);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
XImageFree(XImage *img)
|
||||
{
|
||||
if (img) {
|
||||
XpmFree(img);
|
||||
}
|
||||
}
|
||||
void
|
||||
XDestroyImage(XImage *img)
|
||||
{
|
||||
if (img) {
|
||||
#ifdef __OS2__
|
||||
GpiDeleteBitmap(img->bitmap);
|
||||
#else
|
||||
DeleteObject(img->bitmap); /* check return ??? */
|
||||
#endif
|
||||
XImageFree(img);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
170
src/xpm/simx.h
170
src/xpm/simx.h
@@ -1,170 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* simx.h: 0.1a *
|
||||
* *
|
||||
* This emulates some Xlib functionality for MSW. It's not a general solution, *
|
||||
* it is close related to XPM-lib. It is only intended to satisfy what is need *
|
||||
* there. Thus allowing to read XPM files under MS windows. *
|
||||
* *
|
||||
* Developed by HeDu 3/94 (hedu@cul-ipn.uni-kiel.de) *
|
||||
\*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef _SIMX_H
|
||||
#define _SIMX_H
|
||||
|
||||
#ifdef FOR_MSW
|
||||
|
||||
#if !defined(__OS2__)
|
||||
#include "windows.h" /* MS windows GDI types */
|
||||
#else
|
||||
#define INCL_PM
|
||||
#define INCL_GPI
|
||||
#define INCL_DEV
|
||||
#include<os2.h>
|
||||
typedef unsigned long COLORREF;
|
||||
/*
|
||||
// RGB under OS2 is more like a PALETTEENTRY struct under Windows so we need a real RGB def
|
||||
// #define OS2RGB(r,g,b) ((ULONG ((BYTE) (r) | ((UINT) (g) << 8)) | (((ULONG)(BYTE)(b)) << 16)))
|
||||
*/
|
||||
#ifndef OS2RGB
|
||||
# define OS2RGB(r,g,b) ((unsigned long)r<<16|(unsigned long)g<<8|(unsigned long)b)
|
||||
#endif
|
||||
|
||||
#ifndef GetBValue
|
||||
# define GetBValue(rgb) ((BYTE)((rgb) >> 16))
|
||||
#endif
|
||||
#ifndef GetGValue
|
||||
# define GetGValue(rgb) ((BYTE)(((UINT)(rgb)) >> 8))
|
||||
#endif
|
||||
#ifndef GetRValue
|
||||
# define GetRValue(rgb) ((BYTE)(rgb))
|
||||
#endif
|
||||
#endif /* else __OS2__ */
|
||||
|
||||
|
||||
/*
|
||||
* minimal portability layer between ansi and KR C
|
||||
*/
|
||||
/* this comes from xpm.h, and is here again, to avoid complicated
|
||||
includes, since this is included from xpm.h */
|
||||
/* these defines get undefed at the end of this file */
|
||||
#if __STDC__ || defined(__cplusplus) || defined(c_plusplus)
|
||||
/* ANSI || C++ */
|
||||
# define FUNC(f, t, p) extern t f p
|
||||
# define LFUNC(f, t, p) static t f p
|
||||
#else /* k&R */
|
||||
# define FUNC(f, t, p) extern t f()
|
||||
# define LFUNC(f, t, p) static t f()
|
||||
#endif
|
||||
|
||||
|
||||
FUNC(boundCheckingMalloc, void *, (long s));
|
||||
FUNC(boundCheckingCalloc, void *, (long num, long s));
|
||||
FUNC(boundCheckingRealloc, void *, (void *p, long s));
|
||||
|
||||
/* define MSW types for X window types,
|
||||
I don't know much about MSW, but the following defines do the job */
|
||||
|
||||
#if !defined(__OS2__)
|
||||
typedef HDC Display; /* this should be similar */
|
||||
#else
|
||||
typedef HPS Display;
|
||||
#endif
|
||||
|
||||
typedef void *Screen; /* not used */
|
||||
typedef void *Visual; /* not used yet, is for GRAY, COLOR,
|
||||
* MONO */
|
||||
|
||||
typedef void *Colormap; /* should be COLORPALETTE, not done
|
||||
* yet */
|
||||
|
||||
typedef COLORREF Pixel;
|
||||
|
||||
#define PIXEL_ALREADY_TYPEDEFED /* to let xpm.h know about it */
|
||||
|
||||
typedef struct {
|
||||
Pixel pixel;
|
||||
BYTE red, green, blue;
|
||||
} XColor;
|
||||
|
||||
typedef struct {
|
||||
HBITMAP bitmap;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int depth;
|
||||
} XImage;
|
||||
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
/* some replacements for X... functions */
|
||||
|
||||
/* XDefaultXXX */
|
||||
FUNC(XDefaultVisual, Visual *, (Display *display, Screen *screen));
|
||||
FUNC(XDefaultScreen, Screen *, (Display *d));
|
||||
FUNC(XDefaultColormap, Colormap *, (Display *display, Screen *screen));
|
||||
FUNC(XDefaultDepth, int, (Display *d, Screen *s));
|
||||
|
||||
/* color related */
|
||||
FUNC(XParseColor, int, (Display *, Colormap *, char *, XColor *));
|
||||
FUNC(XAllocColor, int, (Display *, Colormap *, XColor *));
|
||||
FUNC(XQueryColors, void, (Display *display, Colormap *colormap,
|
||||
XColor *xcolors, int ncolors));
|
||||
FUNC(XFreeColors, int, (Display *d, Colormap cmap,
|
||||
unsigned long pixels[],
|
||||
int npixels, unsigned long planes));
|
||||
/* XImage */
|
||||
FUNC(XCreateImage, XImage *, (Display *, Visual *, int depth, int format,
|
||||
int x, int y, int width, int height,
|
||||
int pad, int foo));
|
||||
|
||||
/* free and destroy bitmap */
|
||||
FUNC(XDestroyImage, void /* ? */ , (XImage *));
|
||||
/* free only, bitmap remains */
|
||||
FUNC(XImageFree, void, (XImage *));
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
} /* end of extern "C" */
|
||||
#endif /* cplusplus */
|
||||
|
||||
#define ZPixmap 1 /* not really used */
|
||||
#define XYBitmap 1 /* not really used */
|
||||
|
||||
#ifndef True
|
||||
#define True 1
|
||||
#define False 0
|
||||
#endif
|
||||
#ifndef Bool
|
||||
typedef BOOL Bool; /* take MSW bool */
|
||||
#endif
|
||||
/* make these local here, simx.c gets the same from xpm.h */
|
||||
#undef LFUNC
|
||||
#undef FUNC
|
||||
|
||||
#endif /* def FOR_MSW */
|
||||
|
||||
#endif /* _SIMX_H */
|
512
src/xpm/xpm.h
512
src/xpm/xpm.h
@@ -1,512 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 1989-95 GROUPE BULL
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||
* in this Software without prior written authorization from GROUPE BULL.
|
||||
*/
|
||||
|
||||
/*****************************************************************************\
|
||||
* xpm.h: *
|
||||
* *
|
||||
* XPM library *
|
||||
* Include file *
|
||||
* *
|
||||
* Developed by Arnaud Le Hors *
|
||||
\*****************************************************************************/
|
||||
|
||||
/*
|
||||
* The code related to FOR_MSW has been added by
|
||||
* HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
|
||||
*/
|
||||
|
||||
/*
|
||||
* The code related to AMIGA has been added by
|
||||
* Lorens Younes (d93-hyo@nada.kth.se) 4/96
|
||||
*/
|
||||
|
||||
#ifndef XPM_h
|
||||
#define XPM_h
|
||||
|
||||
#if (defined(_WINDOWS) || defined(__WXMSW__) || defined(WIN32)) && !defined(FOR_MSW)
|
||||
#define FOR_MSW
|
||||
#endif
|
||||
/* Piggyback on MSW for now */
|
||||
#if (defined(__OS2__) || defined(__WXPM__) || defined(OS232)) && !defined(FOR_MSW)
|
||||
#define FOR_MSW
|
||||
#endif
|
||||
|
||||
/*
|
||||
* first some identification numbers:
|
||||
* the version and revision numbers are determined with the following rule:
|
||||
* SO Major number = LIB minor version number.
|
||||
* SO Minor number = LIB sub-minor version number.
|
||||
* e.g: Xpm version 3.2f
|
||||
* we forget the 3 which is the format number, 2 gives 2, and f gives 6.
|
||||
* thus we have XpmVersion = 2 and XpmRevision = 6
|
||||
* which gives SOXPMLIBREV = 2.6
|
||||
*
|
||||
* Then the XpmIncludeVersion number is built from these numbers.
|
||||
*/
|
||||
#define XpmFormat 3
|
||||
#define XpmVersion 4
|
||||
#define XpmRevision 11
|
||||
#define XpmIncludeVersion ((XpmFormat * 100 + XpmVersion) * 100 + XpmRevision)
|
||||
|
||||
#ifndef XPM_NUMBERS
|
||||
|
||||
#ifdef FOR_MSW
|
||||
# define SYSV /* uses memcpy string.h etc. */
|
||||
# include <malloc.h>
|
||||
# include "simx.h" /* defines some X stuff using MSW types */
|
||||
#define NEED_STRCASECMP /* at least for MSVC++ */
|
||||
#else /* FOR_MSW */
|
||||
# ifdef AMIGA
|
||||
# include "amigax.h"
|
||||
# else /* not AMIGA */
|
||||
# include <X11/Xlib.h>
|
||||
# include <X11/Xutil.h>
|
||||
# endif /* not AMIGA */
|
||||
#endif /* FOR_MSW */
|
||||
|
||||
/* let's define Pixel if it is not done yet */
|
||||
#if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
|
||||
typedef unsigned long Pixel; /* Index into colormap */
|
||||
# define PIXEL_ALREADY_TYPEDEFED
|
||||
#endif
|
||||
|
||||
/* make sure we know whether function prototypes are needed or not */
|
||||
#ifndef NeedFunctionPrototypes
|
||||
# if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
|
||||
# define NeedFunctionPrototypes 1
|
||||
# else
|
||||
# define NeedFunctionPrototypes 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* DW: bug in makefile seems to not want to define these, but they are needed! */
|
||||
/* Guillermo, maybe you can look at it */
|
||||
#ifdef FOR_MSW
|
||||
# define FUNC(f, t, p) extern t f p
|
||||
# define LFUNC(f, t, p) static t f p
|
||||
#endif
|
||||
|
||||
/* Return ErrorStatus codes:
|
||||
* null if full success
|
||||
* positive if partial success
|
||||
* negative if failure
|
||||
*/
|
||||
|
||||
#define XpmColorError 1
|
||||
#define XpmSuccess 0
|
||||
#define XpmOpenFailed -1
|
||||
#define XpmFileInvalid -2
|
||||
#define XpmNoMemory -3
|
||||
#define XpmColorFailed -4
|
||||
|
||||
typedef struct {
|
||||
char *name; /* Symbolic color name */
|
||||
char *value; /* Color value */
|
||||
Pixel pixel; /* Color pixel */
|
||||
} XpmColorSymbol;
|
||||
|
||||
typedef struct {
|
||||
char *name; /* name of the extension */
|
||||
unsigned int nlines; /* number of lines in this extension */
|
||||
char **lines; /* pointer to the extension array of strings */
|
||||
} XpmExtension;
|
||||
|
||||
typedef struct {
|
||||
char *string; /* characters string */
|
||||
char *symbolic; /* symbolic name */
|
||||
char *m_color; /* monochrom default */
|
||||
char *g4_color; /* 4 level grayscale default */
|
||||
char *g_color; /* other level grayscale default */
|
||||
char *c_color; /* color default */
|
||||
} XpmColor;
|
||||
|
||||
typedef struct {
|
||||
unsigned int width; /* image width */
|
||||
unsigned int height; /* image height */
|
||||
unsigned int cpp; /* number of characters per pixel */
|
||||
unsigned int ncolors; /* number of colors */
|
||||
XpmColor *colorTable; /* list of related colors */
|
||||
unsigned int *data; /* image data */
|
||||
} XpmImage;
|
||||
|
||||
typedef struct {
|
||||
unsigned long valuemask; /* Specifies which attributes are defined */
|
||||
char *hints_cmt; /* Comment of the hints section */
|
||||
char *colors_cmt; /* Comment of the colors section */
|
||||
char *pixels_cmt; /* Comment of the pixels section */
|
||||
unsigned int x_hotspot; /* Returns the x hotspot's coordinate */
|
||||
unsigned int y_hotspot; /* Returns the y hotspot's coordinate */
|
||||
unsigned int nextensions; /* number of extensions */
|
||||
XpmExtension *extensions; /* pointer to array of extensions */
|
||||
} XpmInfo;
|
||||
|
||||
typedef int (*XpmAllocColorFunc)(
|
||||
#if NeedFunctionPrototypes
|
||||
Display* /* display */,
|
||||
Colormap /* colormap */,
|
||||
char* /* colorname */,
|
||||
XColor* /* xcolor */,
|
||||
void* /* closure */
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef int (*XpmFreeColorsFunc)(
|
||||
#if NeedFunctionPrototypes
|
||||
Display* /* display */,
|
||||
Colormap /* colormap */,
|
||||
Pixel* /* pixels */,
|
||||
int /* npixels */,
|
||||
void* /* closure */
|
||||
#endif
|
||||
);
|
||||
|
||||
typedef struct {
|
||||
unsigned long valuemask; /* Specifies which attributes are
|
||||
defined */
|
||||
|
||||
Visual *visual; /* Specifies the visual to use */
|
||||
Colormap colormap; /* Specifies the colormap to use */
|
||||
unsigned int depth; /* Specifies the depth */
|
||||
unsigned int width; /* Returns the width of the created
|
||||
pixmap */
|
||||
unsigned int height; /* Returns the height of the created
|
||||
pixmap */
|
||||
unsigned int x_hotspot; /* Returns the x hotspot's
|
||||
coordinate */
|
||||
unsigned int y_hotspot; /* Returns the y hotspot's
|
||||
coordinate */
|
||||
unsigned int cpp; /* Specifies the number of char per
|
||||
pixel */
|
||||
Pixel *pixels; /* List of used color pixels */
|
||||
unsigned int npixels; /* Number of used pixels */
|
||||
XpmColorSymbol *colorsymbols; /* List of color symbols to override */
|
||||
unsigned int numsymbols; /* Number of symbols */
|
||||
char *rgb_fname; /* RGB text file name */
|
||||
unsigned int nextensions; /* Number of extensions */
|
||||
XpmExtension *extensions; /* List of extensions */
|
||||
|
||||
unsigned int ncolors; /* Number of colors */
|
||||
XpmColor *colorTable; /* List of colors */
|
||||
/* 3.2 backward compatibility code */
|
||||
char *hints_cmt; /* Comment of the hints section */
|
||||
char *colors_cmt; /* Comment of the colors section */
|
||||
char *pixels_cmt; /* Comment of the pixels section */
|
||||
/* end 3.2 bc */
|
||||
unsigned int mask_pixel; /* Color table index of transparent
|
||||
color */
|
||||
|
||||
/* Color Allocation Directives */
|
||||
Bool exactColors; /* Only use exact colors for visual */
|
||||
unsigned int closeness; /* Allowable RGB deviation */
|
||||
unsigned int red_closeness; /* Allowable red deviation */
|
||||
unsigned int green_closeness; /* Allowable green deviation */
|
||||
unsigned int blue_closeness; /* Allowable blue deviation */
|
||||
int color_key; /* Use colors from this color set */
|
||||
|
||||
Pixel *alloc_pixels; /* Returns the list of alloc'ed color
|
||||
pixels */
|
||||
int nalloc_pixels; /* Returns the number of alloc'ed
|
||||
color pixels */
|
||||
|
||||
Bool alloc_close_colors; /* Specify whether close colors should
|
||||
be allocated using XAllocColor
|
||||
or not */
|
||||
int bitmap_format; /* Specify the format of 1bit depth
|
||||
images: ZPixmap or XYBitmap */
|
||||
|
||||
/* Color functions */
|
||||
XpmAllocColorFunc alloc_color; /* Application color allocator */
|
||||
XpmFreeColorsFunc free_colors; /* Application color de-allocator */
|
||||
void *color_closure; /* Application private data to pass to
|
||||
alloc_color and free_colors */
|
||||
|
||||
} XpmAttributes;
|
||||
|
||||
/* XpmAttributes value masks bits */
|
||||
#define XpmVisual (1L<<0)
|
||||
#define XpmColormap (1L<<1)
|
||||
#define XpmDepth (1L<<2)
|
||||
#define XpmSize (1L<<3) /* width & height */
|
||||
#define XpmHotspot (1L<<4) /* x_hotspot & y_hotspot */
|
||||
#define XpmCharsPerPixel (1L<<5)
|
||||
#define XpmColorSymbols (1L<<6)
|
||||
#define XpmRgbFilename (1L<<7)
|
||||
/* 3.2 backward compatibility code */
|
||||
#define XpmInfos (1L<<8)
|
||||
#define XpmReturnInfos XpmInfos
|
||||
/* end 3.2 bc */
|
||||
#define XpmReturnPixels (1L<<9)
|
||||
#define XpmExtensions (1L<<10)
|
||||
#define XpmReturnExtensions XpmExtensions
|
||||
|
||||
#define XpmExactColors (1L<<11)
|
||||
#define XpmCloseness (1L<<12)
|
||||
#define XpmRGBCloseness (1L<<13)
|
||||
#define XpmColorKey (1L<<14)
|
||||
|
||||
#define XpmColorTable (1L<<15)
|
||||
#define XpmReturnColorTable XpmColorTable
|
||||
|
||||
#define XpmReturnAllocPixels (1L<<16)
|
||||
#define XpmAllocCloseColors (1L<<17)
|
||||
#define XpmBitmapFormat (1L<<18)
|
||||
|
||||
#define XpmAllocColor (1L<<19)
|
||||
#define XpmFreeColors (1L<<20)
|
||||
#define XpmColorClosure (1L<<21)
|
||||
|
||||
|
||||
/* XpmInfo value masks bits */
|
||||
#define XpmComments XpmInfos
|
||||
#define XpmReturnComments XpmComments
|
||||
|
||||
/* XpmAttributes mask_pixel value when there is no mask */
|
||||
#ifndef FOR_MSW
|
||||
#define XpmUndefPixel 0x80000000
|
||||
#else
|
||||
/* int is only 16 bit for MSW */
|
||||
#define XpmUndefPixel 0x8000
|
||||
#endif
|
||||
|
||||
/*
|
||||
* color keys for visual type, they must fit along with the number key of
|
||||
* each related element in xpmColorKeys[] defined in XpmI.h
|
||||
*/
|
||||
#define XPM_MONO 2
|
||||
#define XPM_GREY4 3
|
||||
#define XPM_GRAY4 3
|
||||
#define XPM_GREY 4
|
||||
#define XPM_GRAY 4
|
||||
#define XPM_COLOR 5
|
||||
|
||||
|
||||
/* macros for forward declarations of functions with prototypes */
|
||||
#if NeedFunctionPrototypes
|
||||
# define FUNC(f, t, p) extern t f p
|
||||
# define LFUNC(f, t, p) static t f p
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* functions declarations
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */
|
||||
/* Same for Amiga! */
|
||||
|
||||
#if !defined(FOR_MSW) && !defined(AMIGA)
|
||||
FUNC(XpmCreatePixmapFromData, int, (Display *display,
|
||||
Drawable d,
|
||||
char **data,
|
||||
Pixmap *pixmap_return,
|
||||
Pixmap *shapemask_return,
|
||||
XpmAttributes *attributes));
|
||||
|
||||
FUNC(XpmCreateDataFromPixmap, int, (Display *display,
|
||||
char ***data_return,
|
||||
Pixmap pixmap,
|
||||
Pixmap shapemask,
|
||||
XpmAttributes *attributes));
|
||||
|
||||
FUNC(XpmReadFileToPixmap, int, (Display *display,
|
||||
Drawable d,
|
||||
char *filename,
|
||||
Pixmap *pixmap_return,
|
||||
Pixmap *shapemask_return,
|
||||
XpmAttributes *attributes));
|
||||
|
||||
FUNC(XpmWriteFileFromPixmap, int, (Display *display,
|
||||
char *filename,
|
||||
Pixmap pixmap,
|
||||
Pixmap shapemask,
|
||||
XpmAttributes *attributes));
|
||||
#endif
|
||||
|
||||
FUNC(XpmCreateImageFromData, int, (Display *display,
|
||||
char **data,
|
||||
XImage **image_return,
|
||||
XImage **shapemask_return,
|
||||
XpmAttributes *attributes));
|
||||
|
||||
FUNC(XpmCreateDataFromImage, int, (Display *display,
|
||||
char ***data_return,
|
||||
XImage *image,
|
||||
XImage *shapeimage,
|
||||
XpmAttributes *attributes));
|
||||
|
||||
FUNC(XpmReadFileToImage, int, (Display *display,
|
||||
char *filename,
|
||||
XImage **image_return,
|
||||
XImage **shapeimage_return,
|
||||
XpmAttributes *attributes));
|
||||
|
||||
FUNC(XpmWriteFileFromImage, int, (Display *display,
|
||||
char *filename,
|
||||
XImage *image,
|
||||
XImage *shapeimage,
|
||||
XpmAttributes *attributes));
|
||||
|
||||
FUNC(XpmCreateImageFromBuffer, int, (Display *display,
|
||||
char *buffer,
|
||||
XImage **image_return,
|
||||
XImage **shapemask_return,
|
||||
XpmAttributes *attributes));
|
||||
#if !defined(FOR_MSW) && !defined(AMIGA)
|
||||
FUNC(XpmCreatePixmapFromBuffer, int, (Display *display,
|
||||
Drawable d,
|
||||
char *buffer,
|
||||
Pixmap *pixmap_return,
|
||||
Pixmap *shapemask_return,
|
||||
XpmAttributes *attributes));
|
||||
|
||||
FUNC(XpmCreateBufferFromImage, int, (Display *display,
|
||||
char **buffer_return,
|
||||
XImage *image,
|
||||
XImage *shapeimage,
|
||||
XpmAttributes *attributes));
|
||||
|
||||
FUNC(XpmCreateBufferFromPixmap, int, (Display *display,
|
||||
char **buffer_return,
|
||||
Pixmap pixmap,
|
||||
Pixmap shapemask,
|
||||
XpmAttributes *attributes));
|
||||
#endif
|
||||
FUNC(XpmReadFileToBuffer, int, (char *filename, char **buffer_return));
|
||||
FUNC(XpmWriteFileFromBuffer, int, (char *filename, char *buffer));
|
||||
|
||||
FUNC(XpmReadFileToData, int, (char *filename, char ***data_return));
|
||||
FUNC(XpmWriteFileFromData, int, (char *filename, char **data));
|
||||
|
||||
FUNC(XpmAttributesSize, int, ());
|
||||
FUNC(XpmFreeAttributes, void, (XpmAttributes *attributes));
|
||||
FUNC(XpmFreeExtensions, void, (XpmExtension *extensions,
|
||||
int nextensions));
|
||||
|
||||
FUNC(XpmFreeXpmImage, void, (XpmImage *image));
|
||||
FUNC(XpmFreeXpmInfo, void, (XpmInfo *info));
|
||||
FUNC(XpmGetErrorString, char *, (int errcode));
|
||||
FUNC(XpmLibraryVersion, int, ());
|
||||
|
||||
/* XpmImage functions */
|
||||
FUNC(XpmReadFileToXpmImage, int, (char *filename,
|
||||
XpmImage *image,
|
||||
XpmInfo *info));
|
||||
|
||||
FUNC(XpmWriteFileFromXpmImage, int, (char *filename,
|
||||
XpmImage *image,
|
||||
XpmInfo *info));
|
||||
#if !defined(FOR_MSW) && !defined(AMIGA)
|
||||
FUNC(XpmCreatePixmapFromXpmImage, int, (Display *display,
|
||||
Drawable d,
|
||||
XpmImage *image,
|
||||
Pixmap *pixmap_return,
|
||||
Pixmap *shapemask_return,
|
||||
XpmAttributes *attributes));
|
||||
#endif
|
||||
FUNC(XpmCreateImageFromXpmImage, int, (Display *display,
|
||||
XpmImage *image,
|
||||
XImage **image_return,
|
||||
XImage **shapeimage_return,
|
||||
XpmAttributes *attributes));
|
||||
|
||||
FUNC(XpmCreateXpmImageFromImage, int, (Display *display,
|
||||
XImage *image,
|
||||
XImage *shapeimage,
|
||||
XpmImage *xpmimage,
|
||||
XpmAttributes *attributes));
|
||||
#if !defined(FOR_MSW) && !defined(AMIGA)
|
||||
FUNC(XpmCreateXpmImageFromPixmap, int, (Display *display,
|
||||
Pixmap pixmap,
|
||||
Pixmap shapemask,
|
||||
XpmImage *xpmimage,
|
||||
XpmAttributes *attributes));
|
||||
#endif
|
||||
FUNC(XpmCreateDataFromXpmImage, int, (char ***data_return,
|
||||
XpmImage *image,
|
||||
XpmInfo *info));
|
||||
|
||||
FUNC(XpmCreateXpmImageFromData, int, (char **data,
|
||||
XpmImage *image,
|
||||
XpmInfo *info));
|
||||
|
||||
FUNC(XpmCreateXpmImageFromBuffer, int, (char *buffer,
|
||||
XpmImage *image,
|
||||
XpmInfo *info));
|
||||
|
||||
FUNC(XpmCreateBufferFromXpmImage, int, (char **buffer_return,
|
||||
XpmImage *image,
|
||||
XpmInfo *info));
|
||||
|
||||
FUNC(XpmGetParseError, int, (char *filename,
|
||||
int *linenum_return,
|
||||
int *charnum_return));
|
||||
|
||||
FUNC(XpmFree, void, (void *ptr));
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* for C++ V2.0 */
|
||||
#endif
|
||||
|
||||
|
||||
/* backward compatibility */
|
||||
|
||||
/* for version 3.0c */
|
||||
#define XpmPixmapColorError XpmColorError
|
||||
#define XpmPixmapSuccess XpmSuccess
|
||||
#define XpmPixmapOpenFailed XpmOpenFailed
|
||||
#define XpmPixmapFileInvalid XpmFileInvalid
|
||||
#define XpmPixmapNoMemory XpmNoMemory
|
||||
#define XpmPixmapColorFailed XpmColorFailed
|
||||
|
||||
#define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
|
||||
XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
|
||||
#define XpmWritePixmapFile(dpy, file, pix, mask, att) \
|
||||
XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
|
||||
|
||||
/* for version 3.0b */
|
||||
#define PixmapColorError XpmColorError
|
||||
#define PixmapSuccess XpmSuccess
|
||||
#define PixmapOpenFailed XpmOpenFailed
|
||||
#define PixmapFileInvalid XpmFileInvalid
|
||||
#define PixmapNoMemory XpmNoMemory
|
||||
#define PixmapColorFailed XpmColorFailed
|
||||
|
||||
#define ColorSymbol XpmColorSymbol
|
||||
|
||||
#define XReadPixmapFile(dpy, d, file, pix, mask, att) \
|
||||
XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
|
||||
#define XWritePixmapFile(dpy, file, pix, mask, att) \
|
||||
XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
|
||||
#define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
|
||||
XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
|
||||
#define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
|
||||
XpmCreateDataFromPixmap(dpy, data, pix, mask, att)
|
||||
|
||||
#endif /* XPM_NUMBERS */
|
||||
#endif
|
Reference in New Issue
Block a user