Commit 1d71c9eb authored by Mike Gabriel's avatar Mike Gabriel

library clean-up: Don't build libNX_Xpm anymore. Use system's libXpm shared library.

parent 46318a51
......@@ -17,12 +17,12 @@ Build-Depends:
libfreetype6-dev,
libxmltok1-dev,
libxml2-dev,
libxpm-dev,
autoconf,
pkg-config,
x11proto-core-dev,
expat,
Build-Conflicts:
x11proto-kb-dev,
x11proto-randr-dev,
x11proto-record-dev,
x11proto-xinerama-dev,
......@@ -683,18 +683,16 @@ Multi-Arch: same
Pre-Depends:
${misc:Pre-Depends},
Depends:
${shlibs:Depends},
${misc:Depends},
Breaks: nxlibs (<= 3.5.1),
libnx-x11 (<< 2:3.5.0.29-0x2go2~),
Description: nx-X11 pixmap library
Description: nx-X11 pixmap library (dummy package)
NX is a software suite which implements very efficient
compression of the X11 protocol. This increases performance when
using X applications over a network, especially a slow one.
.
libNX_Xpm provides support and common operation for the XPM pixmap
format, which is commonly used in legacy X applications. XPM is an
extension of the monochrome XBM bitmap specified in the X protocol.
This package removes the obsoleted libNX_Xpm.so.4 library. With
recent versions of NX, the system-wide installed libXpm gets used.
.
This package can be safely removed.
Package: libnx-xpm-dev
Provides: libnx-xpm4-dev
......@@ -702,20 +700,17 @@ Section: libdevel
Architecture: any
Multi-Arch: same
Depends:
libnx-xpm4 (= ${binary:Version}),
${misc:Depends},
Breaks: nxlibs (<= 3.5.1),
libnx-x11-dev (<< 2:3.5.0.29-0x2go2~),
Description: nx-X11 pixmap library (development headers)
Description: nx-X11 pixmap library (development headers, dummy package)
NX is a software suite which implements very efficient
compression of the X11 protocol. This increases performance when
using X applications over a network, especially a slow one.
.
libNX_Xpm provides support and common operation for the XPM pixmap
format, which is commonly used in legacy X applications. XPM is an
extension of the monochrome XBM bitmap specified in the X protocol.
This package removes the obsoleted headers for the libNX_Xpm.so.4
library. With recent versions of NX, the system-wide installed libXpm
gets used.
.
This package contains the development headers for this library.
This package can be safely removed.
Package: libnx-xpm4-dbg
Architecture: any
......@@ -723,20 +718,19 @@ Multi-Arch: same
Pre-Depends:
${misc:Pre-Depends},
Depends:
libnx-xpm4 (= ${binary:Version}),
${misc:Depends},
Section: debug
Breaks: nx-x11-dbg (<< 2:3.5.0.29-0x2go2~),
Description: nx-X11 pixmap library (debug package)
Description: nx-X11 pixmap library (debug package, dummy package)
NX is a software suite which implements very efficient
compression of the X11 protocol. This increases performance when
using X applications over a network, especially a slow one.
.
libNX_Xpm provides support and common operation for the XPM pixmap
format, which is commonly used in legacy X applications. XPM is an
extension of the monochrome XBM bitmap specified in the X protocol.
This package removes the obsoleted debug symbols for the libNX_Xpm.so.4
library. With recent versions of NX, the system-wide installed libXpm
gets used.
.
This package contains debug symbols for this library.
This package can be safely removed.
Package: libnx-xrandr2
Architecture: any
......
usr/lib/*/libNX_Xpm.so
usr/include/*/nx/X11/xpm.h
libNX_Xpm.so.4 libnx-xpm4 #MINVER#
XpmAttributesSize@Base 3.5.0.29
XpmCreateBufferFromImage@Base 3.5.0.29
XpmCreateBufferFromPixmap@Base 3.5.0.29
XpmCreateBufferFromXpmImage@Base 3.5.0.29
XpmCreateDataFromImage@Base 3.5.0.29
XpmCreateDataFromPixmap@Base 3.5.0.29
XpmCreateDataFromXpmImage@Base 3.5.0.29
XpmCreateImageFromBuffer@Base 3.5.0.29
XpmCreateImageFromData@Base 3.5.0.29
XpmCreateImageFromXpmImage@Base 3.5.0.29
XpmCreatePixmapFromBuffer@Base 3.5.0.29
XpmCreatePixmapFromData@Base 3.5.0.29
XpmCreatePixmapFromXpmImage@Base 3.5.0.29
XpmCreateXpmImageFromBuffer@Base 3.5.0.29
XpmCreateXpmImageFromData@Base 3.5.0.29
XpmCreateXpmImageFromImage@Base 3.5.0.29
XpmCreateXpmImageFromPixmap@Base 3.5.0.29
XpmFree@Base 3.5.0.29
XpmFreeAttributes@Base 3.5.0.29
XpmFreeExtensions@Base 3.5.0.29
XpmFreeXpmImage@Base 3.5.0.29
XpmFreeXpmInfo@Base 3.5.0.29
XpmGetErrorString@Base 3.5.0.29
XpmLibraryVersion@Base 3.5.0.29
XpmReadFileToBuffer@Base 3.5.0.29
XpmReadFileToData@Base 3.5.0.29
XpmReadFileToImage@Base 3.5.0.29
XpmReadFileToPixmap@Base 3.5.0.29
XpmReadFileToXpmImage@Base 3.5.0.29
XpmWriteFileFromBuffer@Base 3.5.0.29
XpmWriteFileFromData@Base 3.5.0.29
XpmWriteFileFromImage@Base 3.5.0.29
XpmWriteFileFromPixmap@Base 3.5.0.29
XpmWriteFileFromXpmImage@Base 3.5.0.29
xpmColorKeys@Base 3.5.0.29
xpmCreateImageFromPixmap@Base 3.5.0.29
xpmCreatePixmapFromImage@Base 3.5.0.29
xpmDataTypes@Base 3.5.0.29
xpmFreeColorTable@Base 3.5.0.29
xpmFreeRgbNames@Base 3.5.0.29
xpmGetCmt@Base 3.5.0.29
xpmGetRgbName@Base 3.5.0.29
xpmGetString@Base 3.5.0.29
xpmHashIntern@Base 3.5.0.29
xpmHashSlot@Base 3.5.0.29
xpmHashTableFree@Base 3.5.0.29
xpmHashTableInit@Base 3.5.0.29
xpmInitAttributes@Base 3.5.0.29
xpmInitXpmImage@Base 3.5.0.29
xpmInitXpmInfo@Base 3.5.0.29
xpmNextString@Base 3.5.0.29
xpmNextUI@Base 3.5.0.29
xpmNextWord@Base 3.5.0.29
xpmParseColors@Base 3.5.0.29
xpmParseData@Base 3.5.0.29
xpmParseDataAndCreate@Base 3.5.0.29
xpmParseExtensions@Base 3.5.0.29
xpmParseHeader@Base 3.5.0.29
xpmParseValues@Base 3.5.0.29
xpmPipeThrough@Base 3.5.0.29
xpmReadRgbNames@Base 3.5.0.29
xpmSetAttributes@Base 3.5.0.29
xpmSetInfo@Base 3.5.0.29
xpmSetInfoMask@Base 3.5.0.29
xpm_xynormalizeimagebits@Base 3.5.0.29
xpm_znormalizeimagebits@Base 3.5.0.29
xpmatoui@Base 3.5.0.29
......@@ -3263,9 +3263,9 @@ ProjectUnsharedLibReferences(XFONTENC,NX_fontenc,$(FONTENCLIBSRC),XBuildLibDir)
#ifndef SharedXpmRev
#define SharedXpmRev 4.11
#endif
SharedLibReferences(XPM,NX_Xpm,$(XPMLIBSRC),SOXPMREV,SharedXpmRev)
SharedLibReferences(XPM,Xpm,$(XPMLIBSRC),SOXPMREV,SharedXpmRev)
#else
ProjectUnsharedLibReferences(XPM,NX_Xpm,$(XPMLIBSRC),XBuildLibDir)
ProjectUnsharedLibReferences(XPM,Xpm,$(XPMLIBSRC),XBuildLibDir)
#endif
#if UseFreetype2
......
/*
* 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 *
\*****************************************************************************/
/* October 2004, source code review by Thomas Biege <thomas@suse.de> */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
/* 3.2 backward compatibility code */
LFUNC(CreateOldColorTable, int, (XpmColor *ct, unsigned int ncolors,
XpmColor ***oldct));
LFUNC(FreeOldColorTable, void, (XpmColor **colorTable, unsigned int ncolors));
/*
* Create a colortable compatible with the old style colortable
*/
static int
CreateOldColorTable(ct, ncolors, oldct)
XpmColor *ct;
unsigned int ncolors;
XpmColor ***oldct;
{
XpmColor **colorTable, **color;
unsigned int a;
if (ncolors >= UINT_MAX / sizeof(XpmColor *))
return XpmNoMemory;
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);
}
static void
FreeOldColorTable(colorTable, ncolors)
XpmColor **colorTable;
unsigned int ncolors;
{
unsigned 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
*/
void
xpmFreeColorTable(colorTable, ncolors)
XpmColor *colorTable;
int ncolors;
{
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
*/
void
XpmFreeExtensions(extensions, nextensions)
XpmExtension *extensions;
int nextensions;
{
unsigned int i, j, nlines;
XpmExtension *ext;
char **sptr;
if (extensions && nextensions > 0) {
for (i = 0, ext = extensions; i < 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
*/
void
xpmInitAttributes(attributes)
XpmAttributes *attributes;
{
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
*/
void
xpmSetAttributes(attributes, image, info)
XpmAttributes *attributes;
XpmImage *image;
XpmInfo *info;
{
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
*/
void
XpmFreeAttributes(attributes)
XpmAttributes *attributes;
{
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;
}
/*
* 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.
*/
/*****************************************************************************\
* CrBufFrP.c: *
* *
* XPM library *
* Scan a pixmap and possibly its mask and create an XPM buffer *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
int
XpmCreateBufferFromPixmap(display, buffer_return, pixmap, shapemask,
attributes)
Display *display;
char **buffer_return;
Pixmap pixmap;
Pixmap shapemask;
XpmAttributes *attributes;
{
XImage *ximage = NULL;
XImage *shapeimage = NULL;
unsigned int width = 0;
unsigned int height = 0;
int ErrorStatus;
/* get geometry */
if (attributes && attributes->valuemask & XpmSize) {
width = attributes->width;
height = attributes->height;
}
/* get the ximages */
if (pixmap)
xpmCreateImageFromPixmap(display, pixmap, &ximage, &width, &height);
if (shapemask)
xpmCreateImageFromPixmap(display, shapemask, &shapeimage,
&width, &height);
/* create the buffer */
ErrorStatus = XpmCreateBufferFromImage(display, buffer_return, ximage,
shapeimage, attributes);
/* destroy the ximages */
if (ximage)
XDestroyImage(ximage);
if (shapeimage)
XDestroyImage(shapeimage);
return (ErrorStatus);
}
/*
* 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.
*/
/*****************************************************************************\
* CrDataFP.c: *
* *
* XPM library *
* Scan a pixmap and possibly its mask and create an XPM array *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
int
XpmCreateDataFromPixmap(display, data_return, pixmap, shapemask, attributes)
Display *display;
char ***data_return;
Pixmap pixmap;
Pixmap shapemask;
XpmAttributes *attributes;
{
XImage *ximage = NULL;
XImage *shapeimage = NULL;
unsigned int width = 0;
unsigned int height = 0;
int ErrorStatus;
/* get geometry */
if (attributes && attributes->valuemask & XpmSize) {
width = attributes->width;
height = attributes->height;
}
/* get the ximages */
if (pixmap)
xpmCreateImageFromPixmap(display, pixmap, &ximage, &width, &height);
if (shapemask)
xpmCreateImageFromPixmap(display, shapemask, &shapeimage,
&width, &height);
/* create the data */
ErrorStatus = XpmCreateDataFromImage(display, data_return, ximage,
shapeimage, attributes);
/* destroy the ximages */
if (ximage)
XDestroyImage(ximage);
if (shapeimage)
XDestroyImage(shapeimage);
return (ErrorStatus);
}
/*
* 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 *
\*****************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
LFUNC(OpenBuffer, void, (char *buffer, xpmData *mdata));
int
XpmCreateImageFromBuffer(display, buffer, image_return,
shapeimage_return, attributes)
Display *display;
char *buffer;
XImage **image_return;
XImage **shapeimage_return;
XpmAttributes *attributes;
{
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);
}
int
XpmCreateXpmImageFromBuffer(buffer, image, info)
char *buffer;
XpmImage *image;
XpmInfo *info;
{
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
*/
static void
OpenBuffer(buffer, mdata)
char *buffer;
xpmData *mdata;
{
mdata->type = XPMBUFFER;
mdata->cptr = buffer;
mdata->CommentLength = 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 *
\*****************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
LFUNC(OpenArray, void, (char **data, xpmData *mdata));
int
XpmCreateImageFromData(display, data, image_return,
shapeimage_return, attributes)
Display *display;
char **data;
XImage **image_return;
XImage **shapeimage_return;
XpmAttributes *attributes;
{
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);
}
int
XpmCreateXpmImageFromData(data, image, info)
char **data;
XpmImage *image;
XpmInfo *info;
{
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
*/
static void
OpenArray(data, mdata)
char **data;
xpmData *mdata;
{
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 */
}
/*
* 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.
*/
/*****************************************************************************\
* CrIFrP.c: *
* *
* XPM library *
* Create the XImage related to the given Pixmap. *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
void
xpmCreateImageFromPixmap(display, pixmap, ximage_return, width, height)
Display *display;
Pixmap pixmap;
XImage **ximage_return;
unsigned int *width;
unsigned int *height;
{
unsigned int dum;
int dummy;
Window win;
if (*width == 0 && *height == 0)
XGetGeometry(display, pixmap, &win, &dummy, &dummy,
width, height, &dum, &dum);
*ximage_return = XGetImage(display, pixmap, 0, 0, *width, *height,
AllPlanes, ZPixmap);
}
/*
* 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.
*/
/*****************************************************************************\
* CrPFrBuf.c: *
* *
* XPM library *
* Parse an Xpm buffer and create the pixmap and possibly its mask *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
int
XpmCreatePixmapFromBuffer(display, d, buffer, pixmap_return,
shapemask_return, attributes)
Display *display;
Drawable d;
char *buffer;
Pixmap *pixmap_return;
Pixmap *shapemask_return;
XpmAttributes *attributes;
{
XImage *ximage, *shapeimage;
int ErrorStatus;
/* initialize return values */
if (pixmap_return)
*pixmap_return = 0;
if (shapemask_return)
*shapemask_return = 0;
/* create the images */
ErrorStatus = XpmCreateImageFromBuffer(display, buffer,
(pixmap_return ? &ximage : NULL),
(shapemask_return ?
&shapeimage : NULL),
attributes);
if (ErrorStatus < 0) /* fatal error */
return (ErrorStatus);
/* create the pixmaps and destroy images */
if (pixmap_return && ximage) {
xpmCreatePixmapFromImage(display, d, ximage, pixmap_return);
XDestroyImage(ximage);
}
if (shapemask_return && shapeimage) {
xpmCreatePixmapFromImage(display, d, shapeimage, shapemask_return);
XDestroyImage(shapeimage);
}
return (ErrorStatus);
}
/*
* 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.
*/
/*****************************************************************************\
* CrPFrData.c: *
* *
* XPM library *
* Parse an Xpm array and create the pixmap and possibly its mask *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
int
XpmCreatePixmapFromData(display, d, data, pixmap_return,
shapemask_return, attributes)
Display *display;
Drawable d;
char **data;
Pixmap *pixmap_return;
Pixmap *shapemask_return;
XpmAttributes *attributes;
{
XImage *ximage, *shapeimage;
int ErrorStatus;
/* initialize return values */
if (pixmap_return)
*pixmap_return = 0;
if (shapemask_return)
*shapemask_return = 0;
/* create the images */
ErrorStatus = XpmCreateImageFromData(display, data,
(pixmap_return ? &ximage : NULL),
(shapemask_return ?
&shapeimage : NULL),
attributes);
if (ErrorStatus != XpmSuccess)
return (ErrorStatus);
if (ErrorStatus < 0) /* fatal error */
return (ErrorStatus);
/* create the pixmaps and destroy images */
if (pixmap_return && ximage) {
xpmCreatePixmapFromImage(display, d, ximage, pixmap_return);
XDestroyImage(ximage);
}
if (shapemask_return && shapeimage) {
xpmCreatePixmapFromImage(display, d, shapeimage, shapemask_return);
XDestroyImage(shapeimage);
}
return (ErrorStatus);
}
/*
* 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.
*/
/*****************************************************************************\
* CrPFrI.c: *
* *
* XPM library *
* Create the Pixmap related to the given XImage. *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
void
xpmCreatePixmapFromImage(display, d, ximage, pixmap_return)
Display *display;
Drawable d;
XImage *ximage;
Pixmap *pixmap_return;
{
GC gc;
XGCValues values;
*pixmap_return = XCreatePixmap(display, d, ximage->width,
ximage->height, ximage->depth);
/* set fg and bg in case we have an XYBitmap */
values.foreground = 1;
values.background = 0;
gc = XCreateGC(display, *pixmap_return,
GCForeground | GCBackground, &values);
XPutImage(display, *pixmap_return, gc, ximage, 0, 0, 0, 0,
ximage->width, ximage->height);
XFreeGC(display, gc);
}
/*
* 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 *
\*****************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#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;
}
/*
* 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 *
\*****************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
/*
* Init returned data to free safely later on
*/
void
xpmInitXpmInfo(info)
XpmInfo *info;
{
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
*/
void
XpmFreeXpmInfo(info)
XpmInfo *info;
{
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
*/
void
xpmSetInfoMask(info, attributes)
XpmInfo *info;
XpmAttributes *attributes;
{
info->valuemask = 0;
if (attributes->valuemask & XpmReturnInfos)
info->valuemask |= XpmReturnComments;
if (attributes->valuemask & XpmReturnExtensions)
info->valuemask |= XpmReturnExtensions;
}
/*
* Fill in the XpmInfo with the XpmAttributes
*/
void
xpmSetInfo(info, attributes)
XpmInfo *info;
XpmAttributes *attributes;
{
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;
}
}
/*
* 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.
*/
/*****************************************************************************\
* RdFToBuf.c: *
* *
* XPM library *
* Copy a file to a malloc'ed buffer, provided as a convenience. *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
/*
* The code related to FOR_MSW has been added by
* HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
*/
/* October 2004, source code review by Thomas Biege <thomas@suse.de> */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
#include <sys/stat.h>
#if !defined(FOR_MSW) && !defined(WIN32)
#include <unistd.h>
#endif
#ifndef VAX11C
#include <fcntl.h>
#endif
#if defined(FOR_MSW) || defined(WIN32)
#include <io.h>
#define stat _stat
#define fstat _fstat
#define fdopen _fdopen
#define O_RDONLY _O_RDONLY
#endif
int
XpmReadFileToBuffer(filename, buffer_return)
char *filename;
char **buffer_return;
{
int fd, fcheck;
off_t len;
char *ptr;
struct stat stats;
FILE *fp;
*buffer_return = NULL;
#ifndef VAX11C
fd = open(filename, O_RDONLY);
#else
fd = open(filename, O_RDONLY, NULL);
#endif
if (fd < 0)
return XpmOpenFailed;
if (fstat(fd, &stats)) {
close(fd);
return XpmOpenFailed;
}
fp = fdopen(fd, "r");
if (!fp) {
close(fd);
return XpmOpenFailed;
}
len = stats.st_size;
ptr = (char *) XpmMalloc(len + 1);
if (!ptr) {
fclose(fp);
return XpmNoMemory;
}
fcheck = fread(ptr, 1, len, fp);
fclose(fp);
#ifdef VMS
/* VMS often stores text files in a variable-length record format,
where there are two bytes of size followed by the record. fread
converts this so it looks like a record followed by a newline.
Unfortunately, the size reported by fstat() (and fseek/ftell)
counts the two bytes for the record terminator, while fread()
counts only one. So, fread() sees fewer bytes in the file (size
minus # of records) and thus when asked to read the amount
returned by stat(), it fails.
The best solution, suggested by DEC, seems to consider the length
returned from fstat() as an upper bound and call fread() with
a record length of 1. Then don't check the return value.
We'll check for 0 for gross error that's all.
*/
len = fcheck;
if (fcheck == 0) {
#else
if (fcheck != len) {
#endif
XpmFree(ptr);
return XpmOpenFailed;
}
ptr[len] = '\0';
*buffer_return = ptr;
return XpmSuccess;
}
/*
* 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 *
\*****************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
int
XpmReadFileToData(filename, data_return)
char *filename;
char ***data_return;
{
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);
}
/*
* 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 *
\*****************************************************************************/
/* $XFree86$ */
/* October 2004, source code review by Thomas Biege <thomas@suse.de> */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
#ifndef NO_ZPIPE
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#endif
LFUNC(OpenReadFile, int, (char *filename, xpmData *mdata));
LFUNC(xpmDataClose, void, (xpmData *mdata));
#ifndef CXPMPROG
int
XpmReadFileToImage(display, filename,
image_return, shapeimage_return, attributes)
Display *display;
char *filename;
XImage **image_return;
XImage **shapeimage_return;
XpmAttributes *attributes;
{
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);
}
int
XpmReadFileToXpmImage(filename, image, info)
char *filename;
XpmImage *image;
XpmInfo *info;
{
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 */
#ifndef NO_ZPIPE
/* Do not depend on errno after read_through */
FILE*
xpmPipeThrough(fd, cmd, arg1, mode)
int fd;
const char* cmd;
const char* arg1;
const char* mode;
{
FILE* fp;
int status, fds[2], in = 0, out = 1;
pid_t pid;
if ( 'w' == *mode )
out = 0, in = 1;
if ( pipe(fds) < 0 )
return NULL;
pid = fork();
if ( pid < 0 )
goto fail1;
if ( 0 == pid )
{
close(fds[in]);
if ( dup2(fds[out], out) < 0 )
goto err;
close(fds[out]);
if ( dup2(fd, in) < 0 )
goto err;
close(fd);
pid = fork();
if ( pid < 0 )
goto err;
if ( 0 == pid )
{
execlp(cmd, cmd, arg1, (char *)NULL);
perror(cmd);
goto err;
}
_exit(0);
err:
_exit(1);
}
close(fds[out]);
/* calling process: wait for first child */
while ( waitpid(pid, &status, 0) < 0 && EINTR == errno )
;
if ( WIFSIGNALED(status) ||
(WIFEXITED(status) && WEXITSTATUS(status) != 0) )
goto fail2;
fp = fdopen(fds[in], mode);
if ( !fp )
goto fail2;
close(fd); /* still open in 2nd child */
return fp;
fail1:
close(fds[out]);
fail2:
close(fds[in]);
return NULL;
}
#endif
/*
* open the given file to be read as an xpmData which is returned.
*/
static int
OpenReadFile(filename, mdata)
char *filename;
xpmData *mdata;
{
if (!filename) {
mdata->stream.file = (stdin);
mdata->type = XPMFILE;
} else {
int fd = open(filename, O_RDONLY);
#if defined(NO_ZPIPE)
if ( fd < 0 )
return XpmOpenFailed;
#else
const char* ext = NULL;
if ( fd >= 0 )
ext = strrchr(filename, '.');
#ifdef STAT_ZFILE /* searching for z-files if the given name not found */
else
{
size_t len = strlen(filename);
char *compressfile = (char *) XpmMalloc(len + 4);
if ( !compressfile )
return (XpmNoMemory);
strcpy(compressfile, filename);
strcpy(compressfile + len, ext = ".Z");
fd = open(compressfile, O_RDONLY);
if ( fd < 0 )
{
strcpy(compressfile + len, ext = ".gz");
fd = open(compressfile, O_RDONLY);
if ( fd < 0 )
{
XpmFree(compressfile);
return XpmOpenFailed;
}
}
XpmFree(compressfile);
}
#endif
if ( ext && !strcmp(ext, ".Z") )
{
mdata->type = XPMPIPE;
mdata->stream.file = xpmPipeThrough(fd, "uncompress", "-c", "r");
}
else if ( ext && !strcmp(ext, ".gz") )
{
mdata->type = XPMPIPE;
mdata->stream.file = xpmPipeThrough(fd, "gunzip", "-qc", "r");
}
else
#endif /* z-files */
{
mdata->type = XPMFILE;
mdata->stream.file = fdopen(fd, "r");
}
if (!mdata->stream.file)
{
close(fd);
return (XpmOpenFailed);
}
}
mdata->CommentLength = 0;
#ifdef CXPMPROG
mdata->lineNum = 0;
mdata->charNum = 0;
#endif
return (XpmSuccess);
}
/*
* close the file related to the xpmData if any
*/
static void
xpmDataClose(mdata)
xpmData *mdata;
{
if (mdata->stream.file != (stdin))
fclose(mdata->stream.file);
}
/*
* 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.
*/
/*****************************************************************************\
* RdFToP.c: *
* *
* XPM library *
* Parse an XPM file and create the pixmap and possibly its mask *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
int
XpmReadFileToPixmap(display, d, filename, pixmap_return,
shapemask_return, attributes)
Display *display;
Drawable d;
char *filename;
Pixmap *pixmap_return;
Pixmap *shapemask_return;
XpmAttributes *attributes;
{
XImage *ximage, *shapeimage;
int ErrorStatus;
/* initialize return values */
if (pixmap_return)
*pixmap_return = 0;
if (shapemask_return)
*shapemask_return = 0;
/* create the images */
ErrorStatus = XpmReadFileToImage(display, filename,
(pixmap_return ? &ximage : NULL),
(shapemask_return ? &shapeimage : NULL),
attributes);
if (ErrorStatus < 0) /* fatal error */
return (ErrorStatus);
/* create the pixmaps and destroy images */
if (pixmap_return && ximage) {
xpmCreatePixmapFromImage(display, d, ximage, pixmap_return);
XDestroyImage(ximage);
}
if (shapemask_return && shapeimage) {
xpmCreatePixmapFromImage(display, d, shapeimage, shapemask_return);
XDestroyImage(shapeimage);
}
return (ErrorStatus);
}
/*
* 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.
*/
/*****************************************************************************\
* WrFFrBuf.c: *
* *
* XPM library *
* Write a memory buffer to a file, provided as a convenience. *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
/* October 2004, source code review by Thomas Biege <thomas@suse.de> */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
int
XpmWriteFileFromBuffer(filename, buffer)
char *filename;
char *buffer;
{
int fcheck, len;
FILE *fp = fopen(filename, "w");
if (!fp)
return XpmOpenFailed;
len = strlen(buffer);
fcheck = fwrite(buffer, len, 1, fp);
fclose(fp);
if (fcheck != 1)
return XpmOpenFailed; /* maybe use a better return value */
return XpmSuccess;
}
/*
* 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 *
\*****************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
int
XpmWriteFileFromData(filename, data)
char *filename;
char **data;
{
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);
}
/*
* 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 *
\*****************************************************************************/
/* $XFree86$ */
/*
* The code related to AMIGA has been added by
* Lorens Younes (d93-hyo@nada.kth.se) 4/96
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
#ifndef NO_ZPIPE
#include "sys/wait.h"
#include "sys/types.h"
#include "fcntl.h"
#include "unistd.h"
#include "errno.h"
#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));
int
XpmWriteFileFromImage(display, filename, image, shapeimage, attributes)
Display *display;
char *filename;
XImage *image;
XImage *shapeimage;
XpmAttributes *attributes;
{
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);
}
int
XpmWriteFileFromXpmImage(filename, image, info)
char *filename;
XpmImage *image;
XpmInfo *info;
{
xpmData mdata;
char *name, *dot, *s, new_name[BUFSIZ] = {0};
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 (index(name, '.')) {
strncpy(new_name, name, sizeof(new_name));
new_name[sizeof(new_name)-1] = '\0';
/* change '.' to '_' */
name = s = new_name;
while ((dot = index(s, '.'))) {
*dot = '_';
s = dot;
}
}
if (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);
}
static int
xpmWriteFile(file, image, name, info)
FILE *file;
XpmImage *image;
char *name;
XpmInfo *info;
{
/* 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);
}
static void
WriteColors(file, colors, ncolors)
FILE *file;
XpmColor *colors;
unsigned int ncolors;
{
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");
}
}
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;
{
char *s, *p, *buf;
unsigned int x, y, h;
h = height - 1;
if (cpp != 0 && width >= (UINT_MAX - 3)/cpp)
return XpmNoMemory;
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);
}
static void
WriteExtensions(file, ext, num)
FILE *file;
XpmExtension *ext;
unsigned int num;
{
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\"");
}
#ifndef NO_ZPIPE
FUNC(xpmPipeThrough, FILE*, (int fd,
const char* cmd,
const char* arg1,
const char* mode));
#endif
/*
* open the given file to be written as an xpmData which is returned
*/
static int
OpenWriteFile(filename, mdata)
char *filename;
xpmData *mdata;
{
if (!filename) {
mdata->stream.file = (stdout);
mdata->type = XPMFILE;
} else {
#ifndef NO_ZPIPE
size_t len;
#endif
int fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644);
if ( fd < 0 )
return(XpmOpenFailed);
#ifndef NO_ZPIPE
len = strlen(filename);
if (len > 2 && !strcmp(".Z", filename + (len - 2))) {
mdata->stream.file = xpmPipeThrough(fd, "compress", NULL, "w");
mdata->type = XPMPIPE;
} else if (len > 3 && !strcmp(".gz", filename + (len - 3))) {
mdata->stream.file = xpmPipeThrough(fd, "gzip", "-q", "w");
mdata->type = XPMPIPE;
} else
#endif
{
mdata->stream.file = fdopen(fd, "w");
mdata->type = XPMFILE;
}
if (!mdata->stream.file)
return (XpmOpenFailed);
}
return (XpmSuccess);
}
/*
* close the file related to the xpmData if any
*/
static void
xpmDataClose(mdata)
xpmData *mdata;
{
if (mdata->stream.file != (stdout))
fclose(mdata->stream.file);
}
/*
* 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.
*/
/*****************************************************************************\
* WrFFrP.c: *
* *
* XPM library *
* Write a pixmap and possibly its mask to an XPM file *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
int
XpmWriteFileFromPixmap(display, filename, pixmap, shapemask, attributes)
Display *display;
char *filename;
Pixmap pixmap;
Pixmap shapemask;
XpmAttributes *attributes;
{
XImage *ximage = NULL;
XImage *shapeimage = NULL;
unsigned int width = 0;
unsigned int height = 0;
int ErrorStatus;
/* get geometry */
if (attributes && attributes->valuemask & XpmSize) {
width = attributes->width;
height = attributes->height;
}
/* get the ximages */
if (pixmap)
xpmCreateImageFromPixmap(display, pixmap, &ximage, &width, &height);
if (shapemask)
xpmCreateImageFromPixmap(display, shapemask, &shapeimage,
&width, &height);
/* write to the file */
ErrorStatus = XpmWriteFileFromImage(display, filename, ximage, shapeimage,
attributes);
/* destroy the ximages */
if (ximage)
XDestroyImage(ximage);
if (shapeimage)
XDestroyImage(shapeimage);
return (ErrorStatus);
}
/*
* 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 *
* *
\*****************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
LFUNC(AtomMake, xpmHashAtom, (char *name, void *data));
LFUNC(HashTableGrows, int, (xpmHashTable * table));
static xpmHashAtom
AtomMake(name, data) /* makes an atom */
char *name; /* WARNING: is just pointed to */
void *data;
{
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)
*
*/
xpmHashAtom *
xpmHashSlot(table, s)
xpmHashTable *table;
char *s;
{
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;
}
static int
HashTableGrows(table)
xpmHashTable *table;
{
xpmHashAtom *atomTable = table->atomTable;
unsigned int size = table->size;
xpmHashAtom *t, *p;
int i;
unsigned int oldSize = size;
t = atomTable;
HASH_TABLE_GROWS
table->size = size;
table->limit = size / 3;
if (size >= UINT_MAX / sizeof(*atomTable))
return (XpmNoMemory);
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.
*/
int
xpmHashIntern(table, tag, data)
xpmHashTable *table;
char *tag;
void *data;
{
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
*/
int
xpmHashTableInit(table)
xpmHashTable *table;
{
xpmHashAtom *p;
xpmHashAtom *atomTable;
table->size = INITIAL_HASH_SIZE;
table->limit = table->size / 3;
table->used = 0;
if (table->size >= UINT_MAX / sizeof(*atomTable))
return (XpmNoMemory);
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
*/
void
xpmHashTableFree(table)
xpmHashTable *table;
{
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;
}
/*
* 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 *
\*****************************************************************************/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "XpmI.h"
#ifdef NEED_STRDUP
/*
* in case strdup is not provided by the system here is one
* which does the trick
*/
char *
xpmstrdup(s1)
char *s1;
{
char *s2;
size_t l = strlen(s1) + 1;
if (s2 = (char *) XpmMalloc(l))
strcpy(s2, s1);
return s2;
}
#endif
unsigned int
xpmatoui(p, l, ui_return)
register char *p;
unsigned int l;
unsigned int *ui_return;
{
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.
*/
char *
XpmGetErrorString(errcode)
int errcode;
{
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
void
XpmFree(ptr)
void *ptr;
{
free(ptr);
}
/*
* 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
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#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 */
int
xpmReadRgbNames(rgb_fname, rgbn)
char *rgb_fname;
xpmRgbName rgbn[];
{
/*
* 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
*/
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 */
{
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 */
int
xpmGetRGBfromName(inname, r, g, b)
char *inname;
int *r, *g, *b;
{
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);
}
void
xpmFreeRgbNames(rgbn, rgbn_max)
xpmRgbName rgbn[];
int rgbn_max;
{
/* nothing to do */
}
#endif /* MSW part */
......@@ -213,7 +213,6 @@ XEXTLIBDIR = Xext
#if BuildLibraries
OLDXLIBDIR = oldX
XPMLIBDIR = Xpm
XTSTLIBDIR = Xtst
#endif
......
XCOMM $XFree86: xc/lib/Xpm/Imakefile,v 1.1 1999/01/11 14:40:02 dawes Exp $
/* This is a simplified version of the standard Xpm Imakefile */
#ifdef SunArchitecture
#define DoNormalLib YES
#else
#define DoNormalLib NormalLibXpm
#endif
#define DoSharedLib SharedLibXpm
#define DoExtraLib SharedLibXpm
#define DoDebugLib DebugLibXpm
#define DoProfileLib ProfileLibXpm
#define HasSharedData NO
#define LibName NX_Xpm
#define SoRev SOXPMREV
#define IncSubdir X11
#ifdef SharedXpmReqs
REQUIREDLIBS = SharedXpmReqs
#endif
/*
* if your system doesn't provide strcasecmp add -DNEED_STRCASECMP
* if your system doesn't provide strdup add -DNEED_STRDUP
* if your system doesn't provide pipe add -DNO_ZPIPE
* if on your system sprintf doesn't return the number of bytes transmitted
* add -DVOID_SPRINTF
* if you want xpm to try name.xpm.Z and name.xpm.gz when asked to read
* name.xpm , add -DSTAT_ZFILE
*/
#if defined(LinuxArchitecture)
ZFILEDEF = -DSTAT_ZFILE
#endif
#if defined(UltrixArchitecture) || \
(defined(MipsArchitecture) && !defined(SGIArchitecture))
STRDUPDEF = -DNEED_STRDUP
#endif
#if !HasStrcasecmp
STRCASECMPDEF = -DNEED_STRCASECMP
#endif
#if defined(SunArchitecture) && !defined(SVR4Architecture)
SPRINTFDEF = -DVOID_SPRINTF
#endif
#if HasStrlcat
STRLCATDEF = -DHAS_STRLCAT
#endif
#if HasSnprintf
SNPRINTFDEF = -DHAS_SNPRINTF
#else
SNPRINTFDEF = -Dsnprintf=_XpmSnprintf
SNPRINTFSRCS = snprintf.c
SNPRINTFOBJS = snprintf.o
#endif
#if defined(Win32Architecture)
ZPIPEDEF = -DNO_ZPIPE
#endif
DEFINES = $(STRDUPDEF) $(STRCASECMPDEF) $(SPRINTFDEF) $(STRLCATDEF) \
$(SNPRINTFDEF) $(ZPIPEDEF) $(ZFILEDEF)
HEADERS = xpm.h
SRCS = data.c create.c misc.c rgb.c scan.c parse.c hashtab.c \
CrBufFrI.c CrDatFrP.c CrPFrBuf.c RdFToI.c WrFFrI.c \
CrBufFrP.c CrIFrBuf.c CrPFrDat.c RdFToP.c WrFFrP.c \
CrDatFrI.c CrIFrDat.c RdFToDat.c WrFFrDat.c \
Attrib.c CrIFrP.c CrPFrI.c Image.c Info.c RdFToBuf.c WrFFrBuf.c \
$(SNPRINTFSRCS)
OBJS = data.o create.o misc.o rgb.o scan.o parse.o hashtab.o \
CrBufFrI.o CrDatFrP.o CrPFrBuf.o RdFToI.o WrFFrI.o \
CrBufFrP.o CrIFrBuf.o CrPFrDat.o RdFToP.o WrFFrP.o \
CrDatFrI.o CrIFrDat.o RdFToDat.o WrFFrDat.o \
Attrib.o CrIFrP.o CrPFrI.o Image.o Info.o RdFToBuf.o WrFFrBuf.o \
$(SNPRINTFOBJS)
XPMDIR = $(TOP)/extras/Xpm
XPMLIBDIR = $(TOP)/extras/Xpm/lib
INCLUDES = -I$(XPMLIBDIR)
LINTLIBS = $(LINTXTOLL) $(LINTXLIB)
#include <Library.tmpl>
LinkSourceFile(data.c,$(XPMLIBDIR))
LinkSourceFile(create.c,$(XPMLIBDIR))
LinkSourceFile(misc.c,$(XPMLIBDIR))
LinkSourceFile(rgb.c,$(XPMLIBDIR))
LinkSourceFile(scan.c,$(XPMLIBDIR))
LinkSourceFile(parse.c,$(XPMLIBDIR))
LinkSourceFile(hashtab.c,$(XPMLIBDIR))
LinkSourceFile(CrBufFrI.c,$(XPMLIBDIR))
LinkSourceFile(CrDatFrP.c,$(XPMLIBDIR))
LinkSourceFile(CrPFrBuf.c,$(XPMLIBDIR))
LinkSourceFile(RdFToI.c,$(XPMLIBDIR))
LinkSourceFile(WrFFrI.c,$(XPMLIBDIR))
LinkSourceFile(CrBufFrP.c,$(XPMLIBDIR))
LinkSourceFile(CrIFrBuf.c,$(XPMLIBDIR))
LinkSourceFile(CrPFrDat.c,$(XPMLIBDIR))
LinkSourceFile(RdFToP.c,$(XPMLIBDIR))
LinkSourceFile(WrFFrP.c,$(XPMLIBDIR))
LinkSourceFile(CrDatFrI.c,$(XPMLIBDIR))
LinkSourceFile(CrIFrDat.c,$(XPMLIBDIR))
LinkSourceFile(RdFToDat.c,$(XPMLIBDIR))
LinkSourceFile(WrFFrDat.c,$(XPMLIBDIR))
LinkSourceFile(Attrib.c,$(XPMLIBDIR))
LinkSourceFile(CrIFrP.c,$(XPMLIBDIR))
LinkSourceFile(CrPFrI.c,$(XPMLIBDIR))
LinkSourceFile(Image.c,$(XPMLIBDIR))
LinkSourceFile(Info.c,$(XPMLIBDIR))
LinkSourceFile(RdFToBuf.c,$(XPMLIBDIR))
LinkSourceFile(WrFFrBuf.c,$(XPMLIBDIR))
LinkSourceFile(xpm.h,$(XPMLIBDIR))
#if !HasSnprintf
LinkSourceFile(snprintf.c,$(LIBSRC)/misc)
#endif
DependTarget()
LIBRARY Xpm
VERSION LIBRARY_VERSION
EXPORTS
XpmAttributesSize
XpmCreateBufferFromImage
XpmCreateBufferFromPixmap
XpmCreateBufferFromXpmImage
XpmCreateDataFromImage
XpmCreateDataFromPixmap
XpmCreateDataFromXpmImage
XpmCreateImageFromBuffer
XpmCreateImageFromData
XpmCreateImageFromXpmImage
XpmCreatePixmapFromBuffer
XpmCreatePixmapFromData
XpmCreatePixmapFromXpmImage
XpmCreateXpmImageFromBuffer
XpmCreateXpmImageFromData
XpmCreateXpmImageFromImage
XpmCreateXpmImageFromPixmap
XpmFree
XpmFreeAttributes
XpmFreeExtensions
XpmFreeXpmImage
XpmFreeXpmInfo
XpmGetErrorString
XpmLibraryVersion
XpmReadFileToBuffer
XpmReadFileToData
XpmReadFileToImage
XpmReadFileToPixmap
XpmReadFileToXpmImage
XpmWriteFileFromBuffer
XpmWriteFileFromData
XpmWriteFileFromImage
XpmWriteFileFromPixmap
XpmWriteFileFromXpmImage
/* $XFree86$ */
......@@ -994,7 +994,7 @@ NXAGENTOBJS = hw/nxagent/miinitext.o \
dix/main.o
#endif
XPMLIB = -lNX_Xpm
XPMLIB = -lXpm
NXAGENT = hw/nxagent/LibraryTargetName(nxagent)
NXAGENTLIBS = PreFbLibs $(NXAGENT) FbPostFbLibs $(NXAGENT) $(MI)
NXAGENTSYSLIBS = $(FONTLIBS) $(LDPRELIBS) $(XLIB) $(SYSLIBS) $(XPMLIB)
......
......@@ -33,7 +33,7 @@
#include "../../include/gc.h"
#include "../../include/window.h"
#include "xpm.h"
#include <X11/xpm.h>
#include "Agent.h"
#include "Pixmaps.h"
......
......@@ -34,6 +34,7 @@ BuildRequires: pkgconfig(libpng)
BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(x11)
BuildRequires: pkgconfig(xext)
BuildRequires: pkgconfig(xpm)
%else
BuildRequires: libexpat-devel
BuildRequires: fontconfig-devel
......@@ -43,6 +44,7 @@ BuildRequires: libxml2-devel
BuildRequires: xorg-x11-libX11-devel
BuildRequires: xorg-x11-libXext-devel
BuildRequires: xorg-x11-libfontenc-devel
BuildRequires: xorg-x11-libXpm-devel
%endif
BuildRequires: xorg-x11-util-devel
%endif
......@@ -359,7 +361,7 @@ physical displays as one large virtual display.
%package -n libNX_Xpm-devel
Group: Development/Libraries
Summary: Development files for the NX Pixmap image file format library
Summary: Development files for the NX Pixmap image file format library (dummy package)
Requires: libNX_Xpm4%{?_isa} = %{version}-%{release}
%description -n libNX_Xpm-devel
......@@ -367,16 +369,12 @@ NX is a software suite which implements very efficient compression of
the X11 protocol. This increases performance when using X
applications over a network, especially a slow one.
libXpm facilitates working with XPM (X PixMap), a format for
storing/retrieving X pixmaps to/from files.
This package contains all necessary include files and libraries
needed to develop applications that require these.
This package obsoletes libNX_Xpm-devel in NX and can be safely removed.
%package -n libNX_Xpm4
Group: System Environment/Libraries
Summary: NX Pixmap image file format library
Summary: NX Pixmap image file format library (dummy package)
Requires: %{name}%{?_isa} >= 3.5.0.29
Obsoletes: libNX_Xpm
......@@ -385,8 +383,7 @@ NX is a software suite which implements very efficient compression of
the X11 protocol. This increases performance when using X
applications over a network, especially a slow one.
libNX_Xpm facilitates working with XPM (X PixMap), a format for
storing/retrieving X pixmaps to/from files.
This package obsoletes libNX_Xpm4 in NX and can be safely removed.
%package -n libNX_Xrandr2
......@@ -556,7 +553,6 @@ Requires: libNX_Xau-devel%{?_isa} = %{version}-%{release}
Requires: libNX_Xdmcp-devel%{?_isa} = %{version}-%{release}
Requires: libNX_Xext-devel%{?_isa} = %{version}-%{release}
Requires: libNX_Xfixes-devel%{?_isa} = %{version}-%{release}
Requires: libNX_Xpm-devel%{?_isa} = %{version}-%{release}
Requires: libNX_Xrender-devel%{?_isa} = %{version}-%{release}
Requires: nx-proto-devel%{?_isa} = %{version}-%{release}
Requires: %{name}%{?_isa} = %{version}-%{release}
......@@ -742,7 +738,6 @@ ln -s -f ../../../../%{_lib}/libXext.so.6 %{buildroot}%{_libdir}/nx/X11/Xinerama
%post -n libNX_Xext6 -p /sbin/ldconfig
%post -n libNX_Xfixes3 -p /sbin/ldconfig
%post -n libNX_Xinerama1 -p /sbin/ldconfig
%post -n libNX_Xpm4 -p /sbin/ldconfig
%post -n libNX_Xrandr2 -p /sbin/ldconfig
%post -n libNX_Xrender1 -p /sbin/ldconfig
%post -n libNX_Xtst6 -p /sbin/ldconfig
......@@ -758,7 +753,6 @@ ln -s -f ../../../../%{_lib}/libXext.so.6 %{buildroot}%{_libdir}/nx/X11/Xinerama
%postun -n libNX_Xext6 -p /sbin/ldconfig
%postun -n libNX_Xfixes3 -p /sbin/ldconfig
%postun -n libNX_Xinerama1 -p /sbin/ldconfig
%postun -n libNX_Xpm4 -p /sbin/ldconfig
%postun -n libNX_Xrandr2 -p /sbin/ldconfig
%postun -n libNX_Xrender1 -p /sbin/ldconfig
%postun -n libNX_Xtst6 -p /sbin/ldconfig
......@@ -874,15 +868,6 @@ ln -s -f ../../../../%{_lib}/libXext.so.6 %{buildroot}%{_libdir}/nx/X11/Xinerama
%defattr(-,root,root)
%{_libdir}/libNX_Xinerama.so.1*
%files -n libNX_Xpm-devel
%defattr(-,root,root)
%{_libdir}/libNX_Xpm.so
%{_includedir}/nx/X11/xpm.h
%files -n libNX_Xpm4
%defattr(-,root,root)
%{_libdir}/libNX_Xpm.so.4*
%files -n libNX_Xrandr2
%defattr(-,root,root)
%{_libdir}/libNX_Xrandr.so.2*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment