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