XrdXrootdXPath.hh

Go to the documentation of this file.
00001 #ifndef __XROOTD_XPATH__
00002 #define __XROOTD_XPATH__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                     X r d X r o o t d X P a t h . h h                      */
00006 /*                                                                            */
00007 /* (c) 2004 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-AC03-76-SFO0515 with the Department of Energy              */
00011 /******************************************************************************/
00012 
00013 //         $Id: XrdXrootdXPath.hh 29874 2009-08-21 16:56:04Z ganis $
00014 
00015 #include <strings.h>
00016 #include <stdlib.h>
00017 
00018 #define XROOTDXP_OK        1
00019 #define XROOTDXP_NOLK      2
00020   
00021 class XrdXrootdXPath
00022 {
00023 public:
00024 
00025 inline XrdXrootdXPath *Next()  {return next;}
00026 inline int             Opts()  {return pathopt;}
00027 inline char           *Path()  {return path;}
00028 inline char           *Path(int &PLen)
00029                                {PLen = pathlen; return path;}
00030 
00031        void            Insert(const char *pd, int popt=0, int flags=XROOTDXP_OK)
00032                              {XrdXrootdXPath *pp = 0, *p = next;
00033                               XrdXrootdXPath *newp = new XrdXrootdXPath(pd,popt,flags);
00034                               while(p && newp->pathlen >= p->pathlen)
00035                                    {pp = p; p = p->next;}
00036                               newp->next = p;
00037                               if (pp) pp->next = newp;
00038                                  else     next = newp;
00039                              }
00040 
00041 inline int             Validate(const char *pd, const int pl=0)
00042                                {int plen = (pl ? pl : strlen(pd));
00043                                 XrdXrootdXPath *p = next;
00044                                 while(p && plen >= p->pathlen)
00045                                      {if (!strncmp(pd, p->path, p->pathlen))
00046                                          return p->pathopt;
00047                                       p=p->next;
00048                                      }
00049                                 return 0;
00050                                }
00051 
00052        XrdXrootdXPath(const char *pathdata="",int popt=0,int flags=XROOTDXP_OK)
00053                      {next = 0;
00054                       pathopt = popt | flags;
00055                       pathlen = strlen(pathdata);
00056                       path    = strdup(pathdata);
00057                      }
00058 
00059       ~XrdXrootdXPath() {if (path) free(path);}
00060 
00061 private:
00062 
00063        XrdXrootdXPath *next;
00064        int             pathlen;
00065        int             pathopt;
00066        char           *path;
00067 };
00068 #endif

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