1N/A/***********************************************************************
1N/A* *
1N/A* This software is part of the ast package *
1N/A* Copyright (c) 1997-2011 AT&T Intellectual Property *
1N/A* and is licensed under the *
1N/A* Common Public License, Version 1.0 *
1N/A* by AT&T Intellectual Property *
1N/A* *
1N/A* A copy of the License is available at *
1N/A* http://www.opensource.org/licenses/cpl1.0.txt *
1N/A* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
1N/A* *
1N/A* Information and Software Systems Research *
1N/A* AT&T Research *
1N/A* Florham Park NJ *
1N/A* *
1N/A* Glenn Fowler <gsf@research.att.com> *
1N/A* *
1N/A***********************************************************************/
1N/A#pragma prototyped
1N/A/*
1N/A * Glenn Fowler
1N/A * at&t research
1N/A */
1N/A
1N/A#include "dlllib.h"
1N/A
1N/A#if 0
1N/A
1N/A/*
1N/A * dlopen() wrapper that properly initializes LIBPATH
1N/A * with the path of the dll to be opened
1N/A *
1N/A * 2009-04-15 -- if ld.so re-checked the env this would work ...
1N/A */
1N/A
1N/Avoid*
1N/Adllopen(const char* name, int mode)
1N/A{
1N/A void* dll;
1N/A Dllinfo_t* info;
1N/A char* olibpath;
1N/A char* path;
1N/A char* oenv;
1N/A char* nenv[2];
1N/A char* dir;
1N/A char* base;
1N/A int len;
1N/A
1N/A if (!environ)
1N/A {
1N/A nenv[0] = nenv[1] = 0;
1N/A environ = nenv;
1N/A }
1N/A info = dllinfo();
1N/A oenv = environ[0];
1N/A olibpath = getenv(info->env);
1N/A if (base = strrchr(name, '/'))
1N/A {
1N/A dir = (char*)name;
1N/A len = ++base - dir;
1N/A }
1N/A else
1N/A {
1N/A dir = "./";
1N/A len = 2;
1N/A base = (char*)name;
1N/A }
1N/A path = sfprints("%-.*s%s%c%s=%-.*s%s%s", len, dir, base, 0, info->env, len, dir, olibpath ? ":" : "", olibpath ? olibpath : "");
1N/A environ[0] = path + strlen(path) + 1;
1N/A state.error = 0;
1N/A dll = dlopen(path, mode);
1N/A if (environ == nenv)
1N/A environ = 0;
1N/A else
1N/A environ[0] = oenv;
1N/A return dll;
1N/A}
1N/A
1N/A#else
1N/A
1N/A/*
1N/A * dlopen() wrapper -- waiting for prestidigitaions
1N/A */
1N/A
1N/Avoid*
1N/Adllopen(const char* name, int mode)
1N/A{
1N/A state.error = 0;
1N/A return dlopen(name, mode);
1N/A}
1N/A
1N/A#endif