~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to routines/X11/Xmu/StrToShap.c

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $XConsortium: StrToShap.c,v 1.3 90/12/20 13:36:01 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
#define done(type, value) \
 
24
        {                                                       \
 
25
            if (toVal->addr != NULL) {                          \
 
26
                if (toVal->size < sizeof(type)) {               \
 
27
                    toVal->size = sizeof(type);                 \
 
28
                    return False;                               \
 
29
                }                                               \
 
30
                *(type*)(toVal->addr) = (value);                \
 
31
            }                                                   \
 
32
            else {                                              \
 
33
                static type static_val;                         \
 
34
                static_val = (value);                           \
 
35
                toVal->size = sizeof(type);                     \
 
36
                toVal->addr = (XtPointer)&static_val;           \
 
37
            }                                                   \
 
38
            return True;                                        \
 
39
        }
 
40
 
 
41
 
 
42
Boolean XmuCvtStringToShapeStyle(dpy, args, num_args, from, toVal, data)
 
43
    Display *dpy;
 
44
    XrmValue *args;             /* unused */
 
45
    Cardinal *num_args;         /* unused */
 
46
    XrmValue *from;
 
47
    XrmValue *toVal;
 
48
    XtPointer *data;            /* unused */
 
49
{
 
50
    if (   XmuCompareISOLatin1((char*)from->addr, XtERectangle) == 0
 
51
        || XmuCompareISOLatin1((char*)from->addr, "ShapeRectangle") == 0)
 
52
        done( int, XmuShapeRectangle );
 
53
    if (   XmuCompareISOLatin1((char*)from->addr, XtEOval) == 0
 
54
        || XmuCompareISOLatin1((char*)from->addr, "ShapeOval") == 0)
 
55
        done( int, XmuShapeOval );
 
56
    if (   XmuCompareISOLatin1((char*)from->addr, XtEEllipse) == 0
 
57
        || XmuCompareISOLatin1((char*)from->addr, "ShapeEllipse") == 0)
 
58
        done( int, XmuShapeEllipse );
 
59
    if (   XmuCompareISOLatin1((char*)from->addr, XtERoundedRectangle) == 0
 
60
        || XmuCompareISOLatin1((char*)from->addr, "ShapeRoundedRectangle") == 0)
 
61
        done( int, XmuShapeRoundedRectangle );
 
62
    {
 
63
        int style = 0;
 
64
        char ch, *p = (char*)from->addr;
 
65
        while (ch = *p++) {
 
66
            if (ch >= '0' && ch <= '9') {
 
67
                style *= 10;
 
68
                style += ch - '0';
 
69
            }
 
70
            else break;
 
71
        }
 
72
        if (ch == '\0' && style <= XmuShapeRoundedRectangle)
 
73
            done( int, style );
 
74
    }
 
75
    XtDisplayStringConversionWarning( dpy, (char*)from->addr, XtRShapeStyle );
 
76
    return False;
 
77
}