Home | History | Annotate | Line # | Download | only in citrus
citrus_module.c revision 1.1.2.2
      1  1.1.2.2  nathanw /*	$NetBSD: citrus_module.c,v 1.1.2.2 2002/03/22 20:42:01 nathanw Exp $	*/
      2  1.1.2.2  nathanw 
      3  1.1.2.2  nathanw /*-
      4  1.1.2.2  nathanw  * Copyright (c)1999, 2000, 2001, 2002 Citrus Project,
      5  1.1.2.2  nathanw  * All rights reserved.
      6  1.1.2.2  nathanw  *
      7  1.1.2.2  nathanw  * Redistribution and use in source and binary forms, with or without
      8  1.1.2.2  nathanw  * modification, are permitted provided that the following conditions
      9  1.1.2.2  nathanw  * are met:
     10  1.1.2.2  nathanw  * 1. Redistributions of source code must retain the above copyright
     11  1.1.2.2  nathanw  *    notice, this list of conditions and the following disclaimer.
     12  1.1.2.2  nathanw  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1.2.2  nathanw  *    notice, this list of conditions and the following disclaimer in the
     14  1.1.2.2  nathanw  *    documentation and/or other materials provided with the distribution.
     15  1.1.2.2  nathanw  *
     16  1.1.2.2  nathanw  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     17  1.1.2.2  nathanw  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18  1.1.2.2  nathanw  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19  1.1.2.2  nathanw  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     20  1.1.2.2  nathanw  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21  1.1.2.2  nathanw  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22  1.1.2.2  nathanw  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23  1.1.2.2  nathanw  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24  1.1.2.2  nathanw  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  1.1.2.2  nathanw  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  1.1.2.2  nathanw  * SUCH DAMAGE.
     27  1.1.2.2  nathanw  */
     28  1.1.2.2  nathanw 
     29  1.1.2.2  nathanw /*-
     30  1.1.2.2  nathanw  * Copyright (c) 1998 The NetBSD Foundation, Inc.
     31  1.1.2.2  nathanw  * All rights reserved.
     32  1.1.2.2  nathanw  *
     33  1.1.2.2  nathanw  * This code is derived from software contributed to The NetBSD Foundation
     34  1.1.2.2  nathanw  * by Paul Kranenburg.
     35  1.1.2.2  nathanw  *
     36  1.1.2.2  nathanw  * Redistribution and use in source and binary forms, with or without
     37  1.1.2.2  nathanw  * modification, are permitted provided that the following conditions
     38  1.1.2.2  nathanw  * are met:
     39  1.1.2.2  nathanw  * 1. Redistributions of source code must retain the above copyright
     40  1.1.2.2  nathanw  *    notice, this list of conditions and the following disclaimer.
     41  1.1.2.2  nathanw  * 2. Redistributions in binary form must reproduce the above copyright
     42  1.1.2.2  nathanw  *    notice, this list of conditions and the following disclaimer in the
     43  1.1.2.2  nathanw  *    documentation and/or other materials provided with the distribution.
     44  1.1.2.2  nathanw  * 3. All advertising materials mentioning features or use of this software
     45  1.1.2.2  nathanw  *    must display the following acknowledgement:
     46  1.1.2.2  nathanw  *        This product includes software developed by the NetBSD
     47  1.1.2.2  nathanw  *        Foundation, Inc. and its contributors.
     48  1.1.2.2  nathanw  * 4. Neither the name of The NetBSD Foundation nor the names of its
     49  1.1.2.2  nathanw  *    contributors may be used to endorse or promote products derived
     50  1.1.2.2  nathanw  *    from this software without specific prior written permission.
     51  1.1.2.2  nathanw  *
     52  1.1.2.2  nathanw  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     53  1.1.2.2  nathanw  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     54  1.1.2.2  nathanw  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     55  1.1.2.2  nathanw  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     56  1.1.2.2  nathanw  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     57  1.1.2.2  nathanw  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     58  1.1.2.2  nathanw  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     59  1.1.2.2  nathanw  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     60  1.1.2.2  nathanw  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     61  1.1.2.2  nathanw  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     62  1.1.2.2  nathanw  * POSSIBILITY OF SUCH DAMAGE.
     63  1.1.2.2  nathanw  */
     64  1.1.2.2  nathanw 
     65  1.1.2.2  nathanw /*-
     66  1.1.2.2  nathanw  * Copyright (c) 1993
     67  1.1.2.2  nathanw  *	The Regents of the University of California.  All rights reserved.
     68  1.1.2.2  nathanw  *
     69  1.1.2.2  nathanw  * This code is derived from software contributed to Berkeley by
     70  1.1.2.2  nathanw  * Paul Borman at Krystal Technologies.
     71  1.1.2.2  nathanw  *
     72  1.1.2.2  nathanw  * Redistribution and use in source and binary forms, with or without
     73  1.1.2.2  nathanw  * modification, are permitted provided that the following conditions
     74  1.1.2.2  nathanw  * are met:
     75  1.1.2.2  nathanw  * 1. Redistributions of source code must retain the above copyright
     76  1.1.2.2  nathanw  *    notice, this list of conditions and the following disclaimer.
     77  1.1.2.2  nathanw  * 2. Redistributions in binary form must reproduce the above copyright
     78  1.1.2.2  nathanw  *    notice, this list of conditions and the following disclaimer in the
     79  1.1.2.2  nathanw  *    documentation and/or other materials provided with the distribution.
     80  1.1.2.2  nathanw  * 3. All advertising materials mentioning features or use of this software
     81  1.1.2.2  nathanw  *    must display the following acknowledgement:
     82  1.1.2.2  nathanw  *	This product includes software developed by the University of
     83  1.1.2.2  nathanw  *	California, Berkeley and its contributors.
     84  1.1.2.2  nathanw  * 4. Neither the name of the University nor the names of its contributors
     85  1.1.2.2  nathanw  *    may be used to endorse or promote products derived from this software
     86  1.1.2.2  nathanw  *    without specific prior written permission.
     87  1.1.2.2  nathanw  *
     88  1.1.2.2  nathanw  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     89  1.1.2.2  nathanw  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     90  1.1.2.2  nathanw  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     91  1.1.2.2  nathanw  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     92  1.1.2.2  nathanw  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     93  1.1.2.2  nathanw  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     94  1.1.2.2  nathanw  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     95  1.1.2.2  nathanw  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     96  1.1.2.2  nathanw  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     97  1.1.2.2  nathanw  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     98  1.1.2.2  nathanw  * SUCH DAMAGE.
     99  1.1.2.2  nathanw  */
    100  1.1.2.2  nathanw 
    101  1.1.2.2  nathanw #include <sys/cdefs.h>
    102  1.1.2.2  nathanw #if defined(LIBC_SCCS) && !defined(lint)
    103  1.1.2.2  nathanw __RCSID("$NetBSD: citrus_module.c,v 1.1.2.2 2002/03/22 20:42:01 nathanw Exp $");
    104  1.1.2.2  nathanw #endif /* LIBC_SCCS and not lint */
    105  1.1.2.2  nathanw 
    106  1.1.2.2  nathanw #include <assert.h>
    107  1.1.2.2  nathanw #include <errno.h>
    108  1.1.2.2  nathanw #include <limits.h>
    109  1.1.2.2  nathanw #include <string.h>
    110  1.1.2.2  nathanw #include <stdio.h>
    111  1.1.2.2  nathanw #include <stdlib.h>
    112  1.1.2.2  nathanw #include <unistd.h>
    113  1.1.2.2  nathanw #include <locale.h>
    114  1.1.2.2  nathanw #include <stddef.h>
    115  1.1.2.2  nathanw #include <paths.h>
    116  1.1.2.2  nathanw #include "citrus_module.h"
    117  1.1.2.2  nathanw 
    118  1.1.2.2  nathanw #include <sys/types.h>
    119  1.1.2.2  nathanw #include <dirent.h>
    120  1.1.2.2  nathanw #include <dlfcn.h>
    121  1.1.2.2  nathanw 
    122  1.1.2.2  nathanw #ifdef _I18N_DYNAMIC
    123  1.1.2.2  nathanw 
    124  1.1.2.2  nathanw static int _getdewey(int [], char *);
    125  1.1.2.2  nathanw static int _cmpndewey(int [], int, int [], int);
    126  1.1.2.2  nathanw static const char *_findshlib(char *, int *, int *);
    127  1.1.2.2  nathanw 
    128  1.1.2.2  nathanw static char *_pathI18nModule = NULL;
    129  1.1.2.2  nathanw 
    130  1.1.2.2  nathanw /* from libexec/ld.aout_so/shlib.c */
    131  1.1.2.2  nathanw #undef major
    132  1.1.2.2  nathanw #undef minor
    133  1.1.2.2  nathanw #define MAXDEWEY	3	/*ELF*/
    134  1.1.2.2  nathanw 
    135  1.1.2.2  nathanw static int
    136  1.1.2.2  nathanw _getdewey(int dewey[], char *cp)
    137  1.1.2.2  nathanw {
    138  1.1.2.2  nathanw 	int	i, n;
    139  1.1.2.2  nathanw 
    140  1.1.2.2  nathanw 	_DIAGASSERT(dewey != NULL);
    141  1.1.2.2  nathanw 	_DIAGASSERT(cp != NULL);
    142  1.1.2.2  nathanw 
    143  1.1.2.2  nathanw 	for (n = 0, i = 0; i < MAXDEWEY; i++) {
    144  1.1.2.2  nathanw 		if (*cp == '\0')
    145  1.1.2.2  nathanw 			break;
    146  1.1.2.2  nathanw 
    147  1.1.2.2  nathanw 		if (*cp == '.') cp++;
    148  1.1.2.2  nathanw 		if (*cp < '0' || '9' < *cp)
    149  1.1.2.2  nathanw 			return 0;
    150  1.1.2.2  nathanw 
    151  1.1.2.2  nathanw 		dewey[n++] = (int)strtol(cp, &cp, 10);
    152  1.1.2.2  nathanw 	}
    153  1.1.2.2  nathanw 
    154  1.1.2.2  nathanw 	return n;
    155  1.1.2.2  nathanw }
    156  1.1.2.2  nathanw 
    157  1.1.2.2  nathanw /*
    158  1.1.2.2  nathanw  * Compare two dewey arrays.
    159  1.1.2.2  nathanw  * Return -1 if `d1' represents a smaller value than `d2'.
    160  1.1.2.2  nathanw  * Return  1 if `d1' represents a greater value than `d2'.
    161  1.1.2.2  nathanw  * Return  0 if equal.
    162  1.1.2.2  nathanw  */
    163  1.1.2.2  nathanw static int
    164  1.1.2.2  nathanw _cmpndewey(int d1[], int n1, int d2[], int n2)
    165  1.1.2.2  nathanw {
    166  1.1.2.2  nathanw 	register int	i;
    167  1.1.2.2  nathanw 
    168  1.1.2.2  nathanw 	_DIAGASSERT(d1 != NULL);
    169  1.1.2.2  nathanw 	_DIAGASSERT(d2 != NULL);
    170  1.1.2.2  nathanw 
    171  1.1.2.2  nathanw 	for (i = 0; i < n1 && i < n2; i++) {
    172  1.1.2.2  nathanw 		if (d1[i] < d2[i])
    173  1.1.2.2  nathanw 			return -1;
    174  1.1.2.2  nathanw 		if (d1[i] > d2[i])
    175  1.1.2.2  nathanw 			return 1;
    176  1.1.2.2  nathanw 	}
    177  1.1.2.2  nathanw 
    178  1.1.2.2  nathanw 	if (n1 == n2)
    179  1.1.2.2  nathanw 		return 0;
    180  1.1.2.2  nathanw 
    181  1.1.2.2  nathanw 	if (i == n1)
    182  1.1.2.2  nathanw 		return -1;
    183  1.1.2.2  nathanw 
    184  1.1.2.2  nathanw 	if (i == n2)
    185  1.1.2.2  nathanw 		return 1;
    186  1.1.2.2  nathanw 
    187  1.1.2.2  nathanw 	/* XXX cannot happen */
    188  1.1.2.2  nathanw 	return 0;
    189  1.1.2.2  nathanw }
    190  1.1.2.2  nathanw 
    191  1.1.2.2  nathanw static const char *
    192  1.1.2.2  nathanw _findshlib(char *name, int *majorp, int *minorp)
    193  1.1.2.2  nathanw {
    194  1.1.2.2  nathanw 	int		dewey[MAXDEWEY];
    195  1.1.2.2  nathanw 	int		ndewey;
    196  1.1.2.2  nathanw 	int		tmp[MAXDEWEY];
    197  1.1.2.2  nathanw 	int		i;
    198  1.1.2.2  nathanw 	int		len;
    199  1.1.2.2  nathanw 	char		*lname;
    200  1.1.2.2  nathanw 	static char	path[PATH_MAX];
    201  1.1.2.2  nathanw 	int		major, minor;
    202  1.1.2.2  nathanw 	const char	*search_dirs[1];
    203  1.1.2.2  nathanw 	const int	n_search_dirs = 1;
    204  1.1.2.2  nathanw 
    205  1.1.2.2  nathanw 	_DIAGASSERT(name != NULL);
    206  1.1.2.2  nathanw 	_DIAGASSERT(majorp != NULL);
    207  1.1.2.2  nathanw 	_DIAGASSERT(minorp != NULL);
    208  1.1.2.2  nathanw 
    209  1.1.2.2  nathanw 	major = *majorp;
    210  1.1.2.2  nathanw 	minor = *minorp;
    211  1.1.2.2  nathanw 	path[0] = '\0';
    212  1.1.2.2  nathanw 	search_dirs[0] = _pathI18nModule;
    213  1.1.2.2  nathanw 	len = strlen(name);
    214  1.1.2.2  nathanw 	lname = name;
    215  1.1.2.2  nathanw 
    216  1.1.2.2  nathanw 	ndewey = 0;
    217  1.1.2.2  nathanw 
    218  1.1.2.2  nathanw 	for (i = 0; i < n_search_dirs; i++) {
    219  1.1.2.2  nathanw 		DIR		*dd = opendir(search_dirs[i]);
    220  1.1.2.2  nathanw 		struct dirent	*dp;
    221  1.1.2.2  nathanw 		int		found_dot_a = 0;
    222  1.1.2.2  nathanw 		int		found_dot_so = 0;
    223  1.1.2.2  nathanw 
    224  1.1.2.2  nathanw 		if (dd == NULL)
    225  1.1.2.2  nathanw 			continue;
    226  1.1.2.2  nathanw 
    227  1.1.2.2  nathanw 		while ((dp = readdir(dd)) != NULL) {
    228  1.1.2.2  nathanw 			int	n;
    229  1.1.2.2  nathanw 
    230  1.1.2.2  nathanw 			if (dp->d_namlen < len + 4)
    231  1.1.2.2  nathanw 				continue;
    232  1.1.2.2  nathanw 			if (strncmp(dp->d_name, lname, (size_t)len) != 0)
    233  1.1.2.2  nathanw 				continue;
    234  1.1.2.2  nathanw 			if (strncmp(dp->d_name+len, ".so.", 4) != 0)
    235  1.1.2.2  nathanw 				continue;
    236  1.1.2.2  nathanw 
    237  1.1.2.2  nathanw 			if ((n = _getdewey(tmp, dp->d_name+len+4)) == 0)
    238  1.1.2.2  nathanw 				continue;
    239  1.1.2.2  nathanw 
    240  1.1.2.2  nathanw 			if (major != -1 && found_dot_a)
    241  1.1.2.2  nathanw 				found_dot_a = 0;
    242  1.1.2.2  nathanw 
    243  1.1.2.2  nathanw 			/* XXX should verify the library is a.out/ELF? */
    244  1.1.2.2  nathanw 
    245  1.1.2.2  nathanw 			if (major == -1 && minor == -1) {
    246  1.1.2.2  nathanw 				goto compare_version;
    247  1.1.2.2  nathanw 			} else if (major != -1 && minor == -1) {
    248  1.1.2.2  nathanw 				if (tmp[0] == major)
    249  1.1.2.2  nathanw 					goto compare_version;
    250  1.1.2.2  nathanw 			} else if (major != -1 && minor != -1) {
    251  1.1.2.2  nathanw 				if (tmp[0] == major) {
    252  1.1.2.2  nathanw 					if (n == 1 || tmp[1] >= minor)
    253  1.1.2.2  nathanw 						goto compare_version;
    254  1.1.2.2  nathanw 				}
    255  1.1.2.2  nathanw 			}
    256  1.1.2.2  nathanw 
    257  1.1.2.2  nathanw 			/* else, this file does not qualify */
    258  1.1.2.2  nathanw 			continue;
    259  1.1.2.2  nathanw 
    260  1.1.2.2  nathanw 		compare_version:
    261  1.1.2.2  nathanw 			if (_cmpndewey(tmp, n, dewey, ndewey) <= 0)
    262  1.1.2.2  nathanw 				continue;
    263  1.1.2.2  nathanw 
    264  1.1.2.2  nathanw 			/* We have a better version */
    265  1.1.2.2  nathanw 			found_dot_so = 1;
    266  1.1.2.2  nathanw 			snprintf(path, sizeof(path), "%s/%s", search_dirs[i],
    267  1.1.2.2  nathanw 			    dp->d_name);
    268  1.1.2.2  nathanw 			found_dot_a = 0;
    269  1.1.2.2  nathanw 			bcopy(tmp, dewey, sizeof(dewey));
    270  1.1.2.2  nathanw 			ndewey = n;
    271  1.1.2.2  nathanw 			*majorp = dewey[0];
    272  1.1.2.2  nathanw 			*minorp = dewey[1];
    273  1.1.2.2  nathanw 		}
    274  1.1.2.2  nathanw 		closedir(dd);
    275  1.1.2.2  nathanw 
    276  1.1.2.2  nathanw 		if (found_dot_a || found_dot_so)
    277  1.1.2.2  nathanw 			/*
    278  1.1.2.2  nathanw 			 * There's a lib in this dir; take it.
    279  1.1.2.2  nathanw 			 */
    280  1.1.2.2  nathanw 			return path[0] ? path : NULL;
    281  1.1.2.2  nathanw 	}
    282  1.1.2.2  nathanw 
    283  1.1.2.2  nathanw 	return path[0] ? path : NULL;
    284  1.1.2.2  nathanw }
    285  1.1.2.2  nathanw 
    286  1.1.2.2  nathanw void *
    287  1.1.2.2  nathanw _citrus_find_getops(_citrus_module_t handle, const char *modname,
    288  1.1.2.2  nathanw 		    const char *ifname)
    289  1.1.2.2  nathanw {
    290  1.1.2.2  nathanw 	char name[PATH_MAX];
    291  1.1.2.2  nathanw 	void *p;
    292  1.1.2.2  nathanw 
    293  1.1.2.2  nathanw 	_DIAGASSERT(handle != NULL);
    294  1.1.2.2  nathanw 	_DIAGASSERT(modname != NULL);
    295  1.1.2.2  nathanw 	_DIAGASSERT(ifname != NULL);
    296  1.1.2.2  nathanw 
    297  1.1.2.2  nathanw 	snprintf(name, sizeof(name), "_citrus_%s_%s_getops", modname, ifname);
    298  1.1.2.2  nathanw 	p = dlsym((void *)handle, name);
    299  1.1.2.2  nathanw 	if (!p) {
    300  1.1.2.2  nathanw 		/* a.out case */
    301  1.1.2.2  nathanw 		snprintf(name, sizeof(name),
    302  1.1.2.2  nathanw 			 "__%s_%s_getops", modname, ifname);
    303  1.1.2.2  nathanw 		p = dlsym(handle, name);
    304  1.1.2.2  nathanw 	}
    305  1.1.2.2  nathanw 	return p;
    306  1.1.2.2  nathanw }
    307  1.1.2.2  nathanw 
    308  1.1.2.2  nathanw int
    309  1.1.2.2  nathanw _citrus_load_module(_citrus_module_t *rhandle, const char *encname)
    310  1.1.2.2  nathanw {
    311  1.1.2.2  nathanw 	const char *p;
    312  1.1.2.2  nathanw 	char path[PATH_MAX];
    313  1.1.2.2  nathanw 	int maj, min;
    314  1.1.2.2  nathanw 	void *handle;
    315  1.1.2.2  nathanw 
    316  1.1.2.2  nathanw 	_DIAGASSERT(rhandle != NULL);
    317  1.1.2.2  nathanw 
    318  1.1.2.2  nathanw 	if (_pathI18nModule == NULL) {
    319  1.1.2.2  nathanw 		p = getenv("PATH_I18NMODULE");
    320  1.1.2.2  nathanw 		if (p != NULL && !issetugid()) {
    321  1.1.2.2  nathanw 			_pathI18nModule = strdup(p);
    322  1.1.2.2  nathanw 			if (_pathI18nModule == NULL)
    323  1.1.2.2  nathanw 				return ENOMEM;
    324  1.1.2.2  nathanw 		} else
    325  1.1.2.2  nathanw 			_pathI18nModule = _PATH_I18NMODULE;
    326  1.1.2.2  nathanw 	}
    327  1.1.2.2  nathanw 
    328  1.1.2.2  nathanw 	(void)snprintf(path, sizeof(path), "lib%s", encname);
    329  1.1.2.2  nathanw 	maj = I18NMODULE_MAJOR;
    330  1.1.2.2  nathanw 	min = -1;
    331  1.1.2.2  nathanw 	p = _findshlib(path, &maj, &min);
    332  1.1.2.2  nathanw 	if (!p)
    333  1.1.2.2  nathanw 		return (EINVAL);
    334  1.1.2.2  nathanw 	handle = dlopen(p, RTLD_LAZY);
    335  1.1.2.2  nathanw 	if (!handle)
    336  1.1.2.2  nathanw 		return (EINVAL);
    337  1.1.2.2  nathanw 
    338  1.1.2.2  nathanw 	*rhandle = (_citrus_module_t)handle;
    339  1.1.2.2  nathanw 
    340  1.1.2.2  nathanw 	return (0);
    341  1.1.2.2  nathanw }
    342  1.1.2.2  nathanw 
    343  1.1.2.2  nathanw void
    344  1.1.2.2  nathanw _citrus_unload_module(_citrus_module_t handle)
    345  1.1.2.2  nathanw {
    346  1.1.2.2  nathanw 	if (handle)
    347  1.1.2.2  nathanw 		dlclose((void *)handle);
    348  1.1.2.2  nathanw }
    349  1.1.2.2  nathanw #else
    350  1.1.2.2  nathanw /* !_I18N_DYNAMIC */
    351  1.1.2.2  nathanw 
    352  1.1.2.2  nathanw void *
    353  1.1.2.2  nathanw /*ARGSUSED*/
    354  1.1.2.2  nathanw _citrus_find_getops(_citrus_module_t handle, const char *modname,
    355  1.1.2.2  nathanw 		    const char *ifname)
    356  1.1.2.2  nathanw {
    357  1.1.2.2  nathanw 	return (NULL);
    358  1.1.2.2  nathanw }
    359  1.1.2.2  nathanw 
    360  1.1.2.2  nathanw int
    361  1.1.2.2  nathanw /*ARGSUSED*/
    362  1.1.2.2  nathanw _citrus_load_module(_citrus_module_t *rhandle, char const *modname)
    363  1.1.2.2  nathanw {
    364  1.1.2.2  nathanw 	return (EINVAL);
    365  1.1.2.2  nathanw }
    366  1.1.2.2  nathanw 
    367  1.1.2.2  nathanw void
    368  1.1.2.2  nathanw /*ARGSUSED*/
    369  1.1.2.2  nathanw _citrus_unload_module(_citrus_module_t handle)
    370  1.1.2.2  nathanw {
    371  1.1.2.2  nathanw }
    372  1.1.2.2  nathanw #endif
    373