Converters.c revision 0568f49b
11.1Schristos/*********************************************************** 21.1SchristosCopyright (c) 1993, Oracle and/or its affiliates. All rights reserved. 31.1.1.2Schristos 4Permission is hereby granted, free of charge, to any person obtaining a 5copy of this software and associated documentation files (the "Software"), 6to deal in the Software without restriction, including without limitation 7the rights to use, copy, modify, merge, publish, distribute, sublicense, 8and/or sell copies of the Software, and to permit persons to whom the 9Software is furnished to do so, subject to the following conditions: 10 11The above copyright notice and this permission notice (including the next 12paragraph) shall be included in all copies or substantial portions of the 13Software. 14 15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21DEALINGS IN THE SOFTWARE. 22 23Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts. 24 25 All Rights Reserved 26 27Permission to use, copy, modify, and distribute this software and its 28documentation for any purpose and without fee is hereby granted, 29provided that the above copyright notice appear in all copies and that 30both that copyright notice and this permission notice appear in 31supporting documentation, and that the name of Digital not be 32used in advertising or publicity pertaining to distribution of the 33software without specific, written prior permission. 34 35DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 36ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 37DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 38ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 39WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 40ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 41SOFTWARE. 42 43******************************************************************/ 44 45/* 46 47Copyright 1987, 1988, 1994, 1998 The Open Group 48 49Permission to use, copy, modify, distribute, and sell this software and its 50documentation for any purpose is hereby granted without fee, provided that 51the above copyright notice appear in all copies and that both that 52copyright notice and this permission notice appear in supporting 53documentation. 54 55The above copyright notice and this permission notice shall be included in 56all copies or substantial portions of the Software. 57 58THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 59IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 60FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 61OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 62AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 63CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 64 65Except as contained in this notice, the name of The Open Group shall not be 66used in advertising or otherwise to promote the sale, use or other dealings 67in this Software without prior written authorization from The Open Group. 68 69*/ 70 71/*LINTLIBRARY*/ 72/* Conversion.c - implementations of resource type conversion procs */ 73 74#ifdef HAVE_CONFIG_H 75#include <config.h> 76#endif 77#include "IntrinsicI.h" 78#include "StringDefs.h" 79#include "Shell.h" 80#include <stdio.h> 81#include <X11/cursorfont.h> 82#include <X11/keysym.h> 83#include <X11/Xlocale.h> 84#include <errno.h> /* for StringToDirectoryString */ 85 86#define IsNewline(str) ((str) == '\n') 87#define IsWhitespace(str) ((str)== ' ' || (str) == '\t') 88 89static _Xconst _XtString XtNwrongParameters = "wrongParameters"; 90static _Xconst _XtString XtNconversionError = "conversionError"; 91static _Xconst _XtString XtNmissingCharsetList = "missingCharsetList"; 92 93/* Representation types */ 94 95#define XtQAtom XrmPermStringToQuark(XtRAtom) 96#define XtQCommandArgArray XrmPermStringToQuark(XtRCommandArgArray) 97#define XtQCursor XrmPermStringToQuark(XtRCursor) 98#define XtQDirectoryString XrmPermStringToQuark(XtRDirectoryString) 99#define XtQDisplay XrmPermStringToQuark(XtRDisplay) 100#define XtQFile XrmPermStringToQuark(XtRFile) 101#define XtQFloat XrmPermStringToQuark(XtRFloat) 102#define XtQInitialState XrmPermStringToQuark(XtRInitialState) 103#define XtQPixmap XrmPermStringToQuark(XtRPixmap) 104#define XtQRestartStyle XrmPermStringToQuark(XtRRestartStyle) 105#define XtQShort XrmPermStringToQuark(XtRShort) 106#define XtQUnsignedChar XrmPermStringToQuark(XtRUnsignedChar) 107#define XtQVisual XrmPermStringToQuark(XtRVisual) 108 109static XrmQuark XtQBool; 110static XrmQuark XtQBoolean; 111static XrmQuark XtQColor; 112static XrmQuark XtQDimension; 113static XrmQuark XtQFont; 114static XrmQuark XtQFontSet; 115static XrmQuark XtQFontStruct; 116static XrmQuark XtQGravity; 117static XrmQuark XtQInt; 118static XrmQuark XtQPixel; 119static XrmQuark XtQPosition; 120XrmQuark _XtQString; 121 122void _XtConvertInitialize(void) 123{ 124 XtQBool = XrmPermStringToQuark(XtRBool); 125 XtQBoolean = XrmPermStringToQuark(XtRBoolean); 126 XtQColor = XrmPermStringToQuark(XtRColor); 127 XtQDimension = XrmPermStringToQuark(XtRDimension); 128 XtQFont = XrmPermStringToQuark(XtRFont); 129 XtQFontSet = XrmPermStringToQuark(XtRFontSet); 130 XtQFontStruct = XrmPermStringToQuark(XtRFontStruct); 131 XtQGravity = XrmPermStringToQuark(XtRGravity); 132 XtQInt = XrmPermStringToQuark(XtRInt); 133 XtQPixel = XrmPermStringToQuark(XtRPixel); 134 XtQPosition = XrmPermStringToQuark(XtRPosition); 135 _XtQString = XrmPermStringToQuark(XtRString); 136} 137 138#define donestr(type, value, tstr) \ 139 { \ 140 if (toVal->addr != NULL) { \ 141 if (toVal->size < sizeof(type)) { \ 142 toVal->size = sizeof(type); \ 143 XtDisplayStringConversionWarning(dpy, \ 144 (char*) fromVal->addr, tstr); \ 145 return False; \ 146 } \ 147 *(type*)(toVal->addr) = (type) (value); \ 148 } \ 149 else { \ 150 static type static_val; \ 151 static_val = (type) (value); \ 152 toVal->addr = (XPointer)&static_val; \ 153 } \ 154 toVal->size = sizeof(type); \ 155 return True; \ 156 } 157 158#define done(type, value) \ 159 { \ 160 if (toVal->addr != NULL) { \ 161 if (toVal->size < sizeof(type)) { \ 162 toVal->size = sizeof(type); \ 163 return False; \ 164 } \ 165 *(type*)(toVal->addr) = (type) (value); \ 166 } \ 167 else { \ 168 static type static_val; \ 169 static_val = (type) (value); \ 170 toVal->addr = (XPointer)&static_val; \ 171 } \ 172 toVal->size = sizeof(type); \ 173 return True; \ 174 } 175 176void XtDisplayStringConversionWarning( 177 Display* dpy, 178 _Xconst char* from, 179 _Xconst char* toType 180 ) 181{ 182#ifndef NO_MIT_HACKS 183 /* Allow suppression of conversion warnings. %%% Not specified. */ 184 185 static enum {Check, Report, Ignore} report_it = Check; 186 XtAppContext app = XtDisplayToApplicationContext(dpy); 187 188 LOCK_APP(app); 189 LOCK_PROCESS; 190 if (report_it == Check) { 191 XrmDatabase rdb = XtDatabase(dpy); 192 XrmName xrm_name[2]; 193 XrmClass xrm_class[2]; 194 XrmRepresentation rep_type; 195 XrmValue value; 196 xrm_name[0] = XrmPermStringToQuark( "stringConversionWarnings" ); 197 xrm_name[1] = 0; 198 xrm_class[0] = XrmPermStringToQuark( "StringConversionWarnings" ); 199 xrm_class[1] = 0; 200 if (XrmQGetResource( rdb, xrm_name, xrm_class, 201 &rep_type, &value )) 202 { 203 if (rep_type == XtQBoolean) 204 report_it = *(Boolean*)value.addr ? Report : Ignore; 205 else if (rep_type == _XtQString) { 206 XrmValue toVal; 207 Boolean report; 208 toVal.addr = (XPointer)&report; 209 toVal.size = sizeof(Boolean); 210 if (XtCallConverter(dpy, XtCvtStringToBoolean, (XrmValuePtr)NULL, 211 (Cardinal)0, &value, &toVal, 212 (XtCacheRef*)NULL)) 213 report_it = report ? Report : Ignore; 214 } 215 else report_it = Report; 216 } 217 else report_it = Report; 218 } 219 220 if (report_it == Report) { 221#endif /* ifndef NO_MIT_HACKS */ 222 String params[2]; 223 Cardinal num_params = 2; 224 params[0] = (String)from; 225 params[1] = (String)toType; 226 XtAppWarningMsg(app, 227 XtNconversionError,"string",XtCXtToolkitError, 228 "Cannot convert string \"%s\" to type %s", 229 params,&num_params); 230#ifndef NO_MIT_HACKS 231 } 232#endif /* ifndef NO_MIT_HACKS */ 233 UNLOCK_PROCESS; 234 UNLOCK_APP(app); 235} 236 237void XtStringConversionWarning( 238 _Xconst char* from, 239 _Xconst char* toType 240 ) 241{ 242 String params[2]; 243 Cardinal num_params = 2; 244 params[0] = (String)from; 245 params[1] = (String)toType; 246 XtWarningMsg(XtNconversionError,"string",XtCXtToolkitError, 247 "Cannot convert string \"%s\" to type %s", 248 params,&num_params); 249} 250 251static int CompareISOLatin1(const char *, const char *); 252 253 254static Boolean IsInteger( 255 String string, 256 int *value) 257{ 258 Boolean foundDigit = False; 259 Boolean isNegative = False; 260 Boolean isPositive = False; 261 int val = 0; 262 char ch; 263 /* skip leading whitespace */ 264 while ((ch = *string) == ' ' || ch == '\t') string++; 265 while ((ch = *string++)) { 266 if (ch >= '0' && ch <= '9') { 267 val *= 10; 268 val += ch - '0'; 269 foundDigit = True; 270 continue; 271 } 272 if (IsWhitespace(ch)) { 273 if (!foundDigit) return False; 274 /* make sure only trailing whitespace */ 275 while ((ch = *string++)) { 276 if (!IsWhitespace(ch)) 277 return False; 278 } 279 break; 280 } 281 if (ch == '-' && !foundDigit && !isNegative && !isPositive) { 282 isNegative = True; 283 continue; 284 } 285 if (ch == '+' && !foundDigit && !isNegative && !isPositive) { 286 isPositive = True; 287 continue; 288 } 289 return False; 290 } 291 if (ch == '\0') { 292 if (isNegative) 293 *value = -val; 294 else 295 *value = val; 296 return True; 297 } 298 return False; 299} 300 301 302/*ARGSUSED*/ 303Boolean XtCvtIntToBoolean( 304 Display* dpy, 305 XrmValuePtr args, 306 Cardinal *num_args, 307 XrmValuePtr fromVal, 308 XrmValuePtr toVal, 309 XtPointer *closure_ret) 310{ 311 if (*num_args != 0) 312 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 313 XtNwrongParameters,"cvtIntToBoolean",XtCXtToolkitError, 314 "Integer to Boolean conversion needs no extra arguments", 315 NULL, NULL); 316 done(Boolean, (*(int *)fromVal->addr != 0)); 317} 318 319 320/*ARGSUSED*/ 321Boolean XtCvtIntToShort( 322 Display* dpy, 323 XrmValuePtr args, 324 Cardinal *num_args, 325 XrmValuePtr fromVal, 326 XrmValuePtr toVal, 327 XtPointer *closure_ret) 328{ 329 if (*num_args != 0) 330 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 331 XtNwrongParameters,"cvtIntToShort",XtCXtToolkitError, 332 "Integer to Short conversion needs no extra arguments", 333 NULL, NULL); 334 done(short, (*(int *)fromVal->addr)); 335} 336 337 338/*ARGSUSED*/ 339Boolean XtCvtStringToBoolean( 340 Display* dpy, 341 XrmValuePtr args, 342 Cardinal *num_args, 343 XrmValuePtr fromVal, 344 XrmValuePtr toVal, 345 XtPointer *closure_ret) 346{ 347 String str = (String)fromVal->addr; 348 if (*num_args != 0) 349 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 350 XtNwrongParameters,"cvtStringToBoolean",XtCXtToolkitError, 351 "String to Boolean conversion needs no extra arguments", 352 NULL, NULL); 353 354 if ( (CompareISOLatin1(str, "true") == 0) 355 || (CompareISOLatin1(str, "yes") == 0) 356 || (CompareISOLatin1(str, "on") == 0) 357 || (CompareISOLatin1(str, "1") == 0)) donestr( Boolean, True, XtRBoolean ); 358 359 if ( (CompareISOLatin1(str, "false") == 0) 360 || (CompareISOLatin1(str, "no") == 0) 361 || (CompareISOLatin1(str, "off") == 0) 362 || (CompareISOLatin1(str, "0") == 0)) donestr( Boolean, False, XtRBoolean ); 363 364 XtDisplayStringConversionWarning(dpy, str, XtRBoolean); 365 return False; 366} 367 368 369/*ARGSUSED*/ 370Boolean XtCvtIntToBool( 371 Display* dpy, 372 XrmValuePtr args, 373 Cardinal *num_args, 374 XrmValuePtr fromVal, 375 XrmValuePtr toVal, 376 XtPointer *closure_ret) 377{ 378 if (*num_args != 0) 379 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 380 XtNwrongParameters,"cvtIntToBool",XtCXtToolkitError, 381 "Integer to Bool conversion needs no extra arguments", 382 NULL, NULL); 383 done(Bool, (*(int *)fromVal->addr != 0)); 384} 385 386 387/*ARGSUSED*/ 388Boolean XtCvtStringToBool( 389 Display* dpy, 390 XrmValuePtr args, 391 Cardinal *num_args, 392 XrmValuePtr fromVal, 393 XrmValuePtr toVal, 394 XtPointer *closure_ret) 395{ 396 String str = (String)fromVal->addr; 397 if (*num_args != 0) 398 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 399 XtNwrongParameters,"cvtStringToBool", 400 XtCXtToolkitError, 401 "String to Bool conversion needs no extra arguments", 402 NULL, NULL); 403 404 if ( (CompareISOLatin1(str, "true") == 0) 405 || (CompareISOLatin1(str, "yes") == 0) 406 || (CompareISOLatin1(str, "on") == 0) 407 || (CompareISOLatin1(str, "1") == 0)) donestr( Bool, True, XtRBool ); 408 409 if ( (CompareISOLatin1(str, "false") == 0) 410 || (CompareISOLatin1(str, "no") == 0) 411 || (CompareISOLatin1(str, "off") == 0) 412 || (CompareISOLatin1(str, "0") == 0)) donestr( Bool, False, XtRBool ); 413 414 XtDisplayStringConversionWarning(dpy, (char *) fromVal->addr, XtRBool); 415 return False; 416} 417 418XtConvertArgRec const colorConvertArgs[] = { 419 {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.screen), 420 sizeof(Screen *)}, 421 {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.colormap), 422 sizeof(Colormap)} 423}; 424 425 426/* ARGSUSED */ 427Boolean XtCvtIntToColor( 428 Display* dpy, 429 XrmValuePtr args, 430 Cardinal *num_args, 431 XrmValuePtr fromVal, 432 XrmValuePtr toVal, 433 XtPointer *closure_ret) 434{ 435 XColor c; 436 Screen *screen; 437 Colormap colormap; 438 439 if (*num_args != 2) { 440 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 441 XtNwrongParameters,"cvtIntOrPixelToXColor",XtCXtToolkitError, 442 "Pixel to color conversion needs screen and colormap arguments", 443 NULL, NULL); 444 return False; 445 } 446 screen = *((Screen **) args[0].addr); 447 colormap = *((Colormap *) args[1].addr); 448 c.pixel = (unsigned long) (*(int *)fromVal->addr); 449 450 XQueryColor(DisplayOfScreen(screen), colormap, &c); 451 done(XColor, c); 452} 453 454 455Boolean XtCvtStringToPixel( 456 Display* dpy, 457 XrmValuePtr args, 458 Cardinal *num_args, 459 XrmValuePtr fromVal, 460 XrmValuePtr toVal, 461 XtPointer *closure_ret) 462{ 463 String str = (String)fromVal->addr; 464 XColor screenColor; 465 XColor exactColor; 466 Screen *screen; 467 XtPerDisplay pd = _XtGetPerDisplay(dpy); 468 Colormap colormap; 469 Status status; 470 Cardinal num_params=1; 471 472 if (*num_args != 2) { 473 XtAppWarningMsg(pd->appContext, XtNwrongParameters, "cvtStringToPixel", 474 XtCXtToolkitError, 475 "String to pixel conversion needs screen and colormap arguments", 476 NULL, NULL); 477 return False; 478 } 479 480 screen = *((Screen **) args[0].addr); 481 colormap = *((Colormap *) args[1].addr); 482 483 if (CompareISOLatin1(str, XtDefaultBackground) == 0) { 484 *closure_ret = NULL; 485 if (pd->rv) donestr(Pixel, BlackPixelOfScreen(screen), XtRPixel) 486 else donestr(Pixel, WhitePixelOfScreen(screen), XtRPixel); 487 } 488 if (CompareISOLatin1(str, XtDefaultForeground) == 0) { 489 *closure_ret = NULL; 490 if (pd->rv) donestr(Pixel, WhitePixelOfScreen(screen), XtRPixel) 491 else donestr(Pixel, BlackPixelOfScreen(screen), XtRPixel); 492 } 493 494 status = XAllocNamedColor(DisplayOfScreen(screen), colormap, 495 (char*)str, &screenColor, &exactColor); 496 if (status == 0) { 497 _Xconst _XtString msg; 498 _Xconst _XtString type; 499 String params[1]; 500 501 params[0] = str; 502 /* Server returns a specific error code but Xlib discards it. Ugh */ 503 if (XLookupColor(DisplayOfScreen(screen), colormap, (char*)str, 504 &exactColor, &screenColor)) { 505 type = "noColormap"; 506 msg = "Cannot allocate colormap entry for \"%s\""; 507 } 508 else { 509 type = "badValue"; 510 msg = "Color name \"%s\" is not defined"; 511 } 512 513 XtAppWarningMsg(pd->appContext, type, "cvtStringToPixel", 514 XtCXtToolkitError, msg, params, &num_params); 515 *closure_ret = NULL; 516 return False; 517 } else { 518 *closure_ret = (char*)True; 519 donestr(Pixel, screenColor.pixel, XtRPixel); 520 } 521} 522 523/* ARGSUSED */ 524static void FreePixel( 525 XtAppContext app, 526 XrmValuePtr toVal, 527 XtPointer closure, 528 XrmValuePtr args, 529 Cardinal *num_args) 530{ 531 Screen *screen; 532 Colormap colormap; 533 534 if (*num_args != 2) { 535 XtAppWarningMsg(app, XtNwrongParameters,"freePixel",XtCXtToolkitError, 536 "Freeing a pixel requires screen and colormap arguments", 537 NULL, NULL); 538 return; 539 } 540 541 screen = *((Screen **) args[0].addr); 542 colormap = *((Colormap *) args[1].addr); 543 544 if (closure) { 545 XFreeColors( DisplayOfScreen(screen), colormap, 546 (unsigned long*)toVal->addr, 1, (unsigned long)0 547 ); 548 } 549} 550 551 552/* no longer used by Xt, but it's in the spec */ 553XtConvertArgRec const screenConvertArg[] = { 554 {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.screen), 555 sizeof(Screen *)} 556}; 557 558/*ARGSUSED*/ 559static void FetchDisplayArg( 560 Widget widget, 561 Cardinal *size, 562 XrmValue* value) 563{ 564 if (widget == NULL) { 565 XtErrorMsg("missingWidget", "fetchDisplayArg", XtCXtToolkitError, 566 "FetchDisplayArg called without a widget to reference", 567 NULL, NULL); 568 /* can't return any useful Display and caller will de-ref NULL, 569 so aborting is the only useful option */ 570 } else { 571 value->size = sizeof(Display*); 572 value->addr = (XPointer)&DisplayOfScreen(XtScreenOfObject(widget)); 573 } 574} 575 576static XtConvertArgRec const displayConvertArg[] = { 577 {XtProcedureArg, (XtPointer)FetchDisplayArg, 0}, 578}; 579 580/*ARGSUSED*/ 581Boolean XtCvtStringToCursor( 582 Display* dpy, 583 XrmValuePtr args, 584 Cardinal *num_args, 585 XrmValuePtr fromVal, 586 XrmValuePtr toVal, 587 XtPointer *closure_ret) 588{ 589 static const struct _CursorName { 590 const char *name; 591 unsigned int shape; 592 } cursor_names[] = { 593 {"X_cursor", XC_X_cursor}, 594 {"arrow", XC_arrow}, 595 {"based_arrow_down", XC_based_arrow_down}, 596 {"based_arrow_up", XC_based_arrow_up}, 597 {"boat", XC_boat}, 598 {"bogosity", XC_bogosity}, 599 {"bottom_left_corner", XC_bottom_left_corner}, 600 {"bottom_right_corner", XC_bottom_right_corner}, 601 {"bottom_side", XC_bottom_side}, 602 {"bottom_tee", XC_bottom_tee}, 603 {"box_spiral", XC_box_spiral}, 604 {"center_ptr", XC_center_ptr}, 605 {"circle", XC_circle}, 606 {"clock", XC_clock}, 607 {"coffee_mug", XC_coffee_mug}, 608 {"cross", XC_cross}, 609 {"cross_reverse", XC_cross_reverse}, 610 {"crosshair", XC_crosshair}, 611 {"diamond_cross", XC_diamond_cross}, 612 {"dot", XC_dot}, 613 {"dotbox", XC_dotbox}, 614 {"double_arrow", XC_double_arrow}, 615 {"draft_large", XC_draft_large}, 616 {"draft_small", XC_draft_small}, 617 {"draped_box", XC_draped_box}, 618 {"exchange", XC_exchange}, 619 {"fleur", XC_fleur}, 620 {"gobbler", XC_gobbler}, 621 {"gumby", XC_gumby}, 622 {"hand1", XC_hand1}, 623 {"hand2", XC_hand2}, 624 {"heart", XC_heart}, 625 {"icon", XC_icon}, 626 {"iron_cross", XC_iron_cross}, 627 {"left_ptr", XC_left_ptr}, 628 {"left_side", XC_left_side}, 629 {"left_tee", XC_left_tee}, 630 {"leftbutton", XC_leftbutton}, 631 {"ll_angle", XC_ll_angle}, 632 {"lr_angle", XC_lr_angle}, 633 {"man", XC_man}, 634 {"middlebutton", XC_middlebutton}, 635 {"mouse", XC_mouse}, 636 {"pencil", XC_pencil}, 637 {"pirate", XC_pirate}, 638 {"plus", XC_plus}, 639 {"question_arrow", XC_question_arrow}, 640 {"right_ptr", XC_right_ptr}, 641 {"right_side", XC_right_side}, 642 {"right_tee", XC_right_tee}, 643 {"rightbutton", XC_rightbutton}, 644 {"rtl_logo", XC_rtl_logo}, 645 {"sailboat", XC_sailboat}, 646 {"sb_down_arrow", XC_sb_down_arrow}, 647 {"sb_h_double_arrow", XC_sb_h_double_arrow}, 648 {"sb_left_arrow", XC_sb_left_arrow}, 649 {"sb_right_arrow", XC_sb_right_arrow}, 650 {"sb_up_arrow", XC_sb_up_arrow}, 651 {"sb_v_double_arrow", XC_sb_v_double_arrow}, 652 {"shuttle", XC_shuttle}, 653 {"sizing", XC_sizing}, 654 {"spider", XC_spider}, 655 {"spraycan", XC_spraycan}, 656 {"star", XC_star}, 657 {"target", XC_target}, 658 {"tcross", XC_tcross}, 659 {"top_left_arrow", XC_top_left_arrow}, 660 {"top_left_corner", XC_top_left_corner}, 661 {"top_right_corner", XC_top_right_corner}, 662 {"top_side", XC_top_side}, 663 {"top_tee", XC_top_tee}, 664 {"trek", XC_trek}, 665 {"ul_angle", XC_ul_angle}, 666 {"umbrella", XC_umbrella}, 667 {"ur_angle", XC_ur_angle}, 668 {"watch", XC_watch}, 669 {"xterm", XC_xterm}, 670 }; 671 const struct _CursorName *nP; 672 char *name = (char *)fromVal->addr; 673 register Cardinal i; 674 675 if (*num_args != 1) { 676 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 677 XtNwrongParameters,"cvtStringToCursor",XtCXtToolkitError, 678 "String to cursor conversion needs display argument", 679 NULL, NULL); 680 return False; 681 } 682 683 for (i=0, nP=cursor_names; i < XtNumber(cursor_names); i++, nP++ ) { 684 if (strcmp(name, nP->name) == 0) { 685 Display *display = *(Display**)args[0].addr; 686 Cursor cursor = XCreateFontCursor(display, nP->shape ); 687 donestr(Cursor, cursor, XtRCursor); 688 } 689 } 690 XtDisplayStringConversionWarning(dpy, name, XtRCursor); 691 return False; 692} 693 694/* ARGSUSED */ 695static void FreeCursor( 696 XtAppContext app, 697 XrmValuePtr toVal, 698 XtPointer closure, /* unused */ 699 XrmValuePtr args, 700 Cardinal *num_args) 701{ 702 Display* display; 703 704 if (*num_args != 1) { 705 XtAppWarningMsg(app, 706 XtNwrongParameters,"freeCursor",XtCXtToolkitError, 707 "Free Cursor requires display argument", 708 NULL, NULL); 709 return; 710 } 711 712 display = *(Display**)args[0].addr; 713 XFreeCursor( display, *(Cursor*)toVal->addr ); 714} 715 716/*ARGSUSED*/ 717Boolean XtCvtStringToDisplay( 718 Display* dpy, 719 XrmValuePtr args, 720 Cardinal *num_args, 721 XrmValuePtr fromVal, 722 XrmValuePtr toVal, 723 XtPointer *closure_ret) 724{ 725 Display *d; 726 727 if (*num_args != 0) 728 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 729 XtNwrongParameters,"cvtStringToDisplay",XtCXtToolkitError, 730 "String to Display conversion needs no extra arguments", 731 NULL, NULL); 732 733 d = XOpenDisplay((char *)fromVal->addr); 734 if (d != NULL) 735 donestr(Display*, d, XtRDisplay); 736 737 XtDisplayStringConversionWarning(dpy, (char *) fromVal->addr, XtRDisplay); 738 return False; 739} 740 741 742/*ARGSUSED*/ 743Boolean XtCvtStringToFile( 744 Display* dpy, 745 XrmValuePtr args, 746 Cardinal *num_args, 747 XrmValuePtr fromVal, 748 XrmValuePtr toVal, 749 XtPointer *closure_ret) 750{ 751 FILE *f; 752 753 if (*num_args != 0) 754 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 755 XtNwrongParameters,"cvtStringToFile",XtCXtToolkitError, 756 "String to File conversion needs no extra arguments", 757 NULL, NULL); 758 759 f = fopen((char *)fromVal->addr, "r"); 760 if (f != NULL) 761 donestr(FILE*, f, XtRFile); 762 763 XtDisplayStringConversionWarning(dpy, (char *) fromVal->addr, XtRFile); 764 return False; 765} 766 767/* ARGSUSED */ 768static void FreeFile( 769 XtAppContext app, 770 XrmValuePtr toVal, 771 XtPointer closure, /* unused */ 772 XrmValuePtr args, /* unused */ 773 Cardinal *num_args) 774{ 775 if (*num_args != 0) 776 XtAppWarningMsg(app, 777 XtNwrongParameters,"freeFile",XtCXtToolkitError, 778 "Free File requires no extra arguments", 779 NULL, NULL); 780 781 fclose( *(FILE**)toVal->addr ); 782} 783 784/*ARGSUSED*/ 785Boolean XtCvtIntToFloat( 786 Display* dpy, 787 XrmValuePtr args, 788 Cardinal *num_args, 789 XrmValuePtr fromVal, 790 XrmValuePtr toVal, 791 XtPointer *closure_ret) 792{ 793 if (*num_args != 0) 794 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 795 XtNwrongParameters,"cvtIntToFloat",XtCXtToolkitError, 796 "Integer to Float conversion needs no extra arguments", 797 NULL, NULL); 798 done(float, (*(int *)fromVal->addr)); 799} 800 801/*ARGSUSED*/ 802Boolean XtCvtStringToFloat( 803 Display* dpy, 804 XrmValuePtr args, 805 Cardinal *num_args, 806 XrmValuePtr fromVal, 807 XrmValuePtr toVal, 808 XtPointer *closure_ret) 809{ 810 int ret; 811 float f, nan; 812 813 (void) sscanf ("NaN", "%g", 814 toVal->addr != NULL ? (float*) toVal->addr : &nan); 815 816 if (*num_args != 0) 817 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 818 XtNwrongParameters,"cvtStringToFloat",XtCXtToolkitError, 819 "String to Float conversion needs no extra arguments", 820 NULL, NULL); 821 822 ret = sscanf (fromVal->addr, "%g", &f); 823 if (ret == 0) { 824 if (toVal->addr != NULL && toVal->size == sizeof nan) 825 *(float*)toVal->addr = nan; 826 XtDisplayStringConversionWarning (dpy, (char*) fromVal->addr, XtRFloat); 827 return False; 828 } 829 donestr(float, f, XtRFloat); 830} 831 832/*ARGSUSED*/ 833Boolean XtCvtStringToFont( 834 Display* dpy, 835 XrmValuePtr args, 836 Cardinal *num_args, 837 XrmValuePtr fromVal, 838 XrmValuePtr toVal, 839 XtPointer *closure_ret) 840{ 841 Font f; 842 Display* display; 843 844 if (*num_args != 1) { 845 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 846 XtNwrongParameters,"cvtStringToFont",XtCXtToolkitError, 847 "String to font conversion needs display argument", 848 NULL, NULL); 849 return False; 850 } 851 852 display = *(Display**)args[0].addr; 853 854 if (CompareISOLatin1((String)fromVal->addr, XtDefaultFont) != 0) { 855 f = XLoadFont(display, (char *)fromVal->addr); 856 if (f != 0) { 857 Done: donestr( Font, f, XtRFont ); 858 } 859 XtDisplayStringConversionWarning(dpy, (char *) fromVal->addr, XtRFont); 860 } 861 /* try and get the default font */ 862 863 { 864 XrmName xrm_name[2]; 865 XrmClass xrm_class[2]; 866 XrmRepresentation rep_type; 867 XrmValue value; 868 869 xrm_name[0] = XrmPermStringToQuark ("xtDefaultFont"); 870 xrm_name[1] = 0; 871 xrm_class[0] = XrmPermStringToQuark ("XtDefaultFont"); 872 xrm_class[1] = 0; 873 if (XrmQGetResource(XtDatabase(display), xrm_name, xrm_class, 874 &rep_type, &value)) { 875 if (rep_type == _XtQString) { 876 f = XLoadFont(display, (char *)value.addr); 877 if (f != 0) 878 goto Done; 879 else 880 XtDisplayStringConversionWarning(dpy, (char *)value.addr, 881 XtRFont); 882 } else if (rep_type == XtQFont) { 883 f = *(Font*)value.addr; 884 goto Done; 885 } else if (rep_type == XtQFontStruct) { 886 f = ((XFontStruct*)value.addr)->fid; 887 goto Done; 888 } 889 } 890 } 891 /* Should really do XListFonts, but most servers support this */ 892 f = XLoadFont(display, "-*-*-*-R-*-*-*-120-*-*-*-*-ISO8859-*"); 893 if (f != 0) 894 goto Done; 895 896 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 897 "noFont","cvtStringToFont",XtCXtToolkitError, 898 "Unable to load any usable ISO8859 font", 899 NULL, NULL); 900 901 return False; 902} 903 904/* ARGSUSED */ 905static void FreeFont( 906 XtAppContext app, 907 XrmValuePtr toVal, 908 XtPointer closure, /* unused */ 909 XrmValuePtr args, 910 Cardinal *num_args) 911{ 912 Display *display; 913 if (*num_args != 1) { 914 XtAppWarningMsg(app, 915 XtNwrongParameters,"freeFont",XtCXtToolkitError, 916 "Free Font needs display argument", 917 NULL, NULL); 918 return; 919 } 920 921 display = *(Display**)args[0].addr; 922 XUnloadFont( display, *(Font*)toVal->addr ); 923} 924 925/*ARGSUSED*/ 926Boolean XtCvtIntToFont( 927 Display* dpy, 928 XrmValuePtr args, 929 Cardinal *num_args, 930 XrmValuePtr fromVal, 931 XrmValuePtr toVal, 932 XtPointer *closure_ret) 933{ 934 if (*num_args != 0) 935 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 936 XtNwrongParameters,"cvtIntToFont",XtCXtToolkitError, 937 "Integer to Font conversion needs no extra arguments", 938 NULL, NULL); 939 done(Font, *(int*)fromVal->addr); 940} 941 942/*ARGSUSED*/ 943Boolean XtCvtStringToFontSet( 944 Display* dpy, 945 XrmValuePtr args, 946 Cardinal *num_args, 947 XrmValuePtr fromVal, 948 XrmValuePtr toVal, 949 XtPointer *closure_ret) 950{ 951 XFontSet f; 952 Display* display; 953 char** missing_charset_list; 954 int missing_charset_count; 955 char* def_string; 956 957 if (*num_args != 2) { 958 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 959 XtNwrongParameters,"cvtStringToFontSet",XtCXtToolkitError, 960 "String to FontSet conversion needs display and locale arguments", 961 NULL, NULL); 962 return False; 963 } 964 965 display = *(Display**)args[0].addr; 966 967 if (CompareISOLatin1((String)fromVal->addr, XtDefaultFontSet) != 0) { 968 f = XCreateFontSet(display, (char *)fromVal->addr, 969 &missing_charset_list, &missing_charset_count, &def_string); 970 /* Free any returned missing charset list */ 971 if (missing_charset_count) { 972 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 973 XtNmissingCharsetList,"cvtStringToFontSet",XtCXtToolkitError, 974 "Missing charsets in String to FontSet conversion", 975 NULL, NULL); 976 XFreeStringList(missing_charset_list); 977 } 978 if (f != NULL) { 979 Done: donestr( XFontSet, f, XtRFontSet ); 980 } 981 XtDisplayStringConversionWarning(dpy, (char *)fromVal->addr, XtRFontSet); 982 } 983 /* try and get the default fontset */ 984 985 { 986 XrmName xrm_name[2]; 987 XrmClass xrm_class[2]; 988 XrmRepresentation rep_type; 989 XrmValue value; 990 991 xrm_name[0] = XrmPermStringToQuark ("xtDefaultFontSet"); 992 xrm_name[1] = 0; 993 xrm_class[0] = XrmPermStringToQuark ("XtDefaultFontSet"); 994 xrm_class[1] = 0; 995 if (XrmQGetResource(XtDatabase(display), xrm_name, xrm_class, 996 &rep_type, &value)) { 997 if (rep_type == _XtQString) { 998 999 f = XCreateFontSet(display, (char *)value.addr, 1000 &missing_charset_list, &missing_charset_count, 1001 &def_string); 1002 /* Free any returned missing charset list */ 1003 if (missing_charset_count) { 1004 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1005 XtNmissingCharsetList,"cvtStringToFontSet", 1006 XtCXtToolkitError, 1007 "Missing charsets in String to FontSet conversion", 1008 NULL, NULL); 1009 XFreeStringList(missing_charset_list); 1010 } 1011 if (f != NULL) 1012 goto Done; 1013 else 1014 XtDisplayStringConversionWarning(dpy, (char *)value.addr, 1015 XtRFontSet); 1016 } else if (rep_type == XtQFontSet) { 1017 f = *(XFontSet*)value.addr; 1018 goto Done; 1019 } 1020 } 1021 } 1022 1023 /* Should really do XListFonts, but most servers support this */ 1024 f = XCreateFontSet(display, "-*-*-*-R-*-*-*-120-*-*-*-*,*", 1025 &missing_charset_list, &missing_charset_count, &def_string); 1026 1027 /* Free any returned missing charset list */ 1028 if (missing_charset_count) { 1029 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1030 XtNmissingCharsetList,"cvtStringToFontSet",XtCXtToolkitError, 1031 "Missing charsets in String to FontSet conversion", 1032 NULL, NULL); 1033 XFreeStringList(missing_charset_list); 1034 } 1035 if (f != NULL) 1036 goto Done; 1037 1038 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1039 "noFont","cvtStringToFontSet",XtCXtToolkitError, 1040 "Unable to load any usable fontset", 1041 NULL, NULL); 1042 1043 return False; 1044} 1045 1046/*ARGSUSED*/ 1047static void FreeFontSet( 1048 XtAppContext app, 1049 XrmValuePtr toVal, 1050 XtPointer closure, /* unused */ 1051 XrmValuePtr args, 1052 Cardinal *num_args) 1053{ 1054 Display *display; 1055 if (*num_args != 2) { 1056 XtAppWarningMsg(app, 1057 XtNwrongParameters,"freeFontSet",XtCXtToolkitError, 1058 "FreeFontSet needs display and locale arguments", 1059 NULL, NULL); 1060 return; 1061 } 1062 1063 display = *(Display**)args[0].addr; 1064 XFreeFontSet( display, *(XFontSet*)toVal->addr ); 1065} 1066 1067/*ARGSUSED*/ 1068static void FetchLocaleArg( 1069 Widget widget, /* unused */ 1070 Cardinal *size, /* unused */ 1071 XrmValue *value) 1072{ 1073 static XrmString locale; 1074 1075 locale = XrmQuarkToString(XrmStringToQuark 1076 (setlocale(LC_CTYPE, (char*)NULL))); 1077 value->size = sizeof(XrmString); 1078 value->addr = (XPointer)&locale; 1079} 1080 1081static XtConvertArgRec const localeDisplayConvertArgs[] = { 1082 {XtProcedureArg, (XtPointer)FetchDisplayArg, 0}, 1083 {XtProcedureArg, (XtPointer)FetchLocaleArg, 0}, 1084}; 1085 1086 1087/*ARGSUSED*/ 1088Boolean 1089XtCvtStringToFontStruct( 1090 Display* dpy, 1091 XrmValuePtr args, 1092 Cardinal *num_args, 1093 XrmValuePtr fromVal, 1094 XrmValuePtr toVal, 1095 XtPointer *closure_ret) 1096{ 1097 XFontStruct *f; 1098 Display* display; 1099 1100 if (*num_args != 1) { 1101 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1102 XtNwrongParameters,"cvtStringToFontStruct",XtCXtToolkitError, 1103 "String to font conversion needs display argument", 1104 NULL, NULL); 1105 return False; 1106 } 1107 1108 display = *(Display**)args[0].addr; 1109 1110 if (CompareISOLatin1((String)fromVal->addr, XtDefaultFont) != 0) { 1111 f = XLoadQueryFont(display, (char *)fromVal->addr); 1112 if (f != NULL) { 1113 Done: donestr( XFontStruct*, f, XtRFontStruct); 1114 } 1115 1116 XtDisplayStringConversionWarning(dpy, (char*)fromVal->addr, 1117 XtRFontStruct); 1118 } 1119 1120 /* try and get the default font */ 1121 1122 { 1123 XrmName xrm_name[2]; 1124 XrmClass xrm_class[2]; 1125 XrmRepresentation rep_type; 1126 XrmValue value; 1127 1128 xrm_name[0] = XrmPermStringToQuark ("xtDefaultFont"); 1129 xrm_name[1] = 0; 1130 xrm_class[0] = XrmPermStringToQuark ("XtDefaultFont"); 1131 xrm_class[1] = 0; 1132 if (XrmQGetResource(XtDatabase(display), xrm_name, xrm_class, 1133 &rep_type, &value)) { 1134 if (rep_type == _XtQString) { 1135 f = XLoadQueryFont(display, (char*)value.addr); 1136 if (f != NULL) 1137 goto Done; 1138 else 1139 XtDisplayStringConversionWarning(dpy, (char*)value.addr, 1140 XtRFontStruct); 1141 } else if (rep_type == XtQFont) { 1142 f = XQueryFont(display, *(Font*)value.addr ); 1143 if (f != NULL) goto Done; 1144 } else if (rep_type == XtQFontStruct) { 1145 f = (XFontStruct*)value.addr; 1146 goto Done; 1147 } 1148 } 1149 } 1150 /* Should really do XListFonts, but most servers support this */ 1151 f = XLoadQueryFont(display, "-*-*-*-R-*-*-*-120-*-*-*-*-ISO8859-*"); 1152 if (f != NULL) 1153 goto Done; 1154 1155 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1156 "noFont","cvtStringToFontStruct",XtCXtToolkitError, 1157 "Unable to load any usable ISO8859 font", 1158 NULL, NULL); 1159 1160 return False; 1161} 1162 1163/* ARGSUSED */ 1164static void FreeFontStruct( 1165 XtAppContext app, 1166 XrmValuePtr toVal, 1167 XtPointer closure, /* unused */ 1168 XrmValuePtr args, 1169 Cardinal *num_args) 1170{ 1171 Display *display; 1172 if (*num_args != 1) { 1173 XtAppWarningMsg(app, 1174 XtNwrongParameters,"freeFontStruct",XtCXtToolkitError, 1175 "Free FontStruct requires display argument", 1176 NULL, NULL); 1177 return; 1178 } 1179 1180 display = *(Display**)args[0].addr; 1181 XFreeFont( display, *(XFontStruct**)toVal->addr ); 1182} 1183 1184/*ARGSUSED*/ 1185Boolean XtCvtStringToInt( 1186 Display* dpy, 1187 XrmValuePtr args, 1188 Cardinal *num_args, 1189 XrmValuePtr fromVal, 1190 XrmValuePtr toVal, 1191 XtPointer *closure_ret) 1192{ 1193 int i; 1194 1195 if (*num_args != 0) 1196 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1197 XtNwrongParameters,"cvtStringToInt",XtCXtToolkitError, 1198 "String to Integer conversion needs no extra arguments", 1199 NULL, NULL); 1200 if (IsInteger((String)fromVal->addr, &i)) 1201 donestr(int, i, XtRInt); 1202 1203 XtDisplayStringConversionWarning(dpy, (char *) fromVal->addr, XtRInt); 1204 return False; 1205} 1206 1207/*ARGSUSED*/ 1208Boolean XtCvtStringToShort( 1209 Display* dpy, 1210 XrmValuePtr args, 1211 Cardinal *num_args, 1212 XrmValuePtr fromVal, 1213 XrmValuePtr toVal, 1214 XtPointer *closure_ret) 1215{ 1216 int i; 1217 1218 if (*num_args != 0) 1219 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1220 XtNwrongParameters,"cvtStringToShort",XtCXtToolkitError, 1221 "String to Integer conversion needs no extra arguments", 1222 NULL, NULL); 1223 if (IsInteger((String)fromVal->addr, &i)) 1224 donestr(short, (short)i, XtRShort); 1225 1226 XtDisplayStringConversionWarning(dpy, (char *) fromVal->addr, XtRShort); 1227 return False; 1228} 1229 1230/*ARGSUSED*/ 1231Boolean XtCvtStringToDimension( 1232 Display* dpy, 1233 XrmValuePtr args, 1234 Cardinal *num_args, 1235 XrmValuePtr fromVal, 1236 XrmValuePtr toVal, 1237 XtPointer *closure_ret) 1238{ 1239 int i; 1240 1241 if (*num_args != 0) 1242 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1243 XtNwrongParameters,"cvtStringToDimension",XtCXtToolkitError, 1244 "String to Dimension conversion needs no extra arguments", 1245 NULL, NULL); 1246 if (IsInteger((String)fromVal->addr, &i)) { 1247 if ( i < 0 ) 1248 XtDisplayStringConversionWarning(dpy, (char*)fromVal->addr, 1249 XtRDimension); 1250 donestr(Dimension, (Dimension)i, XtRDimension); 1251 } 1252 XtDisplayStringConversionWarning(dpy, (char *) fromVal->addr, XtRDimension); 1253 return False; 1254} 1255 1256/*ARGSUSED*/ 1257Boolean XtCvtIntToUnsignedChar( 1258 Display* dpy, 1259 XrmValuePtr args, 1260 Cardinal *num_args, 1261 XrmValuePtr fromVal, 1262 XrmValuePtr toVal, 1263 XtPointer *closure_ret) 1264{ 1265 if (*num_args != 0) 1266 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1267 XtNwrongParameters,"cvtIntToUnsignedChar",XtCXtToolkitError, 1268 "Integer to UnsignedChar conversion needs no extra arguments", 1269 NULL, NULL); 1270 done(unsigned char, (*(int *)fromVal->addr)); 1271} 1272 1273 1274/*ARGSUSED*/ 1275Boolean XtCvtStringToUnsignedChar( 1276 Display* dpy, 1277 XrmValuePtr args, 1278 Cardinal *num_args, 1279 XrmValuePtr fromVal, 1280 XrmValuePtr toVal, 1281 XtPointer *closure_ret) 1282{ 1283 int i; 1284 1285 if (*num_args != 0) 1286 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1287 XtNwrongParameters,"cvtStringToUnsignedChar",XtCXtToolkitError, 1288 "String to Integer conversion needs no extra arguments", 1289 NULL, NULL); 1290 if (IsInteger((String)fromVal->addr, &i)) { 1291 if ( i < 0 || i > 255 ) 1292 XtDisplayStringConversionWarning(dpy, (char*)fromVal->addr, 1293 XtRUnsignedChar); 1294 donestr(unsigned char, i, XtRUnsignedChar); 1295 } 1296 XtDisplayStringConversionWarning(dpy, (char*)fromVal->addr, 1297 XtRUnsignedChar); 1298 return False; 1299} 1300 1301 1302/*ARGSUSED*/ 1303Boolean XtCvtColorToPixel( 1304 Display* dpy, 1305 XrmValuePtr args, 1306 Cardinal *num_args, 1307 XrmValuePtr fromVal, 1308 XrmValuePtr toVal, 1309 XtPointer *closure_ret) 1310{ 1311 if (*num_args != 0) 1312 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1313 XtNwrongParameters,"cvtXColorToPixel",XtCXtToolkitError, 1314 "Color to Pixel conversion needs no extra arguments", 1315 NULL, NULL); 1316 done(Pixel, ((XColor *)fromVal->addr)->pixel); 1317} 1318 1319/*ARGSUSED*/ 1320Boolean XtCvtIntToPixel( 1321 Display* dpy, 1322 XrmValuePtr args, 1323 Cardinal *num_args, 1324 XrmValuePtr fromVal, 1325 XrmValuePtr toVal, 1326 XtPointer *closure_ret) 1327{ 1328 if (*num_args != 0) 1329 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1330 XtNwrongParameters,"cvtIntToPixel",XtCXtToolkitError, 1331 "Integer to Pixel conversion needs no extra arguments", 1332 NULL, NULL); 1333 done(Pixel, *(int*)fromVal->addr); 1334} 1335 1336/*ARGSUSED*/ 1337Boolean XtCvtIntToPixmap( 1338 Display* dpy, 1339 XrmValuePtr args, 1340 Cardinal *num_args, 1341 XrmValuePtr fromVal, 1342 XrmValuePtr toVal, 1343 XtPointer *closure_ret) 1344{ 1345 if (*num_args != 0) 1346 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1347 XtNwrongParameters,"cvtIntToPixmap",XtCXtToolkitError, 1348 "Integer to Pixmap conversion needs no extra arguments", 1349 NULL, NULL); 1350 done(Pixmap, *(int*)fromVal->addr); 1351} 1352 1353#ifdef MOTIFBC 1354void LowerCase(register char *source, register *dest) 1355{ 1356 register char ch; 1357 int i; 1358 1359 for (i = 0; (ch = *source) != 0 && i < 999; source++, dest++, i++) { 1360 if ('A' <= ch && ch <= 'Z') 1361 *dest = ch - 'A' + 'a'; 1362 else 1363 *dest = ch; 1364 } 1365 *dest = 0; 1366} 1367#endif 1368 1369static int CompareISOLatin1 (const char *first, const char *second) 1370{ 1371 register const unsigned char *ap, *bp; 1372 1373 for (ap = (const unsigned char *) first, 1374 bp = (const unsigned char *) second; 1375 *ap && *bp; ap++, bp++) { 1376 register unsigned char a, b; 1377 1378 if ((a = *ap) != (b = *bp)) { 1379 /* try lowercasing and try again */ 1380 1381 if ((a >= XK_A) && (a <= XK_Z)) 1382 a = (unsigned char) (a + (XK_a - XK_A)); 1383 else if ((a >= XK_Agrave) && (a <= XK_Odiaeresis)) 1384 a = (unsigned char) (a + (XK_agrave - XK_Agrave)); 1385 else if ((a >= XK_Ooblique) && (a <= XK_Thorn)) 1386 a = (unsigned char) (a + (XK_oslash - XK_Ooblique)); 1387 1388 if ((b >= XK_A) && (b <= XK_Z)) 1389 b = (unsigned char) (b + (XK_a - XK_A)); 1390 else if ((b >= XK_Agrave) && (b <= XK_Odiaeresis)) 1391 b = (unsigned char) (b + (XK_agrave - XK_Agrave)); 1392 else if ((b >= XK_Ooblique) && (b <= XK_Thorn)) 1393 b = (unsigned char) (b + (XK_oslash - XK_Ooblique)); 1394 1395 if (a != b) break; 1396 } 1397 } 1398 return (((int) *bp) - ((int) *ap)); 1399} 1400 1401static void CopyISOLatin1Lowered(char *dst, const char *src) 1402{ 1403 unsigned char *dest = (unsigned char *) dst; 1404 const unsigned char *source = (const unsigned char *) src; 1405 1406 for ( ; *source; source++, dest++) { 1407 if (*source >= XK_A && *source <= XK_Z) 1408 *dest = (unsigned char) (*source + (XK_a - XK_A)); 1409 else if (*source >= XK_Agrave && *source <= XK_Odiaeresis) 1410 *dest = (unsigned char) (*source + (XK_agrave - XK_Agrave)); 1411 else if (*source >= XK_Ooblique && *source <= XK_Thorn) 1412 *dest = (unsigned char) (*source + (XK_oslash - XK_Ooblique)); 1413 else 1414 *dest = *source; 1415 } 1416 *dest = '\0'; 1417} 1418 1419/*ARGSUSED*/ 1420Boolean 1421XtCvtStringToInitialState( 1422 Display* dpy, 1423 XrmValuePtr args, 1424 Cardinal *num_args, 1425 XrmValuePtr fromVal, 1426 XrmValuePtr toVal, 1427 XtPointer *closure_ret) 1428{ 1429 String str = (String)fromVal->addr; 1430 if (*num_args != 0) 1431 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1432 XtNwrongParameters,"cvtStringToInitialState",XtCXtToolkitError, 1433 "String to InitialState conversion needs no extra arguments", 1434 NULL, NULL); 1435 1436 if (CompareISOLatin1(str, "NormalState") == 0) donestr(int, NormalState, XtRInitialState); 1437 if (CompareISOLatin1(str, "IconicState") == 0) donestr(int, IconicState, XtRInitialState); 1438 { 1439 int val; 1440 if (IsInteger(str, &val)) donestr( int, val, XtRInitialState ); 1441 } 1442 XtDisplayStringConversionWarning(dpy, str, XtRInitialState); 1443 return False; 1444} 1445 1446static XtConvertArgRec const visualConvertArgs[] = { 1447 {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.screen), 1448 sizeof(Screen *)}, 1449 {XtWidgetBaseOffset, (XtPointer)XtOffsetOf(WidgetRec, core.depth), 1450 sizeof(Cardinal)} 1451}; 1452 1453/*ARGSUSED*/ 1454Boolean XtCvtStringToVisual( 1455 Display* dpy, 1456 XrmValuePtr args, /* Screen, depth */ 1457 Cardinal *num_args, /* 2 */ 1458 XrmValuePtr fromVal, 1459 XrmValuePtr toVal, 1460 XtPointer *closure_ret) /* unused */ 1461{ 1462 String str = (String)fromVal->addr; 1463 int vc; 1464 XVisualInfo vinfo; 1465 if (*num_args != 2) { 1466 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1467 XtNwrongParameters,"cvtStringToVisual",XtCXtToolkitError, 1468 "String to Visual conversion needs screen and depth arguments", 1469 NULL, NULL); 1470 return False; 1471 } 1472 1473 if (CompareISOLatin1(str, "StaticGray") == 0) vc = StaticGray; 1474 else if (CompareISOLatin1(str, "StaticColor") == 0) vc = StaticColor; 1475 else if (CompareISOLatin1(str, "TrueColor") == 0) vc = TrueColor; 1476 else if (CompareISOLatin1(str, "GrayScale") == 0) vc = GrayScale; 1477 else if (CompareISOLatin1(str, "PseudoColor") == 0) vc = PseudoColor; 1478 else if (CompareISOLatin1(str, "DirectColor") == 0) vc = DirectColor; 1479 else if (!IsInteger(str, &vc)) { 1480 XtDisplayStringConversionWarning(dpy, str, "Visual class name"); 1481 return False; 1482 } 1483 1484 if (XMatchVisualInfo( XDisplayOfScreen((Screen*)*(Screen**)args[0].addr), 1485 XScreenNumberOfScreen((Screen*)*(Screen**)args[0].addr), 1486 (int)*(int*)args[1].addr, 1487 vc, 1488 &vinfo) ) { 1489 donestr( Visual*, vinfo.visual, XtRVisual ); 1490 } 1491 else { 1492 String params[2]; 1493 Cardinal num_params = 2; 1494 params[0] = str; 1495 params[1] = 1496 DisplayString(XDisplayOfScreen((Screen*)*(Screen**)args[0].addr)); 1497 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1498 XtNconversionError, "stringToVisual", XtCXtToolkitError, 1499 "Cannot find Visual of class %s for display %s", 1500 params, &num_params ); 1501 return False; 1502 } 1503} 1504 1505 1506/*ARGSUSED*/ 1507Boolean XtCvtStringToAtom( 1508 Display* dpy, 1509 XrmValuePtr args, 1510 Cardinal *num_args, 1511 XrmValuePtr fromVal, 1512 XrmValuePtr toVal, 1513 XtPointer *closure_ret) 1514{ 1515 Atom atom; 1516 if (*num_args != 1) { 1517 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1518 XtNwrongParameters,"cvtStringToAtom",XtCXtToolkitError, 1519 "String to Atom conversion needs Display argument", 1520 NULL, NULL); 1521 return False; 1522 } 1523 1524 atom = XInternAtom( *(Display**)args->addr, (char*)fromVal->addr, False ); 1525 donestr(Atom, atom, XtRAtom); 1526} 1527 1528/*ARGSUSED*/ 1529Boolean XtCvtStringToDirectoryString( 1530 Display *dpy, 1531 XrmValuePtr args, 1532 Cardinal *num_args, 1533 XrmValuePtr fromVal, 1534 XrmValuePtr toVal, 1535 XtPointer *closure_ret) 1536{ 1537 String str; 1538 char directory[PATH_MAX+1]; 1539 1540 if (*num_args != 0) 1541 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1542 XtNwrongParameters,"cvtStringToDirectoryString",XtCXtToolkitError, 1543 "String to DirectoryString conversion needs no extra arguments", 1544 NULL, NULL); 1545 1546 str = (String)fromVal->addr; 1547 if (CompareISOLatin1(str, "XtCurrentDirectory") == 0) { 1548 /* uglier, but does not depend on compiler knowing return type */ 1549#if !defined(X_NOT_POSIX) || defined(SYSV) || defined(WIN32) 1550 if (getcwd(directory, PATH_MAX + 1)) 1551 str = directory; 1552#else 1553 if (getwd(directory)) 1554 str = directory; 1555#endif 1556 if (!str) { 1557 if (errno == EACCES) 1558 errno = 0; /* reset errno */ 1559 XtDisplayStringConversionWarning(dpy, (char *) fromVal->addr, 1560 XtRDirectoryString); 1561 return False; 1562 } 1563 } 1564 1565 /* Since memory from the resource database or from static buffers of 1566 * system libraries may be freed or overwritten, allocate memory. 1567 * The memory is freed when all cache references are released. 1568 */ 1569 str = XtNewString(str); 1570 donestr(String, str, XtRDirectoryString); 1571} 1572 1573/*ARGSUSED*/ 1574static void FreeDirectoryString( 1575 XtAppContext app, 1576 XrmValuePtr toVal, 1577 XtPointer closure, /* unused */ 1578 XrmValuePtr args, 1579 Cardinal *num_args) 1580{ 1581 if (*num_args != 0) 1582 XtAppWarningMsg(app, 1583 XtNwrongParameters,"freeDirectoryString",XtCXtToolkitError, 1584 "Free Directory String requires no extra arguments", 1585 NULL, NULL); 1586 1587 XtFree((char *) toVal->addr); 1588} 1589 1590/*ARGSUSED*/ 1591Boolean XtCvtStringToRestartStyle( 1592 Display *dpy, 1593 XrmValuePtr args, 1594 Cardinal *num_args, 1595 XrmValuePtr fromVal, 1596 XrmValuePtr toVal, 1597 XtPointer *closure_ret) 1598{ 1599 String str = (String)fromVal->addr; 1600 if (*num_args != 0) 1601 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1602 XtNwrongParameters,"cvtStringToRestartStyle",XtCXtToolkitError, 1603 "String to RestartStyle conversion needs no extra arguments", 1604 NULL, NULL); 1605 1606 if (CompareISOLatin1(str, "RestartIfRunning") == 0) 1607 donestr(unsigned char, SmRestartIfRunning, XtRRestartStyle); 1608 if (CompareISOLatin1(str, "RestartAnyway") == 0) 1609 donestr(unsigned char, SmRestartAnyway, XtRRestartStyle); 1610 if (CompareISOLatin1(str, "RestartImmediately") == 0) 1611 donestr(unsigned char, SmRestartImmediately, XtRRestartStyle); 1612 if (CompareISOLatin1(str, "RestartNever") == 0) 1613 donestr(unsigned char, SmRestartNever, XtRRestartStyle); 1614 XtDisplayStringConversionWarning(dpy, str, XtRRestartStyle); 1615 return False; 1616} 1617 1618/*ARGSUSED*/ 1619Boolean XtCvtStringToCommandArgArray( 1620 Display *dpy, 1621 XrmValuePtr args, 1622 Cardinal *num_args, 1623 XrmValuePtr fromVal, 1624 XrmValuePtr toVal, 1625 XtPointer *closure_ret) 1626{ 1627 String *strarray, *ptr; 1628 char *src; 1629 char *dst, *dst_str; 1630 int tokens, len; 1631 1632 if (*num_args != 0) 1633 XtAppWarningMsg(XtDisplayToApplicationContext(dpy), 1634 XtNwrongParameters,"cvtStringToCommandArgArray",XtCXtToolkitError, 1635 "String to CommandArgArray conversion needs no extra arguments", 1636 NULL, NULL); 1637 1638 src = fromVal->addr; 1639 dst = dst_str = __XtMalloc((unsigned) strlen(src) + 1); 1640 tokens = 0; 1641 1642 while (*src != '\0') { 1643 char *start; 1644 1645 /* skip whitespace */ 1646 while (IsWhitespace(*src) || IsNewline(*src)) 1647 src++; 1648 /* test for end of string */ 1649 if (*src == '\0') 1650 break; 1651 1652 /* start new token */ 1653 tokens++; 1654 start = src; 1655 while (*src != '\0' && !IsWhitespace(*src) && !IsNewline(*src)) { 1656 if (*src == '\\' && 1657 (IsWhitespace(*(src+1)) || IsNewline(*(src+1)))) { 1658 len = (int) (src - start); 1659 if (len) { 1660 /* copy preceeding part of token */ 1661 memcpy(dst, start, (size_t) len); 1662 dst += len; 1663 } 1664 /* skip backslash */ 1665 src++; 1666 /* next part of token starts at whitespace */ 1667 start = src; 1668 } 1669 src++; 1670 } 1671 len = (int) (src - start); 1672 if (len) { 1673 /* copy last part of token */ 1674 memcpy(dst, start, (size_t) len); 1675 dst += len; 1676 } 1677 *dst = '\0'; 1678 if (*src != '\0') 1679 dst++; 1680 } 1681 1682 ptr = strarray = (String*) __XtMalloc((Cardinal)((size_t)(tokens+1) * sizeof(String))); 1683 src = dst_str; 1684 while (--tokens >= 0) { 1685 *ptr = src; 1686 ptr++; 1687 if (tokens) { 1688 len = (int) strlen(src); 1689 src = src + len + 1; 1690 } 1691 } 1692 *ptr = NULL; 1693 1694 *closure_ret = (XtPointer) strarray; 1695 donestr(char**, strarray, XtRCommandArgArray) 1696} 1697 1698/*ARGSUSED*/ 1699static void ArgArrayDestructor( 1700 XtAppContext app, 1701 XrmValuePtr toVal, 1702 XtPointer closure, 1703 XrmValuePtr args, 1704 Cardinal *num_args) 1705{ 1706 if (closure) { 1707 _XtString *strarray = (_XtString*) closure; 1708 XtFree(*strarray); 1709 XtFree((char *) strarray); 1710 } 1711} 1712 1713/*ARGSUSED*/ 1714Boolean XtCvtStringToGravity ( 1715 Display* dpy, 1716 XrmValuePtr args, 1717 Cardinal *num_args, 1718 XrmValuePtr fromVal, 1719 XrmValuePtr toVal, 1720 XtPointer *closure_ret) 1721{ 1722 static struct _namepair { 1723 XrmQuark quark; 1724 const char *name; 1725 int gravity; 1726 } names[] = { 1727 { NULLQUARK, "forget", ForgetGravity }, 1728 { NULLQUARK, "northwest", NorthWestGravity }, 1729 { NULLQUARK, "north", NorthGravity }, 1730 { NULLQUARK, "northeast", NorthEastGravity }, 1731 { NULLQUARK, "west", WestGravity }, 1732 { NULLQUARK, "center", CenterGravity }, 1733 { NULLQUARK, "east", EastGravity }, 1734 { NULLQUARK, "southwest", SouthWestGravity }, 1735 { NULLQUARK, "south", SouthGravity }, 1736 { NULLQUARK, "southeast", SouthEastGravity }, 1737 { NULLQUARK, "static", StaticGravity }, 1738 { NULLQUARK, "unmap", UnmapGravity }, 1739 { NULLQUARK, "0", ForgetGravity }, 1740 { NULLQUARK, "1", NorthWestGravity }, 1741 { NULLQUARK, "2", NorthGravity }, 1742 { NULLQUARK, "3", NorthEastGravity }, 1743 { NULLQUARK, "4", WestGravity }, 1744 { NULLQUARK, "5", CenterGravity }, 1745 { NULLQUARK, "6", EastGravity }, 1746 { NULLQUARK, "7", SouthWestGravity }, 1747 { NULLQUARK, "8", SouthGravity }, 1748 { NULLQUARK, "9", SouthEastGravity }, 1749 { NULLQUARK, "10", StaticGravity }, 1750 { NULLQUARK, NULL, ForgetGravity } 1751 }; 1752 static Boolean haveQuarks = FALSE; 1753 char lowerName[40]; 1754 XrmQuark q; 1755 char *s; 1756 struct _namepair *np; 1757 1758 if (*num_args != 0) { 1759 XtAppWarningMsg(XtDisplayToApplicationContext (dpy), 1760 "wrongParameters","cvtStringToGravity","XtToolkitError", 1761 "String to Gravity conversion needs no extra arguments", 1762 NULL, NULL); 1763 return False; 1764 } 1765 if (!haveQuarks) { 1766 for (np = names; np->name; np++) { 1767 np->quark = XrmPermStringToQuark (np->name); 1768 } 1769 haveQuarks = TRUE; 1770 } 1771 s = (char *) fromVal->addr; 1772 if (strlen(s) < sizeof lowerName) { 1773 CopyISOLatin1Lowered (lowerName, s); 1774 q = XrmStringToQuark (lowerName); 1775 for (np = names; np->name; np++) 1776 if (np->quark == q) donestr(int, np->gravity, XtRGravity); 1777 } 1778 XtDisplayStringConversionWarning(dpy, (char *)fromVal->addr, XtRGravity); 1779 return False; 1780} 1781 1782void _XtAddDefaultConverters( 1783 ConverterTable table) 1784{ 1785#define Add(from, to, proc, convert_args, num_args, cache) \ 1786 _XtTableAddConverter(table, from, to, proc, \ 1787 (XtConvertArgList) convert_args, (Cardinal)num_args, \ 1788 True, cache, (XtDestructor)NULL, True) 1789 1790#define Add2(from, to, proc, convert_args, num_args, cache, destructor) \ 1791 _XtTableAddConverter(table, from, to, proc, \ 1792 (XtConvertArgList) convert_args, (Cardinal)num_args, \ 1793 True, cache, destructor, True) 1794 1795 Add(XtQColor, XtQPixel, XtCvtColorToPixel, NULL, 0, XtCacheNone); 1796 1797 Add(XtQInt, XtQBool, XtCvtIntToBool, NULL, 0, XtCacheNone); 1798 Add(XtQInt, XtQBoolean, XtCvtIntToBoolean, NULL, 0, XtCacheNone); 1799 Add(XtQInt, XtQColor, XtCvtIntToColor, 1800 colorConvertArgs, XtNumber(colorConvertArgs), XtCacheByDisplay); 1801 Add(XtQInt, XtQDimension, XtCvtIntToShort, NULL, 0, XtCacheNone); 1802 Add(XtQInt, XtQFloat, XtCvtIntToFloat, NULL, 0, XtCacheNone); 1803 Add(XtQInt, XtQFont, XtCvtIntToFont, NULL, 0, XtCacheNone); 1804 Add(XtQInt, XtQPixel, XtCvtIntToPixel, NULL, 0, XtCacheNone); 1805 Add(XtQInt, XtQPixmap, XtCvtIntToPixmap, NULL, 0, XtCacheNone); 1806 Add(XtQInt, XtQPosition, XtCvtIntToShort, NULL, 0, XtCacheNone); 1807 Add(XtQInt, XtQShort, XtCvtIntToShort, NULL, 0, XtCacheNone); 1808 Add(XtQInt, XtQUnsignedChar,XtCvtIntToUnsignedChar,NULL, 0, XtCacheNone); 1809 1810 Add(XtQPixel, XtQColor, XtCvtIntToColor, 1811 colorConvertArgs, XtNumber(colorConvertArgs), XtCacheByDisplay); 1812 1813 Add(_XtQString, XtQAtom, XtCvtStringToAtom, 1814 displayConvertArg, XtNumber(displayConvertArg), XtCacheNone); 1815 Add(_XtQString, XtQBool, XtCvtStringToBool, NULL, 0, XtCacheNone); 1816 Add(_XtQString, XtQBoolean, XtCvtStringToBoolean, NULL, 0, XtCacheNone); 1817 Add2(_XtQString, XtQCommandArgArray, XtCvtStringToCommandArgArray, 1818 NULL, 0, XtCacheNone | XtCacheRefCount, ArgArrayDestructor); 1819 Add2(_XtQString, XtQCursor, XtCvtStringToCursor, 1820 displayConvertArg, XtNumber(displayConvertArg), 1821 XtCacheByDisplay, FreeCursor); 1822 Add(_XtQString, XtQDimension, XtCvtStringToDimension,NULL, 0, XtCacheNone); 1823 Add2(_XtQString, XtQDirectoryString, XtCvtStringToDirectoryString, NULL, 0, 1824 XtCacheNone | XtCacheRefCount, FreeDirectoryString); 1825 Add(_XtQString, XtQDisplay, XtCvtStringToDisplay, NULL, 0, XtCacheAll); 1826 Add2(_XtQString, XtQFile, XtCvtStringToFile, NULL, 0, 1827 XtCacheAll | XtCacheRefCount, FreeFile); 1828 Add(_XtQString, XtQFloat, XtCvtStringToFloat, NULL, 0, XtCacheNone); 1829 1830 Add2(_XtQString, XtQFont, XtCvtStringToFont, 1831 displayConvertArg, XtNumber(displayConvertArg), 1832 XtCacheByDisplay, FreeFont); 1833 Add2(_XtQString, XtQFontSet, XtCvtStringToFontSet, 1834 localeDisplayConvertArgs, XtNumber(localeDisplayConvertArgs), 1835 XtCacheByDisplay, FreeFontSet); 1836 Add2(_XtQString, XtQFontStruct,XtCvtStringToFontStruct, 1837 displayConvertArg, XtNumber(displayConvertArg), 1838 XtCacheByDisplay, FreeFontStruct); 1839 1840 Add(_XtQString, XtQGravity, XtCvtStringToGravity, NULL, 0, XtCacheNone); 1841 Add(_XtQString, XtQInitialState, XtCvtStringToInitialState, NULL, 0, 1842 XtCacheNone); 1843 Add(_XtQString, XtQInt, XtCvtStringToInt, NULL, 0, XtCacheAll); 1844 Add2(_XtQString, XtQPixel, XtCvtStringToPixel, 1845 colorConvertArgs, XtNumber(colorConvertArgs), 1846 XtCacheByDisplay, FreePixel); 1847 Add(_XtQString, XtQPosition, XtCvtStringToShort, NULL, 0, XtCacheAll); 1848 Add(_XtQString, XtQRestartStyle, XtCvtStringToRestartStyle, NULL, 0, 1849 XtCacheNone); 1850 Add(_XtQString, XtQShort, XtCvtStringToShort, NULL, 0, XtCacheAll); 1851 Add(_XtQString, XtQUnsignedChar, XtCvtStringToUnsignedChar, 1852 NULL, 0, XtCacheAll); 1853 Add2(_XtQString, XtQVisual, XtCvtStringToVisual, 1854 visualConvertArgs, XtNumber(visualConvertArgs), 1855 XtCacheByDisplay, NULL); 1856 1857 _XtAddTMConverters(table); 1858} 1859