XRootD
XrdCmsParser.hh
Go to the documentation of this file.
1 #ifndef __XRDCMSPARSER_H__
2 #define __XRDCMSPARSER_H__
3 /******************************************************************************/
4 /* */
5 /* X r d C m s P a r s e r . h h */
6 /* */
7 /* (c) 2007 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 "XProtocol/YProtocol.hh"
34 
35 #include "XrdCms/XrdCmsRRData.hh"
36 #include "XrdOuc/XrdOucPup.hh"
37 
38 /******************************************************************************/
39 /* C l a s s X r d C m s P a r s e r */
40 /******************************************************************************/
41 
42 class XrdOucErrInfo;
43 class XrdOucBuffer;
44 
46 {
47 public:
48 
49 static int Decode(const char *Man, XrdCms::CmsRRHdr &hdr,
50  XrdOucBuffer *dBuff, XrdOucErrInfo *eInfo);
51 
52 static int mapError(const char *ecode);
53 
54 static int mapError(int ecode);
55 
56 static int Pack(int rnum, struct iovec *iovP, struct iovec *iovE,
57  char *Base, char *Work);
58 
59 inline int Parse(XrdCms::CmsLoginData *Data,
60  const char *Aps, const char *Apt)
61  {Data->SID = Data->Paths = 0;
62  return Pup.Unpack(Aps,Apt,vecArgs[XrdCms::kYR_login],
63  (char *)Data);
64  }
65 
66 inline int Parse(int rnum, const char *Aps, const char *Apt,
67  XrdCmsRRData *Data)
68  {Data->Opaque = Data->Opaque2 = Data->Path = 0;
69  return rnum < XrdCms::kYR_MaxReq
70  && vecArgs[rnum] != 0
71  && Pup.Unpack(Aps, Apt,
72  vecArgs[rnum], (char *)Data);
73  }
74 
75 static XrdOucPup Pup;
76 
77 static XrdOucPupArgs *PupArgs(int rnum)
78  {return rnum < XrdCms::kYR_MaxReq ? vecArgs[rnum] : 0;}
79 
80  XrdCmsParser();
82 
83 private:
84 
85 static const char **PupNVec;
86 static XrdOucPupNames PupName;
87 
88 static XrdOucPupArgs fwdArgA[]; // chmod | mkdir | mkpath | trunc
89 static XrdOucPupArgs fwdArgB[]; // mv
90 static XrdOucPupArgs fwdArgC[]; // rm | rmdir
91 static XrdOucPupArgs locArgs[]; // locate | select
92 static XrdOucPupArgs padArgs[]; // prepadd
93 static XrdOucPupArgs pdlArgs[]; // prepdel
94 static XrdOucPupArgs avlArgs[]; // avail
95 static XrdOucPupArgs pthArgs[]; // statfs | try
96 static XrdOucPupArgs lodArgs[]; // load
97 static XrdOucPupArgs logArgs[]; // login
98 
99 static XrdOucPupArgs *vecArgs[XrdCms::kYR_MaxReq];
100 };
101 
102 namespace XrdCms
103 {
104 extern XrdCmsParser Parser;
105 }
106 #endif
static int mapError(const char *ecode)
static int Pack(int rnum, struct iovec *iovP, struct iovec *iovE, char *Base, char *Work)
int Parse(int rnum, const char *Aps, const char *Apt, XrdCmsRRData *Data)
Definition: XrdCmsParser.hh:66
static int Decode(const char *Man, XrdCms::CmsRRHdr &hdr, XrdOucBuffer *dBuff, XrdOucErrInfo *eInfo)
static XrdOucPupArgs * PupArgs(int rnum)
Definition: XrdCmsParser.hh:77
static XrdOucPup Pup
Definition: XrdCmsParser.hh:75
int Parse(XrdCms::CmsLoginData *Data, const char *Aps, const char *Apt)
Definition: XrdCmsParser.hh:59
char * Opaque2
Definition: XrdCmsRRData.hh:58
static int Unpack(char **buff, const char *bend, char **data, int &dlen)
Definition: XrdOucPup.cc:250
XrdCmsParser Parser
@ kYR_login
Definition: YProtocol.hh:90
@ kYR_MaxReq
Definition: YProtocol.hh:118