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