1/*
2Copyright 1996, 1998  The Open Group
3
4Permission to use, copy, modify, distribute, and sell this software and its
5documentation for any purpose is hereby granted without fee, provided that
6the above copyright notice appear in all copies and that both that
7copyright notice and this permission notice appear in supporting
8documentation.
9
10The above copyright notice and this permission notice shall be included
11in all copies or substantial portions of the Software.
12
13THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
14OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
17OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
18ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
19OTHER DEALINGS IN THE SOFTWARE.
20
21Except as contained in this notice, the name of The Open Group shall
22not be used in advertising or otherwise to promote the sale, use or
23other dealings in this Software without prior written authorization
24from The Open Group.
25*/
26/*
27 * Copyright 1995 by FUJITSU LIMITED
28 * This is source code modified by FUJITSU LIMITED under the Joint
29 * Development Agreement for the CDE/Motif PST.
30 *
31 * Modifier: Takanori Tateno   FUJITSU LIMITED
32 *
33 */
34
35/*
36 * A dynamically loaded locale.
37 * Supports: All locale names.
38 * How: Loads $(XLOCALEDIR)/xi18n.so and forwards the request to that library.
39 * Platforms: Only those defining USE_DYNAMIC_LOADER (none known).
40 */
41
42#ifdef USE_DYNAMIC_LOADER
43#ifdef HAVE_CONFIG_H
44#include <config.h>
45#endif
46#include <stdio.h>
47#include <string.h>
48#include <dlfcn.h>
49
50#include "Xlibint.h"
51#include "Xlcint.h"
52
53#ifndef XLOCALEDIR
54#define XLOCALEDIR "/usr/lib/X11/locale"
55#endif
56
57#define LCLIBNAME    "xi18n.so"
58
59XLCd
60_XlcDynamicLoader(
61    const char *name)
62{
63    char libpath[1024];
64    XLCdMethods _XlcGenericMethods;
65    XLCd lcd;
66    void *nlshandler;
67
68    snprintf(libpath, sizeof(libpath), "%s/%s/%s",
69	     XLOCALEDIR, name, LCLIBNAME);
70    nlshandler = dlopen(libpath,LAZY);
71    _XlcGenericMethods = (XLCdMethods)dlsym(nlshandler,"genericMethods");
72    lcd = _XlcCreateLC(name,_XlcGenericMethods);
73
74    return lcd;
75}
76#else
77typedef int dummy;
78#endif /* USE_DYNAMIC_LOADER */
79