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 //------------------------------------------------------------------------------
72 //------------------------------------------------------------------------------
73 
74 void *getLibrary(bool allMsgs=true, bool global=false);
75 
76 //------------------------------------------------------------------------------
88 //------------------------------------------------------------------------------
89 
90 void *getPlugin(const char *pname, int optional=0);
91 
92 //------------------------------------------------------------------------------
107 //------------------------------------------------------------------------------
108 
109 void *getPlugin(const char *pname, int optional, bool global);
110 
111 //------------------------------------------------------------------------------
116 //------------------------------------------------------------------------------
117 
118 void *Persist() {void *lHan = libHandle; libHandle = 0; return lHan;}
119 
120 //------------------------------------------------------------------------------
137 //------------------------------------------------------------------------------
138 
139 static
140 bool Preload(const char *path, char *ebuff=0, int eblen=0);
141 
142 //------------------------------------------------------------------------------
151 //------------------------------------------------------------------------------
152 
153 static
154 bool VerCmp(XrdVersionInfo &vInf1, XrdVersionInfo &vInf2, bool noMsg=false);
155 
156 //------------------------------------------------------------------------------
163 //------------------------------------------------------------------------------
164 
165  XrdSysPlugin(XrdSysError *erp, const char *path)
166  : eDest(erp), libName(0), libPath(path ? strdup(path) : 0),
167  libHandle(0), myInfo(0), eBuff(0), eBLen(0), msgCnt(-1) {}
168 
169 //------------------------------------------------------------------------------
183 //------------------------------------------------------------------------------
184 
185  XrdSysPlugin(XrdSysError *erp, const char *path, const char *lname,
186  XrdVersionInfo *vinf=0, int msgNum=-1)
187  : eDest(erp), libName(lname),
188  libPath(path ? strdup(path) : 0), libHandle(0),
189  myInfo(vinf), eBuff(0), eBLen(0), msgCnt(msgNum) {}
190 
191 //------------------------------------------------------------------------------
208 //------------------------------------------------------------------------------
209 
210  XrdSysPlugin(char *ebuff, int eblen, const char *path, const char *lname,
211  XrdVersionInfo *vinf=0, int msgNum=-1)
212  : eDest(0), libName(lname),
213  libPath(path ? strdup(path) : 0), libHandle(0),
214  myInfo(vinf), eBuff(ebuff), eBLen(eblen), msgCnt(msgNum) {}
215 
216 //------------------------------------------------------------------------------
218 //------------------------------------------------------------------------------
219 
220  ~XrdSysPlugin();
221 
222 private:
224 
225 cvResult badVersion(XrdVersionInfo &urInfo,char mmv,int majv,int minv);
226 cvResult chkVersion(XrdVersionInfo &urInfo, const char *pname, void *lh);
227 static int DLflags();
228 static void *Find(const char *libname);
229 void Inform(const char *txt1, const char *txt2=0, const char *txt3=0,
230  const char *txt4=0, const char *txt5=0, int noHush=0);
231 cvResult libMsg(const char *txt1, const char *txt2, const char *mSym=0);
232 const char *msgSuffix(const char *Word, char *buff, int bsz);
233 
235 const char *libName;
236 char *libPath;
237 void *libHandle;
238 XrdVersionInfo *myInfo;
239 char *eBuff;
240 int eBLen;
241 int msgCnt;
242 
243 struct PLlist {PLlist *next;
244  char *libPath;
245  void *libHandle;
246  };
247 
248 static PLlist *plList;
249 };
250 #endif
Definition: XrdSysPlugin.hh:223
void * libHandle
Definition: XrdSysPlugin.hh:237
int msgCnt
Definition: XrdSysPlugin.hh:241
Definition: XrdSysPlugin.hh:223
static bool VerCmp(XrdVersionInfo &vInf1, XrdVersionInfo &vInf2, bool noMsg=false)
int eBLen
Definition: XrdSysPlugin.hh:240
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:243
char * libPath
Definition: XrdSysPlugin.hh:244
XrdVersionInfo * myInfo
Definition: XrdSysPlugin.hh:238
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:210
void * getLibrary(bool allMsgs=true, bool global=false)
Definition: XrdSysError.hh:89
Definition: XrdSysPlugin.hh:223
void * Persist()
Definition: XrdSysPlugin.hh:118
Definition: XrdSysPlugin.hh:52
static void * Find(const char *libname)
Definition: XrdSysPlugin.hh:223
void * libHandle
Definition: XrdSysPlugin.hh:245
const char * libName
Definition: XrdSysPlugin.hh:235
cvResult libMsg(const char *txt1, const char *txt2, const char *mSym=0)
static int DLflags()
char * libPath
Definition: XrdSysPlugin.hh:236
XrdSysError * eDest
Definition: XrdSysPlugin.hh:234
~XrdSysPlugin()
Destructor.
char * eBuff
Definition: XrdSysPlugin.hh:239
XrdSysPlugin(XrdSysError *erp, const char *path, const char *lname, XrdVersionInfo *vinf=0, int msgNum=-1)
Definition: XrdSysPlugin.hh:185
XrdSysPlugin(XrdSysError *erp, const char *path)
Definition: XrdSysPlugin.hh:165
void * getPlugin(const char *pname, int optional=0)
Definition: XrdSysPlugin.hh:223
cvResult
Definition: XrdSysPlugin.hh:223
cvResult chkVersion(XrdVersionInfo &urInfo, const char *pname, void *lh)
static PLlist * plList
Definition: XrdSysPlugin.hh:248
PLlist * next
Definition: XrdSysPlugin.hh:243