XRootD
Loading...
Searching...
No Matches
XrdOucSiteName.cc
Go to the documentation of this file.
1/******************************************************************************/
2/* */
3/* X r d O u c S i t e N a m e . c c */
4/* */
5/* (c) 2012 by the Board of Trustees of the Leland Stanford, Jr., University */
6/* All Rights Reserved */
7/* Produced by Andrew Hanushevsky for Stanford University under contract */
8/* DE-AC02-76-SFO0515 with the Department of Energy */
9/* */
10/* This file is part of the XRootD software suite. */
11/* */
12/* XRootD is free software: you can redistribute it and/or modify it under */
13/* the terms of the GNU Lesser General Public License as published by the */
14/* Free Software Foundation, either version 3 of the License, or (at your */
15/* option) any later version. */
16/* */
17/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
18/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
19/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
20/* License for more details. */
21/* */
22/* You should have received a copy of the GNU Lesser General Public License */
23/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
24/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
25/* */
26/* The copyright holder's institutional names and contributor's names may not */
27/* be used to endorse or promote products derived from this software without */
28/* specific prior written permission of the institution or contributor. */
29/******************************************************************************/
30
31#include <cctype>
32#include <cstring>
33
34#include "XrdOuc/XrdOucEnv.hh"
36
37const char *XrdOucSiteName::Set(const char *name, int maxlen)
38{
39 char *site;
40 int i, n;
41
42// Validate the name
43//
44 if (name)
45 {site = strdup(name);
46 n = strlen(site);
47 if (n > maxlen) {site[maxlen] = 0; n = maxlen;}
48 for (i = 0; i < n; i++)
49 if (!isalnum(site[i]) && !strspn(&(site[i]), "_-:")) site[i] = '.';
50 } else site = strdup("");
51
52// Export the name
53//
54 XrdOucEnv::Export("XRDSITE", site);
55
56// Return the string, it cannot be deleted now
57//
58 return site;
59}
static int Export(const char *Var, const char *Val)
Definition XrdOucEnv.cc:170
static const char * Set(const char *name, int maxlen=15)