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 //------------------------------------------------------------------------------ 00072 //------------------------------------------------------------------------------ 00073 00074 void *getLibrary(bool allMsgs=true, bool global=false); 00075 00076 //------------------------------------------------------------------------------ 00088 //------------------------------------------------------------------------------ 00089 00090 void *getPlugin(const char *pname, int optional=0); 00091 00092 //------------------------------------------------------------------------------ 00107 //------------------------------------------------------------------------------ 00108 00109 void *getPlugin(const char *pname, int optional, bool global); 00110 00111 //------------------------------------------------------------------------------ 00116 //------------------------------------------------------------------------------ 00117 00118 void *Persist() {void *lHan = libHandle; libHandle = 0; return lHan;} 00119 00120 //------------------------------------------------------------------------------ 00137 //------------------------------------------------------------------------------ 00138 00139 static 00140 bool Preload(const char *path, char *ebuff=0, int eblen=0); 00141 00142 //------------------------------------------------------------------------------ 00151 //------------------------------------------------------------------------------ 00152 00153 static 00154 bool VerCmp(XrdVersionInfo &vInf1, XrdVersionInfo &vInf2, bool noMsg=false); 00155 00156 //------------------------------------------------------------------------------ 00163 //------------------------------------------------------------------------------ 00164 00165 XrdSysPlugin(XrdSysError *erp, const char *path) 00166 : eDest(erp), libName(0), libPath(path ? strdup(path) : 0), 00167 libHandle(0), myInfo(0), eBuff(0), eBLen(0), msgCnt(-1) {} 00168 00169 //------------------------------------------------------------------------------ 00183 //------------------------------------------------------------------------------ 00184 00185 XrdSysPlugin(XrdSysError *erp, const char *path, const char *lname, 00186 XrdVersionInfo *vinf=0, int msgNum=-1) 00187 : eDest(erp), libName(lname), 00188 libPath(path ? strdup(path) : 0), libHandle(0), 00189 myInfo(vinf), eBuff(0), eBLen(0), msgCnt(msgNum) {} 00190 00191 //------------------------------------------------------------------------------ 00208 //------------------------------------------------------------------------------ 00209 00210 XrdSysPlugin(char *ebuff, int eblen, const char *path, const char *lname, 00211 XrdVersionInfo *vinf=0, int msgNum=-1) 00212 : eDest(0), libName(lname), 00213 libPath(path ? strdup(path) : 0), libHandle(0), 00214 myInfo(vinf), eBuff(ebuff), eBLen(eblen), msgCnt(msgNum) {} 00215 00216 //------------------------------------------------------------------------------ 00218 //------------------------------------------------------------------------------ 00219 00220 ~XrdSysPlugin(); 00221 00222 private: 00223 enum cvResult {cvBad = 0, cvNone, cvMissing, cvClean, cvDirty}; 00224 00225 cvResult badVersion(XrdVersionInfo &urInfo,char mmv,int majv,int minv); 00226 cvResult chkVersion(XrdVersionInfo &urInfo, const char *pname, void *lh); 00227 static int DLflags(); 00228 static void *Find(const char *libname); 00229 void Inform(const char *txt1, const char *txt2=0, const char *txt3=0, 00230 const char *txt4=0, const char *txt5=0, int noHush=0); 00231 cvResult libMsg(const char *txt1, const char *txt2, const char *mSym=0); 00232 const char *msgSuffix(const char *Word, char *buff, int bsz); 00233 00234 XrdSysError *eDest; 00235 const char *libName; 00236 char *libPath; 00237 void *libHandle; 00238 XrdVersionInfo *myInfo; 00239 char *eBuff; 00240 int eBLen; 00241 int msgCnt; 00242 00243 struct PLlist {PLlist *next; 00244 char *libPath; 00245 void *libHandle; 00246 }; 00247 00248 static PLlist *plList; 00249 }; 00250 #endif