00001 #ifndef __XRDPSS_UTILS_HH__ 00002 #define __XRDPSS_UTILS_HH__ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d P s s U t i l s . h h */ 00006 /* */ 00007 /* (c) 2020 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00011 /* */ 00012 /* This file is part of the XRootD software suite. */ 00013 /* */ 00014 /* XRootD is free software: you can redistribute it and/or modify it under */ 00015 /* the terms of the GNU Lesser General Public License as published by the */ 00016 /* Free Software Foundation, either version 3 of the License, or (at your */ 00017 /* option) any later version. */ 00018 /* */ 00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 00021 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 00022 /* License for more details. */ 00023 /* */ 00024 /* You should have received a copy of the GNU Lesser General Public License */ 00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 00026 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 00027 /* */ 00028 /* The copyright holder's institutional names and contributor's names may not */ 00029 /* be used to endorse or promote products derived from this software without */ 00030 /* specific prior written permission of the institution or contributor. */ 00031 /******************************************************************************/ 00032 00033 #include <vector> 00034 00035 class XrdPssUtils 00036 { 00037 public: 00038 00039 // Get the domain associated with he hostname 00040 // 00041 static 00042 const char *getDomain(const char *hName); 00043 00044 // Check if protocol will send this to an xrootd protocol server 00045 // 00046 static bool is4Xrootd(const char *pname); 00047 00048 // Validate a protocol (i.e. it is one we actually support) 00049 // 00050 static 00051 const char *valProt(const char *pname, int &plen, int adj=0); 00052 00053 // Vectorize a comma separated list and return pointers into the input string 00054 // to each element in the list. The list itself is modified. 00055 // 00056 static bool Vectorize(char *str, std::vector<char *> &vec, char sep); 00057 00058 XrdPssUtils() {} 00059 ~XrdPssUtils() {} 00060 }; 00061 00062 // A quick inline to test for xroot path forwarding 00063 // 00064 #define IS_FWDPATH(x) ((*(x+1) == 'x' || *(x+1) == 'r') \ 00065 && (!strncmp("/xroot:/", x,8) || !strncmp("/root:/", x,7)\ 00066 || !strncmp("/xroots:/",x,9) || !strncmp("/roots:/",x,8))) 00067 #endif