xrootd
XrdCpConfig.hh
Go to the documentation of this file.
00001 #ifndef __XRDCPCONFIG_HH__
00002 #define __XRDCPCONFIG_HH__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                        X r d C p C o n f i g . h h                         */
00006 /*                                                                            */
00007 /* (c) 2012 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 "XrdCks/XrdCksData.hh"
00034 
00035 struct option;
00036 class  XrdCks;
00037 class  XrdCksCalc;
00038 class  XrdCpFile;
00039 class  XrdSysError;
00040   
00041 class XrdCpConfig
00042 {
00043 public:
00044 
00045 struct defVar
00046       {        defVar     *Next;    // -> Next such definition, 0 if no more
00047                const char *vName;   // -> Variable name
00048        union  {const char *strVal;  // -> String  value if in strDefs
00049                int         intVal;  //    Integer value if in intDefs
00050               };
00051                defVar(const char *vn, const char *vl) : vName(vn), strVal(vl) {}
00052                defVar(const char *vn, int         vl) : vName(vn), intVal(vl) {}
00053       };
00054 
00055        defVar      *intDefs;       // -> -DI settings
00056        defVar      *strDefs;       // -> -DS settings
00057        const char  *dstOpq;        // -> -OD setting (dest opaque)
00058        const char  *srcOpq;        // -> -OS setting (src  opaque)
00059        const char  *Pgm;           // -> Program name
00060         long long   xRate;         // -xrate value in bytes/sec   (0 if not set)
00061              char  *pHost;         // -> SOCKS4 proxy hname       (0 if none)
00062              int    pPort;         //    SOCKS4 proxy port
00063              int    OpSpec;        // Bit mask of set options     (see Doxxxx)
00064              int    Dlvl;          // Debug level                 (0 to 3)
00065              int    nSrcs;         // Number of sources wanted    (dflt 1)
00066              int    nStrm;         // Number of streams wanted    (dflt 1)
00067              int    Retry;         // Max times to retry connects (<0->use dflt)
00068              int    Verbose;       // True if --verbose specified
00069              int    CksLen;        // Binary length of checksum, if any
00070 
00071              int    numFiles;      // Number of source files
00072        long long    totBytes;      // Total number of bytes for local files
00073 
00074 XrdCksData          CksData;       // Checksum information
00075 XrdCks             *CksMan;        // -> Checksum manager
00076 XrdCksCalc         *CksObj;        // -> Cks computation object   (0 if no cks)
00077 const char         *CksVal;        // -> Cks argument (0 if none)
00078 
00079 XrdCpFile          *srcFile;       // List of source files
00080 XrdCpFile          *dstFile;       // The destination for the copy
00081 
00082 static XrdSysError *Log;           // -> Error message object
00083 
00084 static const int    DoAdler    =  0x00000001; //  -adler {legacy}
00085 
00086 static const int    OpCksum    =  'C';
00087 static const int    DoCksum    =  0x00000002; // --cksum <type>
00088 static const int    DoCkprt    =  0x00000004; // --cksum <type>:print
00089 
00090 static const int    OpCoerce   =  'F';
00091 static const int    DoCoerce   =  0x00000008; // -F | --coerce
00092 
00093 static const int    OpDebug    =  'd';
00094 static const int    DoDebug    =  0x00000010; // -d | --debug <val>
00095 
00096 static const int    OpForce    =  'f';
00097 static const int    DoForce    =  0x00000020; // -f | --force
00098 
00099 static const int    OpHelp     =  'h';
00100 static const int    DoHelp     =  0x00000040; // -h | --help
00101 
00102 static const int    OpIfile    =  'I';
00103 static const int    DoIfile    =  0x00100000; // -I | --infiles
00104 
00105 static const int    OpLicense  =  'H';        // -H | --license
00106 
00107 static const int    DoMD5      =  0x00000080; // -md5 {legacy}
00108 
00109 static const int    OpNoPbar   =  'N';
00110 static const int    DoNoPbar   =  0x00000100; // -N | --nopbar | -np {legacy}
00111 
00112 static const int    OpPosc     =  'P';
00113 static const int    DoPosc     =  0x00000200; // -P | --posc
00114 
00115 static const int    OpProxy    =  'D';
00116 static const int    DoProxy    =  0x00000400; // -D | --proxy
00117 
00118 static const int    OpRecurse  =  'r';
00119 static const int    OpRecursv  =  'R';
00120 static const int    DoRecurse  =  0x00000800; // -r | --recursive | -R {legacy}
00121 
00122 static const int    OpRetry    =  't';
00123 static const int    DoRetry    =  0x00001000; // --coerce
00124 
00125 static const int    OpServer   =  0x03;
00126 static const int    DoServer   =  0x00002000; // -s | --silent
00127 
00128 static const int    OpSilent   =  's';
00129 static const int    DoSilent   =  0x00004000; // -s | --silent
00130 
00131 static const int    OpSources  =  'y';
00132 static const int    DoSources  =  0x00008000; // -y | --sources
00133 
00134 static const int    OpStreams  =  'S';
00135 static const int    DoStreams  =  0x00010000; // -S | --streams
00136 
00137 static const int    OpTpc      =  'T';
00138 static const int    DoTpc      =  0x00020000; // -T | --tpc {first | only}
00139 static const int    DoTpcOnly  =  0x00100000; // -T | --tpc          only
00140 
00141 static const int    OpVerbose  =  'v';
00142 static const int    DoVerbose  =  0x00040000; // -v | --verbose
00143 
00144 static const int    OpVersion  =  'V';        // -V | --version
00145 
00146 static const int    OpXrate    =  'X';
00147 static const int    DoXrate    =  0x00080000; // -X | --xrate
00148 
00149 // Call Config with the parameters passed to main() to fill out this object. If
00150 // the method returns then no errors have been found. Otherwise, it exits.
00151 // The following options may be passed (largely to support legacy stuff):
00152 //
00153 static const int    opt1Src     = 0x00000001; // Only one source is allowed
00154 static const int    optNoXtnd   = 0x00000002; // Do not index source directories
00155 static const int    optRmtRec   = 0x00000004; // Allow remote recursive copy
00156 static const int    optNoStdIn  = 0x00000008; // Disallow '-' as src for stdin
00157 
00158              void   Config(int argc, char **argv, int Opts=0);
00159 
00160 // Method to check for setting
00161 //
00162 inline       int    Want(int What) {return (OpSpec & What) != 0;}
00163 
00164                     XrdCpConfig(const char *pgname);
00165                    ~XrdCpConfig();
00166 
00167 private:
00168              int    a2i(const char *item, int *val, int minv, int maxv=-1);
00169              int    a2l(const char *item, long long *val,
00170                         long long minv, long long maxv=-1);
00171              int    a2t(const char *item, int *val, int minv, int maxv=-1);
00172              int    a2x(const char *Val, char *Buff, int Vlen);
00173              int    a2z(const char *item, long long *val,
00174                                           long long minv, long long maxv=-1);
00175              int    defCks(const char *opval);
00176              int    defOpq(const char *theOp);
00177              int    defOpt(const char *theOp, const char *theArg);
00178              void   defPxy(const char *opval);
00179        const char  *Human(long long Val, char *Buff, int Blen);
00180              int    Legacy(int oIndex);
00181              int    Legacy(const char *theOp, const char *theArg);
00182              void   License();
00183        const char  *OpName();
00184              void   ProcFile(const char *fname);
00185              void   Usage(int rc=0);
00186 
00187        const char  *PName;
00188              int    Opts;
00189              int    Argc;
00190              char **Argv;
00191            defVar  *intDend;
00192            defVar  *strDend;
00193 
00194 static const  char   *opLetters;
00195 static struct option  opVec[];
00196 
00197 static const int    dfltSrcs   = 12;
00198 
00199        XrdCpFile   *pFile;
00200        XrdCpFile   *pLast;
00201        XrdCpFile   *pPrev;
00202        char        *inFile;
00203        char       **parmVal;
00204        int          parmCnt;
00205        int          isLcl;
00206 };
00207 #endif