xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XrdCpConfig.hh
Go to the documentation of this file.
1 #ifndef __XRDCPCONFIG_HH__
2 #define __XRDCPCONFIG_HH__
3 /******************************************************************************/
4 /* */
5 /* X r d C p C o n f i g . h h */
6 /* */
7 /* (c) 2012 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include "XrdCks/XrdCksData.hh"
34 
35 #include <cctype>
36 #include <cstdint>
37 
38 #include <string>
39 #include <vector>
40 
41 struct option;
42 class XrdCks;
43 class XrdCksCalc;
44 class XrdCpFile;
45 class XrdSysError;
46 
48 {
49 public:
50 
51 struct defVar
52  { defVar *Next; // -> Next such definition, 0 if no more
53  const char *vName; // -> Variable name
54  union {const char *strVal; // -> String value if in strDefs
55  int intVal; // Integer value if in intDefs
56  };
57  defVar(const char *vn, const char *vl)
58  : Next(0), vName(vn), strVal(vl) {}
59  defVar(const char *vn, int vl)
60  : Next(0), vName(vn), intVal(vl) {}
61  };
62 
63  defVar *intDefs; // -> -DI settings
64  defVar *strDefs; // -> -DS settings
65  const char *dstOpq; // -> -OD setting (dest opaque)
66  const char *srcOpq; // -> -OS setting (src opaque)
67  const char *Pgm; // -> Program name
68  long long xRate; // -> xrate value in bytes/sec (0 if not set)
69  long long xRateThreashold; // -> xrate threshold value in bytes/sec (0 if not set)
70  int Parallel; // Number of simultaneous copy ops (1 to 4)
71  char *pHost; // -> SOCKS4 proxy hname (0 if none)
72  int pPort; // SOCKS4 proxy port
73  long long OpSpec; // Bit mask of set options (see Doxxxx)
74  int Dlvl; // Debug level (0 to 3)
75  int nSrcs; // Number of sources wanted (dflt 1)
76  int nStrm; // Number of streams wanted (dflt 1)
77  int Retry; // Max times to retry failed copy job
78  std::string RetryPolicy; // retry policy (to force or to continue)
79  int Verbose; // True if --verbose specified
80  int CksLen; // Binary length of checksum, if any
81 
82  int numFiles; // Number of source files
83  long long totBytes; // Total number of bytes for local files
84 
85 XrdCksData CksData; // Checksum information
86 XrdCks *CksMan; // -> Checksum manager
87 XrdCksCalc *CksObj; // -> Cks computation object (0 if no cks)
88 const char *CksVal; // -> Cks argument (0 if none)
89 
90 XrdCpFile *srcFile; // List of source files
91 XrdCpFile *dstFile; // The destination for the copy
92 
93 char *zipFile; // The file name if the URL points to a ZIP archive
94 
95 static XrdSysError *Log; // -> Error message object
96 
97 std::vector<std::string> AddCksVal; // -> Additional checksum argument
98 
99 static const uint64_t OpCksum = 'C'; // -adler -MD5 legacy -> DoCksrc
100 static const uint64_t DoCksrc = 0x0000000000000001LL; // --cksum <type>:source
101 static const uint64_t DoCksum = 0x0000000000000002LL; // --cksum <type>
102 static const uint64_t DoCkprt = 0x0000000000000004LL; // --cksum <type>:print
103 
104 static const uint64_t OpCoerce = 'F';
105 static const uint64_t DoCoerce = 0x0000000000000008LL; // -F | --coerce
106 
107 static const uint64_t OpDebug = 'd';
108 static const uint64_t DoDebug = 0x0000000000000010LL; // -d | --debug <val>
109 
110 static const uint64_t OpForce = 'f';
111 static const uint64_t DoForce = 0x0000000000000020LL; // -f | --force
112 
113 static const uint64_t OpHelp = 'h';
114 static const uint64_t DoHelp = 0x0000000000000040LL; // -h | --help
115 
116 static const uint64_t OpIfile = 'I';
117 static const uint64_t DoIfile = 0x0000000000000080LL; // -I | --infiles
118 
119 static const uint64_t OpLicense = 'H'; // -H | --license
120 
121 static const uint64_t OpNoPbar = 'N'; // -N | --nopbar | -np {legacy}
122 static const uint64_t DoNoPbar = 0x0000000000000100LL;
123 
124 static const uint64_t OpPosc = 'P';
125 static const uint64_t DoPosc = 0x0000000000000200LL; // -P | --posc
126 
127 static const uint64_t OpProxy = 'D';
128 static const uint64_t DoProxy = 0x0000000000000400LL; // -D | --proxy
129 
130 static const uint64_t OpRecurse = 'r';
131 static const uint64_t OpRecursv = 'R'; // -r | --recursive | -R {legacy}
132 static const uint64_t DoRecurse = 0x0000000000000800LL;
133 
134 static const uint64_t OpRetry = 't';
135 static const uint64_t DoRetry = 0x0000000000001000LL; // -t | --retry
136 
137 static const uint64_t OpServer = 0x03;
138 static const uint64_t DoServer = 0x0000000000002000LL; // --server
139 
140 static const uint64_t OpSilent = 's';
141 static const uint64_t DoSilent = 0x0000000000004000LL; // -s | --silent
142 
143 static const uint64_t OpSources = 'y';
144 static const uint64_t DoSources = 0x0000000000008000LL; // -y | --sources
145 
146 static const uint64_t OpStreams = 'S';
147 static const uint64_t DoStreams = 0x0000000000010000LL; // -S | --streams
148 
149 static const uint64_t OpTpc = 'T'; // -T | --tpc [delegate] {first | only}
150 static const uint64_t DoTpc = 0x0000000000020000LL; // --tpc {first | only}
151 static const uint64_t DoTpcOnly = 0x0000000000100000LL; // --tpc only
152 static const uint64_t DoTpcDlgt = 0x0000000000800000LL; // --tpc delegate ...
153 
154 static const uint64_t OpVerbose = 'v';
155 static const uint64_t DoVerbose = 0x0000000000040000LL; // -v | --verbose
156 
157 static const uint64_t OpVersion = 'V'; // -V | --version
158 
159 static const uint64_t OpXrate = 'X';
160 static const uint64_t DoXrate = 0x0000000000080000LL; // -X | --xrate
161 
162 static const uint64_t OpParallel = 0x04;
163 static const uint64_t DoParallel = 0x0000000000200000LL; // --parallel
164 
165 static const uint64_t OpDynaSrc = 'Z';
166 static const uint64_t DoDynaSrc = 0x0000000000400000LL; // --dynamic-src
167 
168 // const uint64_t DoTpcDlgt = 0x0000000000800000LL; // Marker for bit used
169 
170 static const uint64_t OpZip = 'z';
171 static const uint64_t DoZip = 0x0000000001000000LL; // -z | --zip
172 
173 static const uint64_t OpTlsNoData = 'E';
174 static const uint64_t DoTlsNoData = 0x0000000002000000LL; // -E | --tlsnodata
175 
176 static const uint64_t OpNoTlsOK = 0x05;
177 static const uint64_t DoNoTlsOK = 0x0000000004000000LL; // --notlsok
178 
179 static const uint64_t OpTlsMLF = 0x06;
180 static const uint64_t DoTlsMLF = 0x0000000008000000LL; // --tlsmetalink
181 
182 static const uint64_t OpPath = 'p';
183 static const uint64_t DoPath = 0x0000000010000000LL; // -p | --path
184 
185 static const uint64_t OpXAttr = 0x07;
186 static const uint64_t DoXAttr = 0x0000000020000000LL; // --xattr
187 
188 static const uint64_t OpZipMtlnCksum = 0x08;
189 static const uint64_t DoZipMtlnCksum = 0x0000000040000000LL; // --zip-mtln-cksum
190 
191 static const uint64_t OpRmOnBadCksum = 0x09;
192 static const uint64_t DoRmOnBadCksum = 0x0000000080000000LL; // --rm-bad-cksum
193 
194 static const uint64_t OpContinue = 0x10;
195 static const uint64_t DoContinue = 0x0000000100000000LL; // --continue
196 
197 static const uint64_t OpXrateThreashold = 0x11;
198 static const uint64_t DoXrateThreashold = 0x0000000200000000LL; // --xrate-threashold
199 
200 static const uint64_t OpRetryPolicy = 0x12;
201 static const uint64_t DoRetryPolicy = 0x0000000400000000LL; // --retry-policy
202 
203 static const uint64_t OpZipAppend = 0x13;
204 static const uint64_t DoZipAppend = 0x0000000800000000LL; // --zip-append
205 
206 // Flag to allow the use of HTTP (and HTTPS) as source and destination
207 // protocols. If specified, the XrdClHttp client plugin must be available
208 // for the transfer operations to succeed.
209 static const int OpAllowHttp = 'A';
210 static const int DoAllowHttp = 0x2000000; // --allow-http
211 
212 // Call Config with the parameters passed to main() to fill out this object. If
213 // the method returns then no errors have been found. Otherwise, it exits.
214 // The following options may be passed (largely to support legacy stuff):
215 //
216 static const int opt1Src = 0x00000001; // Only one source is allowed
217 static const int optNoXtnd = 0x00000002; // Do not index source directories
218 static const int optRmtRec = 0x00000004; // Allow remote recursive copy
219 static const int optNoStdIn = 0x00000008; // Disallow '-' as src for stdin
220 static const int optNoLclCp = 0x00000010; // Disallow local/local copy
221 
222  void Config(int argc, char **argv, int Opts=0);
223 
224 // Method to check for setting
225 //
226 inline int Want(uint64_t What) {return (OpSpec & What) != 0;}
227 
228  XrdCpConfig(const char *pgname);
229  ~XrdCpConfig();
230 
231 private:
232  int a2i(const char *item, int *val, int minv, int maxv=-1);
233  int a2l(const char *item, long long *val,
234  long long minv, long long maxv=-1);
235  int a2t(const char *item, int *val, int minv, int maxv=-1);
236  int a2x(const char *Val, char *Buff, int Vlen);
237  int a2z(const char *item, long long *val,
238  long long minv, long long maxv=-1);
239  int defCks(const char *opval);
240  int defOpq(const char *theOp);
241  int defOpt(const char *theOp, const char *theArg);
242  void defPxy(const char *opval);
243  const char *Human(long long Val, char *Buff, int Blen);
244  int Legacy(int oIndex);
245  int Legacy(const char *theOp, const char *theArg);
246  void License();
247  const char *OpName();
248  void ProcFile(const char *fname);
249  void Usage(int rc=0);
250 
251  static void toLower( char cstr[] )
252  {
253  for( int i = 0; cstr[i]; ++i )
254  cstr[i] = tolower( cstr[i] );
255  }
256 
257 
258  const char *PName;
259  int Opts;
260  int Argc;
261  char **Argv;
264 
265 static const char *opLetters;
266 static struct option opVec[];
267 
268 static const int dfltSrcs = 12;
269 
273  char *inFile;
274  char **parmVal;
275  int parmCnt;
276  int isLcl;
277 };
278 #endif
static const uint64_t DoServer
Definition: XrdCpConfig.hh:138
static const uint64_t OpTpc
Definition: XrdCpConfig.hh:149
defVar * intDend
Definition: XrdCpConfig.hh:262
int a2z(const char *item, long long *val, long long minv, long long maxv=-1)
static const uint64_t OpCoerce
Definition: XrdCpConfig.hh:104
defVar(const char *vn, int vl)
Definition: XrdCpConfig.hh:59
char * pHost
Definition: XrdCpConfig.hh:71
const char * strVal
Definition: XrdCpConfig.hh:54
XrdCpFile * pFile
Definition: XrdCpConfig.hh:270
int nStrm
Definition: XrdCpConfig.hh:76
static const uint64_t DoPosc
Definition: XrdCpConfig.hh:125
static const uint64_t OpTlsNoData
Definition: XrdCpConfig.hh:173
XrdCks * CksMan
Definition: XrdCpConfig.hh:86
const char * CksVal
Definition: XrdCpConfig.hh:88
long long totBytes
Definition: XrdCpConfig.hh:83
static const uint64_t OpHelp
Definition: XrdCpConfig.hh:113
int isLcl
Definition: XrdCpConfig.hh:276
static const uint64_t OpServer
Definition: XrdCpConfig.hh:137
Definition: XrdCks.hh:91
int Verbose
Definition: XrdCpConfig.hh:79
static const uint64_t OpLicense
Definition: XrdCpConfig.hh:119
static const uint64_t OpPath
Definition: XrdCpConfig.hh:182
int Dlvl
Definition: XrdCpConfig.hh:74
static struct option opVec[]
Definition: XrdCpConfig.hh:266
static const uint64_t OpStreams
Definition: XrdCpConfig.hh:146
static const uint64_t OpRetryPolicy
Definition: XrdCpConfig.hh:200
int nSrcs
Definition: XrdCpConfig.hh:75
int parmCnt
Definition: XrdCpConfig.hh:275
char ** parmVal
Definition: XrdCpConfig.hh:274
static const uint64_t OpXrate
Definition: XrdCpConfig.hh:159
static const uint64_t OpCksum
Definition: XrdCpConfig.hh:99
static const uint64_t DoTpcDlgt
Definition: XrdCpConfig.hh:152
XrdCpFile * pLast
Definition: XrdCpConfig.hh:271
static const uint64_t DoRecurse
Definition: XrdCpConfig.hh:132
static const uint64_t DoCksrc
Definition: XrdCpConfig.hh:100
int Legacy(int oIndex)
XrdCpFile * dstFile
Definition: XrdCpConfig.hh:91
static const int DoAllowHttp
Definition: XrdCpConfig.hh:210
char ** Argv
Definition: XrdCpConfig.hh:261
XrdCpConfig(const char *pgname)
defVar * strDefs
Definition: XrdCpConfig.hh:64
static XrdSysError * Log
Definition: XrdCpConfig.hh:95
static const uint64_t OpSources
Definition: XrdCpConfig.hh:143
static const uint64_t OpTlsMLF
Definition: XrdCpConfig.hh:179
static const uint64_t DoZipAppend
Definition: XrdCpConfig.hh:204
static const uint64_t OpZipMtlnCksum
Definition: XrdCpConfig.hh:188
static const uint64_t DoNoPbar
Definition: XrdCpConfig.hh:122
int a2l(const char *item, long long *val, long long minv, long long maxv=-1)
int Want(uint64_t What)
Definition: XrdCpConfig.hh:226
static const uint64_t DoParallel
Definition: XrdCpConfig.hh:163
static const uint64_t OpRecurse
Definition: XrdCpConfig.hh:130
static const uint64_t DoRetryPolicy
Definition: XrdCpConfig.hh:201
static const uint64_t DoTlsNoData
Definition: XrdCpConfig.hh:174
static const uint64_t DoPath
Definition: XrdCpConfig.hh:183
static const uint64_t DoDebug
Definition: XrdCpConfig.hh:108
const char * Human(long long Val, char *Buff, int Blen)
static const uint64_t OpParallel
Definition: XrdCpConfig.hh:162
Definition: XrdCksData.hh:37
static const uint64_t DoForce
Definition: XrdCpConfig.hh:111
defVar * strDend
Definition: XrdCpConfig.hh:263
static const uint64_t OpXAttr
Definition: XrdCpConfig.hh:185
std::vector< std::string > AddCksVal
Definition: XrdCpConfig.hh:97
Definition: XrdSysError.hh:89
static const uint64_t DoDynaSrc
Definition: XrdCpConfig.hh:166
static const uint64_t DoVerbose
Definition: XrdCpConfig.hh:155
static const uint64_t OpVerbose
Definition: XrdCpConfig.hh:154
static const uint64_t DoSources
Definition: XrdCpConfig.hh:144
XrdCpFile * pPrev
Definition: XrdCpConfig.hh:272
static const uint64_t OpForce
Definition: XrdCpConfig.hh:110
defVar * intDefs
Definition: XrdCpConfig.hh:63
const char * dstOpq
Definition: XrdCpConfig.hh:65
static const uint64_t DoHelp
Definition: XrdCpConfig.hh:114
static const uint64_t OpVersion
Definition: XrdCpConfig.hh:157
static const uint64_t DoTlsMLF
Definition: XrdCpConfig.hh:180
Definition: XrdCpFile.hh:36
Definition: XrdCksCalc.hh:39
defVar * Next
Definition: XrdCpConfig.hh:52
void defPxy(const char *opval)
int defOpt(const char *theOp, const char *theArg)
std::string RetryPolicy
Definition: XrdCpConfig.hh:78
defVar(const char *vn, const char *vl)
Definition: XrdCpConfig.hh:57
int defCks(const char *opval)
static const uint64_t OpXrateThreashold
Definition: XrdCpConfig.hh:197
static const uint64_t OpContinue
Definition: XrdCpConfig.hh:194
Definition: XrdCpConfig.hh:47
int CksLen
Definition: XrdCpConfig.hh:80
static const uint64_t OpDebug
Definition: XrdCpConfig.hh:107
static const uint64_t OpNoPbar
Definition: XrdCpConfig.hh:121
XrdCksCalc * CksObj
Definition: XrdCpConfig.hh:87
XrdCpFile * srcFile
Definition: XrdCpConfig.hh:90
static const uint64_t DoSilent
Definition: XrdCpConfig.hh:141
void License()
int intVal
Definition: XrdCpConfig.hh:55
static const uint64_t OpProxy
Definition: XrdCpConfig.hh:127
static const uint64_t OpZip
Definition: XrdCpConfig.hh:170
static const uint64_t DoRetry
Definition: XrdCpConfig.hh:135
int numFiles
Definition: XrdCpConfig.hh:82
static const int optNoXtnd
Definition: XrdCpConfig.hh:217
static const uint64_t DoProxy
Definition: XrdCpConfig.hh:128
int a2t(const char *item, int *val, int minv, int maxv=-1)
static const uint64_t OpDynaSrc
Definition: XrdCpConfig.hh:165
static const int optRmtRec
Definition: XrdCpConfig.hh:218
int Parallel
Definition: XrdCpConfig.hh:70
long long xRateThreashold
Definition: XrdCpConfig.hh:69
static const uint64_t OpNoTlsOK
Definition: XrdCpConfig.hh:176
void Usage(int rc=0)
static const uint64_t OpZipAppend
Definition: XrdCpConfig.hh:203
static const int dfltSrcs
Definition: XrdCpConfig.hh:268
void Config(int argc, char **argv, int Opts=0)
static const uint64_t DoTpcOnly
Definition: XrdCpConfig.hh:151
char * zipFile
Definition: XrdCpConfig.hh:93
int pPort
Definition: XrdCpConfig.hh:72
static const char * opLetters
Definition: XrdCpConfig.hh:265
static const uint64_t DoContinue
Definition: XrdCpConfig.hh:195
static const uint64_t OpRmOnBadCksum
Definition: XrdCpConfig.hh:191
int Argc
Definition: XrdCpConfig.hh:260
long long xRate
Definition: XrdCpConfig.hh:68
static const uint64_t DoRmOnBadCksum
Definition: XrdCpConfig.hh:192
int a2i(const char *item, int *val, int minv, int maxv=-1)
static const uint64_t DoStreams
Definition: XrdCpConfig.hh:147
static const uint64_t DoTpc
Definition: XrdCpConfig.hh:150
static const int optNoLclCp
Definition: XrdCpConfig.hh:220
void ProcFile(const char *fname)
static const uint64_t OpSilent
Definition: XrdCpConfig.hh:140
const char * vName
Definition: XrdCpConfig.hh:53
const char * srcOpq
Definition: XrdCpConfig.hh:66
int a2x(const char *Val, char *Buff, int Vlen)
static const uint64_t OpRetry
Definition: XrdCpConfig.hh:134
XrdCksData CksData
Definition: XrdCpConfig.hh:85
static const uint64_t DoZipMtlnCksum
Definition: XrdCpConfig.hh:189
static const uint64_t OpIfile
Definition: XrdCpConfig.hh:116
Definition: XrdCpConfig.hh:51
static const int optNoStdIn
Definition: XrdCpConfig.hh:219
static const uint64_t DoXAttr
Definition: XrdCpConfig.hh:186
static const uint64_t DoCksum
Definition: XrdCpConfig.hh:101
long long OpSpec
Definition: XrdCpConfig.hh:73
static const uint64_t DoXrate
Definition: XrdCpConfig.hh:160
static void toLower(char cstr[])
Definition: XrdCpConfig.hh:251
const char * PName
Definition: XrdCpConfig.hh:258
static const uint64_t DoIfile
Definition: XrdCpConfig.hh:117
static const uint64_t DoZip
Definition: XrdCpConfig.hh:171
static const int opt1Src
Definition: XrdCpConfig.hh:216
int Opts
Definition: XrdCpConfig.hh:259
const char * OpName()
static const uint64_t DoXrateThreashold
Definition: XrdCpConfig.hh:198
static const uint64_t OpRecursv
Definition: XrdCpConfig.hh:131
const char * Pgm
Definition: XrdCpConfig.hh:67
static const uint64_t OpPosc
Definition: XrdCpConfig.hh:124
static const int OpAllowHttp
Definition: XrdCpConfig.hh:209
static const uint64_t DoCkprt
Definition: XrdCpConfig.hh:102
int defOpq(const char *theOp)
static const uint64_t DoCoerce
Definition: XrdCpConfig.hh:105
char * inFile
Definition: XrdCpConfig.hh:273
static const uint64_t DoNoTlsOK
Definition: XrdCpConfig.hh:177
int Retry
Definition: XrdCpConfig.hh:77