/*
- * Copyright (C) 1989-94 GROUPE BULL
+ * 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
*/
/*****************************************************************************\
-* XpmCrIFrBuf.c: *
+* CrIFrBuf.c: *
* *
* XPM library *
* Parse an Xpm buffer (file in memory) and create the image and possibly its *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
-#include "xpm34p.h"
+#include "XpmI.h"
+
+LFUNC(OpenBuffer, void, (char *buffer, xpmData *mdata));
int
-XpmCreateImageFromBuffer(Display *display, char *buffer, XImage **image_return,
- XImage **shapeimage_return, XpmAttributes *attributes)
+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;
- /* create an XpmImage from the buffer */
+ 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 = XpmCreateXpmImageFromBuffer(buffer, &image, &info);
+ ErrorStatus = xpmParseDataAndCreate(display, &mdata,
+ image_return, shapeimage_return,
+ &image, &info, attributes);
} else
- ErrorStatus = XpmCreateXpmImageFromBuffer(buffer, &image, NULL);
-
- if (ErrorStatus != XpmSuccess)
- return (ErrorStatus);
-
- /* create the related ximages */
- ErrorStatus = XpmCreateImageFromXpmImage(display, &image,
- image_return, shapeimage_return,
- attributes);
+ 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);
}
int
-XpmCreateXpmImageFromBuffer(char *buffer, XpmImage *image, XpmInfo *info)
+XpmCreateXpmImageFromBuffer(buffer, image, info)
+ char *buffer;
+ XpmImage *image;
+ XpmInfo *info;
{
xpmData mdata;
int ErrorStatus;
xpmInitXpmInfo(info);
/* open buffer to read */
- xpmOpenBuffer(buffer, &mdata);
+ OpenBuffer(buffer, &mdata);
/* create the XpmImage from the XpmData */
ErrorStatus = xpmParseData(&mdata, image, info);
- xpmDataClose(&mdata);
-
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;
+}