|
Packit |
3ff832 |
/******************************************************************
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
Copyright 1994, 1995 by Sun Microsystems, Inc.
|
|
Packit |
3ff832 |
Copyright 1993, 1994 by Hewlett-Packard Company
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
Permission to use, copy, modify, distribute, and sell this software
|
|
Packit |
3ff832 |
and its documentation for any purpose is hereby granted without fee,
|
|
Packit |
3ff832 |
provided that the above copyright notice appear in all copies and
|
|
Packit |
3ff832 |
that both that copyright notice and this permission notice appear
|
|
Packit |
3ff832 |
in supporting documentation, and that the name of Sun Microsystems, Inc.
|
|
Packit |
3ff832 |
and Hewlett-Packard not be used in advertising or publicity pertaining to
|
|
Packit |
3ff832 |
distribution of the software without specific, written prior permission.
|
|
Packit |
3ff832 |
Sun Microsystems, Inc. and Hewlett-Packard make no representations about
|
|
Packit |
3ff832 |
the suitability of this software for any purpose. It is provided "as is"
|
|
Packit |
3ff832 |
without express or implied warranty.
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
SUN MICROSYSTEMS INC. AND HEWLETT-PACKARD COMPANY DISCLAIMS ALL
|
|
Packit |
3ff832 |
WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
|
|
Packit |
3ff832 |
WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
|
Packit |
3ff832 |
SUN MICROSYSTEMS, INC. AND HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY
|
|
Packit |
3ff832 |
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
|
Packit |
3ff832 |
RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
|
Packit |
3ff832 |
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
|
Packit |
3ff832 |
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
Author: Hidetoshi Tajima(tajima@Eng.Sun.COM) Sun Microsystems, Inc.
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
This version tidied and debugged by Steve Underwood May 1999
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
******************************************************************/
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
#include <stdlib.h>
|
|
Packit |
3ff832 |
#include <X11/Xlib.h>
|
|
Packit |
3ff832 |
#include "IMdkit.h"
|
|
Packit |
3ff832 |
#include <stdarg.h>
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
#define Va_start(a,b) va_start(a,b)
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
static void _IMCountVaList (va_list var, int *total_count)
|
|
Packit |
3ff832 |
{
|
|
Packit |
3ff832 |
char *attr;
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
*total_count = 0;
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
for (attr = va_arg (var, char *); attr; attr = va_arg (var, char *))
|
|
Packit |
3ff832 |
{
|
|
Packit |
3ff832 |
(void)va_arg (var, XIMArg *);
|
|
Packit |
3ff832 |
++(*total_count);
|
|
Packit |
3ff832 |
}
|
|
Packit |
3ff832 |
/*endfor*/
|
|
Packit |
3ff832 |
}
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
static void _IMVaToNestedList (va_list var, int max_count, XIMArg **args_return)
|
|
Packit |
3ff832 |
{
|
|
Packit |
3ff832 |
XIMArg *args;
|
|
Packit |
3ff832 |
char *attr;
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
if (max_count <= 0)
|
|
Packit |
3ff832 |
{
|
|
Packit |
3ff832 |
*args_return = (XIMArg *) NULL;
|
|
Packit |
3ff832 |
return;
|
|
Packit |
3ff832 |
}
|
|
Packit |
3ff832 |
/*endif*/
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
args = (XIMArg *) malloc ((unsigned) (max_count + 1)*sizeof (XIMArg));
|
|
Packit |
3ff832 |
*args_return = args;
|
|
Packit |
3ff832 |
if (!args)
|
|
Packit |
3ff832 |
return;
|
|
Packit |
3ff832 |
/*endif*/
|
|
Packit |
3ff832 |
for (attr = va_arg (var, char *); attr; attr = va_arg (var, char *))
|
|
Packit |
3ff832 |
{
|
|
Packit |
3ff832 |
args->name = attr;
|
|
Packit |
3ff832 |
args->value = va_arg (var, XPointer);
|
|
Packit |
3ff832 |
args++;
|
|
Packit |
3ff832 |
}
|
|
Packit |
3ff832 |
/*endfor*/
|
|
Packit |
3ff832 |
args->name = (char *) NULL;
|
|
Packit |
3ff832 |
}
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
char *IMGetIMValues (XIMS ims, ...)
|
|
Packit |
3ff832 |
{
|
|
Packit |
3ff832 |
va_list var;
|
|
Packit |
3ff832 |
int total_count;
|
|
Packit |
3ff832 |
XIMArg *args;
|
|
Packit |
3ff832 |
char *ret;
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
Va_start (var, ims);
|
|
Packit |
3ff832 |
_IMCountVaList (var, &total_count);
|
|
Packit |
3ff832 |
va_end (var);
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
Va_start (var, ims);
|
|
Packit |
3ff832 |
_IMVaToNestedList (var, total_count, &args);
|
|
Packit |
3ff832 |
va_end (var);
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
ret = (*ims->methods->getIMValues) (ims, args);
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
if (args)
|
|
Packit |
3ff832 |
XFree ((char *) args);
|
|
Packit |
3ff832 |
/*endif*/
|
|
Packit |
3ff832 |
return ret;
|
|
Packit |
3ff832 |
}
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
char *IMSetIMValues (XIMS ims, ...)
|
|
Packit |
3ff832 |
{
|
|
Packit |
3ff832 |
va_list var;
|
|
Packit |
3ff832 |
int total_count;
|
|
Packit |
3ff832 |
XIMArg *args;
|
|
Packit |
3ff832 |
char *ret;
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
Va_start (var, ims);
|
|
Packit |
3ff832 |
_IMCountVaList (var, &total_count);
|
|
Packit |
3ff832 |
va_end (var);
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
Va_start (var, ims);
|
|
Packit |
3ff832 |
_IMVaToNestedList (var, total_count, &args);
|
|
Packit |
3ff832 |
va_end (var);
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
ret = (*ims->methods->setIMValues) (ims, args);
|
|
Packit |
3ff832 |
|
|
Packit |
3ff832 |
if (args)
|
|
Packit |
3ff832 |
XFree ((char *) args);
|
|
Packit |
3ff832 |
/*endif*/
|
|
Packit |
3ff832 |
return ret;
|
|
Packit |
3ff832 |
}
|