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 "Xlcint.h"
311ab64890Smrg
321ab64890SmrgXOC
331ab64890SmrgXCreateOC(XOM om, ...)
341ab64890Smrg{
351ab64890Smrg    va_list var;
361ab64890Smrg    XlcArgList args;
371ab64890Smrg    XOC oc;
381ab64890Smrg    int num_args;
391ab64890Smrg
401ab64890Smrg    va_start(var, om);
411ab64890Smrg    _XlcCountVaList(var, &num_args);
421ab64890Smrg    va_end(var);
431ab64890Smrg
441ab64890Smrg    va_start(var, om);
451ab64890Smrg    _XlcVaToArgList(var, num_args, &args);
461ab64890Smrg    va_end(var);
471ab64890Smrg
481ab64890Smrg    if (args == (XlcArgList) NULL)
491ab64890Smrg	return (XOC) NULL;
501ab64890Smrg
511ab64890Smrg    oc = (*om->methods->create_oc)(om, args, num_args);
521ab64890Smrg
531ab64890Smrg    Xfree(args);
541ab64890Smrg
551ab64890Smrg    if (oc) {
561ab64890Smrg	oc->core.next = om->core.oc_list;
571ab64890Smrg	om->core.oc_list = oc;
581ab64890Smrg    }
591ab64890Smrg
601ab64890Smrg    return oc;
611ab64890Smrg}
621ab64890Smrg
631ab64890Smrgvoid
641ab64890SmrgXDestroyOC(XOC oc)
651ab64890Smrg{
661ab64890Smrg    XOC prev, oc_list;
671ab64890Smrg
681ab64890Smrg    prev = oc_list = oc->core.om->core.oc_list;
691ab64890Smrg    if (oc_list == oc)
701ab64890Smrg	oc->core.om->core.oc_list = oc_list->core.next;
711ab64890Smrg    else {
721ab64890Smrg	while ((oc_list = oc_list->core.next)) {
731ab64890Smrg	    if (oc_list == oc) {
741ab64890Smrg		prev->core.next = oc_list->core.next;
751ab64890Smrg		break;
761ab64890Smrg	    }
771ab64890Smrg	    prev = oc_list;
781ab64890Smrg	}
791ab64890Smrg    }
801ab64890Smrg
811ab64890Smrg    (*oc->methods->destroy)(oc);
821ab64890Smrg}
831ab64890Smrg
841ab64890SmrgXOM
851ab64890SmrgXOMOfOC(XOC oc)
861ab64890Smrg{
871ab64890Smrg    return oc->core.om;
881ab64890Smrg}
891ab64890Smrg
901ab64890Smrgchar *
911ab64890SmrgXSetOCValues(XOC oc, ...)
921ab64890Smrg{
931ab64890Smrg    va_list var;
941ab64890Smrg    XlcArgList args;
951ab64890Smrg    char *ret;
961ab64890Smrg    int num_args;
971ab64890Smrg
981ab64890Smrg    va_start(var, oc);
991ab64890Smrg    _XlcCountVaList(var, &num_args);
1001ab64890Smrg    va_end(var);
1011ab64890Smrg
1021ab64890Smrg    va_start(var, oc);
1031ab64890Smrg    _XlcVaToArgList(var, num_args, &args);
1041ab64890Smrg    va_end(var);
1051ab64890Smrg
1061ab64890Smrg    if (args == (XlcArgList) NULL)
1071ab64890Smrg	return (char *) NULL;
1081ab64890Smrg
1091ab64890Smrg    ret = (*oc->methods->set_values)(oc, args, num_args);
1101ab64890Smrg
1111ab64890Smrg    Xfree(args);
1121ab64890Smrg
1131ab64890Smrg    return ret;
1141ab64890Smrg}
1151ab64890Smrg
1161ab64890Smrgchar *
1171ab64890SmrgXGetOCValues(XOC oc, ...)
1181ab64890Smrg{
1191ab64890Smrg    va_list var;
1201ab64890Smrg    XlcArgList args;
1211ab64890Smrg    char *ret;
1221ab64890Smrg    int num_args;
1231ab64890Smrg
1241ab64890Smrg    va_start(var, oc);
1251ab64890Smrg    _XlcCountVaList(var, &num_args);
1261ab64890Smrg    va_end(var);
1271ab64890Smrg
1281ab64890Smrg    va_start(var, oc);
1291ab64890Smrg    _XlcVaToArgList(var, num_args, &args);
1301ab64890Smrg    va_end(var);
1311ab64890Smrg
1321ab64890Smrg    if (args == (XlcArgList) NULL)
1331ab64890Smrg	return (char *) NULL;
1341ab64890Smrg
1351ab64890Smrg    ret = (*oc->methods->get_values)(oc, args, num_args);
1361ab64890Smrg
1371ab64890Smrg    Xfree(args);
1381ab64890Smrg
1391ab64890Smrg    return ret;
1401ab64890Smrg}
141