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/*
1N/A * return plugin version for dll
1N/A * 0 if there is none
1N/A * path!=0 enables library level diagnostics
1N/A */
1N/A
1N/Aextern unsigned long
1N/Adllversion(void* dll, const char* path)
1N/A{
1N/A Dll_plugin_version_f pvf;
1N/A
1N/A if (pvf = (Dll_plugin_version_f)dlllook(dll, "plugin_version"))
1N/A return (*pvf)();
1N/A if (path)
1N/A {
1N/A state.error = 1;
1N/A sfsprintf(state.errorbuf, sizeof(state.errorbuf), "plugin_version() not found");
1N/A errorf("dll", NiL, 1, "%s: %s", path, state.errorbuf);
1N/A }
1N/A return 0;
1N/A}
1N/A
1N/A/*
1N/A * check if dll on path has plugin version >= ver
1N/A * 1 returned on success, 0 on failure
1N/A * path!=0 enables library level diagnostics
1N/A * cur!=0 gets actual version
1N/A */
1N/A
1N/Aextern int
1N/Adllcheck(void* dll, const char* path, unsigned long ver, unsigned long* cur)
1N/A{
1N/A unsigned long v;
1N/A Dll_plugin_version_f pvf;
1N/A
1N/A state.error = 0;
1N/A if (ver || cur)
1N/A {
1N/A v = dllversion(dll, path);
1N/A if (cur)
1N/A *cur = v;
1N/A }
1N/A if (!ver)
1N/A return 1;
1N/A if (!v)
1N/A return 0;
1N/A if (v < ver)
1N/A {
1N/A if (path)
1N/A {
1N/A state.error = 1;
1N/A sfsprintf(state.errorbuf, sizeof(state.errorbuf), "plugin version %lu older than caller %lu", v, ver);
1N/A errorf("dll", NiL, 1, "%s: %s", path, state.errorbuf);
1N/A }
1N/A return 0;
1N/A }
1N/A return 1;
1N/A}