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
35class XrdOucEnv;
36
38{
39public:
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
49const 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
61const char *thePath() {return Path;}
62
63const 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), CgiBuff(0), 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), CgiBuff(0), CgiUsr(""), CgiUsz(0),
73 CgiSsz(0), sidP(0) {Setup(0, xtra, addusrcgi, addident);}
74
75 ~XrdPssUrlInfo() {if (*theID == 'p' && sidP) sidP->Release(&idVal);
76 if (CgiBuff) free(CgiBuff);
77 }
78
79private:
80void Setup(XrdOucEnv *envP, const char *xtra, bool addusrcgi, bool addident);
81
82const char *tident;
83const char *Path;
84 char *CgiBuff;
85const char *CgiUsr;
86 int CgiUsz;
87 int CgiSsz;
89 char theID[14];
91 char CgiSfx[512];
92};
93#endif
Definition: XrdOucEnv.hh:42
Definition: XrdOucSid.hh:46
bool Obtain(theSid *sidP)
bool Release(theSid *sidP)
Definition: XrdPssUrlInfo.hh:38
const char * Tident()
Definition: XrdPssUrlInfo.hh:63
int CgiUsz
Definition: XrdPssUrlInfo.hh:86
int CgiSsz
Definition: XrdPssUrlInfo.hh:87
void setID(XrdOucSid *sP)
Definition: XrdPssUrlInfo.hh:55
XrdPssUrlInfo(XrdOucEnv *envP, const char *path, const char *xtra="", bool addusrcgi=true, bool addident=true)
Definition: XrdPssUrlInfo.hh:65
const char * getID()
Definition: XrdPssUrlInfo.hh:49
XrdOucSid * sidP
Definition: XrdPssUrlInfo.hh:88
XrdOucSid::theSid idVal
Definition: XrdPssUrlInfo.hh:90
bool Extend(const char *cgi, int cgiln)
char * CgiBuff
Definition: XrdPssUrlInfo.hh:84
bool hasCGI()
Definition: XrdPssUrlInfo.hh:51
char theID[14]
Definition: XrdPssUrlInfo.hh:89
const char * CgiUsr
Definition: XrdPssUrlInfo.hh:85
~XrdPssUrlInfo()
Definition: XrdPssUrlInfo.hh:75
void setID(const char *tid=0)
const char * Path
Definition: XrdPssUrlInfo.hh:83
bool addCGI(char *buff, int blen)
Definition: XrdPssUrlInfo.hh:41
void Setup(XrdOucEnv *envP, const char *xtra, bool addusrcgi, bool addident)
XrdPssUrlInfo(const char *tid, const char *path, const char *xtra="", bool addusrcgi=true, bool addident=true)
Definition: XrdPssUrlInfo.hh:70
const char * thePath()
Definition: XrdPssUrlInfo.hh:61
char CgiSfx[512]
Definition: XrdPssUrlInfo.hh:91
const char * tident
Definition: XrdPssUrlInfo.hh:82
The type to pass to Obtain(). Simply cast the char[2] to (theSid *).
Definition: XrdOucSid.hh:53
short sidS
Definition: XrdOucSid.hh:53