import less(1)
[unleashed/tickless.git] / usr / src / lib / libdll / common / dllopen.c
blobf0a0609bd69834e1e8e7ab4a1732f38435ed5fc6
1 /***********************************************************************
2 * *
3 * This software is part of the ast package *
4 * Copyright (c) 1997-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
8 * *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
12 * *
13 * Information and Software Systems Research *
14 * AT&T Research *
15 * Florham Park NJ *
16 * *
17 * Glenn Fowler <gsf@research.att.com> *
18 * *
19 ***********************************************************************/
20 #pragma prototyped
22 * Glenn Fowler
23 * at&t research
26 #include <ast.h>
27 #include <dlldefs.h>
28 #include <error.h>
30 #if 0
33 * dlopen() wrapper that properly initializes LIBPATH
34 * with the path of the dll to be opened
36 * 2009-04-15 -- if ld.so re-checked the env this would work ...
39 void*
40 dllopen(const char* name, int mode)
42 void* dll;
43 Dllinfo_t* info;
44 char* olibpath;
45 char* path;
46 char* oenv;
47 char* nenv[2];
48 char* dir;
49 char* base;
50 int len;
52 if (!environ)
54 nenv[0] = nenv[1] = 0;
55 environ = nenv;
57 info = dllinfo();
58 oenv = environ[0];
59 olibpath = getenv(info->env);
60 if (base = strrchr(name, '/'))
62 dir = (char*)name;
63 len = ++base - dir;
65 else
67 dir = "./";
68 len = 2;
69 base = (char*)name;
71 path = sfprints("%-.*s%s%c%s=%-.*s%s%s", len, dir, base, 0, info->env, len, dir, olibpath ? ":" : "", olibpath ? olibpath : "");
72 environ[0] = path + strlen(path) + 1;
73 dll = dlopen(path, mode);
74 if (environ == nenv)
75 environ = 0;
76 else
77 environ[0] = oenv;
78 return dll;
81 #else
84 * dlopen() wrapper -- waiting for prestidigitaions
87 void*
88 dllopen(const char* name, int mode)
90 return dlopen(name, mode);
93 #endif