xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 <ctype.h>
36 
37 struct option;
38 class XrdCks;
39 class XrdCksCalc;
40 class XrdCpFile;
41 class XrdSysError;
42 
44 {
45 public:
46 
47 struct defVar
48  { defVar *Next; // -> Next such definition, 0 if no more
49  const char *vName; // -> Variable name
50  union {const char *strVal; // -> String value if in strDefs
51  int intVal; // Integer value if in intDefs
52  };
53  defVar(const char *vn, const char *vl)
54  : Next(0), vName(vn), strVal(vl) {}
55  defVar(const char *vn, int vl)
56  : Next(0), vName(vn), intVal(vl) {}
57  };
58 
59  defVar *intDefs; // -> -DI settings
60  defVar *strDefs; // -> -DS settings
61  const char *dstOpq; // -> -OD setting (dest opaque)
62  const char *srcOpq; // -> -OS setting (src opaque)
63  const char *Pgm; // -> Program name
64  long long xRate; // -xrate value in bytes/sec (0 if not set)
65  int Parallel; // Number of simultaneous copy ops (1 to 4)
66  char *pHost; // -> SOCKS4 proxy hname (0 if none)
67  int pPort; // SOCKS4 proxy port
68  int OpSpec; // Bit mask of set options (see Doxxxx)
69  int Dlvl; // Debug level (0 to 3)
70  int nSrcs; // Number of sources wanted (dflt 1)
71  int nStrm; // Number of streams wanted (dflt 1)
72  int Retry; // Max times to retry connects (<0->use dflt)
73  int Verbose; // True if --verbose specified
74  int CksLen; // Binary length of checksum, if any
75 
76  int numFiles; // Number of source files
77  long long totBytes; // Total number of bytes for local files
78 
79 XrdCksData CksData; // Checksum information
80 XrdCks *CksMan; // -> Checksum manager
81 XrdCksCalc *CksObj; // -> Cks computation object (0 if no cks)
82 const char *CksVal; // -> Cks argument (0 if none)
83 
84 XrdCpFile *srcFile; // List of source files
85 XrdCpFile *dstFile; // The destination for the copy
86 
87 char *zipFile; // The file name if the URL points to a ZIP archive
88 
89 static XrdSysError *Log; // -> Error message object
90 
91 static const int OpCksum = 'C'; // -adler -MD5 legacy -> DoCksrc
92 static const int DoCksrc = 0x00000001; // --cksum <type>:source
93 static const int DoCksum = 0x00000002; // --cksum <type>
94 static const int DoCkprt = 0x00000004; // --cksum <type>:print
95 
96 static const int OpCoerce = 'F';
97 static const int DoCoerce = 0x00000008; // -F | --coerce
98 
99 static const int OpDebug = 'd';
100 static const int DoDebug = 0x00000010; // -d | --debug <val>
101 
102 static const int OpForce = 'f';
103 static const int DoForce = 0x00000020; // -f | --force
104 
105 static const int OpHelp = 'h';
106 static const int DoHelp = 0x00000040; // -h | --help
107 
108 static const int OpIfile = 'I';
109 static const int DoIfile = 0x00000080; // -I | --infiles
110 
111 static const int OpLicense = 'H'; // -H | --license
112 
113 static const int OpNoPbar = 'N';
114 static const int DoNoPbar = 0x00000100; // -N | --nopbar | -np {legacy}
115 
116 static const int OpPath = 'p';
117 static const int DoPath = 0x00800000; // -p | --path
118 
119 static const int OpPosc = 'P';
120 static const int DoPosc = 0x00000200; // -P | --posc
121 
122 static const int OpProxy = 'D';
123 static const int DoProxy = 0x00000400; // -D | --proxy
124 
125 static const int OpRecurse = 'r';
126 static const int OpRecursv = 'R';
127 static const int DoRecurse = 0x00000800; // -r | --recursive | -R {legacy}
128 
129 static const int OpRetry = 't';
130 static const int DoRetry = 0x00001000; // -t | --retry
131 
132 static const int OpServer = 0x03;
133 static const int DoServer = 0x00002000; // --server
134 
135 static const int OpSilent = 's';
136 static const int DoSilent = 0x00004000; // -s | --silent
137 
138 static const int OpSources = 'y';
139 static const int DoSources = 0x00008000; // -y | --sources
140 
141 static const int OpStreams = 'S';
142 static const int DoStreams = 0x00010000; // -S | --streams
143 
144 static const int OpTpc = 'T';
145 static const int DoTpc = 0x00020000; // -T | --tpc {first | only}
146 static const int DoTpcOnly = 0x00100000; // -T | --tpc only
147 static const int DoTpcDlgt = 0x00800000; // -T | --tpc delegate ...
148 
149 static const int OpVerbose = 'v';
150 static const int DoVerbose = 0x00040000; // -v | --verbose
151 
152 static const int OpVersion = 'V'; // -V | --version
153 
154 static const int OpXrate = 'X';
155 static const int DoXrate = 0x00080000; // -X | --xrate
156 
157 static const int OpParallel = 0x04;
158 static const int DoParallel = 0x00200000; // --parallel
159 
160 static const int OpDynaSrc = 'Z';
161 static const int DoDynaSrc = 0x00400000; // --dynamic-src
162 
163 // const int DoTpcDlgt = 0x00800000; // Marker to show bit used
164 
165 static const int OpZip = 'z';
166 static const int DoZip = 0x01000000;// --zip
167 
168 // Flag to allow the use of HTTP (and HTTPS) as source and destination
169 // protocols. If specified, the XrdClHttp client plugin must be available
170 // for the transfer operations to succeed.
171 static const int OpAllowHttp = 'A';
172 static const int DoAllowHttp = 0x2000000; // --allow-http
173 
174 // Call Config with the parameters passed to main() to fill out this object. If
175 // the method returns then no errors have been found. Otherwise, it exits.
176 // The following options may be passed (largely to support legacy stuff):
177 //
178 static const int opt1Src = 0x00000001; // Only one source is allowed
179 static const int optNoXtnd = 0x00000002; // Do not index source directories
180 static const int optRmtRec = 0x00000004; // Allow remote recursive copy
181 static const int optNoStdIn = 0x00000008; // Disallow '-' as src for stdin
182 static const int optNoLclCp = 0x00000010; // Disallow local/local copy
183 
184  void Config(int argc, char **argv, int Opts=0);
185 
186 // Method to check for setting
187 //
188 inline int Want(int What) {return (OpSpec & What) != 0;}
189 
190  XrdCpConfig(const char *pgname);
191  ~XrdCpConfig();
192 
193 private:
194  int a2i(const char *item, int *val, int minv, int maxv=-1);
195  int a2l(const char *item, long long *val,
196  long long minv, long long maxv=-1);
197  int a2t(const char *item, int *val, int minv, int maxv=-1);
198  int a2x(const char *Val, char *Buff, int Vlen);
199  int a2z(const char *item, long long *val,
200  long long minv, long long maxv=-1);
201  int defCks(const char *opval);
202  int defOpq(const char *theOp);
203  int defOpt(const char *theOp, const char *theArg);
204  void defPxy(const char *opval);
205  const char *Human(long long Val, char *Buff, int Blen);
206  int Legacy(int oIndex);
207  int Legacy(const char *theOp, const char *theArg);
208  void License();
209  const char *OpName();
210  void ProcFile(const char *fname);
211  void Usage(int rc=0);
212 
213  static void toLower( char cstr[] )
214  {
215  for( int i = 0; cstr[i]; ++i )
216  cstr[i] = tolower( cstr[i] );
217  }
218 
219 
220  const char *PName;
221  int Opts;
222  int Argc;
223  char **Argv;
226 
227 static const char *opLetters;
228 static struct option opVec[];
229 
230 static const int dfltSrcs = 12;
231 
235  char *inFile;
236  char **parmVal;
237  int parmCnt;
238  int isLcl;
239 };
240 #endif
defVar * intDend
Definition: XrdCpConfig.hh:224
int a2z(const char *item, long long *val, long long minv, long long maxv=-1)
defVar(const char *vn, int vl)
Definition: XrdCpConfig.hh:55
static const int OpRecurse
Definition: XrdCpConfig.hh:125
char * pHost
Definition: XrdCpConfig.hh:66
const char * strVal
Definition: XrdCpConfig.hh:50
XrdCpFile * pFile
Definition: XrdCpConfig.hh:232
static const int DoPath
Definition: XrdCpConfig.hh:117
int nStrm
Definition: XrdCpConfig.hh:71
XrdCks * CksMan
Definition: XrdCpConfig.hh:80
const char * CksVal
Definition: XrdCpConfig.hh:82
long long totBytes
Definition: XrdCpConfig.hh:77
int isLcl
Definition: XrdCpConfig.hh:238
static const int DoHelp
Definition: XrdCpConfig.hh:106
Definition: XrdCks.hh:48
static const int OpTpc
Definition: XrdCpConfig.hh:144
int Verbose
Definition: XrdCpConfig.hh:73
int Dlvl
Definition: XrdCpConfig.hh:69
static const int DoXrate
Definition: XrdCpConfig.hh:155
static struct option opVec[]
Definition: XrdCpConfig.hh:228
static const int DoTpc
Definition: XrdCpConfig.hh:145
int nSrcs
Definition: XrdCpConfig.hh:70
int parmCnt
Definition: XrdCpConfig.hh:237
char ** parmVal
Definition: XrdCpConfig.hh:236
static const int DoDebug
Definition: XrdCpConfig.hh:100
static const int DoZip
Definition: XrdCpConfig.hh:166
XrdCpFile * pLast
Definition: XrdCpConfig.hh:233
static const int DoSilent
Definition: XrdCpConfig.hh:136
int Legacy(int oIndex)
XrdCpFile * dstFile
Definition: XrdCpConfig.hh:85
static const int DoAllowHttp
Definition: XrdCpConfig.hh:172
char ** Argv
Definition: XrdCpConfig.hh:223
XrdCpConfig(const char *pgname)
static const int DoStreams
Definition: XrdCpConfig.hh:142
defVar * strDefs
Definition: XrdCpConfig.hh:60
static XrdSysError * Log
Definition: XrdCpConfig.hh:89
static const int OpPath
Definition: XrdCpConfig.hh:116
int a2l(const char *item, long long *val, long long minv, long long maxv=-1)
static const int OpStreams
Definition: XrdCpConfig.hh:141
static const int OpVersion
Definition: XrdCpConfig.hh:152
static const int DoNoPbar
Definition: XrdCpConfig.hh:114
const char * Human(long long Val, char *Buff, int Blen)
static const int DoDynaSrc
Definition: XrdCpConfig.hh:161
Definition: XrdCksData.hh:37
defVar * strDend
Definition: XrdCpConfig.hh:225
static const int DoTpcOnly
Definition: XrdCpConfig.hh:146
Definition: XrdSysError.hh:89
static const int DoRecurse
Definition: XrdCpConfig.hh:127
XrdCpFile * pPrev
Definition: XrdCpConfig.hh:234
defVar * intDefs
Definition: XrdCpConfig.hh:59
static const int OpIfile
Definition: XrdCpConfig.hh:108
const char * dstOpq
Definition: XrdCpConfig.hh:61
static const int OpRetry
Definition: XrdCpConfig.hh:129
static const int OpParallel
Definition: XrdCpConfig.hh:157
Definition: XrdCpFile.hh:36
Definition: XrdCksCalc.hh:39
defVar * Next
Definition: XrdCpConfig.hh:48
void defPxy(const char *opval)
int defOpt(const char *theOp, const char *theArg)
defVar(const char *vn, const char *vl)
Definition: XrdCpConfig.hh:53
static const int DoIfile
Definition: XrdCpConfig.hh:109
int defCks(const char *opval)
Definition: XrdCpConfig.hh:43
int CksLen
Definition: XrdCpConfig.hh:74
static const int DoCksum
Definition: XrdCpConfig.hh:93
static const int DoCksrc
Definition: XrdCpConfig.hh:92
static const int OpProxy
Definition: XrdCpConfig.hh:122
XrdCksCalc * CksObj
Definition: XrdCpConfig.hh:81
XrdCpFile * srcFile
Definition: XrdCpConfig.hh:84
void License()
int intVal
Definition: XrdCpConfig.hh:51
static const int OpPosc
Definition: XrdCpConfig.hh:119
static const int DoTpcDlgt
Definition: XrdCpConfig.hh:147
int numFiles
Definition: XrdCpConfig.hh:76
static const int DoSources
Definition: XrdCpConfig.hh:139
static const int optNoXtnd
Definition: XrdCpConfig.hh:179
static const int DoVerbose
Definition: XrdCpConfig.hh:150
static const int OpCksum
Definition: XrdCpConfig.hh:91
int a2t(const char *item, int *val, int minv, int maxv=-1)
static const int optRmtRec
Definition: XrdCpConfig.hh:180
int Parallel
Definition: XrdCpConfig.hh:65
static const int OpDynaSrc
Definition: XrdCpConfig.hh:160
static const int DoRetry
Definition: XrdCpConfig.hh:130
static const int DoPosc
Definition: XrdCpConfig.hh:120
void Usage(int rc=0)
static const int dfltSrcs
Definition: XrdCpConfig.hh:230
void Config(int argc, char **argv, int Opts=0)
static const int OpDebug
Definition: XrdCpConfig.hh:99
char * zipFile
Definition: XrdCpConfig.hh:87
static const int OpRecursv
Definition: XrdCpConfig.hh:126
int pPort
Definition: XrdCpConfig.hh:67
static const char * opLetters
Definition: XrdCpConfig.hh:227
static const int OpHelp
Definition: XrdCpConfig.hh:105
static const int OpSilent
Definition: XrdCpConfig.hh:135
int Argc
Definition: XrdCpConfig.hh:222
long long xRate
Definition: XrdCpConfig.hh:64
int a2i(const char *item, int *val, int minv, int maxv=-1)
static const int optNoLclCp
Definition: XrdCpConfig.hh:182
void ProcFile(const char *fname)
static const int OpCoerce
Definition: XrdCpConfig.hh:96
static const int DoParallel
Definition: XrdCpConfig.hh:158
const char * vName
Definition: XrdCpConfig.hh:49
const char * srcOpq
Definition: XrdCpConfig.hh:62
static const int OpLicense
Definition: XrdCpConfig.hh:111
int a2x(const char *Val, char *Buff, int Vlen)
static const int OpForce
Definition: XrdCpConfig.hh:102
XrdCksData CksData
Definition: XrdCpConfig.hh:79
Definition: XrdCpConfig.hh:47
static const int optNoStdIn
Definition: XrdCpConfig.hh:181
static const int OpSources
Definition: XrdCpConfig.hh:138
static const int DoForce
Definition: XrdCpConfig.hh:103
static void toLower(char cstr[])
Definition: XrdCpConfig.hh:213
const char * PName
Definition: XrdCpConfig.hh:220
int OpSpec
Definition: XrdCpConfig.hh:68
static const int DoCoerce
Definition: XrdCpConfig.hh:97
static const int opt1Src
Definition: XrdCpConfig.hh:178
static const int OpXrate
Definition: XrdCpConfig.hh:154
int Opts
Definition: XrdCpConfig.hh:221
const char * OpName()
static const int OpZip
Definition: XrdCpConfig.hh:165
const char * Pgm
Definition: XrdCpConfig.hh:63
static const int DoCkprt
Definition: XrdCpConfig.hh:94
int Want(int What)
Definition: XrdCpConfig.hh:188
static const int DoServer
Definition: XrdCpConfig.hh:133
static const int OpAllowHttp
Definition: XrdCpConfig.hh:171
static const int OpVerbose
Definition: XrdCpConfig.hh:149
int defOpq(const char *theOp)
static const int OpNoPbar
Definition: XrdCpConfig.hh:113
static const int OpServer
Definition: XrdCpConfig.hh:132
static const int DoProxy
Definition: XrdCpConfig.hh:123
char * inFile
Definition: XrdCpConfig.hh:235
int Retry
Definition: XrdCpConfig.hh:72