lcDynamic.c revision 1ab64890
11ab64890Smrg/* $Xorg: lcDynamic.c,v 1.4 2001/02/09 02:03:39 xorgcvs Exp $ */ 21ab64890Smrg/* 31ab64890SmrgCopyright 1996, 1998 The Open Group 41ab64890Smrg 51ab64890SmrgPermission to use, copy, modify, distribute, and sell this software and its 61ab64890Smrgdocumentation for any purpose is hereby granted without fee, provided that 71ab64890Smrgthe above copyright notice appear in all copies and that both that 81ab64890Smrgcopyright notice and this permission notice appear in supporting 91ab64890Smrgdocumentation. 101ab64890Smrg 111ab64890SmrgThe above copyright notice and this permission notice shall be included 121ab64890Smrgin all copies or substantial portions of the Software. 131ab64890Smrg 141ab64890SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 151ab64890SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 161ab64890SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 171ab64890SmrgIN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR 181ab64890SmrgOTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 191ab64890SmrgARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 201ab64890SmrgOTHER DEALINGS IN THE SOFTWARE. 211ab64890Smrg 221ab64890SmrgExcept as contained in this notice, the name of The Open Group shall 231ab64890Smrgnot be used in advertising or otherwise to promote the sale, use or 241ab64890Smrgother dealings in this Software without prior written authorization 251ab64890Smrgfrom The Open Group. 261ab64890Smrg*/ 271ab64890Smrg/* 281ab64890Smrg * Copyright 1995 by FUJITSU LIMITED 291ab64890Smrg * This is source code modified by FUJITSU LIMITED under the Joint 301ab64890Smrg * Development Agreement for the CDE/Motif PST. 311ab64890Smrg * 321ab64890Smrg * Modifier: Takanori Tateno FUJITSU LIMITED 331ab64890Smrg * 341ab64890Smrg */ 351ab64890Smrg/* $XFree86: xc/lib/X11/lcDynamic.c,v 1.4 2001/01/17 19:41:53 dawes Exp $ */ 361ab64890Smrg 371ab64890Smrg/* 381ab64890Smrg * A dynamically loaded locale. 391ab64890Smrg * Supports: All locale names. 401ab64890Smrg * How: Loads $(XLOCALEDIR)/xi18n.so and forwards the request to that library. 411ab64890Smrg * Platforms: Only those defining USE_DYNAMIC_LOADER (none known). 421ab64890Smrg */ 431ab64890Smrg 441ab64890Smrg#ifdef USE_DYNAMIC_LOADER 451ab64890Smrg#ifdef HAVE_CONFIG_H 461ab64890Smrg#include <config.h> 471ab64890Smrg#endif 481ab64890Smrg#include <stdio.h> 491ab64890Smrg#include <string.h> 501ab64890Smrg#include <dlfcn.h> 511ab64890Smrg 521ab64890Smrg#include "Xlibint.h" 531ab64890Smrg#include "Xlcint.h" 541ab64890Smrg 551ab64890Smrg#ifndef XLOCALEDIR 561ab64890Smrg#define XLOCALEDIR "/usr/lib/X11/locale" 571ab64890Smrg#endif 581ab64890Smrg 591ab64890Smrg#define LCLIBNAME "xi18n.so" 601ab64890Smrg 611ab64890SmrgXLCd 621ab64890Smrg_XlcDynamicLoader( 631ab64890Smrg const char *name) 641ab64890Smrg{ 651ab64890Smrg char libpath[1024]; 661ab64890Smrg XLCdMethods _XlcGenericMethods; 671ab64890Smrg XLCd lcd; 681ab64890Smrg void *nlshandler; 691ab64890Smrg 701ab64890Smrg sprintf(libpath,"%s/%s/%s", 711ab64890Smrg XLOCALEDIR,name,LCLIBNAME); 721ab64890Smrg nlshandler = dlopen(libpath,LAZY); 731ab64890Smrg _XlcGenericMethods = (XLCdMethods)dlsym(nlshandler,"genericMethods"); 741ab64890Smrg lcd = _XlcCreateLC(name,_XlcGenericMethods); 751ab64890Smrg 761ab64890Smrg return lcd; 771ab64890Smrg} 781ab64890Smrg#else 791ab64890Smrgtypedef int dummy; 801ab64890Smrg#endif /* USE_DYNAMIC_LOADER */ 81