Back to index

plt-scheme  4.2.1
Info.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1989-95 GROUPE BULL
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a copy
00005  * of this software and associated documentation files (the "Software"), to
00006  * deal in the Software without restriction, including without limitation the
00007  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
00008  * sell copies of the Software, and to permit persons to whom the Software is
00009  * furnished to do so, subject to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice shall be included in
00012  * all copies or substantial portions of the Software.
00013  *
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00017  * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00018  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00019  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00020  *
00021  * Except as contained in this notice, the name of GROUPE BULL shall not be
00022  * used in advertising or otherwise to promote the sale, use or other dealings
00023  * in this Software without prior written authorization from GROUPE BULL.
00024  */
00025 
00026 /*****************************************************************************\
00027 *  Info.c:                                                                    *
00028 *                                                                             *
00029 *  XPM library                                                                *
00030 *  Functions related to the XpmInfo structure.                                *
00031 *                                                                             *
00032 *  Developed by Arnaud Le Hors                                                *
00033 \*****************************************************************************/
00034 
00035 #include "xpmP.h"
00036 
00037 /*
00038  * Init returned data to free safely later on
00039  */
00040 void
00041 xpmInitXpmInfo(info)
00042     XpmInfo *info;
00043 {
00044     if (info) {
00045        info->hints_cmt = NULL;
00046        info->colors_cmt = NULL;
00047        info->pixels_cmt = NULL;
00048        info->extensions = NULL;
00049        info->nextensions = 0;
00050     }
00051 }
00052 
00053 /*
00054  * Free the XpmInfo data which have been allocated
00055  */
00056 void
00057 XpmFreeXpmInfo(info)
00058     XpmInfo *info;
00059 {
00060     if (info) {
00061        if (info->valuemask & XpmComments) {
00062            if (info->hints_cmt) {
00063               XpmFree(info->hints_cmt);
00064               info->hints_cmt = NULL;
00065            }
00066            if (info->colors_cmt) {
00067               XpmFree(info->colors_cmt);
00068               info->colors_cmt = NULL;
00069            }
00070            if (info->pixels_cmt) {
00071               XpmFree(info->pixels_cmt);
00072               info->pixels_cmt = NULL;
00073            }
00074        }
00075        if (info->valuemask & XpmReturnExtensions && info->nextensions) {
00076            XpmFreeExtensions(info->extensions, info->nextensions);
00077            info->extensions = NULL;
00078            info->nextensions = 0;
00079        }
00080        info->valuemask = 0;
00081     }
00082 }
00083 
00084 /*
00085  * Set the XpmInfo valuemask to retrieve required info
00086  */
00087 void
00088 xpmSetInfoMask(info, attributes)
00089     XpmInfo *info;
00090     XpmAttributes *attributes;
00091 {
00092     info->valuemask = 0;
00093     if (attributes->valuemask & XpmReturnInfos)
00094        info->valuemask |= XpmReturnComments;
00095     if (attributes->valuemask & XpmReturnExtensions)
00096        info->valuemask |= XpmReturnExtensions;
00097 }
00098 
00099 /*
00100  * Fill in the XpmInfo with the XpmAttributes
00101  */
00102 void
00103 xpmSetInfo(info, attributes)
00104     XpmInfo *info;
00105     XpmAttributes *attributes;
00106 {
00107     info->valuemask = 0;
00108     if (attributes->valuemask & XpmInfos) {
00109        info->valuemask |= XpmComments | XpmColorTable;
00110        info->hints_cmt = attributes->hints_cmt;
00111        info->colors_cmt = attributes->colors_cmt;
00112        info->pixels_cmt = attributes->pixels_cmt;
00113     }
00114     if (attributes->valuemask & XpmExtensions) {
00115        info->valuemask |= XpmExtensions;
00116        info->extensions = attributes->extensions;
00117        info->nextensions = attributes->nextensions;
00118     }
00119     if (attributes->valuemask & XpmHotspot) {
00120        info->valuemask |= XpmHotspot;
00121        info->x_hotspot = attributes->x_hotspot;
00122        info->y_hotspot = attributes->y_hotspot;
00123     }
00124 }