XrdXrootdLoadLib.cc

Go to the documentation of this file.
00001 /******************************************************************************/
00002 /*                                                                            */
00003 /*                   X r d X r o o t d L o a d L i b . c c                    */
00004 /*                                                                            */
00005 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University  */
00006 /*       All Rights Reserved. See XrdInfo.cc for complete License Terms       */
00007 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00008 /*              DE-AC03-76-SFO0515 with the Department of Energy              */
00009 /******************************************************************************/
00010 
00011 //       $Id: XrdXrootdLoadLib.cc 29874 2009-08-21 16:56:04Z ganis $ 
00012 
00013 const char *XrdXrootdLoadLibCVSID = "$Id: XrdXrootdLoadLib.cc 29874 2009-08-21 16:56:04Z ganis $";
00014 
00015 // Bypass Solaris ELF madness
00016 //
00017 #ifdef __solaris__
00018 #include <sys/isa_defs.h>
00019 #if defined(_ILP32) && (_FILE_OFFSET_BITS != 32)
00020 #undef  _FILE_OFFSET_BITS
00021 #define _FILE_OFFSET_BITS 32
00022 #undef  _LARGEFILE_SOURCE
00023 #endif
00024 #endif
00025   
00026 #include <dlfcn.h>
00027 #ifndef __macos__
00028 #include <link.h>
00029 #endif
00030 
00031 #include "XrdOuc/XrdOucEnv.hh"
00032 #include "XrdSec/XrdSecInterface.hh"
00033 #include "XrdSfs/XrdSfsInterface.hh"
00034 #include "XrdSys/XrdSysError.hh"
00035   
00036 /******************************************************************************/
00037 /*                        G l o b a l   S y m b o l s                         */
00038 /******************************************************************************/
00039   
00040 XrdSecProtocol *(*XrdXrootdSecGetProtocol)(const char             *hostname,
00041                                            const struct sockaddr  &netaddr,
00042                                            const XrdSecParameters &parms,
00043                                                  XrdOucErrInfo    *einfo) = 0;
00044 
00045 /******************************************************************************/
00046 /*                 x r o o t d _ l o a d F i l e s y s t e m                  */
00047 /******************************************************************************/
00048 
00049 XrdSfsFileSystem *XrdXrootdloadFileSystem(XrdSysError *eDest, 
00050                                           char *fslib, const char *cfn)
00051 {
00052    void *libhandle;
00053    XrdSfsFileSystem *(*ep)(XrdSfsFileSystem *, XrdSysLogger *, const char *);
00054    XrdSfsFileSystem *FS;
00055 
00056 // Record the library path in the environment
00057 //
00058    XrdOucEnv::Export("XRDOFSLIB", fslib);
00059 
00060 // Open the file system library
00061 //
00062    if (!(libhandle = dlopen(fslib, RTLD_NOW)))
00063       {eDest->Emsg("Config",dlerror(),"opening shared library",fslib);
00064        return 0;
00065       }
00066 
00067 // Get the file system object creator
00068 //
00069    if (!(ep = (XrdSfsFileSystem *(*)(XrdSfsFileSystem *,XrdSysLogger *,const char *))
00070                                   dlsym(libhandle,"XrdSfsGetFileSystem")))
00071       {eDest->Emsg("Config", dlerror(),
00072                    "finding XrdSfsGetFileSystem() in", fslib);
00073        return 0;
00074       }
00075 
00076 // Get the file system object
00077 //
00078    if (!(FS = (*ep)(0, eDest->logger(), cfn)))
00079       {eDest->Emsg("Config", "Unable to create file system object via",fslib);
00080        return 0;
00081       }
00082 
00083 // All done
00084 //
00085    return FS;
00086 }
00087   
00088 /******************************************************************************/
00089 /*                   x r o o t d _ l o a d S e c u r i t y                    */
00090 /******************************************************************************/
00091 
00092 XrdSecService *XrdXrootdloadSecurity(XrdSysError *eDest, char *seclib, char *cfn)
00093 {
00094    void *libhandle;
00095    XrdSecService *(*ep)(XrdSysLogger *, const char *cfn);
00096    XrdSecService *CIA;
00097 
00098 // Open the security library
00099 //
00100    if (!(libhandle = dlopen(seclib, RTLD_NOW)))
00101       {eDest->Emsg("Config",dlerror(),"opening shared library",seclib);
00102        return 0;
00103       }
00104 
00105 // Get the server object creator
00106 //
00107    if (!(ep = (XrdSecService *(*)(XrdSysLogger *, const char *cfn))dlsym(libhandle,
00108               "XrdSecgetService")))
00109       {eDest->Emsg("Config", dlerror(),
00110                    "finding XrdSecgetService() in", seclib);
00111        return 0;
00112       }
00113 
00114 // Get the server object
00115 //
00116    if (!(CIA = (*ep)(eDest->logger(), cfn)))
00117       {eDest->Emsg("Config", "Unable to create security service object via",seclib);
00118        return 0;
00119       }
00120 
00121 // Get the client object creator (in case we are acting as a client)
00122 //
00123    if (!(XrdXrootdSecGetProtocol = 
00124                  (XrdSecProtocol *(*)(const char             *,
00125                                       const struct sockaddr  &,
00126                                       const XrdSecParameters &,
00127                                             XrdOucErrInfo    *))
00128                  dlsym(libhandle, "XrdSecGetProtocol")))
00129       {eDest->Emsg("Config", dlerror(),
00130                    "finding XrdSecGetProtocol() in", seclib);
00131        return 0;
00132       }
00133 
00134 // All done
00135 //
00136    return CIA;
00137 }

Generated on Tue Jul 5 14:47:04 2011 for ROOT_528-00b_version by  doxygen 1.5.1