/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1997-2012 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* *18***********************************************************************/19#pragma prototyped20/*21* Glenn Fowler22* AT&T Research23*/2425#include "dlllib.h"2627/*28* return plugin version for dll29* 0 if there is none30* path!=0 enables library level diagnostics31*/3233extern unsigned long34dllversion(void* dll, const char* path)35{36Dll_plugin_version_f pvf;3738if (pvf = (Dll_plugin_version_f)dlllook(dll, "plugin_version"))39return (*pvf)();40if (path)41{42state.error = 1;43sfsprintf(state.errorbuf, sizeof(state.errorbuf), "plugin_version() not found");44errorf("dll", NiL, 1, "dllversion: %s: %s", path, state.errorbuf);45}46return 0;47}4849/*50* check if dll on path has plugin version >= ver51* 1 returned on success, 0 on failure52* path!=0 enables library level diagnostics53* cur!=0 gets actual version54*/5556extern int57dllcheck(void* dll, const char* path, unsigned long ver, unsigned long* cur)58{59unsigned long v;6061state.error = 0;62if (ver || cur)63{64v = dllversion(dll, path);65if (cur)66*cur = v;67}68if (!ver)69return 1;70if (!v)71return 0;72if (v < ver)73{74if (path)75{76state.error = 1;77sfsprintf(state.errorbuf, sizeof(state.errorbuf), "plugin version %lu older than caller %lu", v, ver);78errorf("dll", NiL, 1, "dllcheck: %s: %s", path, state.errorbuf);79}80return 0;81}82errorf("dll", NiL, -1, "dllversion: %s: %lu >= %lu", path, v, ver);83return 1;84}858687