1444c061aSmrg/*********************************************************** 2fdf6a26fSmrgCopyright (c) 1993, Oracle and/or its affiliates. 31477040fSmrg 41477040fSmrgPermission is hereby granted, free of charge, to any person obtaining a 51477040fSmrgcopy of this software and associated documentation files (the "Software"), 61477040fSmrgto deal in the Software without restriction, including without limitation 71477040fSmrgthe rights to use, copy, modify, merge, publish, distribute, sublicense, 81477040fSmrgand/or sell copies of the Software, and to permit persons to whom the 91477040fSmrgSoftware is furnished to do so, subject to the following conditions: 101477040fSmrg 111477040fSmrgThe above copyright notice and this permission notice (including the next 121477040fSmrgparagraph) shall be included in all copies or substantial portions of the 131477040fSmrgSoftware. 141477040fSmrg 151477040fSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 161477040fSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 171477040fSmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 181477040fSmrgTHE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 191477040fSmrgLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 201477040fSmrgFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 211477040fSmrgDEALINGS IN THE SOFTWARE. 221477040fSmrg 231477040fSmrgCopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts. 24444c061aSmrg 25444c061aSmrg All Rights Reserved 26444c061aSmrg 271477040fSmrgPermission to use, copy, modify, and distribute this software and its 281477040fSmrgdocumentation for any purpose and without fee is hereby granted, 29444c061aSmrgprovided that the above copyright notice appear in all copies and that 301477040fSmrgboth that copyright notice and this permission notice appear in 311477040fSmrgsupporting documentation, and that the name of Digital not be 32444c061aSmrgused in advertising or publicity pertaining to distribution of the 331477040fSmrgsoftware without specific, written prior permission. 34444c061aSmrg 35444c061aSmrgDIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 36444c061aSmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 37444c061aSmrgDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 38444c061aSmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 39444c061aSmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 40444c061aSmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 41444c061aSmrgSOFTWARE. 42444c061aSmrg 43444c061aSmrg******************************************************************/ 44444c061aSmrg 45444c061aSmrg/* 46444c061aSmrg 47444c061aSmrgCopyright 1987, 1988, 1994, 1998 The Open Group 48444c061aSmrg 49444c061aSmrgPermission to use, copy, modify, distribute, and sell this software and its 50444c061aSmrgdocumentation for any purpose is hereby granted without fee, provided that 51444c061aSmrgthe above copyright notice appear in all copies and that both that 52444c061aSmrgcopyright notice and this permission notice appear in supporting 53444c061aSmrgdocumentation. 54444c061aSmrg 55444c061aSmrgThe above copyright notice and this permission notice shall be included in 56444c061aSmrgall copies or substantial portions of the Software. 57444c061aSmrg 58444c061aSmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 59444c061aSmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 60444c061aSmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 61444c061aSmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 62444c061aSmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 63444c061aSmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 64444c061aSmrg 65444c061aSmrgExcept as contained in this notice, the name of The Open Group shall not be 66444c061aSmrgused in advertising or otherwise to promote the sale, use or other dealings 67444c061aSmrgin this Software without prior written authorization from The Open Group. 68444c061aSmrg 69444c061aSmrg*/ 70444c061aSmrg 71444c061aSmrg#ifdef HAVE_CONFIG_H 72444c061aSmrg#include <config.h> 73444c061aSmrg#endif 74444c061aSmrg#include "IntrinsicI.h" 75444c061aSmrg#include "VarargsI.h" 76444c061aSmrg#include "Shell.h" 77444c061aSmrg#include "ShellP.h" 78444c061aSmrg#include "StringDefs.h" 79444c061aSmrg#include <stdio.h> 80444c061aSmrg 81a3bd7f05Smrgstatic XrmClass QBoolean, QString, QCallProc, QImmediate; 82444c061aSmrgstatic XrmName QinitialResourcesPersistent, QInitialResourcesPersistent; 83444c061aSmrgstatic XrmClass QTranslations, QTranslationTable; 84444c061aSmrgstatic XrmName Qtranslations, QbaseTranslations; 85444c061aSmrgstatic XrmName Qscreen; 86444c061aSmrgstatic XrmClass QScreen; 87444c061aSmrg 88a3bd7f05Smrgvoid 89a3bd7f05Smrg_XtCopyFromParent(Widget widget, int offset, XrmValue *value) 90444c061aSmrg{ 91444c061aSmrg if (widget->core.parent == NULL) { 92a3bd7f05Smrg XtAppWarningMsg(XtWidgetToApplicationContext(widget), 93a3bd7f05Smrg "invalidParent", "xtCopyFromParent", XtCXtToolkitError, 94a3bd7f05Smrg "CopyFromParent must have non-NULL parent", NULL, NULL); 95444c061aSmrg value->addr = NULL; 96444c061aSmrg return; 97444c061aSmrg } 98a3bd7f05Smrg value->addr = (XPointer) (((char *) widget->core.parent) + offset); 99a3bd7f05Smrg} /* _XtCopyFromParent */ 100444c061aSmrg 101a3bd7f05Smrgvoid 102a3bd7f05Smrg_XtCopyFromArg(XtArgVal src, char *dst, register unsigned int size) 103444c061aSmrg{ 104444c061aSmrg if (size > sizeof(XtArgVal)) 105a3bd7f05Smrg (void) memmove((char *) dst, (char *) src, (size_t) size); 106444c061aSmrg else { 107a3bd7f05Smrg union { 108a3bd7f05Smrg long longval; 109444c061aSmrg#ifdef LONG64 110a3bd7f05Smrg int intval; 111444c061aSmrg#endif 112a3bd7f05Smrg short shortval; 113a3bd7f05Smrg char charval; 114a3bd7f05Smrg char *charptr; 115a3bd7f05Smrg XtPointer ptr; 116a3bd7f05Smrg } u; 117a3bd7f05Smrg char *p = (char *) &u; 118a3bd7f05Smrg 119a3bd7f05Smrg if (size == sizeof(long)) 120a3bd7f05Smrg u.longval = (long) src; 121444c061aSmrg#ifdef LONG64 122a3bd7f05Smrg else if (size == sizeof(int)) 123a3bd7f05Smrg u.intval = (int) src; 124444c061aSmrg#endif 125a3bd7f05Smrg else if (size == sizeof(short)) 126a3bd7f05Smrg u.shortval = (short) src; 127a3bd7f05Smrg else if (size == sizeof(char)) 128a3bd7f05Smrg u.charval = (char) src; 129a3bd7f05Smrg else if (size == sizeof(XtPointer)) 130a3bd7f05Smrg u.ptr = (XtPointer) src; 131a3bd7f05Smrg else if (size == sizeof(char *)) 132a3bd7f05Smrg u.charptr = (char *) src; 133a3bd7f05Smrg else 134a3bd7f05Smrg p = (char *) &src; 135a3bd7f05Smrg 136fdf6a26fSmrg (void) memcpy(dst, p, (size_t) size); 137444c061aSmrg } 138a3bd7f05Smrg} /* _XtCopyFromArg */ 139444c061aSmrg 140a3bd7f05Smrgvoid 141a3bd7f05Smrg_XtCopyToArg(char *src, XtArgVal *dst, register unsigned int size) 142444c061aSmrg{ 143444c061aSmrg if (!*dst) { 144444c061aSmrg#ifdef GETVALUES_BUG 145a3bd7f05Smrg /* old GetValues semantics (storing directly into arglists) are bad, 146a3bd7f05Smrg * but preserve for compatibility as long as arglist contains NULL. 147a3bd7f05Smrg */ 148a3bd7f05Smrg union { 149a3bd7f05Smrg long longval; 150444c061aSmrg#ifdef LONG64 151a3bd7f05Smrg int intval; 152444c061aSmrg#endif 153a3bd7f05Smrg short shortval; 154a3bd7f05Smrg char charval; 155a3bd7f05Smrg char *charptr; 156a3bd7f05Smrg XtPointer ptr; 157a3bd7f05Smrg } u; 158a3bd7f05Smrg 159a3bd7f05Smrg if (size <= sizeof(XtArgVal)) { 160fdf6a26fSmrg (void) memcpy(&u, src, (size_t) size); 161a3bd7f05Smrg if (size == sizeof(long)) 162a3bd7f05Smrg *dst = (XtArgVal) u.longval; 163444c061aSmrg#ifdef LONG64 164a3bd7f05Smrg else if (size == sizeof(int)) 165a3bd7f05Smrg *dst = (XtArgVal) u.intval; 166444c061aSmrg#endif 167a3bd7f05Smrg else if (size == sizeof(short)) 168a3bd7f05Smrg *dst = (XtArgVal) u.shortval; 169a3bd7f05Smrg else if (size == sizeof(char)) 170a3bd7f05Smrg *dst = (XtArgVal) u.charval; 171a3bd7f05Smrg else if (size == sizeof(char *)) 172a3bd7f05Smrg *dst = (XtArgVal) u.charptr; 173a3bd7f05Smrg else if (size == sizeof(XtPointer)) 174a3bd7f05Smrg *dst = (XtArgVal) u.ptr; 175a3bd7f05Smrg else 176a3bd7f05Smrg (void) memmove((char *) dst, (char *) src, (size_t) size); 177a3bd7f05Smrg } 178a3bd7f05Smrg else 179a3bd7f05Smrg (void) memmove((char *) dst, (char *) src, (size_t) size); 180444c061aSmrg#else 181a3bd7f05Smrg XtErrorMsg("invalidGetValues", "xtGetValues", XtCXtToolkitError, 182a3bd7f05Smrg "NULL ArgVal in XtGetValues", NULL, NULL); 183444c061aSmrg#endif 184444c061aSmrg } 185444c061aSmrg else { 186a3bd7f05Smrg /* proper GetValues semantics: argval is pointer to destination */ 187a3bd7f05Smrg (void) memmove((char *) *dst, (char *) src, (size_t) size); 188444c061aSmrg } 189a3bd7f05Smrg} /* _XtCopyToArg */ 190444c061aSmrg 191a3bd7f05Smrgstatic void 192a3bd7f05SmrgCopyToArg(char *src, XtArgVal *dst, register unsigned int size) 193444c061aSmrg{ 194444c061aSmrg if (!*dst) { 195a3bd7f05Smrg /* old GetValues semantics (storing directly into arglists) are bad, 196a3bd7f05Smrg * but preserve for compatibility as long as arglist contains NULL. 197a3bd7f05Smrg */ 198a3bd7f05Smrg union { 199a3bd7f05Smrg long longval; 200444c061aSmrg#ifdef LONG64 201a3bd7f05Smrg int intval; 202444c061aSmrg#endif 203a3bd7f05Smrg short shortval; 204a3bd7f05Smrg char charval; 205a3bd7f05Smrg char *charptr; 206a3bd7f05Smrg XtPointer ptr; 207a3bd7f05Smrg } u; 208a3bd7f05Smrg 209a3bd7f05Smrg if (size <= sizeof(XtArgVal)) { 210fdf6a26fSmrg (void) memcpy(&u, src, (size_t) size); 211a3bd7f05Smrg if (size == sizeof(long)) 212a3bd7f05Smrg *dst = (XtArgVal) u.longval; 213444c061aSmrg#ifdef LONG64 214a3bd7f05Smrg else if (size == sizeof(int)) 215a3bd7f05Smrg *dst = (XtArgVal) u.intval; 216444c061aSmrg#endif 217a3bd7f05Smrg else if (size == sizeof(short)) 218a3bd7f05Smrg *dst = (XtArgVal) u.shortval; 219a3bd7f05Smrg else if (size == sizeof(char)) 220a3bd7f05Smrg *dst = (XtArgVal) u.charval; 221a3bd7f05Smrg else if (size == sizeof(char *)) 222a3bd7f05Smrg *dst = (XtArgVal) u.charptr; 223a3bd7f05Smrg else if (size == sizeof(XtPointer)) 224a3bd7f05Smrg *dst = (XtArgVal) u.ptr; 225a3bd7f05Smrg else 226a3bd7f05Smrg (void) memmove((char *) dst, (char *) src, (size_t) size); 227a3bd7f05Smrg } 228a3bd7f05Smrg else 229a3bd7f05Smrg (void) memmove((char *) dst, (char *) src, (size_t) size); 230444c061aSmrg } 231444c061aSmrg else { 232a3bd7f05Smrg /* proper GetValues semantics: argval is pointer to destination */ 233a3bd7f05Smrg (void) memmove((char *) *dst, (char *) src, (size_t) size); 234444c061aSmrg } 235a3bd7f05Smrg} /* CopyToArg */ 236444c061aSmrg 237a3bd7f05Smrgstatic Cardinal 238a3bd7f05SmrgCountTreeDepth(Widget w) 239444c061aSmrg{ 240444c061aSmrg Cardinal count; 241444c061aSmrg 2429e7bcd65Smrg for (count = 1; w != NULL; w = (Widget) w->core.parent) 243a3bd7f05Smrg count++; 244444c061aSmrg 245444c061aSmrg return count; 246444c061aSmrg} 247444c061aSmrg 248a3bd7f05Smrgstatic void 249a3bd7f05SmrgGetNamesAndClasses(register Widget w, 250a3bd7f05Smrg register XrmNameList names, 251a3bd7f05Smrg register XrmClassList classes) 252444c061aSmrg{ 253444c061aSmrg register Cardinal length, j; 254444c061aSmrg register XrmQuark t; 255444c061aSmrg WidgetClass class; 256444c061aSmrg 257444c061aSmrg /* Return null-terminated quark arrays, with length the number of 258444c061aSmrg quarks (not including NULL) */ 259444c061aSmrg 260444c061aSmrg LOCK_PROCESS; 261444c061aSmrg for (length = 0; w != NULL; w = (Widget) w->core.parent) { 262a3bd7f05Smrg names[length] = w->core.xrm_name; 263a3bd7f05Smrg class = XtClass(w); 264a3bd7f05Smrg /* KLUDGE KLUDGE KLUDGE KLUDGE */ 265a3bd7f05Smrg if (w->core.parent == NULL && XtIsApplicationShell(w)) { 266a3bd7f05Smrg classes[length] = 267a3bd7f05Smrg ((ApplicationShellWidget) w)->application.xrm_class; 268a3bd7f05Smrg } 269a3bd7f05Smrg else 270a3bd7f05Smrg classes[length] = class->core_class.xrm_class; 271a3bd7f05Smrg length++; 272a3bd7f05Smrg } 273444c061aSmrg UNLOCK_PROCESS; 274444c061aSmrg /* They're in backwards order, flop them around */ 275a3bd7f05Smrg for (j = 0; j < length / 2; j++) { 276a3bd7f05Smrg t = names[j]; 277a3bd7f05Smrg names[j] = names[length - j - 1]; 278a3bd7f05Smrg names[length - j - 1] = t; 279444c061aSmrg t = classes[j]; 280a3bd7f05Smrg classes[j] = classes[length - j - 1]; 281a3bd7f05Smrg classes[length - j - 1] = t; 282444c061aSmrg } 283444c061aSmrg names[length] = NULLQUARK; 284444c061aSmrg classes[length] = NULLQUARK; 285a3bd7f05Smrg} /* GetNamesAndClasses */ 286444c061aSmrg 287a3bd7f05Smrg/* Spiffy fast compiled form of resource list. */ 288a3bd7f05Smrg/* XtResourceLists are compiled in-place into XrmResourceLists */ 289a3bd7f05Smrg/* All atoms are replaced by quarks, and offsets are -offset-1 to */ 290a3bd7f05Smrg/* indicate that this list has been compiled already */ 291444c061aSmrg 292a3bd7f05Smrgvoid 293a3bd7f05Smrg_XtCompileResourceList(register XtResourceList resources, 294a3bd7f05Smrg Cardinal num_resources) 295444c061aSmrg{ 296444c061aSmrg register Cardinal count; 297444c061aSmrg 298444c061aSmrg#define xrmres ((XrmResourceList) resources) 299444c061aSmrg#define PSToQ XrmPermStringToQuark 300444c061aSmrg 301444c061aSmrg for (count = 0; count < num_resources; resources++, count++) { 302a3bd7f05Smrg xrmres->xrm_name = PSToQ(resources->resource_name); 303a3bd7f05Smrg xrmres->xrm_class = PSToQ(resources->resource_class); 304a3bd7f05Smrg xrmres->xrm_type = PSToQ(resources->resource_type); 305a3bd7f05Smrg xrmres->xrm_offset = (int) 306a3bd7f05Smrg (-(int) resources->resource_offset - 1); 307a3bd7f05Smrg xrmres->xrm_default_type = PSToQ(resources->default_type); 308444c061aSmrg } 309444c061aSmrg#undef PSToQ 310444c061aSmrg#undef xrmres 311a3bd7f05Smrg} /* _XtCompileResourceList */ 312444c061aSmrg 313444c061aSmrg/* Like _XtCompileResourceList, but strings are not permanent */ 314a3bd7f05Smrgstatic void 315a3bd7f05SmrgXrmCompileResourceListEphem(register XtResourceList resources, 316a3bd7f05Smrg Cardinal num_resources) 317444c061aSmrg{ 318444c061aSmrg register Cardinal count; 319444c061aSmrg 320444c061aSmrg#define xrmres ((XrmResourceList) resources) 321444c061aSmrg 322444c061aSmrg for (count = 0; count < num_resources; resources++, count++) { 323a3bd7f05Smrg xrmres->xrm_name = StringToName(resources->resource_name); 324a3bd7f05Smrg xrmres->xrm_class = StringToClass(resources->resource_class); 325a3bd7f05Smrg xrmres->xrm_type = StringToQuark(resources->resource_type); 326a3bd7f05Smrg xrmres->xrm_offset = (int) 327a3bd7f05Smrg (-(int) resources->resource_offset - 1); 328a3bd7f05Smrg xrmres->xrm_default_type = StringToQuark(resources->default_type); 329444c061aSmrg } 330444c061aSmrg#undef xrmres 331a3bd7f05Smrg} /* XrmCompileResourceListEphem */ 332444c061aSmrg 333a3bd7f05Smrgstatic void 334a3bd7f05SmrgBadSize(Cardinal size, XrmQuark name) 335444c061aSmrg{ 336444c061aSmrg String params[2]; 337444c061aSmrg Cardinal num_params = 2; 338444c061aSmrg 339fdf6a26fSmrg params[0] = (String) (XtIntPtr) size; 340444c061aSmrg params[1] = XrmQuarkToString(name); 341444c061aSmrg XtWarningMsg("invalidSizeOverride", "xtDependencies", XtCXtToolkitError, 342a3bd7f05Smrg "Representation size %d must match superclass's to override %s", 343a3bd7f05Smrg params, &num_params); 344a3bd7f05Smrg} /* BadType */ 345444c061aSmrg 346444c061aSmrg/* 347444c061aSmrg * Create a new resource list, with the class resources following the 348444c061aSmrg * superclass's resources. If a resource in the class list overrides 349444c061aSmrg * a superclass resource, then just replace the superclass entry in place. 350444c061aSmrg * 351444c061aSmrg * At the same time, add a level of indirection to the XtResourceList to 352444c061aSmrg * create and XrmResourceList. 353444c061aSmrg */ 354a3bd7f05Smrgvoid 355a3bd7f05Smrg_XtDependencies(XtResourceList *class_resp, /* VAR */ 356a3bd7f05Smrg Cardinal *class_num_resp, /* VAR */ 357a3bd7f05Smrg XrmResourceList *super_res, 358a3bd7f05Smrg Cardinal super_num_res, 359a3bd7f05Smrg Cardinal super_widget_size) 360444c061aSmrg{ 361444c061aSmrg register XrmResourceList *new_res; 362a3bd7f05Smrg Cardinal new_num_res; 363a3bd7f05Smrg XrmResourceList class_res = (XrmResourceList) *class_resp; 364a3bd7f05Smrg Cardinal class_num_res = *class_num_resp; 365a3bd7f05Smrg register Cardinal i, j; 366a3bd7f05Smrg Cardinal new_next; 367444c061aSmrg 368444c061aSmrg if (class_num_res == 0) { 369a3bd7f05Smrg /* Just point to superclass resource list */ 370a3bd7f05Smrg *class_resp = (XtResourceList) super_res; 371a3bd7f05Smrg *class_num_resp = super_num_res; 372a3bd7f05Smrg return; 373444c061aSmrg } 374444c061aSmrg 375444c061aSmrg /* Allocate and initialize new_res with superclass resource pointers */ 376444c061aSmrg new_num_res = super_num_res + class_num_res; 377fdf6a26fSmrg new_res = XtMallocArray(new_num_res, (Cardinal) sizeof(XrmResourceList)); 378444c061aSmrg if (super_num_res > 0) 379fdf6a26fSmrg memcpy(new_res, super_res, super_num_res * sizeof(XrmResourceList)); 3809e7bcd65Smrg 381444c061aSmrg /* Put pointers to class resource entries into new_res */ 382444c061aSmrg new_next = super_num_res; 383444c061aSmrg for (i = 0; i < class_num_res; i++) { 384a3bd7f05Smrg if ((Cardinal) (-class_res[i].xrm_offset - 1) < super_widget_size) { 385a3bd7f05Smrg /* Probably an override of superclass resources--look for overlap */ 386a3bd7f05Smrg for (j = 0; j < super_num_res; j++) { 387a3bd7f05Smrg if (class_res[i].xrm_offset == new_res[j]->xrm_offset) { 388a3bd7f05Smrg /* Spec is silent on what fields subclass can override. 389a3bd7f05Smrg * The only two of real concern are type & size. 390a3bd7f05Smrg * Although allowing type to be over-ridden introduces 391a3bd7f05Smrg * the possibility of errors, it's at present the only 392a3bd7f05Smrg * reasonable way to allow a subclass to force a private 393a3bd7f05Smrg * converter to be invoked for a subset of fields. 394a3bd7f05Smrg */ 395a3bd7f05Smrg /* We do insist that size be identical to superclass */ 396a3bd7f05Smrg if (class_res[i].xrm_size != new_res[j]->xrm_size) { 397a3bd7f05Smrg BadSize(class_res[i].xrm_size, 398a3bd7f05Smrg (XrmQuark) class_res[i].xrm_name); 399a3bd7f05Smrg class_res[i].xrm_size = new_res[j]->xrm_size; 400a3bd7f05Smrg } 401a3bd7f05Smrg new_res[j] = &(class_res[i]); 402a3bd7f05Smrg new_num_res--; 403a3bd7f05Smrg goto NextResource; 404a3bd7f05Smrg } 405a3bd7f05Smrg } /* for j */ 406a3bd7f05Smrg } 407a3bd7f05Smrg /* Not an overlap, add an entry to new_res */ 408a3bd7f05Smrg new_res[new_next++] = &(class_res[i]); 409a3bd7f05Smrg NextResource:; 410a3bd7f05Smrg } /* for i */ 411444c061aSmrg 412444c061aSmrg /* Okay, stuff new resources back into class record */ 413444c061aSmrg *class_resp = (XtResourceList) new_res; 414444c061aSmrg *class_num_resp = new_num_res; 415a3bd7f05Smrg} /* _XtDependencies */ 416444c061aSmrg 417a3bd7f05Smrgvoid 418a3bd7f05Smrg_XtResourceDependencies(WidgetClass wc) 419444c061aSmrg{ 420444c061aSmrg WidgetClass sc; 421444c061aSmrg 422444c061aSmrg sc = wc->core_class.superclass; 423444c061aSmrg if (sc == NULL) { 424a3bd7f05Smrg _XtDependencies(&(wc->core_class.resources), 425a3bd7f05Smrg &(wc->core_class.num_resources), 426a3bd7f05Smrg (XrmResourceList *) NULL, (unsigned) 0, (unsigned) 0); 427a3bd7f05Smrg } 428a3bd7f05Smrg else { 429a3bd7f05Smrg _XtDependencies(&(wc->core_class.resources), 430a3bd7f05Smrg &(wc->core_class.num_resources), 431a3bd7f05Smrg (XrmResourceList *) sc->core_class.resources, 432a3bd7f05Smrg sc->core_class.num_resources, 433a3bd7f05Smrg sc->core_class.widget_size); 434444c061aSmrg } 435a3bd7f05Smrg} /* _XtResourceDependencies */ 436444c061aSmrg 437a3bd7f05Smrgvoid 438a3bd7f05Smrg_XtConstraintResDependencies(ConstraintWidgetClass wc) 439444c061aSmrg{ 440444c061aSmrg if (wc == (ConstraintWidgetClass) constraintWidgetClass) { 441a3bd7f05Smrg _XtDependencies(&(wc->constraint_class.resources), 442a3bd7f05Smrg &(wc->constraint_class.num_resources), 443a3bd7f05Smrg (XrmResourceList *) NULL, (unsigned) 0, (unsigned) 0); 444444c061aSmrg } 445a3bd7f05Smrg else { 446a3bd7f05Smrg ConstraintWidgetClass sc; 447a3bd7f05Smrg 448a3bd7f05Smrg sc = (ConstraintWidgetClass) wc->core_class.superclass; 449a3bd7f05Smrg _XtDependencies(&(wc->constraint_class.resources), 450a3bd7f05Smrg &(wc->constraint_class.num_resources), 451a3bd7f05Smrg (XrmResourceList *) sc->constraint_class.resources, 452a3bd7f05Smrg sc->constraint_class.num_resources, 453a3bd7f05Smrg sc->constraint_class.constraint_size); 454a3bd7f05Smrg } 455a3bd7f05Smrg} /* _XtConstraintResDependencies */ 4569e7bcd65Smrg 457a3bd7f05SmrgXrmResourceList * 458a3bd7f05Smrg_XtCreateIndirectionTable(XtResourceList resources, Cardinal num_resources) 459444c061aSmrg{ 460444c061aSmrg register Cardinal idx; 461a3bd7f05Smrg XrmResourceList *table; 462444c061aSmrg 463fdf6a26fSmrg table = XtMallocArray(num_resources, (Cardinal) sizeof(XrmResourceList)); 464444c061aSmrg for (idx = 0; idx < num_resources; idx++) 465a3bd7f05Smrg table[idx] = (XrmResourceList) (&(resources[idx])); 466444c061aSmrg return table; 467444c061aSmrg} 468444c061aSmrg 469a3bd7f05Smrgstatic XtCacheRef * 470a3bd7f05SmrgGetResources(Widget widget, /* Widget resources are associated with */ 471a3bd7f05Smrg char *base, /* Base address of memory to write to */ 472a3bd7f05Smrg XrmNameList names, /* Full inheritance name of widget */ 473a3bd7f05Smrg XrmClassList classes, /* Full inheritance class of widget */ 474a3bd7f05Smrg XrmResourceList *table, /* The list of resources required. */ 475a3bd7f05Smrg unsigned num_resources, /* number of items in resource list */ 476a3bd7f05Smrg XrmQuarkList quark_args, /* Arg names quarkified */ 477a3bd7f05Smrg ArgList args, /* ArgList to override resources */ 478a3bd7f05Smrg unsigned num_args, /* number of items in arg list */ 479a3bd7f05Smrg XtTypedArgList typed_args, /* Typed arg list to override resources */ 480a3bd7f05Smrg Cardinal *pNumTypedArgs, /* number of items in typed arg list */ 481a3bd7f05Smrg Boolean tm_hack) /* do baseTranslations */ 482a3bd7f05Smrg{ 483444c061aSmrg/* 484444c061aSmrg * assert: *pNumTypedArgs == 0 if num_args > 0 485444c061aSmrg * assert: num_args == 0 if *pNumTypedArgs > 0 486444c061aSmrg */ 487444c061aSmrg#define SEARCHLISTLEN 100 488444c061aSmrg#define MAXRESOURCES 400 489444c061aSmrg 490a3bd7f05Smrg XrmValue value; 491a3bd7f05Smrg XrmQuark rawType; 492a3bd7f05Smrg XrmValue convValue; 493a3bd7f05Smrg XrmHashTable stackSearchList[SEARCHLISTLEN]; 494a3bd7f05Smrg XrmHashTable *searchList = stackSearchList; 495a3bd7f05Smrg unsigned int searchListSize = SEARCHLISTLEN; 496a3bd7f05Smrg Boolean found[MAXRESOURCES]; 497a3bd7f05Smrg int typed[MAXRESOURCES]; 498a3bd7f05Smrg XtCacheRef cache_ref[MAXRESOURCES]; 499a3bd7f05Smrg XtCacheRef *cache_ptr, *cache_base; 500a3bd7f05Smrg Boolean persistent_resources = True; 501a3bd7f05Smrg Boolean found_persistence = False; 502a3bd7f05Smrg int num_typed_args = (int) *pNumTypedArgs; 503a3bd7f05Smrg XrmDatabase db; 504a3bd7f05Smrg Boolean do_tm_hack = False; 505444c061aSmrg 506444c061aSmrg if ((args == NULL) && (num_args != 0)) { 507a3bd7f05Smrg XtAppWarningMsg(XtWidgetToApplicationContext(widget), 508a3bd7f05Smrg "invalidArgCount", "getResources", XtCXtToolkitError, 509a3bd7f05Smrg "argument count > 0 on NULL argument list", NULL, NULL); 510a3bd7f05Smrg num_args = 0; 511444c061aSmrg } 512444c061aSmrg if (num_resources == 0) { 513a3bd7f05Smrg return NULL; 514a3bd7f05Smrg } 515a3bd7f05Smrg else if (num_resources >= MAXRESOURCES) { 516a3bd7f05Smrg XtAppWarningMsg(XtWidgetToApplicationContext(widget), 517a3bd7f05Smrg "invalidResourceCount", "getResources", 518a3bd7f05Smrg XtCXtToolkitError, "too many resources", NULL, NULL); 519a3bd7f05Smrg return NULL; 520a3bd7f05Smrg } 521a3bd7f05Smrg else if (table == NULL) { 522a3bd7f05Smrg XtAppWarningMsg(XtWidgetToApplicationContext(widget), 523a3bd7f05Smrg "invalidResourceCount", "getResources", 524a3bd7f05Smrg XtCXtToolkitError, 525a3bd7f05Smrg "resource count > 0 on NULL resource list", NULL, NULL); 526a3bd7f05Smrg return NULL; 527444c061aSmrg } 528444c061aSmrg 529444c061aSmrg /* Mark each resource as not found on arg list */ 5300568f49bSmrg memset((void *) found, 0, (size_t) (num_resources * sizeof(Boolean))); 5310568f49bSmrg memset((void *) typed, 0, (size_t) (num_resources * sizeof(int))); 532444c061aSmrg 533444c061aSmrg /* Copy the args into the resources, mark each as found */ 534444c061aSmrg { 535a3bd7f05Smrg register ArgList arg; 536a3bd7f05Smrg register XtTypedArgList typed_arg; 537a3bd7f05Smrg register XrmName argName; 538a3bd7f05Smrg register Cardinal j; 539a3bd7f05Smrg register int i; 540a3bd7f05Smrg register XrmResourceList rx; 541a3bd7f05Smrg register XrmResourceList *res; 542a3bd7f05Smrg 543a3bd7f05Smrg for (arg = args, i = 0; (Cardinal) i < num_args; i++, arg++) { 544a3bd7f05Smrg argName = quark_args[i]; 545a3bd7f05Smrg if (argName == QinitialResourcesPersistent) { 546a3bd7f05Smrg persistent_resources = (Boolean) arg->value; 547a3bd7f05Smrg found_persistence = True; 548a3bd7f05Smrg continue; 549a3bd7f05Smrg } 550a3bd7f05Smrg for (j = 0, res = table; j < num_resources; j++, res++) { 551a3bd7f05Smrg rx = *res; 552a3bd7f05Smrg if (argName == rx->xrm_name) { 553a3bd7f05Smrg _XtCopyFromArg(arg->value, 554a3bd7f05Smrg base - rx->xrm_offset - 1, rx->xrm_size); 555a3bd7f05Smrg found[j] = TRUE; 556a3bd7f05Smrg break; 557a3bd7f05Smrg } 558a3bd7f05Smrg } 559a3bd7f05Smrg } 560a3bd7f05Smrg for (typed_arg = typed_args, i = 0; i < num_typed_args; 561a3bd7f05Smrg i++, typed_arg++) { 562a3bd7f05Smrg register XrmRepresentation argType; 563a3bd7f05Smrg 564a3bd7f05Smrg argName = quark_args[i]; 565a3bd7f05Smrg argType = (typed_arg->type == NULL) ? NULLQUARK 566a3bd7f05Smrg : XrmStringToRepresentation(typed_arg->type); 567a3bd7f05Smrg if (argName == QinitialResourcesPersistent) { 568a3bd7f05Smrg persistent_resources = (Boolean) typed_arg->value; 569a3bd7f05Smrg found_persistence = True; 570a3bd7f05Smrg break; 571a3bd7f05Smrg } 572a3bd7f05Smrg for (j = 0, res = table; j < num_resources; j++, res++) { 573a3bd7f05Smrg rx = *res; 574a3bd7f05Smrg if (argName == rx->xrm_name) { 575a3bd7f05Smrg if (argType != NULLQUARK && argType != rx->xrm_type) { 576a3bd7f05Smrg typed[j] = i + 1; 577a3bd7f05Smrg } 578a3bd7f05Smrg else { 579a3bd7f05Smrg _XtCopyFromArg(typed_arg->value, 580a3bd7f05Smrg base - rx->xrm_offset - 1, rx->xrm_size); 581a3bd7f05Smrg } 582a3bd7f05Smrg found[j] = TRUE; 583a3bd7f05Smrg break; 584a3bd7f05Smrg } 585a3bd7f05Smrg } 586a3bd7f05Smrg } 587444c061aSmrg } 588444c061aSmrg 589444c061aSmrg /* Ask resource manager for a list of database levels that we can 590444c061aSmrg do a single-level search on each resource */ 591444c061aSmrg 592444c061aSmrg db = XtScreenDatabase(XtScreenOfObject(widget)); 593444c061aSmrg while (!XrmQGetSearchList(db, names, classes, 594a3bd7f05Smrg searchList, (int) searchListSize)) { 595a3bd7f05Smrg if (searchList == stackSearchList) 596a3bd7f05Smrg searchList = NULL; 597fdf6a26fSmrg searchListSize *= 2; 598fdf6a26fSmrg searchList = XtReallocArray(searchList, searchListSize, 599fdf6a26fSmrg (Cardinal) sizeof(XrmHashTable)); 600444c061aSmrg } 6019e7bcd65Smrg 602444c061aSmrg if (persistent_resources) 603a3bd7f05Smrg cache_base = NULL; 604444c061aSmrg else 605a3bd7f05Smrg cache_base = cache_ref; 606444c061aSmrg /* geez, this is an ugly mess */ 607444c061aSmrg if (XtIsShell(widget)) { 608a3bd7f05Smrg register XrmResourceList *res; 609a3bd7f05Smrg register Cardinal j; 610a3bd7f05Smrg Screen *oldscreen = widget->core.screen; 611a3bd7f05Smrg 612a3bd7f05Smrg /* look up screen resource first, since real rdb depends on it */ 613a3bd7f05Smrg for (res = table, j = 0; j < num_resources; j++, res++) { 614a3bd7f05Smrg if ((*res)->xrm_name != Qscreen) 615a3bd7f05Smrg continue; 616a3bd7f05Smrg if (typed[j]) { 617a3bd7f05Smrg register XtTypedArg *arg = typed_args + typed[j] - 1; 618a3bd7f05Smrg XrmQuark from_type; 619a3bd7f05Smrg XrmValue from_val, to_val; 620a3bd7f05Smrg 621a3bd7f05Smrg from_type = StringToQuark(arg->type); 622a3bd7f05Smrg from_val.size = (Cardinal) arg->size; 623a3bd7f05Smrg if ((from_type == QString) || 624a3bd7f05Smrg ((unsigned) arg->size > sizeof(XtArgVal))) 625a3bd7f05Smrg from_val.addr = (XPointer) arg->value; 626a3bd7f05Smrg else 627a3bd7f05Smrg from_val.addr = (XPointer) &arg->value; 628a3bd7f05Smrg to_val.size = sizeof(Screen *); 629a3bd7f05Smrg to_val.addr = (XPointer) &widget->core.screen; 630a3bd7f05Smrg found[j] = _XtConvert(widget, from_type, &from_val, 631a3bd7f05Smrg QScreen, &to_val, cache_base); 632a3bd7f05Smrg if (cache_base && *cache_base) 633a3bd7f05Smrg cache_base++; 634a3bd7f05Smrg } 635a3bd7f05Smrg if (!found[j]) { 636a3bd7f05Smrg if (XrmQGetSearchResource(searchList, Qscreen, QScreen, 637a3bd7f05Smrg &rawType, &value)) { 638a3bd7f05Smrg if (rawType != QScreen) { 639a3bd7f05Smrg convValue.size = sizeof(Screen *); 640a3bd7f05Smrg convValue.addr = (XPointer) &widget->core.screen; 641a3bd7f05Smrg (void) _XtConvert(widget, rawType, &value, 642a3bd7f05Smrg QScreen, &convValue, cache_base); 643a3bd7f05Smrg if (cache_base && *cache_base) 644a3bd7f05Smrg cache_base++; 645a3bd7f05Smrg } 646a3bd7f05Smrg else { 647a3bd7f05Smrg widget->core.screen = *((Screen **) value.addr); 648a3bd7f05Smrg } 649a3bd7f05Smrg } 650a3bd7f05Smrg } 651a3bd7f05Smrg break; 652a3bd7f05Smrg } 653a3bd7f05Smrg /* now get the database to use for the rest of the resources */ 654a3bd7f05Smrg if (widget->core.screen != oldscreen) { 655a3bd7f05Smrg db = XtScreenDatabase(widget->core.screen); 656a3bd7f05Smrg while (!XrmQGetSearchList(db, names, classes, 657a3bd7f05Smrg searchList, (int) searchListSize)) { 658a3bd7f05Smrg if (searchList == stackSearchList) 659a3bd7f05Smrg searchList = NULL; 660a3bd7f05Smrg searchList = (XrmHashTable *) XtRealloc((char *) searchList, 661a3bd7f05Smrg (Cardinal) (sizeof 662a3bd7f05Smrg (XrmHashTable) 663a3bd7f05Smrg * 664a3bd7f05Smrg (searchListSize 665a3bd7f05Smrg *= 2))); 666a3bd7f05Smrg } 667a3bd7f05Smrg } 668444c061aSmrg } 669444c061aSmrg 670444c061aSmrg /* go to the resource manager for those resources not found yet */ 671444c061aSmrg /* if it's not in the resource database use the default value */ 672444c061aSmrg 673444c061aSmrg { 674a3bd7f05Smrg register XrmResourceList rx; 675a3bd7f05Smrg register XrmResourceList *res; 676a3bd7f05Smrg register Cardinal j; 677a3bd7f05Smrg register XrmRepresentation xrm_type; 678a3bd7f05Smrg register XrmRepresentation xrm_default_type; 679a3bd7f05Smrg char char_val; 680a3bd7f05Smrg short short_val; 681a3bd7f05Smrg int int_val; 682a3bd7f05Smrg long long_val; 683a3bd7f05Smrg char *char_ptr; 684a3bd7f05Smrg 685a3bd7f05Smrg if (!found_persistence) { 686a3bd7f05Smrg if (XrmQGetSearchResource(searchList, QinitialResourcesPersistent, 687a3bd7f05Smrg QInitialResourcesPersistent, &rawType, 688a3bd7f05Smrg &value)) { 689a3bd7f05Smrg if (rawType != QBoolean) { 690a3bd7f05Smrg convValue.size = sizeof(Boolean); 691a3bd7f05Smrg convValue.addr = (XPointer) &persistent_resources; 692a3bd7f05Smrg (void) _XtConvert(widget, rawType, &value, QBoolean, 693a3bd7f05Smrg &convValue, NULL); 694a3bd7f05Smrg } 695a3bd7f05Smrg else 696a3bd7f05Smrg persistent_resources = *(Boolean *) value.addr; 697a3bd7f05Smrg } 698a3bd7f05Smrg } 699a3bd7f05Smrg if (persistent_resources) 700a3bd7f05Smrg cache_ptr = NULL; 701a3bd7f05Smrg else if (cache_base) 702a3bd7f05Smrg cache_ptr = cache_base; 703a3bd7f05Smrg else 704a3bd7f05Smrg cache_ptr = cache_ref; 705a3bd7f05Smrg 706a3bd7f05Smrg for (res = table, j = 0; j < num_resources; j++, res++) { 707a3bd7f05Smrg rx = *res; 708a3bd7f05Smrg xrm_type = (XrmRepresentation) rx->xrm_type; 709a3bd7f05Smrg if (typed[j]) { 710a3bd7f05Smrg register XtTypedArg *arg = typed_args + typed[j] - 1; 711a3bd7f05Smrg 712a3bd7f05Smrg /* 7139e7bcd65Smrg * This resource value has been specified as a typed arg and 714a3bd7f05Smrg * has to be converted. Typed arg conversions are done here 715a3bd7f05Smrg * to correctly interpose them with normal resource conversions. 716444c061aSmrg */ 717a3bd7f05Smrg XrmQuark from_type; 718a3bd7f05Smrg XrmValue from_val, to_val; 719a3bd7f05Smrg Boolean converted; 720a3bd7f05Smrg 721a3bd7f05Smrg from_type = StringToQuark(arg->type); 722a3bd7f05Smrg from_val.size = (Cardinal) arg->size; 723a3bd7f05Smrg if ((from_type == QString) || 724a3bd7f05Smrg ((unsigned) arg->size > sizeof(XtArgVal))) 725a3bd7f05Smrg from_val.addr = (XPointer) arg->value; 726a3bd7f05Smrg else 727a3bd7f05Smrg from_val.addr = (XPointer) &arg->value; 728a3bd7f05Smrg to_val.size = rx->xrm_size; 729a3bd7f05Smrg to_val.addr = base - rx->xrm_offset - 1; 730a3bd7f05Smrg converted = _XtConvert(widget, from_type, &from_val, 731a3bd7f05Smrg xrm_type, &to_val, cache_ptr); 732a3bd7f05Smrg if (converted) { 733a3bd7f05Smrg 734a3bd7f05Smrg /* Copy the converted value back into the typed argument. 735a3bd7f05Smrg * normally the data should be <= sizeof(XtArgVal) and 736a3bd7f05Smrg * is stored directly into the 'value' field .... BUT 737a3bd7f05Smrg * if the resource size is greater than sizeof(XtArgVal) 738a3bd7f05Smrg * then we dynamically alloc a block of store to hold the 739a3bd7f05Smrg * data and zap a copy in there !!! .... freeing it later 740a3bd7f05Smrg * the size field in the typed arg is negated to indicate 741a3bd7f05Smrg * that the store pointed to by the value field is 742a3bd7f05Smrg * dynamic ....... 743a3bd7f05Smrg * "freeing" happens in the case of _XtCreate after the 744a3bd7f05Smrg * CallInitialize ..... other clients of GetResources 745a3bd7f05Smrg * using typed args should be aware of the need to free 746a3bd7f05Smrg * this store ..... 747a3bd7f05Smrg */ 748a3bd7f05Smrg 749a3bd7f05Smrg if (rx->xrm_size > sizeof(XtArgVal)) { 750a3bd7f05Smrg arg->value = 751a3bd7f05Smrg (XtArgVal) (void *) __XtMalloc(rx->xrm_size); 752a3bd7f05Smrg arg->size = -(arg->size); 753a3bd7f05Smrg } 754a3bd7f05Smrg else { /* will fit - copy directly into value field */ 755a3bd7f05Smrg arg->value = (XtArgVal) NULL; 756a3bd7f05Smrg } 757a3bd7f05Smrg CopyToArg((char *) (base - rx->xrm_offset - 1), 758a3bd7f05Smrg &arg->value, rx->xrm_size); 759a3bd7f05Smrg 760a3bd7f05Smrg } 761a3bd7f05Smrg else { 762a3bd7f05Smrg /* Conversion failed. Get default value. */ 763a3bd7f05Smrg found[j] = False; 764a3bd7f05Smrg } 765a3bd7f05Smrg 766a3bd7f05Smrg if (cache_ptr && *cache_ptr) 767a3bd7f05Smrg cache_ptr++; 768a3bd7f05Smrg } 769a3bd7f05Smrg 770a3bd7f05Smrg if (!found[j]) { 771a3bd7f05Smrg Boolean already_copied = False; 772a3bd7f05Smrg Boolean have_value = False; 773a3bd7f05Smrg 774a3bd7f05Smrg if (XrmQGetSearchResource(searchList, 775a3bd7f05Smrg (XrmName) rx->xrm_name, 776a3bd7f05Smrg (XrmClass) rx->xrm_class, &rawType, 777a3bd7f05Smrg &value)) { 778a3bd7f05Smrg if (rawType != xrm_type) { 779a3bd7f05Smrg convValue.size = rx->xrm_size; 780a3bd7f05Smrg convValue.addr = (XPointer) (base - rx->xrm_offset - 1); 781a3bd7f05Smrg already_copied = have_value = 782a3bd7f05Smrg _XtConvert(widget, rawType, &value, 783a3bd7f05Smrg xrm_type, &convValue, cache_ptr); 784a3bd7f05Smrg if (cache_ptr && *cache_ptr) 785a3bd7f05Smrg cache_ptr++; 786a3bd7f05Smrg } 787a3bd7f05Smrg else 788a3bd7f05Smrg have_value = True; 789a3bd7f05Smrg if (have_value && rx->xrm_name == Qtranslations) 790a3bd7f05Smrg do_tm_hack = True; 791a3bd7f05Smrg } 792a3bd7f05Smrg LOCK_PROCESS; 793a3bd7f05Smrg if (!have_value && ((rx->xrm_default_type == QImmediate) 794a3bd7f05Smrg || (rx->xrm_default_type == xrm_type) 795a3bd7f05Smrg || (rx->xrm_default_addr != NULL))) { 796a3bd7f05Smrg /* Convert default value to proper type */ 797a3bd7f05Smrg xrm_default_type = (XrmRepresentation) rx->xrm_default_type; 798a3bd7f05Smrg if (xrm_default_type == QCallProc) { 799a3bd7f05Smrg (*(XtResourceDefaultProc) (rx->xrm_default_addr)) 800a3bd7f05Smrg (widget, -(rx->xrm_offset + 1), &value); 801a3bd7f05Smrg 802a3bd7f05Smrg } 803a3bd7f05Smrg else if (xrm_default_type == QImmediate) { 804a3bd7f05Smrg /* XtRImmediate == XtRString for type XtRString */ 805a3bd7f05Smrg if (xrm_type == QString) { 806a3bd7f05Smrg value.addr = rx->xrm_default_addr; 807a3bd7f05Smrg } 808a3bd7f05Smrg else if (rx->xrm_size == sizeof(int)) { 809a3bd7f05Smrg int_val = (int) (long) rx->xrm_default_addr; 810a3bd7f05Smrg value.addr = (XPointer) &int_val; 811a3bd7f05Smrg } 812a3bd7f05Smrg else if (rx->xrm_size == sizeof(short)) { 813a3bd7f05Smrg short_val = (short) (long) rx->xrm_default_addr; 814a3bd7f05Smrg value.addr = (XPointer) &short_val; 815a3bd7f05Smrg } 816a3bd7f05Smrg else if (rx->xrm_size == sizeof(char)) { 817a3bd7f05Smrg char_val = (char) (long) rx->xrm_default_addr; 818a3bd7f05Smrg value.addr = (XPointer) &char_val; 819a3bd7f05Smrg } 820a3bd7f05Smrg else if (rx->xrm_size == sizeof(long)) { 821a3bd7f05Smrg long_val = (long) rx->xrm_default_addr; 822a3bd7f05Smrg value.addr = (XPointer) &long_val; 823a3bd7f05Smrg } 824a3bd7f05Smrg else if (rx->xrm_size == sizeof(char *)) { 825a3bd7f05Smrg char_ptr = (char *) rx->xrm_default_addr; 826a3bd7f05Smrg value.addr = (XPointer) &char_ptr; 827a3bd7f05Smrg } 828a3bd7f05Smrg else { 829a3bd7f05Smrg value.addr = (XPointer) &(rx->xrm_default_addr); 830a3bd7f05Smrg } 831a3bd7f05Smrg } 832a3bd7f05Smrg else if (xrm_default_type == xrm_type) { 833a3bd7f05Smrg value.addr = rx->xrm_default_addr; 834a3bd7f05Smrg } 835a3bd7f05Smrg else { 836a3bd7f05Smrg value.addr = rx->xrm_default_addr; 837a3bd7f05Smrg if (xrm_default_type == QString) { 838a3bd7f05Smrg value.size = 839a3bd7f05Smrg (unsigned) strlen((char *) value.addr) + 1; 840a3bd7f05Smrg } 841a3bd7f05Smrg else { 842a3bd7f05Smrg value.size = sizeof(XtPointer); 843a3bd7f05Smrg } 844a3bd7f05Smrg convValue.size = rx->xrm_size; 845a3bd7f05Smrg convValue.addr = (XPointer) (base - rx->xrm_offset - 1); 846a3bd7f05Smrg already_copied = 847a3bd7f05Smrg _XtConvert(widget, xrm_default_type, &value, 848a3bd7f05Smrg xrm_type, &convValue, cache_ptr); 849a3bd7f05Smrg if (!already_copied) 850a3bd7f05Smrg value.addr = NULL; 851a3bd7f05Smrg if (cache_ptr && *cache_ptr) 852a3bd7f05Smrg cache_ptr++; 853a3bd7f05Smrg } 854a3bd7f05Smrg } 855a3bd7f05Smrg if (!already_copied) { 856a3bd7f05Smrg if (xrm_type == QString) { 857a3bd7f05Smrg *((String *) (base - rx->xrm_offset - 1)) = value.addr; 858a3bd7f05Smrg } 859a3bd7f05Smrg else { 860a3bd7f05Smrg if (value.addr != NULL) { 861a3bd7f05Smrg XtMemmove(base - rx->xrm_offset - 1, 862a3bd7f05Smrg value.addr, rx->xrm_size); 863a3bd7f05Smrg } 864a3bd7f05Smrg else { 865a3bd7f05Smrg /* didn't get value, initialize to NULL... */ 866a3bd7f05Smrg XtBZero(base - rx->xrm_offset - 1, rx->xrm_size); 867a3bd7f05Smrg } 868a3bd7f05Smrg } 869a3bd7f05Smrg } 870a3bd7f05Smrg UNLOCK_PROCESS; 871a3bd7f05Smrg } 872a3bd7f05Smrg } 873a3bd7f05Smrg for (res = table, j = 0; j < num_resources; j++, res++) { 874a3bd7f05Smrg if (!found[j] && typed[j]) { 875a3bd7f05Smrg /* 876a3bd7f05Smrg * This resource value was specified as a typed arg. 877a3bd7f05Smrg * However, the default value is being used here since 878a3bd7f05Smrg * type type conversion failed, so we compress the list. 879a3bd7f05Smrg */ 880a3bd7f05Smrg register XtTypedArg *arg = typed_args + typed[j] - 1; 881a3bd7f05Smrg register int i; 882a3bd7f05Smrg 883a3bd7f05Smrg for (i = num_typed_args - typed[j]; i > 0; i--, arg++) { 884a3bd7f05Smrg *arg = *(arg + 1); 885a3bd7f05Smrg } 886a3bd7f05Smrg num_typed_args--; 887a3bd7f05Smrg } 888a3bd7f05Smrg } 889a3bd7f05Smrg if (tm_hack) 890a3bd7f05Smrg widget->core.tm.current_state = NULL; 891a3bd7f05Smrg if (tm_hack && 892a3bd7f05Smrg (!widget->core.tm.translations || 893a3bd7f05Smrg (do_tm_hack && 894a3bd7f05Smrg widget->core.tm.translations->operation != XtTableReplace)) && 895a3bd7f05Smrg XrmQGetSearchResource(searchList, QbaseTranslations, 896a3bd7f05Smrg QTranslations, &rawType, &value)) { 897a3bd7f05Smrg if (rawType != QTranslationTable) { 898a3bd7f05Smrg convValue.size = sizeof(XtTranslations); 899a3bd7f05Smrg convValue.addr = (XPointer) &widget->core.tm.current_state; 900a3bd7f05Smrg (void) _XtConvert(widget, rawType, &value, 901a3bd7f05Smrg QTranslationTable, &convValue, cache_ptr); 902a3bd7f05Smrg if (cache_ptr && *cache_ptr) 903a3bd7f05Smrg cache_ptr++; 904a3bd7f05Smrg } 905a3bd7f05Smrg else { 906a3bd7f05Smrg /* value.addr can be NULL see: !already_copied */ 907a3bd7f05Smrg if (value.addr) 908a3bd7f05Smrg *((XtTranslations *) &widget->core.tm.current_state) = 909a3bd7f05Smrg *((XtTranslations *) value.addr); 910a3bd7f05Smrg } 911a3bd7f05Smrg } 912444c061aSmrg } 913a3bd7f05Smrg if ((Cardinal) num_typed_args != *pNumTypedArgs) 914a3bd7f05Smrg *pNumTypedArgs = (Cardinal) num_typed_args; 915a3bd7f05Smrg if (searchList != stackSearchList) 916a3bd7f05Smrg XtFree((char *) searchList); 917444c061aSmrg if (!cache_ptr) 918a3bd7f05Smrg cache_ptr = cache_base; 919444c061aSmrg if (cache_ptr && cache_ptr != cache_ref) { 920a3bd7f05Smrg int cache_ref_size = (int) (cache_ptr - cache_ref); 921fdf6a26fSmrg XtCacheRef *refs = XtMallocArray((Cardinal) cache_ref_size + 1, 922fdf6a26fSmrg (Cardinal) sizeof(XtCacheRef)); 923a3bd7f05Smrg 924fdf6a26fSmrg (void) memcpy(refs, cache_ref, 925fdf6a26fSmrg sizeof(XtCacheRef) * (size_t) cache_ref_size); 926a3bd7f05Smrg refs[cache_ref_size] = NULL; 927a3bd7f05Smrg return refs; 928444c061aSmrg } 929a3bd7f05Smrg return (XtCacheRef *) NULL; 930444c061aSmrg} 931444c061aSmrg 932a3bd7f05Smrgstatic void 933a3bd7f05SmrgCacheArgs(ArgList args, 934a3bd7f05Smrg Cardinal num_args, 935a3bd7f05Smrg XtTypedArgList typed_args, 936a3bd7f05Smrg Cardinal num_typed_args, 937a3bd7f05Smrg XrmQuarkList quark_cache, 938a3bd7f05Smrg Cardinal num_quarks, 939a3bd7f05Smrg XrmQuarkList *pQuarks) /* RETURN */ 940a3bd7f05Smrg{ 941a3bd7f05Smrg register XrmQuarkList quarks; 942a3bd7f05Smrg register Cardinal i; 943a3bd7f05Smrg register Cardinal count; 944444c061aSmrg 945444c061aSmrg count = (args != NULL) ? num_args : num_typed_args; 946444c061aSmrg 947444c061aSmrg if (num_quarks < count) { 948fdf6a26fSmrg quarks = XtMallocArray(count, (Cardinal) sizeof(XrmQuark)); 949a3bd7f05Smrg } 950a3bd7f05Smrg else { 951a3bd7f05Smrg quarks = quark_cache; 952444c061aSmrg } 953444c061aSmrg *pQuarks = quarks; 954444c061aSmrg 955444c061aSmrg if (args != NULL) { 956a3bd7f05Smrg for (i = count; i; i--) 957a3bd7f05Smrg *quarks++ = StringToQuark((args++)->name); 958444c061aSmrg } 959444c061aSmrg else { 960a3bd7f05Smrg for (i = count; i; i--) 961a3bd7f05Smrg *quarks++ = StringToQuark((typed_args++)->name); 962444c061aSmrg } 963444c061aSmrg} 964444c061aSmrg 965444c061aSmrg#define FreeCache(cache, pointer) \ 966a3bd7f05Smrg if (cache != pointer) XtFree((char *)pointer) 967a3bd7f05Smrg 968a3bd7f05SmrgXtCacheRef * 969a3bd7f05Smrg_XtGetResources(register Widget w, 970a3bd7f05Smrg ArgList args, 971a3bd7f05Smrg Cardinal num_args, 972a3bd7f05Smrg XtTypedArgList typed_args, 973a3bd7f05Smrg Cardinal *num_typed_args) 974444c061aSmrg{ 975a3bd7f05Smrg XrmName *names, names_s[50]; 976a3bd7f05Smrg XrmClass *classes, classes_s[50]; 977a3bd7f05Smrg XrmQuark quark_cache[100]; 978a3bd7f05Smrg XrmQuarkList quark_args; 979a3bd7f05Smrg WidgetClass wc; 980a3bd7f05Smrg XtCacheRef *cache_refs = NULL; 981a3bd7f05Smrg Cardinal count; 982444c061aSmrg 983444c061aSmrg wc = XtClass(w); 984444c061aSmrg 985444c061aSmrg count = CountTreeDepth(w); 986a3bd7f05Smrg names = (XrmName *) XtStackAlloc(count * sizeof(XrmName), names_s); 987a3bd7f05Smrg classes = (XrmClass *) XtStackAlloc(count * sizeof(XrmClass), classes_s); 9880568f49bSmrg if (names == NULL || classes == NULL) { 989a3bd7f05Smrg _XtAllocError(NULL); 990a3bd7f05Smrg } 991a3bd7f05Smrg else { 992a3bd7f05Smrg 993a3bd7f05Smrg /* Get names, classes for widget and ancestors */ 994a3bd7f05Smrg GetNamesAndClasses(w, names, classes); 995a3bd7f05Smrg 996a3bd7f05Smrg /* Compile arg list into quarks */ 997a3bd7f05Smrg CacheArgs(args, num_args, typed_args, *num_typed_args, quark_cache, 998a3bd7f05Smrg XtNumber(quark_cache), &quark_args); 999a3bd7f05Smrg 1000a3bd7f05Smrg /* Get normal resources */ 1001a3bd7f05Smrg LOCK_PROCESS; 1002a3bd7f05Smrg cache_refs = GetResources(w, (char *) w, names, classes, 1003a3bd7f05Smrg (XrmResourceList *) wc->core_class.resources, 1004a3bd7f05Smrg wc->core_class.num_resources, quark_args, 1005a3bd7f05Smrg args, num_args, typed_args, num_typed_args, 1006a3bd7f05Smrg XtIsWidget(w)); 1007a3bd7f05Smrg 1008a3bd7f05Smrg if (w->core.constraints != NULL) { 1009a3bd7f05Smrg ConstraintWidgetClass cwc; 1010a3bd7f05Smrg XtCacheRef *cache_refs_core; 1011a3bd7f05Smrg 1012a3bd7f05Smrg cwc = (ConstraintWidgetClass) XtClass(w->core.parent); 1013a3bd7f05Smrg cache_refs_core = 1014a3bd7f05Smrg GetResources(w, (char *) w->core.constraints, names, classes, 1015a3bd7f05Smrg (XrmResourceList *) cwc->constraint_class. 1016a3bd7f05Smrg resources, cwc->constraint_class.num_resources, 1017a3bd7f05Smrg quark_args, args, num_args, typed_args, 1018a3bd7f05Smrg num_typed_args, False); 1019a3bd7f05Smrg XtFree((char *) cache_refs_core); 1020a3bd7f05Smrg } 1021a3bd7f05Smrg FreeCache(quark_cache, quark_args); 1022a3bd7f05Smrg UNLOCK_PROCESS; 1023a3bd7f05Smrg XtStackFree((XtPointer) names, names_s); 1024a3bd7f05Smrg XtStackFree((XtPointer) classes, classes_s); 1025444c061aSmrg } 1026444c061aSmrg return cache_refs; 1027a3bd7f05Smrg} /* _XtGetResources */ 1028a3bd7f05Smrg 1029a3bd7f05Smrgvoid 1030a3bd7f05Smrg_XtGetSubresources(Widget w, /* Widget "parent" of subobject */ 1031a3bd7f05Smrg XtPointer base, /* Base address to write to */ 1032a3bd7f05Smrg const char *name, /* name of subobject */ 1033a3bd7f05Smrg const char *class, /* class of subobject */ 1034a3bd7f05Smrg XtResourceList resources, /* resource list for subobject */ 1035a3bd7f05Smrg Cardinal num_resources, 1036a3bd7f05Smrg ArgList args, /* arg list to override resources */ 1037a3bd7f05Smrg Cardinal num_args, 1038a3bd7f05Smrg XtTypedArgList typed_args, 1039a3bd7f05Smrg Cardinal num_typed_args) 1040444c061aSmrg{ 1041a3bd7f05Smrg XrmName *names, names_s[50]; 1042a3bd7f05Smrg XrmClass *classes, classes_s[50]; 1043a3bd7f05Smrg XrmQuark quark_cache[100]; 1044a3bd7f05Smrg XrmQuarkList quark_args; 1045a3bd7f05Smrg Cardinal count, ntyped_args = num_typed_args; 1046a3bd7f05Smrg XtCacheRef *Resrc = NULL; 1047a3bd7f05Smrg 1048444c061aSmrg WIDGET_TO_APPCON(w); 1049444c061aSmrg 1050a3bd7f05Smrg if (num_resources == 0) 1051a3bd7f05Smrg return; 1052444c061aSmrg 1053444c061aSmrg LOCK_APP(app); 1054444c061aSmrg count = CountTreeDepth(w); 1055a3bd7f05Smrg count++; /* make sure there's enough room for name and class */ 1056a3bd7f05Smrg names = (XrmName *) XtStackAlloc(count * sizeof(XrmName), names_s); 1057a3bd7f05Smrg classes = (XrmClass *) XtStackAlloc(count * sizeof(XrmClass), classes_s); 10580568f49bSmrg if (names == NULL || classes == NULL) { 1059a3bd7f05Smrg _XtAllocError(NULL); 1060a3bd7f05Smrg } 1061a3bd7f05Smrg else { 1062fdf6a26fSmrg XrmResourceList *table; 1063fdf6a26fSmrg 1064a3bd7f05Smrg /* Get full name, class of subobject */ 1065a3bd7f05Smrg GetNamesAndClasses(w, names, classes); 1066a3bd7f05Smrg count -= 2; 1067a3bd7f05Smrg names[count] = StringToName(name); 1068a3bd7f05Smrg classes[count] = StringToClass(class); 1069a3bd7f05Smrg count++; 1070a3bd7f05Smrg names[count] = NULLQUARK; 1071a3bd7f05Smrg classes[count] = NULLQUARK; 1072a3bd7f05Smrg 1073a3bd7f05Smrg /* Compile arg list into quarks */ 1074a3bd7f05Smrg CacheArgs(args, num_args, typed_args, num_typed_args, 1075a3bd7f05Smrg quark_cache, XtNumber(quark_cache), &quark_args); 1076a3bd7f05Smrg 1077a3bd7f05Smrg /* Compile resource list if needed */ 1078a3bd7f05Smrg if (((int) resources->resource_offset) >= 0) { 1079a3bd7f05Smrg XrmCompileResourceListEphem(resources, num_resources); 1080a3bd7f05Smrg } 1081a3bd7f05Smrg table = _XtCreateIndirectionTable(resources, num_resources); 1082a3bd7f05Smrg Resrc = 1083a3bd7f05Smrg GetResources(w, (char *) base, names, classes, table, num_resources, 1084a3bd7f05Smrg quark_args, args, num_args, typed_args, &ntyped_args, 1085a3bd7f05Smrg False); 1086a3bd7f05Smrg FreeCache(quark_cache, quark_args); 1087a3bd7f05Smrg XtFree((char *) table); 1088a3bd7f05Smrg XtFree((char *) Resrc); 1089a3bd7f05Smrg XtStackFree((XtPointer) names, names_s); 1090a3bd7f05Smrg XtStackFree((XtPointer) classes, classes_s); 1091a3bd7f05Smrg UNLOCK_APP(app); 1092444c061aSmrg } 1093444c061aSmrg} 1094444c061aSmrg 1095a3bd7f05Smrgvoid 1096a3bd7f05SmrgXtGetSubresources(Widget w, /* Widget "parent" of subobject */ 1097a3bd7f05Smrg XtPointer base, /* Base address to write to */ 1098a3bd7f05Smrg _Xconst char *name, /* name of subobject */ 1099a3bd7f05Smrg _Xconst char *class, /* class of subobject */ 1100a3bd7f05Smrg XtResourceList resources, /* resource list for subobject */ 1101a3bd7f05Smrg Cardinal num_resources, 1102a3bd7f05Smrg ArgList args, /* arg list to override resources */ 1103a3bd7f05Smrg Cardinal num_args) 1104444c061aSmrg{ 1105a3bd7f05Smrg _XtGetSubresources(w, base, name, class, resources, num_resources, args, 1106a3bd7f05Smrg num_args, NULL, 0); 1107444c061aSmrg} 1108444c061aSmrg 1109a3bd7f05Smrgvoid 1110a3bd7f05Smrg_XtGetApplicationResources(Widget w, /* Application shell widget */ 1111a3bd7f05Smrg XtPointer base, /* Base address to write to */ 1112a3bd7f05Smrg XtResourceList resources, /* resource list for subobject */ 1113a3bd7f05Smrg Cardinal num_resources, 1114a3bd7f05Smrg ArgList args, /* arg list to override resources */ 1115a3bd7f05Smrg Cardinal num_args, 1116a3bd7f05Smrg XtTypedArgList typed_args, 1117a3bd7f05Smrg Cardinal num_typed_args) 1118444c061aSmrg{ 1119a3bd7f05Smrg XrmName *names, names_s[50]; 1120a3bd7f05Smrg XrmClass *classes, classes_s[50]; 1121a3bd7f05Smrg XrmQuark quark_cache[100]; 1122a3bd7f05Smrg XrmQuarkList quark_args; 1123a3bd7f05Smrg XrmResourceList *table; 1124a3bd7f05Smrg Cardinal ntyped_args = num_typed_args; 1125a3bd7f05Smrg 1126444c061aSmrg#ifdef XTHREADS 1127a3bd7f05Smrg XtAppContext app; 1128444c061aSmrg#endif 1129a3bd7f05Smrg XtCacheRef *Resrc = NULL; 1130444c061aSmrg 1131a3bd7f05Smrg if (num_resources == 0) 1132a3bd7f05Smrg return; 1133444c061aSmrg 1134444c061aSmrg#ifdef XTHREADS 1135a3bd7f05Smrg if (w == NULL) 1136a3bd7f05Smrg app = _XtDefaultAppContext(); 1137a3bd7f05Smrg else 1138a3bd7f05Smrg app = XtWidgetToApplicationContext(w); 1139444c061aSmrg#endif 1140444c061aSmrg 1141444c061aSmrg LOCK_APP(app); 1142444c061aSmrg /* Get full name, class of application */ 1143444c061aSmrg if (w == NULL) { 1144a3bd7f05Smrg /* hack for R2 compatibility */ 1145a3bd7f05Smrg XtPerDisplay pd = _XtGetPerDisplay(_XtDefaultAppContext()->list[0]); 1146a3bd7f05Smrg 1147a3bd7f05Smrg names = (XrmName *) XtStackAlloc(2 * sizeof(XrmName), names_s); 1148a3bd7f05Smrg classes = (XrmClass *) XtStackAlloc(2 * sizeof(XrmClass), classes_s); 1149a3bd7f05Smrg if (names == NULL || classes == NULL) { 1150a3bd7f05Smrg _XtAllocError(NULL); 1151a3bd7f05Smrg } 1152a3bd7f05Smrg else { 1153a3bd7f05Smrg names[0] = pd->name; 1154a3bd7f05Smrg names[1] = NULLQUARK; 1155a3bd7f05Smrg classes[0] = pd->class; 1156a3bd7f05Smrg classes[1] = NULLQUARK; 1157a3bd7f05Smrg } 1158444c061aSmrg } 1159444c061aSmrg else { 1160a3bd7f05Smrg Cardinal count = CountTreeDepth(w); 1161a3bd7f05Smrg 1162a3bd7f05Smrg names = (XrmName *) XtStackAlloc(count * sizeof(XrmName), names_s); 1163a3bd7f05Smrg classes = 1164a3bd7f05Smrg (XrmClass *) XtStackAlloc(count * sizeof(XrmClass), classes_s); 1165a3bd7f05Smrg if (names == NULL || classes == NULL) { 1166a3bd7f05Smrg _XtAllocError(NULL); 1167a3bd7f05Smrg } 1168a3bd7f05Smrg else { 1169a3bd7f05Smrg GetNamesAndClasses(w, names, classes); 1170a3bd7f05Smrg } 1171444c061aSmrg } 1172444c061aSmrg 1173444c061aSmrg /* Compile arg list into quarks */ 1174a3bd7f05Smrg CacheArgs(args, num_args, typed_args, num_typed_args, quark_cache, 1175a3bd7f05Smrg XtNumber(quark_cache), &quark_args); 1176444c061aSmrg /* Compile resource list if needed */ 1177444c061aSmrg if (((int) resources->resource_offset) >= 0) { 1178a3bd7f05Smrg XrmCompileResourceListEphem(resources, num_resources); 1179444c061aSmrg } 1180a3bd7f05Smrg table = _XtCreateIndirectionTable(resources, num_resources); 1181444c061aSmrg 1182a3bd7f05Smrg Resrc = GetResources(w, (char *) base, names, classes, table, num_resources, 1183a3bd7f05Smrg quark_args, args, num_args, 1184a3bd7f05Smrg typed_args, &ntyped_args, False); 1185444c061aSmrg FreeCache(quark_cache, quark_args); 1186a3bd7f05Smrg XtFree((char *) table); 1187a3bd7f05Smrg XtFree((char *) Resrc); 1188444c061aSmrg if (w != NULL) { 1189a3bd7f05Smrg XtStackFree((XtPointer) names, names_s); 1190a3bd7f05Smrg XtStackFree((XtPointer) classes, classes_s); 1191444c061aSmrg } 1192444c061aSmrg UNLOCK_APP(app); 1193444c061aSmrg} 1194444c061aSmrg 1195a3bd7f05Smrgvoid 1196a3bd7f05SmrgXtGetApplicationResources(Widget w, /* Application shell widget */ 1197a3bd7f05Smrg XtPointer base, /* Base address to write to */ 1198a3bd7f05Smrg XtResourceList resources, /* resource list for subobject */ 1199a3bd7f05Smrg Cardinal num_resources, 1200a3bd7f05Smrg ArgList args, /* arg list to override resources */ 1201a3bd7f05Smrg Cardinal num_args) 1202444c061aSmrg{ 1203a3bd7f05Smrg _XtGetApplicationResources(w, base, resources, num_resources, args, 1204a3bd7f05Smrg num_args, NULL, 0); 1205444c061aSmrg} 1206444c061aSmrg 1207444c061aSmrgstatic Boolean initialized = FALSE; 1208444c061aSmrg 1209a3bd7f05Smrgvoid 1210a3bd7f05Smrg_XtResourceListInitialize(void) 1211444c061aSmrg{ 1212444c061aSmrg LOCK_PROCESS; 1213444c061aSmrg if (initialized) { 1214a3bd7f05Smrg XtWarningMsg("initializationError", "xtInitialize", XtCXtToolkitError, 1215a3bd7f05Smrg "Initializing Resource Lists twice", NULL, NULL); 1216a3bd7f05Smrg UNLOCK_PROCESS; 1217a3bd7f05Smrg return; 1218444c061aSmrg } 1219444c061aSmrg initialized = TRUE; 1220444c061aSmrg UNLOCK_PROCESS; 1221444c061aSmrg 1222444c061aSmrg QBoolean = XrmPermStringToQuark(XtCBoolean); 1223444c061aSmrg QString = XrmPermStringToQuark(XtCString); 1224444c061aSmrg QCallProc = XrmPermStringToQuark(XtRCallProc); 1225444c061aSmrg QImmediate = XrmPermStringToQuark(XtRImmediate); 1226a3bd7f05Smrg QinitialResourcesPersistent = 1227a3bd7f05Smrg XrmPermStringToQuark(XtNinitialResourcesPersistent); 1228a3bd7f05Smrg QInitialResourcesPersistent = 1229a3bd7f05Smrg XrmPermStringToQuark(XtCInitialResourcesPersistent); 1230444c061aSmrg Qtranslations = XrmPermStringToQuark(XtNtranslations); 1231444c061aSmrg QbaseTranslations = XrmPermStringToQuark("baseTranslations"); 1232444c061aSmrg QTranslations = XrmPermStringToQuark(XtCTranslations); 1233444c061aSmrg QTranslationTable = XrmPermStringToQuark(XtRTranslationTable); 1234444c061aSmrg Qscreen = XrmPermStringToQuark(XtNscreen); 1235444c061aSmrg QScreen = XrmPermStringToQuark(XtCScreen); 1236444c061aSmrg} 1237