11ab64890Smrg/*
21ab64890Smrg * Copyright 1992, 1993 by TOSHIBA Corp.
31ab64890Smrg *
41ab64890Smrg * Permission to use, copy, modify, and distribute this software and its
51ab64890Smrg * documentation for any purpose and without fee is hereby granted, provided
61ab64890Smrg * that the above copyright notice appear in all copies and that both that
71ab64890Smrg * copyright notice and this permission notice appear in supporting
81ab64890Smrg * documentation, and that the name of TOSHIBA not be used in advertising
91ab64890Smrg * or publicity pertaining to distribution of the software without specific,
101ab64890Smrg * written prior permission. TOSHIBA make no representations about the
111ab64890Smrg * suitability of this software for any purpose.  It is provided "as is"
121ab64890Smrg * without express or implied warranty.
131ab64890Smrg *
141ab64890Smrg * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
151ab64890Smrg * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
161ab64890Smrg * TOSHIBA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
171ab64890Smrg * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
181ab64890Smrg * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
191ab64890Smrg * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
201ab64890Smrg * SOFTWARE.
211ab64890Smrg *
221ab64890Smrg * Author: Katsuhisa Yano	TOSHIBA Corp.
231ab64890Smrg *			   	mopi@osa.ilab.toshiba.co.jp
241ab64890Smrg */
251ab64890Smrg
261ab64890Smrg#ifdef HAVE_CONFIG_H
271ab64890Smrg#include <config.h>
281ab64890Smrg#endif
291ab64890Smrg#include "Xlibint.h"
301ab64890Smrg#include "XlcPubI.h"
311ab64890Smrg
321ab64890Smrgchar *
331ab64890Smrg_XGetLCValues(XLCd lcd, ...)
341ab64890Smrg{
351ab64890Smrg    va_list var;
361ab64890Smrg    XlcArgList args;
371ab64890Smrg    char *ret;
381ab64890Smrg    int num_args;
391ab64890Smrg    XLCdPublicMethodsPart *methods = XLC_PUBLIC_METHODS(lcd);
401ab64890Smrg
411ab64890Smrg    va_start(var, lcd);
421ab64890Smrg    _XlcCountVaList(var, &num_args);
431ab64890Smrg    va_end(var);
441ab64890Smrg
451ab64890Smrg    va_start(var, lcd);
461ab64890Smrg    _XlcVaToArgList(var, num_args, &args);
471ab64890Smrg    va_end(var);
481ab64890Smrg
491ab64890Smrg    if (args == (XlcArgList) NULL)
501ab64890Smrg	return (char *) NULL;
5161b2299dSmrg
521ab64890Smrg    ret = (*methods->get_values)(lcd, args, num_args);
531ab64890Smrg
541ab64890Smrg    Xfree(args);
551ab64890Smrg
561ab64890Smrg    return ret;
571ab64890Smrg}
581ab64890Smrg
591ab64890Smrgvoid
601ab64890Smrg_XlcDestroyLC(
611ab64890Smrg    XLCd lcd)
621ab64890Smrg{
631ab64890Smrg    XLCdPublicMethods methods = (XLCdPublicMethods) lcd->methods;
641ab64890Smrg
651ab64890Smrg    (*methods->pub.destroy)(lcd);
661ab64890Smrg}
671ab64890Smrg
681ab64890SmrgXLCd
691ab64890Smrg_XlcCreateLC(
701ab64890Smrg    const char *name,
711ab64890Smrg    XLCdMethods methods)
721ab64890Smrg{
731ab64890Smrg    XLCdPublicMethods pub_methods = (XLCdPublicMethods) methods;
741ab64890Smrg    XLCd lcd;
751ab64890Smrg
761ab64890Smrg    lcd = (*pub_methods->pub.create)(name, methods);
771ab64890Smrg    if (lcd == NULL)
781ab64890Smrg	return (XLCd) NULL;
791ab64890Smrg
801ab64890Smrg    if (lcd->core->name == NULL) {
812d67cb4fSmrg	lcd->core->name = strdup(name);
8261b2299dSmrg	if (lcd->core->name == NULL)
831ab64890Smrg	    goto err;
841ab64890Smrg    }
8561b2299dSmrg
861ab64890Smrg    if (lcd->methods == NULL)
871ab64890Smrg	lcd->methods = methods;
881ab64890Smrg
891ab64890Smrg    if ((*pub_methods->pub.initialize)(lcd) == False)
901ab64890Smrg	goto err;
9161b2299dSmrg
921ab64890Smrg    return lcd;
931ab64890Smrg
941ab64890Smrgerr:
951ab64890Smrg    _XlcDestroyLC(lcd);
961ab64890Smrg
971ab64890Smrg    return (XLCd) NULL;
981ab64890Smrg}
99