Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:27:55

0001 #ifndef __OUC_TLIST__
0002 #define __OUC_TLIST__
0003 /******************************************************************************/
0004 /*                                                                            */
0005 /*                        X r d O u c T L i s t . h h                         */
0006 /*                                                                            */
0007 /* (c) 2003 by the Board of Trustees of the Leland Stanford, Jr., University  */
0008 /*                            All Rights Reserved                             */
0009 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
0010 /*              DE-AC02-76-SFO0515 with the Department of Energy              */
0011 /*                                                                            */
0012 /* This file is part of the XRootD software suite.                            */
0013 /*                                                                            */
0014 /* XRootD is free software: you can redistribute it and/or modify it under    */
0015 /* the terms of the GNU Lesser General Public License as published by the     */
0016 /* Free Software Foundation, either version 3 of the License, or (at your     */
0017 /* option) any later version.                                                 */
0018 /*                                                                            */
0019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
0020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
0021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
0022 /* License for more details.                                                  */
0023 /*                                                                            */
0024 /* You should have received a copy of the GNU Lesser General Public License   */
0025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
0026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
0027 /*                                                                            */
0028 /* The copyright holder's institutional names and contributor's names may not */
0029 /* be used to endorse or promote products derived from this software without  */
0030 /* specific prior written permission of the institution or contributor.       */
0031 /******************************************************************************/
0032 
0033 #include <cstdlib>
0034 #include <cstring>
0035 #include <strings.h>
0036   
0037 /******************************************************************************/
0038 /*                     C l a s s   X r d O u c T L i s t                      */
0039 /******************************************************************************/
0040   
0041 class XrdOucTList
0042 {
0043 public:
0044 
0045 XrdOucTList *next;
0046 char        *text;
0047 union
0048 {
0049 long long    dval;
0050 int          ival[2];
0051 short        sval[4];
0052 char         cval[8];
0053 int          val;
0054 };
0055 
0056              XrdOucTList(const char *tval, long long *dv,XrdOucTList *np=0)
0057                         {next=np; text = (tval ? strdup(tval) : 0); dval=*dv;}
0058 
0059              XrdOucTList(const char *tval=0, int num=0, XrdOucTList *np=0)
0060                         {next=np; text = (tval ? strdup(tval) : 0); val=num;}
0061 
0062              XrdOucTList(const char *tval, int   iv[2], XrdOucTList *np=0)
0063                         {next=np; text = (tval ? strdup(tval) : 0);
0064                          memcpy(ival, iv, sizeof(ival));}
0065 
0066              XrdOucTList(const char *tval, short sv[4], XrdOucTList *np=0)
0067                         {next=np; text = (tval ? strdup(tval) : 0);
0068                          memcpy(sval, sv, sizeof(sval));}
0069 
0070              XrdOucTList(const char *tval, char  cv[8], XrdOucTList *np=0)
0071                         {text = (tval ? strdup(tval) : 0); next=np;
0072                          memcpy(cval, cv, sizeof(cval));}
0073 
0074             ~XrdOucTList() {if (text) free(text);}
0075 };
0076 
0077 /******************************************************************************/
0078 /*               C l a s s   X r d O u c T L i s t H e l p e r                */
0079 /******************************************************************************/
0080   
0081 class XrdOucTListHelper
0082 {
0083 public:
0084 
0085 XrdOucTList **Anchor;
0086 
0087       XrdOucTListHelper(XrdOucTList **p) : Anchor(p) {}
0088      ~XrdOucTListHelper() {XrdOucTList *tp;
0089                            while((tp = *Anchor))
0090                                 {*Anchor = tp->next; delete tp;}
0091                           }
0092 };
0093   
0094 /******************************************************************************/
0095 /*                 C l a s s   X r d O u c T L i s t F I F O                  */
0096 /******************************************************************************/
0097   
0098 class XrdOucTListFIFO
0099 {
0100 public:
0101 
0102 XrdOucTList *first;
0103 XrdOucTList *last;
0104 
0105 inline void  Add(XrdOucTList *tP)
0106                 {if (last) last->next = tP;
0107                     else   first = tP;
0108                  last = tP;
0109                 }
0110 
0111 inline void  Clear() {XrdOucTList *tP;
0112                       while((tP = first)) {first = tP->next; delete tP;}
0113                       first = last = 0;
0114                      }
0115 
0116 XrdOucTList *Pop() {XrdOucTList *tP = first; first = last = 0; return tP;}
0117 
0118              XrdOucTListFIFO() : first(0), last(0) {}
0119             ~XrdOucTListFIFO() {Clear();}
0120 };
0121 #endif