00001 #ifndef __XRDSYSPLUGIN__ 00002 #define __XRDSYSPLUGIN__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d S y s P l u g i n . h h */ 00006 /* */ 00007 /* (c) 2005 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00011 /* */ 00012 /* This file is part of the XRootD software suite. */ 00013 /* */ 00014 /* XRootD is free software: you can redistribute it and/or modify it under */ 00015 /* the terms of the GNU Lesser General Public License as published by the */ 00016 /* Free Software Foundation, either version 3 of the License, or (at your */ 00017 /* option) any later version. */ 00018 /* */ 00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00021 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00022 /* License for more details. */ 00023 /* */ 00024 /* You should have received a copy of the GNU Lesser General Public License */ 00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00026 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00027 /* */ 00028 /* The copyright holder's institutional names and contributor's names may not */ 00029 /* be used to endorse or promote products derived from this software without */ 00030 /* specific prior written permission of the institution or contributor. */ 00031 /******************************************************************************/ 00032 00033 #include <string.h> 00034 00035 struct XrdVersionInfo; 00036 00037 class XrdSysError; 00038 00039 //------------------------------------------------------------------------------ 00050 //------------------------------------------------------------------------------ 00051 00052 class XrdSysPlugin 00053 { 00054 public: 00055 00056 //------------------------------------------------------------------------------ 00068 //------------------------------------------------------------------------------ 00069 00070 void *getPlugin(const char *pname, int optional=0); 00071 00072 //------------------------------------------------------------------------------ 00087 //------------------------------------------------------------------------------ 00088 00089 void *getPlugin(const char *pname, int optional, bool global); 00090 00091 //------------------------------------------------------------------------------ 00096 //------------------------------------------------------------------------------ 00097 00098 void *Persist() {void *lHan = libHandle; libHandle = 0; return lHan;} 00099 00100 //------------------------------------------------------------------------------ 00117 //------------------------------------------------------------------------------ 00118 00119 static 00120 bool Preload(const char *path, char *ebuff=0, int eblen=0); 00121 00122 //------------------------------------------------------------------------------ 00131 //------------------------------------------------------------------------------ 00132 00133 static 00134 bool VerCmp(XrdVersionInfo &vInf1, XrdVersionInfo &vInf2, bool noMsg=false); 00135 00136 //------------------------------------------------------------------------------ 00143 //------------------------------------------------------------------------------ 00144 00145 XrdSysPlugin(XrdSysError *erp, const char *path) 00146 : eDest(erp), libName(0), libPath(path ? strdup(path) : 0), 00147 libHandle(0), myInfo(0), eBuff(0), eBLen(0), msgCnt(-1) {} 00148 00149 //------------------------------------------------------------------------------ 00163 //------------------------------------------------------------------------------ 00164 00165 XrdSysPlugin(XrdSysError *erp, const char *path, const char *lname, 00166 XrdVersionInfo *vinf=0, int msgNum=-1) 00167 : eDest(erp), libName(lname), 00168 libPath(path ? strdup(path) : 0), libHandle(0), 00169 myInfo(vinf), eBuff(0), eBLen(0), msgCnt(msgNum) {} 00170 00171 //------------------------------------------------------------------------------ 00188 //------------------------------------------------------------------------------ 00189 00190 XrdSysPlugin(char *ebuff, int eblen, const char *path, const char *lname, 00191 XrdVersionInfo *vinf=0, int msgNum=-1) 00192 : eDest(0), libName(lname), 00193 libPath(path ? strdup(path) : 0), libHandle(0), 00194 myInfo(vinf), eBuff(ebuff), eBLen(eblen), msgCnt(msgNum) {} 00195 00196 //------------------------------------------------------------------------------ 00198 //------------------------------------------------------------------------------ 00199 00200 ~XrdSysPlugin(); 00201 00202 private: 00203 enum cvResult {cvBad = 0, cvNone, cvMissing, cvClean, cvDirty}; 00204 00205 cvResult badVersion(XrdVersionInfo &urInfo,char mmv,int majv,int minv); 00206 cvResult chkVersion(XrdVersionInfo &urInfo, const char *pname, void *lh); 00207 static int DLflags(); 00208 static void *Find(const char *libname); 00209 void Inform(const char *txt1, const char *txt2=0, const char *txt3=0, 00210 const char *txt4=0, const char *txt5=0, int noHush=0); 00211 cvResult libMsg(const char *txt1, const char *txt2, const char *mSym=0); 00212 const char *msgSuffix(const char *Word, char *buff, int bsz); 00213 00214 XrdSysError *eDest; 00215 const char *libName; 00216 char *libPath; 00217 void *libHandle; 00218 XrdVersionInfo *myInfo; 00219 char *eBuff; 00220 int eBLen; 00221 int msgCnt; 00222 00223 struct PLlist {PLlist *next; 00224 char *libPath; 00225 void *libHandle; 00226 }; 00227 00228 static PLlist *plList; 00229 }; 00230 #endif