Blame lib/Xm/XpmInfo.c

Packit b099d7
/* $XConsortium: XpmInfo.c /main/2 1996/09/20 08:12:43 pascale $ */
Packit b099d7
/*
Packit b099d7
 * Copyright (C) 1989-95 GROUPE BULL
Packit b099d7
 *
Packit b099d7
 * Permission is hereby granted, free of charge, to any person obtaining a copy
Packit b099d7
 * of this software and associated documentation files (the "Software"), to
Packit b099d7
 * deal in the Software without restriction, including without limitation the
Packit b099d7
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
Packit b099d7
 * sell copies of the Software, and to permit persons to whom the Software is
Packit b099d7
 * furnished to do so, subject to the following conditions:
Packit b099d7
 *
Packit b099d7
 * The above copyright notice and this permission notice shall be included in
Packit b099d7
 * all copies or substantial portions of the Software.
Packit b099d7
 *
Packit b099d7
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Packit b099d7
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Packit b099d7
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
Packit b099d7
 * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
Packit b099d7
 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
Packit b099d7
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Packit b099d7
 *
Packit b099d7
 * Except as contained in this notice, the name of GROUPE BULL shall not be
Packit b099d7
 * used in advertising or otherwise to promote the sale, use or other dealings
Packit b099d7
 * in this Software without prior written authorization from GROUPE BULL.
Packit b099d7
 */
Packit b099d7
Packit b099d7
/*****************************************************************************\
Packit b099d7
*  Info.c:                                                                    *
Packit b099d7
*                                                                             *
Packit b099d7
*  XPM library                                                                *
Packit b099d7
*  Functions related to the XpmInfo structure.                                *
Packit b099d7
*                                                                             *
Packit b099d7
*  Developed by Arnaud Le Hors                                                *
Packit b099d7
\*****************************************************************************/
Packit b099d7
Packit b099d7
#ifdef HAVE_CONFIG_H
Packit b099d7
#include <config.h>
Packit b099d7
#endif
Packit b099d7
Packit b099d7
Packit b099d7
#include "XpmI.h"
Packit b099d7
Packit b099d7
/*
Packit b099d7
 * Init returned data to free safely later on
Packit b099d7
 */
Packit b099d7
void
Packit b099d7
xpmInitXpmInfo(info)
Packit b099d7
    XpmInfo *info;
Packit b099d7
{
Packit b099d7
    if (info) {
Packit b099d7
	info->hints_cmt = NULL;
Packit b099d7
	info->colors_cmt = NULL;
Packit b099d7
	info->pixels_cmt = NULL;
Packit b099d7
	info->extensions = NULL;
Packit b099d7
	info->nextensions = 0;
Packit b099d7
    }
Packit b099d7
}
Packit b099d7
Packit b099d7
/*
Packit b099d7
 * Free the XpmInfo data which have been allocated
Packit b099d7
 */
Packit b099d7
void
Packit b099d7
XpmFreeXpmInfo(info)
Packit b099d7
    XpmInfo *info;
Packit b099d7
{
Packit b099d7
    if (info) {
Packit b099d7
	if (info->valuemask & XpmComments) {
Packit b099d7
	    if (info->hints_cmt) {
Packit b099d7
		XpmFree(info->hints_cmt);
Packit b099d7
		info->hints_cmt = NULL;
Packit b099d7
	    }
Packit b099d7
	    if (info->colors_cmt) {
Packit b099d7
		XpmFree(info->colors_cmt);
Packit b099d7
		info->colors_cmt = NULL;
Packit b099d7
	    }
Packit b099d7
	    if (info->pixels_cmt) {
Packit b099d7
		XpmFree(info->pixels_cmt);
Packit b099d7
		info->pixels_cmt = NULL;
Packit b099d7
	    }
Packit b099d7
	}
Packit b099d7
	if (info->valuemask & XpmReturnExtensions && info->nextensions) {
Packit b099d7
	    XpmFreeExtensions(info->extensions, info->nextensions);
Packit b099d7
	    info->extensions = NULL;
Packit b099d7
	    info->nextensions = 0;
Packit b099d7
	}
Packit b099d7
	info->valuemask = 0;
Packit b099d7
    }
Packit b099d7
}
Packit b099d7
Packit b099d7
/*
Packit b099d7
 * Set the XpmInfo valuemask to retrieve required info
Packit b099d7
 */
Packit b099d7
void
Packit b099d7
xpmSetInfoMask(info, attributes)
Packit b099d7
    XpmInfo *info;
Packit b099d7
    XpmAttributes *attributes;
Packit b099d7
{
Packit b099d7
    info->valuemask = 0;
Packit b099d7
    if (attributes->valuemask & XpmReturnInfos)
Packit b099d7
	info->valuemask |= XpmReturnComments;
Packit b099d7
    if (attributes->valuemask & XpmReturnExtensions)
Packit b099d7
	info->valuemask |= XpmReturnExtensions;
Packit b099d7
}
Packit b099d7
Packit b099d7
/*
Packit b099d7
 * Fill in the XpmInfo with the XpmAttributes
Packit b099d7
 */
Packit b099d7
void
Packit b099d7
xpmSetInfo(info, attributes)
Packit b099d7
    XpmInfo *info;
Packit b099d7
    XpmAttributes *attributes;
Packit b099d7
{
Packit b099d7
    info->valuemask = 0;
Packit b099d7
    if (attributes->valuemask & XpmInfos) {
Packit b099d7
	info->valuemask |= XpmComments | XpmColorTable;
Packit b099d7
	info->hints_cmt = attributes->hints_cmt;
Packit b099d7
	info->colors_cmt = attributes->colors_cmt;
Packit b099d7
	info->pixels_cmt = attributes->pixels_cmt;
Packit b099d7
    }
Packit b099d7
    if (attributes->valuemask & XpmExtensions) {
Packit b099d7
	info->valuemask |= XpmExtensions;
Packit b099d7
	info->extensions = attributes->extensions;
Packit b099d7
	info->nextensions = attributes->nextensions;
Packit b099d7
    }
Packit b099d7
    if (attributes->valuemask & XpmHotspot) {
Packit b099d7
	info->valuemask |= XpmHotspot;
Packit b099d7
	info->x_hotspot = attributes->x_hotspot;
Packit b099d7
	info->y_hotspot = attributes->y_hotspot;
Packit b099d7
    }
Packit b099d7
}