1 /*
2 * Copyright 1992, 1993 by TOSHIBA Corp.
3 *
4 * Permission to use, copy, modify, and distribute this software and its
5 * documentation for any purpose and without fee is hereby granted, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of TOSHIBA not be used in advertising
9 * or publicity pertaining to distribution of the software without specific,
10 * written prior permission. TOSHIBA make no representations about the
11 * suitability of this software for any purpose. It is provided "as is"
12 * without express or implied warranty.
13 *
14 * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
15 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
16 * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
17 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
19 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
20 * SOFTWARE.
21 *
22 * Author: Katsuhisa Yano TOSHIBA Corp.
23 * mopi@osa.ilab.toshiba.co.jp
24 */
25
26 #ifdef HAVE_CONFIG_H
27 #include <config.h>
28 #endif
29 #include "Xlibint.h"
30 #include "XlcPubI.h"
31
32 char *
_XGetLCValues(XLCd lcd,...)33 _XGetLCValues(XLCd lcd, ...)
34 {
35 va_list var;
36 XlcArgList args;
37 char *ret;
38 int num_args;
39 XLCdPublicMethodsPart *methods = XLC_PUBLIC_METHODS(lcd);
40
41 va_start(var, lcd);
42 _XlcCountVaList(var, &num_args);
43 va_end(var);
44
45 va_start(var, lcd);
46 _XlcVaToArgList(var, num_args, &args);
47 va_end(var);
48
49 if (args == (XlcArgList) NULL)
50 return (char *) NULL;
51
52 ret = (*methods->get_values)(lcd, args, num_args);
53
54 Xfree(args);
55
56 return ret;
57 }
58
59 void
_XlcDestroyLC(XLCd lcd)60 _XlcDestroyLC(
61 XLCd lcd)
62 {
63 XLCdPublicMethods methods = (XLCdPublicMethods) lcd->methods;
64
65 (*methods->pub.destroy)(lcd);
66 }
67
68 XLCd
_XlcCreateLC(const char * name,XLCdMethods methods)69 _XlcCreateLC(
70 const char *name,
71 XLCdMethods methods)
72 {
73 XLCdPublicMethods pub_methods = (XLCdPublicMethods) methods;
74 XLCd lcd;
75
76 lcd = (*pub_methods->pub.create)(name, methods);
77 if (lcd == NULL)
78 return (XLCd) NULL;
79
80 if (lcd->core->name == NULL) {
81 lcd->core->name = strdup(name);
82 if (lcd->core->name == NULL)
83 goto err;
84 }
85
86 if (lcd->methods == NULL)
87 lcd->methods = methods;
88
89 if ((*pub_methods->pub.initialize)(lcd) == False)
90 goto err;
91
92 return lcd;
93
94 err:
95 _XlcDestroyLC(lcd);
96
97 return (XLCd) NULL;
98 }
99