xrootd
Loading...
Searching...
No Matches
XrdOucUtils.hh
Go to the documentation of this file.
1#ifndef __XRDOUCUTILS_HH__
2#define __XRDOUCUTILS_HH__
3/******************************************************************************/
4/* */
5/* X r d O u c U t i l s . h h */
6/* */
7/* (c) 2005 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 <sys/types.h>
34#include <sys/stat.h>
35#include <string>
36
37class XrdSysError;
38class XrdOucString;
39class XrdOucStream;
40
42{
43public:
44
45static const mode_t pathMode = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
46
47static int argList(char *args, char **argV, int argC);
48
49static char *bin2hex(char *inbuff, int dlen, char *buff, int blen, bool sep=true);
50
51static bool endsWith(const char *text, const char *ending, int endlen);
52
53static char *eText(int rc, char *eBuff, int eBlen);
54
55static int doIf(XrdSysError *eDest, XrdOucStream &Config,
56 const char *what, const char *hname,
57 const char *nname, const char *pname);
58
59static bool findPgm(const char *pgm, XrdOucString& path);
60
61static int fmtBytes(long long val, char *buff, int bsz);
62
63static char *genPath(const char *path, const char *inst, const char *psfx=0);
64
65static int genPath(char *buff, int blen, const char *path, const char *psfx=0);
66
67static char *getFile(const char *path, int &rc, int maxsz=10240,
68 bool notempty=true);
69
70static bool getGID(const char *gName, gid_t &gID);
71
72static bool getUID(const char *uName, uid_t &uID, gid_t *gID=0);
73
74static int GidName(gid_t gID, char *gName, int gNsz, time_t keepT=0);
75
76static int GroupName(gid_t gID, char *gName, int gNsz);
77
78static const char *i2bstr(char *buff, int blen, int val, bool pad=false);
79
80static char *Ident(long long &mySID, char *iBuff, int iBlen,
81 const char *iHost, const char *iProg, const char *iName,
82 int Port);
83
84static const char *InstName(int TranOpt=0);
85
86static const char *InstName(const char *name, int Fillit=1);
87
88static int is1of(char *val, const char **clist);
89
90static int isFWD(const char *path, int *port=0, char *hBuff=0, int hBLen=0,
91 bool pTrim=false);
92
93static int Log2(unsigned long long n);
94
95static int Log10(unsigned long long n);
96
97static void makeHome(XrdSysError &eDest, const char *inst);
98
99static bool makeHome(XrdSysError &eDest, const char *inst,
100 const char *path, mode_t mode);
101
102static int makePath(char *path, mode_t mode, bool reset=false);
103
104static bool mode2mask(const char *mode, mode_t &mask);
105
106static bool parseLib(XrdSysError &eDest, XrdOucStream &Config,
107 const char *libName, char *&path, char **libparm);
108
109static char *parseHome(XrdSysError &eDest, XrdOucStream &Config, int &mode);
110
111static int ReLink(const char *path, const char *target, mode_t mode=0);
112
113static void Sanitize(char *instr, char subc='_');
114
115static char *subLogfn(XrdSysError &eDest, const char *inst, char *logfn);
116
117static void toLower(char *str);
118
119static int Token(const char **str, char delim, char *buff, int bsz);
120
121static void Undercover(XrdSysError &eDest, int noLog, int *pipeFD = 0);
122
123static int UidName(uid_t uID, char *uName, int uNsz, time_t keepT=0);
124
125static int UserName(uid_t uID, char *uName, int uNsz);
126
127static
128const char *ValPath(const char *path, mode_t allow, bool isdir);
129
130static bool PidFile(XrdSysError &eDest, const char *path);
131
132static int getModificationTime(const char * path, time_t & modificationTime);
133
134static void trim(std::string & str);
135
138};
139#endif
Definition XrdOucStream.hh:47
Definition XrdOucString.hh:254
Definition XrdOucUtils.hh:42
static const mode_t pathMode
Definition XrdOucUtils.hh:45
static const char * InstName(const char *name, int Fillit=1)
static const char * i2bstr(char *buff, int blen, int val, bool pad=false)
static bool getGID(const char *gName, gid_t &gID)
static void Undercover(XrdSysError &eDest, int noLog, int *pipeFD=0)
static char * parseHome(XrdSysError &eDest, XrdOucStream &Config, int &mode)
static int GroupName(gid_t gID, char *gName, int gNsz)
static char * subLogfn(XrdSysError &eDest, const char *inst, char *logfn)
static int makePath(char *path, mode_t mode, bool reset=false)
static char * Ident(long long &mySID, char *iBuff, int iBlen, const char *iHost, const char *iProg, const char *iName, int Port)
static bool findPgm(const char *pgm, XrdOucString &path)
static int is1of(char *val, const char **clist)
static int Log10(unsigned long long n)
static const char * ValPath(const char *path, mode_t allow, bool isdir)
static char * genPath(const char *path, const char *inst, const char *psfx=0)
static bool makeHome(XrdSysError &eDest, const char *inst, const char *path, mode_t mode)
static int Log2(unsigned long long n)
static char * eText(int rc, char *eBuff, int eBlen)
static void makeHome(XrdSysError &eDest, const char *inst)
static int genPath(char *buff, int blen, const char *path, const char *psfx=0)
static int UserName(uid_t uID, char *uName, int uNsz)
XrdOucUtils()
Definition XrdOucUtils.hh:136
static char * bin2hex(char *inbuff, int dlen, char *buff, int blen, bool sep=true)
static int isFWD(const char *path, int *port=0, char *hBuff=0, int hBLen=0, bool pTrim=false)
static bool parseLib(XrdSysError &eDest, XrdOucStream &Config, const char *libName, char *&path, char **libparm)
static void trim(std::string &str)
static bool getUID(const char *uName, uid_t &uID, gid_t *gID=0)
~XrdOucUtils()
Definition XrdOucUtils.hh:137
static int fmtBytes(long long val, char *buff, int bsz)
static void toLower(char *str)
static int GidName(gid_t gID, char *gName, int gNsz, time_t keepT=0)
static int doIf(XrdSysError *eDest, XrdOucStream &Config, const char *what, const char *hname, const char *nname, const char *pname)
static int ReLink(const char *path, const char *target, mode_t mode=0)
static bool endsWith(const char *text, const char *ending, int endlen)
static int UidName(uid_t uID, char *uName, int uNsz, time_t keepT=0)
static bool PidFile(XrdSysError &eDest, const char *path)
static void Sanitize(char *instr, char subc='_')
static char * getFile(const char *path, int &rc, int maxsz=10240, bool notempty=true)
static int argList(char *args, char **argV, int argC)
static int getModificationTime(const char *path, time_t &modificationTime)
static int Token(const char **str, char delim, char *buff, int bsz)
static const char * InstName(int TranOpt=0)
static bool mode2mask(const char *mode, mode_t &mask)
Definition XrdSysError.hh:90