Info.c revision a966c04f
1a966c04fSmrg/* 2a966c04fSmrg * Copyright (C) 1989-95 GROUPE BULL 3a966c04fSmrg * 4a966c04fSmrg * Permission is hereby granted, free of charge, to any person obtaining a copy 5a966c04fSmrg * of this software and associated documentation files (the "Software"), to 6a966c04fSmrg * deal in the Software without restriction, including without limitation the 7a966c04fSmrg * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8a966c04fSmrg * sell copies of the Software, and to permit persons to whom the Software is 9a966c04fSmrg * furnished to do so, subject to the following conditions: 10a966c04fSmrg * 11a966c04fSmrg * The above copyright notice and this permission notice shall be included in 12a966c04fSmrg * all copies or substantial portions of the Software. 13a966c04fSmrg * 14a966c04fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15a966c04fSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16a966c04fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17a966c04fSmrg * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18a966c04fSmrg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19a966c04fSmrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20a966c04fSmrg * 21a966c04fSmrg * Except as contained in this notice, the name of GROUPE BULL shall not be 22a966c04fSmrg * used in advertising or otherwise to promote the sale, use or other dealings 23a966c04fSmrg * in this Software without prior written authorization from GROUPE BULL. 24a966c04fSmrg */ 25a966c04fSmrg 26a966c04fSmrg/*****************************************************************************\ 27a966c04fSmrg* Info.c: * 28a966c04fSmrg* * 29a966c04fSmrg* XPM library * 30a966c04fSmrg* Functions related to the XpmInfo structure. * 31a966c04fSmrg* * 32a966c04fSmrg* Developed by Arnaud Le Hors * 33a966c04fSmrg\*****************************************************************************/ 34a966c04fSmrg 35a966c04fSmrg#ifdef HAVE_CONFIG_H 36a966c04fSmrg#include <config.h> 37a966c04fSmrg#endif 38a966c04fSmrg#include "XpmI.h" 39a966c04fSmrg 40a966c04fSmrg/* 41a966c04fSmrg * Init returned data to free safely later on 42a966c04fSmrg */ 43a966c04fSmrgvoid 44a966c04fSmrgxpmInitXpmInfo(info) 45a966c04fSmrg XpmInfo *info; 46a966c04fSmrg{ 47a966c04fSmrg if (info) { 48a966c04fSmrg info->hints_cmt = NULL; 49a966c04fSmrg info->colors_cmt = NULL; 50a966c04fSmrg info->pixels_cmt = NULL; 51a966c04fSmrg info->extensions = NULL; 52a966c04fSmrg info->nextensions = 0; 53a966c04fSmrg } 54a966c04fSmrg} 55a966c04fSmrg 56a966c04fSmrg/* 57a966c04fSmrg * Free the XpmInfo data which have been allocated 58a966c04fSmrg */ 59a966c04fSmrgvoid 60a966c04fSmrgXpmFreeXpmInfo(info) 61a966c04fSmrg XpmInfo *info; 62a966c04fSmrg{ 63a966c04fSmrg if (info) { 64a966c04fSmrg if (info->valuemask & XpmComments) { 65a966c04fSmrg if (info->hints_cmt) { 66a966c04fSmrg XpmFree(info->hints_cmt); 67a966c04fSmrg info->hints_cmt = NULL; 68a966c04fSmrg } 69a966c04fSmrg if (info->colors_cmt) { 70a966c04fSmrg XpmFree(info->colors_cmt); 71a966c04fSmrg info->colors_cmt = NULL; 72a966c04fSmrg } 73a966c04fSmrg if (info->pixels_cmt) { 74a966c04fSmrg XpmFree(info->pixels_cmt); 75a966c04fSmrg info->pixels_cmt = NULL; 76a966c04fSmrg } 77a966c04fSmrg } 78a966c04fSmrg if (info->valuemask & XpmReturnExtensions && info->nextensions) { 79a966c04fSmrg XpmFreeExtensions(info->extensions, info->nextensions); 80a966c04fSmrg info->extensions = NULL; 81a966c04fSmrg info->nextensions = 0; 82a966c04fSmrg } 83a966c04fSmrg info->valuemask = 0; 84a966c04fSmrg } 85a966c04fSmrg} 86a966c04fSmrg 87a966c04fSmrg/* 88a966c04fSmrg * Set the XpmInfo valuemask to retrieve required info 89a966c04fSmrg */ 90a966c04fSmrgvoid 91a966c04fSmrgxpmSetInfoMask(info, attributes) 92a966c04fSmrg XpmInfo *info; 93a966c04fSmrg XpmAttributes *attributes; 94a966c04fSmrg{ 95a966c04fSmrg info->valuemask = 0; 96a966c04fSmrg if (attributes->valuemask & XpmReturnInfos) 97a966c04fSmrg info->valuemask |= XpmReturnComments; 98a966c04fSmrg if (attributes->valuemask & XpmReturnExtensions) 99a966c04fSmrg info->valuemask |= XpmReturnExtensions; 100a966c04fSmrg} 101a966c04fSmrg 102a966c04fSmrg/* 103a966c04fSmrg * Fill in the XpmInfo with the XpmAttributes 104a966c04fSmrg */ 105a966c04fSmrgvoid 106a966c04fSmrgxpmSetInfo(info, attributes) 107a966c04fSmrg XpmInfo *info; 108a966c04fSmrg XpmAttributes *attributes; 109a966c04fSmrg{ 110a966c04fSmrg info->valuemask = 0; 111a966c04fSmrg if (attributes->valuemask & XpmInfos) { 112a966c04fSmrg info->valuemask |= XpmComments | XpmColorTable; 113a966c04fSmrg info->hints_cmt = attributes->hints_cmt; 114a966c04fSmrg info->colors_cmt = attributes->colors_cmt; 115a966c04fSmrg info->pixels_cmt = attributes->pixels_cmt; 116a966c04fSmrg } 117a966c04fSmrg if (attributes->valuemask & XpmExtensions) { 118a966c04fSmrg info->valuemask |= XpmExtensions; 119a966c04fSmrg info->extensions = attributes->extensions; 120a966c04fSmrg info->nextensions = attributes->nextensions; 121a966c04fSmrg } 122a966c04fSmrg if (attributes->valuemask & XpmHotspot) { 123a966c04fSmrg info->valuemask |= XpmHotspot; 124a966c04fSmrg info->x_hotspot = attributes->x_hotspot; 125a966c04fSmrg info->y_hotspot = attributes->y_hotspot; 126a966c04fSmrg } 127a966c04fSmrg} 128