Back to index

plt-scheme  4.2.1
Functions
RdFToI.c File Reference
#include "xpmP.h"
#include <sys/stat.h>

Go to the source code of this file.

Functions

 LFUNC (OpenReadFile, int,(char *filename, xpmData *mdata))
 LFUNC (xpmDataClose, void,(xpmData *mdata))
int XpmReadFileToImage (Display *display, char *filename, XImage **image_return, XImage **shapeimage_return, XpmAttributes *attributes)
int XpmReadFileToXpmImage (char *filename, XpmImage *image, XpmInfo *info)
static int OpenReadFile (char *filename, xpmData *mdata)
static void xpmDataClose (xpmData *mdata)

Function Documentation

LFUNC ( OpenReadFile  ,
int  ,
(char *filename, xpmData *mdata)   
)
LFUNC ( xpmDataClose  ,
void  ,
(xpmData *mdata)   
)
static int OpenReadFile ( char *  filename,
xpmData mdata 
) [static]

Definition at line 109 of file RdFToI.c.

{
#ifdef ZPIPE
    char *compressfile, buf[BUFSIZ];
    struct stat status;

#endif

    if (!filename) {
       mdata->stream.file = (stdin);
       mdata->type = XPMFILE;
    } else {
#ifdef ZPIPE
       if (((int) strlen(filename) > 2) &&
           !strcmp(".Z", filename + (strlen(filename) - 2))) {
           mdata->type = XPMPIPE;
           sprintf(buf, "uncompress -c \"%s\"", filename);
           if (!(mdata->stream.file = popen(buf, "r")))
              return (XpmOpenFailed);

       } else if (((int) strlen(filename) > 3) &&
                 !strcmp(".gz", filename + (strlen(filename) - 3))) {
           mdata->type = XPMPIPE;
           sprintf(buf, "gunzip -qc \"%s\"", filename);
           if (!(mdata->stream.file = popen(buf, "r")))
              return (XpmOpenFailed);

       } else {
           if (!(compressfile = (char *) XpmMalloc(strlen(filename) + 4)))
              return (XpmNoMemory);

           strcpy(compressfile, filename);
           strcat(compressfile, ".Z");
           if (!stat(compressfile, &status)) {
              sprintf(buf, "uncompress -c \"%s\"", compressfile);
              if (!(mdata->stream.file = popen(buf, "r"))) {
                  XpmFree(compressfile);
                  return (XpmOpenFailed);
              }
              mdata->type = XPMPIPE;
           } else {
              strcpy(compressfile, filename);
              strcat(compressfile, ".gz");
              if (!stat(compressfile, &status)) {
                  sprintf(buf, "gunzip -c \"%s\"", compressfile);
                  if (!(mdata->stream.file = popen(buf, "r"))) {
                     XpmFree(compressfile);
                     return (XpmOpenFailed);
                  }
                  mdata->type = XPMPIPE;
              } else {
#endif
                  if (!(mdata->stream.file = fopen(filename, "r"))) {
#ifdef ZPIPE
                     XpmFree(compressfile);
#endif
                     return (XpmOpenFailed);
                  }
                  mdata->type = XPMFILE;
#ifdef ZPIPE
              }
           }
           XpmFree(compressfile);
       }
#endif
    }
    mdata->CommentLength = 0;
    return (XpmSuccess);
}

Here is the caller graph for this function:

static void xpmDataClose ( xpmData mdata) [static]

Definition at line 185 of file RdFToI.c.

{
    switch (mdata->type) {
    case XPMFILE:
       if (mdata->stream.file != (stdin))
           fclose(mdata->stream.file);
       break;
#ifdef ZPIPE
    case XPMPIPE:
       pclose(mdata->stream.file);
       break;
#endif
    }
}

Here is the caller graph for this function:

int XpmReadFileToImage ( Display *  display,
char *  filename,
XImage **  image_return,
XImage **  shapeimage_return,
XpmAttributes attributes 
)

Definition at line 42 of file RdFToI.c.

{
    XpmImage image;
    XpmInfo info;
    int ErrorStatus;

    /* create an XpmImage from the file */
    if (attributes) {
       xpmInitAttributes(attributes);
       xpmSetInfoMask(&info, attributes);
       ErrorStatus = XpmReadFileToXpmImage(filename, &image, &info);
    } else
       ErrorStatus = XpmReadFileToXpmImage(filename, &image, NULL);

    if (ErrorStatus != XpmSuccess)
       return (ErrorStatus);

    /* create the related ximages */
    ErrorStatus = XpmCreateImageFromXpmImage(display, &image,
                                        image_return, shapeimage_return,
                                        attributes);
    if (attributes) {
       if (ErrorStatus >= 0)              /* no fatal error */
           xpmSetAttributes(attributes, &image, &info);
       XpmFreeXpmInfo(&info);
    }
    /* free the XpmImage */
    XpmFreeXpmImage(&image);

    return (ErrorStatus);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int XpmReadFileToXpmImage ( char *  filename,
XpmImage image,
XpmInfo info 
)

Definition at line 81 of file RdFToI.c.

{
    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);
}

Here is the call graph for this function:

Here is the caller graph for this function: