home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / lib / Xmu / StrToJust.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-20  |  1.8 KB  |  62 lines

  1. /* $XConsortium: StrToJust.c,v 1.6 90/12/20 13:30:18 converse Exp $ */
  2.  
  3. /* 
  4.  * Copyright 1988 by the Massachusetts Institute of Technology
  5.  *
  6.  * Permission to use, copy, modify, and distribute this software and its
  7.  * documentation for any purpose and without fee is hereby granted, provided 
  8.  * that the above copyright notice appear in all copies and that both that 
  9.  * copyright notice and this permission notice appear in supporting 
  10.  * documentation, and that the name of M.I.T. not be used in advertising
  11.  * or publicity pertaining to distribution of the software without specific, 
  12.  * written prior permission. M.I.T. makes no representations about the 
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  */
  17.  
  18. #include <X11/Intrinsic.h>
  19. #include "Converters.h"
  20. #include "CharSet.h"
  21.  
  22. /* ARGSUSED */
  23. void
  24. XmuCvtStringToJustify(args, num_args, fromVal, toVal)
  25.     XrmValuePtr args;        /* unused */
  26.     Cardinal    *num_args;    /* unused */
  27.     XrmValuePtr fromVal;
  28.     XrmValuePtr toVal;
  29. {
  30.     static XtJustify    e;
  31.     static XrmQuark    XrmQEleft;
  32.     static XrmQuark    XrmQEcenter;
  33.     static XrmQuark    XrmQEright;
  34.     static int        haveQuarks;
  35.     XrmQuark    q;
  36.     char    *s = (char *) fromVal->addr;
  37.     char        lowerName[1000];
  38.  
  39.     if (s == NULL) return;
  40.  
  41.     if (!haveQuarks) {
  42.     XrmQEleft   = XrmPermStringToQuark(XtEleft);
  43.     XrmQEcenter = XrmPermStringToQuark(XtEcenter);
  44.     XrmQEright  = XrmPermStringToQuark(XtEright);
  45.     haveQuarks = 1;
  46.     }
  47.  
  48.     XmuCopyISOLatin1Lowered(lowerName, s);
  49.  
  50.     q = XrmStringToQuark(lowerName);
  51.  
  52.     toVal->size = sizeof(XtJustify);
  53.     toVal->addr = (caddr_t) &e;
  54.  
  55.     if (q == XrmQEleft)   { e = XtJustifyLeft;   return; }
  56.     if (q == XrmQEcenter) { e = XtJustifyCenter; return; }
  57.     if (q == XrmQEright)  { e = XtJustifyRight;  return; }
  58.  
  59.     toVal->size = 0;
  60.     toVal->addr = NULL;
  61. }
  62.