xrootd
XrdSysPlugin.hh
Go to the documentation of this file.
1 #ifndef __XRDSYSPLUGIN__
2 #define __XRDSYSPLUGIN__
3 /******************************************************************************/
4 /* */
5 /* X r d S y s P l u g i n . h h */
6 /* */
7 /* (c) 2005 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include <string.h>
34 
35 struct XrdVersionInfo;
36 
37 class XrdSysError;
38 
39 //------------------------------------------------------------------------------
50 //------------------------------------------------------------------------------
51 
53 {
54 public:
55 
56 //------------------------------------------------------------------------------
68 //------------------------------------------------------------------------------
69 
70 void *getPlugin(const char *pname, int optional=0);
71 
72 //------------------------------------------------------------------------------
87 //------------------------------------------------------------------------------
88 
89 void *getPlugin(const char *pname, int optional, bool global);
90 
91 //------------------------------------------------------------------------------
96 //------------------------------------------------------------------------------
97 
98 void *Persist() {void *lHan = libHandle; libHandle = 0; return lHan;}
99 
100 //------------------------------------------------------------------------------
117 //------------------------------------------------------------------------------
118 
119 static
120 bool Preload(const char *path, char *ebuff=0, int eblen=0);
121 
122 //------------------------------------------------------------------------------
131 //------------------------------------------------------------------------------
132 
133 static
134 bool VerCmp(XrdVersionInfo &vInf1, XrdVersionInfo &vInf2, bool noMsg=false);
135 
136 //------------------------------------------------------------------------------
143 //------------------------------------------------------------------------------
144 
145  XrdSysPlugin(XrdSysError *erp, const char *path)
146  : eDest(erp), libName(0), libPath(path ? strdup(path) : 0),
147  libHandle(0), myInfo(0), eBuff(0), eBLen(0), msgCnt(-1) {}
148 
149 //------------------------------------------------------------------------------
163 //------------------------------------------------------------------------------
164 
165  XrdSysPlugin(XrdSysError *erp, const char *path, const char *lname,
166  XrdVersionInfo *vinf=0, int msgNum=-1)
167  : eDest(erp), libName(lname),
168  libPath(path ? strdup(path) : 0), libHandle(0),
169  myInfo(vinf), eBuff(0), eBLen(0), msgCnt(msgNum) {}
170 
171 //------------------------------------------------------------------------------
188 //------------------------------------------------------------------------------
189 
190  XrdSysPlugin(char *ebuff, int eblen, const char *path, const char *lname,
191  XrdVersionInfo *vinf=0, int msgNum=-1)
192  : eDest(0), libName(lname),
193  libPath(path ? strdup(path) : 0), libHandle(0),
194  myInfo(vinf), eBuff(ebuff), eBLen(eblen), msgCnt(msgNum) {}
195 
196 //------------------------------------------------------------------------------
198 //------------------------------------------------------------------------------
199 
200  ~XrdSysPlugin();
201 
202 private:
204 
205 cvResult badVersion(XrdVersionInfo &urInfo,char mmv,int majv,int minv);
206 cvResult chkVersion(XrdVersionInfo &urInfo, const char *pname, void *lh);
207 static int DLflags();
208 static void *Find(const char *libname);
209 void Inform(const char *txt1, const char *txt2=0, const char *txt3=0,
210  const char *txt4=0, const char *txt5=0, int noHush=0);
211 cvResult libMsg(const char *txt1, const char *txt2, const char *mSym=0);
212 const char *msgSuffix(const char *Word, char *buff, int bsz);
213 
215 const char *libName;
216 char *libPath;
217 void *libHandle;
218 XrdVersionInfo *myInfo;
219 char *eBuff;
220 int eBLen;
221 int msgCnt;
222 
223 struct PLlist {PLlist *next;
224  char *libPath;
225  void *libHandle;
226  };
227 
228 static PLlist *plList;
229 };
230 #endif
Definition: XrdSysPlugin.hh:203
void * libHandle
Definition: XrdSysPlugin.hh:217
int msgCnt
Definition: XrdSysPlugin.hh:221
Definition: XrdSysPlugin.hh:203
static bool VerCmp(XrdVersionInfo &vInf1, XrdVersionInfo &vInf2, bool noMsg=false)
int eBLen
Definition: XrdSysPlugin.hh:220
static bool Preload(const char *path, char *ebuff=0, int eblen=0)
cvResult badVersion(XrdVersionInfo &urInfo, char mmv, int majv, int minv)
void Inform(const char *txt1, const char *txt2=0, const char *txt3=0, const char *txt4=0, const char *txt5=0, int noHush=0)
Definition: XrdSysPlugin.hh:223
char * libPath
Definition: XrdSysPlugin.hh:224
XrdVersionInfo * myInfo
Definition: XrdSysPlugin.hh:218
const char * msgSuffix(const char *Word, char *buff, int bsz)
XrdSysPlugin(char *ebuff, int eblen, const char *path, const char *lname, XrdVersionInfo *vinf=0, int msgNum=-1)
Definition: XrdSysPlugin.hh:190
Definition: XrdSysError.hh:89
Definition: XrdSysPlugin.hh:203
void * Persist()
Definition: XrdSysPlugin.hh:98
Definition: XrdSysPlugin.hh:52
static void * Find(const char *libname)
Definition: XrdSysPlugin.hh:203
void * libHandle
Definition: XrdSysPlugin.hh:225
const char * libName
Definition: XrdSysPlugin.hh:215
cvResult libMsg(const char *txt1, const char *txt2, const char *mSym=0)
static int DLflags()
char * libPath
Definition: XrdSysPlugin.hh:216
XrdSysError * eDest
Definition: XrdSysPlugin.hh:214
~XrdSysPlugin()
Destructor.
char * eBuff
Definition: XrdSysPlugin.hh:219
XrdSysPlugin(XrdSysError *erp, const char *path, const char *lname, XrdVersionInfo *vinf=0, int msgNum=-1)
Definition: XrdSysPlugin.hh:165
XrdSysPlugin(XrdSysError *erp, const char *path)
Definition: XrdSysPlugin.hh:145
void * getPlugin(const char *pname, int optional=0)
Definition: XrdSysPlugin.hh:203
cvResult
Definition: XrdSysPlugin.hh:203
cvResult chkVersion(XrdVersionInfo &urInfo, const char *pname, void *lh)
static PLlist * plList
Definition: XrdSysPlugin.hh:228
PLlist * next
Definition: XrdSysPlugin.hh:223