home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3065 / string-convert.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-15  |  1.1 KB  |  38 lines

  1. /*
  2.  *    string-convert.c : A kludgy way to prevent getting a warning
  3.  *        message of the form "can't convert NULL to type Widget".
  4.  *
  5.  *    George Ferguson, ferguson@cs.rochester.edu, 8 Feb 1991.
  6.  *
  7.  *    This code is lifted from lib/Xt/Converters.c in the X11R4 source
  8.  *    tree. I would register my own converter for string to widget, but
  9.  *    there's no way to get the default converter, so I'd end up copying
  10.  *    or rewriting even more code. By the way, this works because the
  11.  *    converter returns NULL when it fails, which is what we want.
  12.  *
  13.  *    $Id: string-convert.c,v 2.0 91/02/08 15:55:32 ferguson Exp $
  14.  */
  15. #include <X11/Intrinsic.h>
  16. #include <X11/StringDefs.h>
  17.  
  18. /* from IntrinsicI.h */
  19. static String XtNconversionError = "conversionError";
  20. extern String XtCXtToolkitError;
  21.  
  22. void XtStringConversionWarning(from, toType)
  23.     String from, toType;
  24. {
  25.     String params[2];
  26.     Cardinal num_params = 2;
  27.  
  28.     if (strcasecmp(from,"NULL") == 0 &&
  29.         strcasecmp(toType,XtRWidget) == 0)
  30.         return;
  31.  
  32.     params[0] = from;
  33.     params[1] = toType;
  34.     XtWarningMsg(XtNconversionError,"string",XtCXtToolkitError,
  35.             "Cannot convert string \"%s\" to type %s",
  36.             params,&num_params);
  37. }
  38.