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

« back to all changes in this revision

Viewing changes to routines/X11/Xmu/StrToBS.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: StrToBS.c,v 1.2 90/12/20 13:27:50 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
#define done(address, type) \
 
23
        { (*toVal).size = sizeof(type); (*toVal).addr = (caddr_t) address; }
 
24
 
 
25
/* ARGSUSED */
 
26
void
 
27
XmuCvtStringToBackingStore (args, num_args, fromVal, toVal)
 
28
    XrmValue    *args;          /* unused */
 
29
    Cardinal    *num_args;      /* unused */
 
30
    XrmValuePtr fromVal;
 
31
    XrmValuePtr toVal;
 
32
{
 
33
    char        lowerString[1024];
 
34
    XrmQuark    q;
 
35
    static int  backingStoreType;
 
36
    static XrmQuark XtQEnotUseful, XtQEwhenMapped, XtQEalways, XtQEdefault;
 
37
    static int haveQuarks = 0;
 
38
 
 
39
    if (*num_args != 0)
 
40
        XtWarning("String to BackingStore conversion needs no extra arguments");
 
41
    if (!haveQuarks) {
 
42
        XmuCopyISOLatin1Lowered (lowerString, XtEnotUseful);
 
43
        XtQEnotUseful = XrmStringToQuark(lowerString);
 
44
        XmuCopyISOLatin1Lowered (lowerString, XtEwhenMapped);
 
45
        XtQEwhenMapped = XrmStringToQuark(lowerString);
 
46
        XmuCopyISOLatin1Lowered (lowerString, XtEalways);
 
47
        XtQEalways = XrmStringToQuark(lowerString);
 
48
        XmuCopyISOLatin1Lowered (lowerString, XtEdefault);
 
49
        XtQEdefault = XrmStringToQuark(lowerString);
 
50
        haveQuarks = 1;
 
51
    }
 
52
    XmuCopyISOLatin1Lowered (lowerString, (char *) fromVal->addr);
 
53
    q = XrmStringToQuark (lowerString);
 
54
    if (q == XtQEnotUseful) {
 
55
        backingStoreType = NotUseful;
 
56
        done (&backingStoreType, int);
 
57
    } else if (q == XtQEwhenMapped) {
 
58
        backingStoreType = WhenMapped;
 
59
        done (&backingStoreType, int);
 
60
    } else if (q == XtQEalways) {
 
61
        backingStoreType = Always;
 
62
        done (&backingStoreType, int);
 
63
    } else if (q == XtQEdefault) {
 
64
        backingStoreType = Always + WhenMapped + NotUseful;
 
65
        done (&backingStoreType, int);
 
66
    } else {
 
67
        XtStringConversionWarning((char *) fromVal->addr, "BackingStore");
 
68
    }
 
69
}