3 Copyright 1988, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
31 #include <X11/Intrinsic.h>
32 #include "Converters.h"
36 #define done(type, value) \
38 if (toVal->addr != NULL) { \
39 if (toVal->size < sizeof(type)) { \
40 toVal->size = sizeof(type); \
43 *(type*)(toVal->addr) = (value); \
46 static type static_val; \
47 static_val = (value); \
48 toVal->addr = (XtPointer)&static_val; \
50 toVal->size = sizeof(type); \
57 XmuCvtStringToShapeStyle(Display *dpy, XrmValue *args, Cardinal *num_args,
58 XrmValue *from, XrmValue *toVal, XtPointer *data)
60 String name = (String)from->addr;
62 if (XmuCompareISOLatin1(name, XtERectangle) == 0)
63 done(int, XmuShapeRectangle);
64 if (XmuCompareISOLatin1(name, XtEOval) == 0)
65 done(int, XmuShapeOval);
66 if (XmuCompareISOLatin1(name, XtEEllipse) == 0)
67 done(int, XmuShapeEllipse);
68 if (XmuCompareISOLatin1(name, XtERoundedRectangle) == 0)
69 done(int, XmuShapeRoundedRectangle);
71 XtDisplayStringConversionWarning(dpy, name, XtRShapeStyle);
78 XmuCvtShapeStyleToString(Display *dpy, XrmValue *args, Cardinal *num_args,
79 XrmValue *fromVal, XrmValue *toVal, XtPointer *data)
84 switch (*(int *)fromVal->addr)
86 case XmuShapeRectangle:
87 buffer = XtERectangle;
95 case XmuShapeRoundedRectangle:
96 buffer = XtERoundedRectangle;
99 XtAppWarning(XtDisplayToApplicationContext(dpy),
100 "Cannot convert ShapeStyle to String");
107 size = strlen(buffer) + 1;
108 if (toVal->addr != NULL)
110 if (toVal->size <= size)
115 strcpy((char *)toVal->addr, buffer);
118 toVal->addr = (XPointer)buffer;