xrootd
XrdOucMsubs.hh
Go to the documentation of this file.
00001 #ifndef __XRDOUCMSUBS_H__
00002 #define __XRDOUCMSUBS_H__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                        X r d O u c M S u b s . h h                         */
00006 /*                                                                            */
00007 /* (c) 2006 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-AC02-76-SFO0515 with the Department of Energy              */
00011 /*                                                                            */
00012 /* This file is part of the XRootD software suite.                            */
00013 /*                                                                            */
00014 /* XRootD is free software: you can redistribute it and/or modify it under    */
00015 /* the terms of the GNU Lesser General Public License as published by the     */
00016 /* Free Software Foundation, either version 3 of the License, or (at your     */
00017 /* option) any later version.                                                 */
00018 /*                                                                            */
00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
00021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
00022 /* License for more details.                                                  */
00023 /*                                                                            */
00024 /* You should have received a copy of the GNU Lesser General Public License   */
00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
00026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
00027 /*                                                                            */
00028 /* The copyright holder's institutional names and contributor's names may not */
00029 /* be used to endorse or promote products derived from this software without  */
00030 /* specific prior written permission of the institution or contributor.       */
00031 /******************************************************************************/
00032 
00033 #include <stdlib.h>
00034 
00035 #include "XrdSys/XrdSysError.hh"
00036 #include "XrdOuc/XrdOucEnv.hh"
00037 #include "XrdOuc/XrdOucName2Name.hh"
00038 
00039 /******************************************************************************/
00040 /*      P r e d e f i n e d   E n v i r o n m e n t   V a r i a b l e s       */
00041 /******************************************************************************/
00042 
00043 #define CMS_CID             "cms&cid"
00044 #define SEC_USER            "sec&user"
00045 #define SEC_HOST            "sec&host"
00046 #define SEC_POLICY          "sec&policy"
00047 #define XRD_INS             "xrd&ins"
00048   
00049 /******************************************************************************/
00050 /*                           X r d O u c M s u b s                            */
00051 /******************************************************************************/
00052   
00053 struct XrdOucMsubsInfo
00054 {
00055 const char      *Tid;       // $TID   or $RID  unless Rid is defined.
00056 XrdOucEnv       *Env;
00057 XrdOucName2Name *N2N;
00058 const char      *lfn;       // $LFN
00059 const char      *lfn2;      // $LFN2  or $NOTIFY or $SRC
00060 const char      *pfn;       // $PFN
00061 const char      *pfn2;      // $PFN2             or $DST
00062 const char      *misc;      // $OPTS  or $MDP
00063 const char      *Rid;       // $RID for real
00064 char            *pfnbuff;
00065 char            *rfnbuff;
00066 char            *pfn2buff;
00067 char            *rfn2buff;
00068 mode_t           Mode;      // $FMODE or $PRTY
00069 int              Oflag;     // $OFLAG
00070 char             mbuff[12];
00071 char             obuff[4];
00072 
00073              XrdOucMsubsInfo(const char *tid, XrdOucEnv *envP, 
00074                              XrdOucName2Name *n2np,
00075                              const char *lfnP, const char *lfn2P,
00076                              mode_t mode=0,    int ofl=0,
00077                              const char *Opts=0, const char *ridP=0,
00078                              const char *pfnP=0, const char *pfn2P=0)
00079                             : Tid(tid), Env(envP), N2N(n2np),
00080                               lfn(lfnP), lfn2(lfn2P), pfn(pfnP), pfn2(pfn2P),
00081                               misc(Opts), Rid(ridP), Mode(mode), Oflag(ofl)
00082                               {pfnbuff = rfnbuff = pfn2buff = rfn2buff = 0;}
00083             ~XrdOucMsubsInfo(){if (pfnbuff ) free(pfnbuff);
00084                                if (rfnbuff ) free(rfnbuff);
00085                                if (pfn2buff) free(pfn2buff);
00086                                if (rfn2buff) free(rfn2buff);
00087                               }
00088 };
00089   
00090 class XrdOucMsubs
00091 {
00092 public:
00093 
00094 static const int maxElem = 32;
00095 
00096 int   Parse(const char *oname, char *msg);
00097 
00098 int   Subs(XrdOucMsubsInfo &Info, char **Data, int *Dlen);
00099 
00100       XrdOucMsubs(XrdSysError *errp);
00101      ~XrdOucMsubs();
00102 
00103 private:
00104 char *getVal(XrdOucMsubsInfo &Info, int vNum);
00105 
00106 enum vNum {vLFN =  1, vPFN =  2, vRFN =  3, vLFN2 =  4, vPFN2 =  5, vRFN2 =  6,
00107            vFM  =  7, vOFL =  8, vUSR =  9, vHST  = 10, vTID  = 11,
00108            vNFY = 12, vOPT = 13, vPTY = 14, vRID  = 15, vCGI  = 16,
00109            vMDP = 17, vSRC = 18, vDST = 19, vCID  = 20, vINS  = 21};
00110 
00111 static const int   vMax = 22;
00112 static const char *vName[vMax];
00113 
00114 XrdSysError *eDest;
00115 char        *mText;
00116 char        *mData[maxElem+1];
00117 int          mDlen[maxElem+1];
00118 int          numElem;
00119 };
00120 #endif