xrootd
XrdPssUrlInfo.hh
Go to the documentation of this file.
1 #ifndef _XRDPSS_URLINFO_H
2 #define _XRDPSS_URLINFO_H
3 /******************************************************************************/
4 /* */
5 /* X r d P s s U r l I n f o . h h */
6 /* */
7 /* (c) 2018 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 <stdio.h>
34 
35 class XrdOucEnv;
36 
38 {
39 public:
40 
41  bool addCGI(char *buff, int blen)
42  {if ((CgiSsz + CgiUsz) >= blen) return false;
43  int n = snprintf(buff, blen, "?%s%s", CgiUsr, CgiSfx);
44  return n < blen;
45  }
46 
47  bool Extend(const char *cgi, int cgiln);
48 
49 const char *getID() {return theID;}
50 
51  bool hasCGI() {return CgiSsz || CgiUsz;}
52 
53  void setID(const char *tid=0);
54 
55  void setID(XrdOucSid *sP)
56  {if (sP != 0 && !(sP->Obtain(&idVal))) return;
57  sidP = sP;
58  snprintf(theID, sizeof(theID), "p%d@", idVal.sidS);
59  }
60 
61 const char *thePath() {return Path;}
62 
63 const char *Tident() {return tident;}
64 
65  XrdPssUrlInfo(XrdOucEnv *envP, const char *path, const char *xtra="",
66  bool addusrcgi=true, bool addident=true)
67  : tident("unk.0:0@host"), Path(path), CgiUsr(""), CgiUsz(0),
68  CgiSsz(0), sidP(0) {Setup(envP, xtra, addusrcgi, addident);}
69 
70  XrdPssUrlInfo(const char *tid, const char *path, const char *xtra="",
71  bool addusrcgi=true, bool addident=true)
72  : tident(tid), Path(path), CgiUsr(""), CgiUsz(0),
73  CgiSsz(0), sidP(0) {Setup(0, xtra, addusrcgi, addident);}
74 
75  ~XrdPssUrlInfo() {if (*theID == 'p' && sidP) sidP->Release(&idVal);}
76 
77 private:
78 void Setup(XrdOucEnv *envP, const char *xtra, bool addusrcgi, bool addident);
79 
80 const char *tident;
81 const char *Path;
82 const char *CgiUsr;
83  int CgiUsz;
84  int CgiSsz;
86  char theID[14];
88  char CgiSfx[512];
89 };
90 #endif
XrdPssUrlInfo::CgiUsr
const char * CgiUsr
Definition: XrdPssUrlInfo.hh:82
XrdPssUrlInfo::CgiSfx
char CgiSfx[512]
Definition: XrdPssUrlInfo.hh:88
XrdOucSid::theSid::sidS
short sidS
Definition: XrdOucSid.hh:53
XrdPssUrlInfo::hasCGI
bool hasCGI()
Definition: XrdPssUrlInfo.hh:51
XrdPssUrlInfo::CgiUsz
int CgiUsz
Definition: XrdPssUrlInfo.hh:83
XrdPssUrlInfo::setID
void setID(XrdOucSid *sP)
Definition: XrdPssUrlInfo.hh:55
XrdPssUrlInfo::addCGI
bool addCGI(char *buff, int blen)
Definition: XrdPssUrlInfo.hh:41
XrdPssUrlInfo::Setup
void Setup(XrdOucEnv *envP, const char *xtra, bool addusrcgi, bool addident)
XrdPssUrlInfo::~XrdPssUrlInfo
~XrdPssUrlInfo()
Definition: XrdPssUrlInfo.hh:75
XrdPssUrlInfo::Path
const char * Path
Definition: XrdPssUrlInfo.hh:81
XrdPssUrlInfo::setID
void setID(const char *tid=0)
XrdPssUrlInfo::idVal
XrdOucSid::theSid idVal
Definition: XrdPssUrlInfo.hh:87
XrdPssUrlInfo::Tident
const char * Tident()
Definition: XrdPssUrlInfo.hh:63
XrdPssUrlInfo
Definition: XrdPssUrlInfo.hh:37
XrdPssUrlInfo::CgiSsz
int CgiSsz
Definition: XrdPssUrlInfo.hh:84
XrdOucEnv
Definition: XrdOucEnv.hh:41
XrdPssUrlInfo::Extend
bool Extend(const char *cgi, int cgiln)
XrdPssUrlInfo::XrdPssUrlInfo
XrdPssUrlInfo(const char *tid, const char *path, const char *xtra="", bool addusrcgi=true, bool addident=true)
Definition: XrdPssUrlInfo.hh:70
XrdPssUrlInfo::tident
const char * tident
Definition: XrdPssUrlInfo.hh:80
XrdOucSid::theSid
The type to pass to Obtain(). Simply cast the char[2] to (theSid *).
Definition: XrdOucSid.hh:53
XrdOucSid
Definition: XrdOucSid.hh:45
XrdPssUrlInfo::theID
char theID[14]
Definition: XrdPssUrlInfo.hh:86
XrdPssUrlInfo::thePath
const char * thePath()
Definition: XrdPssUrlInfo.hh:61
XrdOucSid::Release
bool Release(theSid *sidP)
XrdOucSid::Obtain
bool Obtain(theSid *sidP)
XrdPssUrlInfo::XrdPssUrlInfo
XrdPssUrlInfo(XrdOucEnv *envP, const char *path, const char *xtra="", bool addusrcgi=true, bool addident=true)
Definition: XrdPssUrlInfo.hh:65
XrdPssUrlInfo::getID
const char * getID()
Definition: XrdPssUrlInfo.hh:49
XrdPssUrlInfo::sidP
XrdOucSid * sidP
Definition: XrdPssUrlInfo.hh:85