00001 #ifndef __XRDCPCONFIG_HH__
00002 #define __XRDCPCONFIG_HH__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "XrdCks/XrdCksData.hh"
00034
00035 #include <ctype.h>
00036 #include <stdint.h>
00037
00038 struct option;
00039 class XrdCks;
00040 class XrdCksCalc;
00041 class XrdCpFile;
00042 class XrdSysError;
00043
00044 class XrdCpConfig
00045 {
00046 public:
00047
00048 struct defVar
00049 { defVar *Next;
00050 const char *vName;
00051 union {const char *strVal;
00052 int intVal;
00053 };
00054 defVar(const char *vn, const char *vl)
00055 : Next(0), vName(vn), strVal(vl) {}
00056 defVar(const char *vn, int vl)
00057 : Next(0), vName(vn), intVal(vl) {}
00058 };
00059
00060 defVar *intDefs;
00061 defVar *strDefs;
00062 const char *dstOpq;
00063 const char *srcOpq;
00064 const char *Pgm;
00065 long long xRate;
00066 int Parallel;
00067 char *pHost;
00068 int pPort;
00069 int OpSpec;
00070 int Dlvl;
00071 int nSrcs;
00072 int nStrm;
00073 int Retry;
00074 int Verbose;
00075 int CksLen;
00076
00077 int numFiles;
00078 long long totBytes;
00079
00080 XrdCksData CksData;
00081 XrdCks *CksMan;
00082 XrdCksCalc *CksObj;
00083 const char *CksVal;
00084
00085 XrdCpFile *srcFile;
00086 XrdCpFile *dstFile;
00087
00088 char *zipFile;
00089
00090 static XrdSysError *Log;
00091
00092 static const uint64_t OpCksum = 'C';
00093 static const uint64_t DoCksrc = 0x0000000000000001LL;
00094 static const uint64_t DoCksum = 0x0000000000000002LL;
00095 static const uint64_t DoCkprt = 0x0000000000000004LL;
00096
00097 static const uint64_t OpCoerce = 'F';
00098 static const uint64_t DoCoerce = 0x0000000000000008LL;
00099
00100 static const uint64_t OpDebug = 'd';
00101 static const uint64_t DoDebug = 0x0000000000000010LL;
00102
00103 static const uint64_t OpForce = 'f';
00104 static const uint64_t DoForce = 0x0000000000000020LL;
00105
00106 static const uint64_t OpHelp = 'h';
00107 static const uint64_t DoHelp = 0x0000000000000040LL;
00108
00109 static const uint64_t OpIfile = 'I';
00110 static const uint64_t DoIfile = 0x0000000000000080LL;
00111
00112 static const uint64_t OpLicense = 'H';
00113
00114 static const uint64_t OpNoPbar = 'N';
00115 static const uint64_t DoNoPbar = 0x0000000000000100LL;
00116
00117 static const uint64_t OpPosc = 'P';
00118 static const uint64_t DoPosc = 0x0000000000000200LL;
00119
00120 static const uint64_t OpProxy = 'D';
00121 static const uint64_t DoProxy = 0x0000000000000400LL;
00122
00123 static const uint64_t OpRecurse = 'r';
00124 static const uint64_t OpRecursv = 'R';
00125 static const uint64_t DoRecurse = 0x0000000000000800LL;
00126
00127 static const uint64_t OpRetry = 't';
00128 static const uint64_t DoRetry = 0x0000000000001000LL;
00129
00130 static const uint64_t OpServer = 0x03;
00131 static const uint64_t DoServer = 0x0000000000002000LL;
00132
00133 static const uint64_t OpSilent = 's';
00134 static const uint64_t DoSilent = 0x0000000000004000LL;
00135
00136 static const uint64_t OpSources = 'y';
00137 static const uint64_t DoSources = 0x0000000000008000LL;
00138
00139 static const uint64_t OpStreams = 'S';
00140 static const uint64_t DoStreams = 0x0000000000010000LL;
00141
00142 static const uint64_t OpTpc = 'T';
00143 static const uint64_t DoTpc = 0x0000000000020000LL;
00144 static const uint64_t DoTpcOnly = 0x0000000000100000LL;
00145 static const uint64_t DoTpcDlgt = 0x0000000000800000LL;
00146
00147 static const uint64_t OpVerbose = 'v';
00148 static const uint64_t DoVerbose = 0x0000000000040000LL;
00149
00150 static const uint64_t OpVersion = 'V';
00151
00152 static const uint64_t OpXrate = 'X';
00153 static const uint64_t DoXrate = 0x0000000000080000LL;
00154
00155 static const uint64_t OpParallel = 0x04;
00156 static const uint64_t DoParallel = 0x0000000000200000LL;
00157
00158 static const uint64_t OpDynaSrc = 'Z';
00159 static const uint64_t DoDynaSrc = 0x0000000000400000LL;
00160
00161
00162
00163 static const uint64_t OpZip = 'z';
00164 static const uint64_t DoZip = 0x0000000001000000LL;
00165
00166 static const uint64_t OpPath = 'p';
00167 static const uint64_t DoPath = 0x0000000010000000LL;
00168
00169 static const uint64_t OpZipMtlnCksum = 0x08;
00170 static const uint64_t DoZipMtlnCksum = 0x0000000040000000LL;
00171
00172 static const uint64_t OpRmOnBadCksum = 0x09;
00173 static const uint64_t DoRmOnBadCksum = 0x0000000080000000LL;
00174
00175 static const uint64_t OpContinue = 0x10;
00176 static const uint64_t DoContinue = 0x0000000100000000LL;
00177
00178
00179
00180
00181 static const int OpAllowHttp = 'A';
00182 static const int DoAllowHttp = 0x2000000;
00183
00184
00185
00186
00187
00188 static const int opt1Src = 0x00000001;
00189 static const int optNoXtnd = 0x00000002;
00190 static const int optRmtRec = 0x00000004;
00191 static const int optNoStdIn = 0x00000008;
00192 static const int optNoLclCp = 0x00000010;
00193
00194 void Config(int argc, char **argv, int Opts=0);
00195
00196
00197
00198 inline int Want(uint64_t What) {return (OpSpec & What) != 0;}
00199
00200 XrdCpConfig(const char *pgname);
00201 ~XrdCpConfig();
00202
00203 private:
00204 int a2i(const char *item, int *val, int minv, int maxv=-1);
00205 int a2l(const char *item, long long *val,
00206 long long minv, long long maxv=-1);
00207 int a2t(const char *item, int *val, int minv, int maxv=-1);
00208 int a2x(const char *Val, char *Buff, int Vlen);
00209 int a2z(const char *item, long long *val,
00210 long long minv, long long maxv=-1);
00211 int defCks(const char *opval);
00212 int defOpq(const char *theOp);
00213 int defOpt(const char *theOp, const char *theArg);
00214 void defPxy(const char *opval);
00215 const char *Human(long long Val, char *Buff, int Blen);
00216 int Legacy(int oIndex);
00217 int Legacy(const char *theOp, const char *theArg);
00218 void License();
00219 const char *OpName();
00220 void ProcFile(const char *fname);
00221 void Usage(int rc=0);
00222
00223 static void toLower( char cstr[] )
00224 {
00225 for( int i = 0; cstr[i]; ++i )
00226 cstr[i] = tolower( cstr[i] );
00227 }
00228
00229
00230 const char *PName;
00231 int Opts;
00232 int Argc;
00233 char **Argv;
00234 defVar *intDend;
00235 defVar *strDend;
00236
00237 static const char *opLetters;
00238 static struct option opVec[];
00239
00240 static const int dfltSrcs = 12;
00241
00242 XrdCpFile *pFile;
00243 XrdCpFile *pLast;
00244 XrdCpFile *pPrev;
00245 char *inFile;
00246 char **parmVal;
00247 int parmCnt;
00248 int isLcl;
00249 };
00250 #endif