Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

XrdOucPList.hh

Go to the documentation of this file.
00001 #ifndef __OUC_PLIST__
00002 #define __OUC_PLIST__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                        X r d O u c P L i s t . h h                         */
00006 /*                                                                            */
00007 /* (c) 2003 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 #include <strings.h>
00014 #include <stdlib.h>
00015   
00016 class XrdOucPList
00017 {
00018 public:
00019 
00020 inline int                 Attr() {return attrs;}
00021 inline unsigned long long  Flag() {return flags;}
00022 inline XrdOucPList        *Next() {return next;}
00023 inline char               *Path() {return path;}
00024 inline int                 Plen() {return pathlen;}
00025 
00026 inline int          PathOK(const char *pd, const int pl)
00027                           {return pl >= pathlen && !strncmp(pd, path, pathlen);}
00028 
00029 inline void         Set(int                aval) {attrs = aval;}
00030 inline void         Set(unsigned long long fval) {flags = fval;}
00031 
00032              XrdOucPList(const char *pd="", unsigned long long fv=0)
00033                         : flags(fv), next(0),  path(strdup(pd)),
00034                           pathlen(strlen(pd)), attrs(0) {}
00035             ~XrdOucPList()
00036                   {if (path) free(path);}
00037 
00038 friend class XrdOucPListAnchor;
00039 
00040 private:
00041 
00042 unsigned long long flags;
00043 XrdOucPList       *next;
00044 char              *path;
00045 int                pathlen;
00046 int                attrs;
00047 };
00048 
00049 class XrdOucPListAnchor : public XrdOucPList
00050 {
00051 public:
00052 
00053 inline XrdOucPList *About(const char *pathname)
00054                    {int plen = strlen(pathname); 
00055                     XrdOucPList *p = next;
00056                     while(p) {if (p->PathOK(pathname, plen)) break;
00057                               p=p->next;
00058                              }
00059                     return p;
00060                    }
00061 
00062 inline void        Default(unsigned long long x) {dflts = x;}
00063 
00064 inline void        Empty(XrdOucPList *newlist=0)
00065                    {XrdOucPList *p = next;
00066                     while(p) {next = p->next; delete p; p = next;}
00067                     next = newlist;
00068                    }
00069 
00070 inline unsigned long long  Find(const char *pathname)
00071                    {int plen = strlen(pathname); 
00072                     XrdOucPList *p = next;
00073                     while(p) {if (p->PathOK(pathname, plen)) break;
00074                               p=p->next;
00075                              }
00076                     return (p ? p->flags : dflts);
00077                    }
00078 
00079 inline XrdOucPList *Match(const char *pathname)
00080                    {int plen = strlen(pathname); 
00081                     XrdOucPList *p = next;
00082                     while(p) {if (p->pathlen == plen 
00083                               &&  !strcmp(p->path, pathname)) break;
00084                               p=p->next;
00085                              }
00086                     return p;
00087                    }
00088 
00089 inline XrdOucPList *First() {return next;}
00090 
00091 inline void        Insert(XrdOucPList *newitem)
00092                    {XrdOucPList *pp = 0, *cp = next;
00093                     while(cp && newitem->pathlen < cp->pathlen) {pp=cp;cp=cp->next;}
00094                     if (pp) {newitem->next = pp->next; pp->next = newitem;}
00095                        else {newitem->next = next;         next = newitem;}
00096                    }
00097 
00098 inline int         NotEmpty() {return next != 0;}
00099 
00100                    XrdOucPListAnchor(unsigned long long dfx=0) {dflts = dfx;}
00101                   ~XrdOucPListAnchor() {}
00102 
00103 private:
00104 
00105 unsigned long long dflts;
00106 };
00107 #endif

Generated on Sun Nov 6 13:35:16 2011 for xrootd by  doxygen 1.3.9.1