dll_lib.c revision 3f54fd611f536639ec30dd53c48e5ec1897cc7d9
/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1997-2012 AT&T Intellectual Property *
* and is licensed under the *
* Eclipse Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* Glenn Fowler
* AT&T Research
*/
#include "dlllib.h"
typedef void* (*Dll_lib_f)(const char*, void*, const char*);
typedef struct Dll_lib_s
{
char* path;
char base[1];
} Dll_lib_t;
/*
* split <name,base,type,opts> from name into names
*/
{
char* s;
char* t;
char* b;
char* e;
size_t n;
return 0;
if (!names)
{
if (n = (s - (char*)0) % sizeof(names))
s += sizeof(names) - n;
names = (Dllnames_t*)s;
}
/*
* determine the base name
*/
s++;
else
s = (char*)name;
s += 3;
t = s;
while (b < e && *t && *t != '.' && *t != '-' && *t != ':')
*b++ = *t++;
*b++ = 0;
/*
* determine the optional type
*/
if (t = strrchr(s, ':'))
{
while (b < e && s < t)
*b++ = *s++;
*b++ = 0;
while (b < e && *++t)
*b++ = *t;
*b++ = 0;
}
else
{
}
return names;
}
/*
* return method pointer for <id,version> in names
*/
void*
{
void* dll;
ssize_t n;
char sym[64];
if (!names)
return 0;
/*
* check if plugin already loaded
*/
{
goto init;
}
/*
* load
*/
if (!(dll = dllplugin(names->id, names->name, NiL, version, NiL, RTLD_LAZY, names->path, names->data + sizeof(names->data) - names->path)) && (streq(names->name, names->base) || !(dll = dllplugin(names->id, names->base, NiL, version, NiL, RTLD_LAZY, names->path, names->data + sizeof(names->data) - names->path))))
{
if (dllerrorf)
else
return 0;
}
/*
* init
*/
{
if (dllerrorf)
(*dllerrorf)(NiL, disc, 2, "%s: %s: initialization function not found in library", names->path, sym);
else
errorf("dll", NiL, -1, "dll_lib: %s version %lu initialization function %s not found in library", names->name, version, sym);
return 0;
}
/*
* add to the loaded list
*/
{
}
init:
}
/*
* return method pointer for <id,name,version>
*/
void*
{
}