Loading...
Searching...
No Matches
XrdOucUtils.hh
Go to the documentation of this file.
#ifndef __XRDOUCUTILS_HH__
#define __XRDOUCUTILS_HH__
/******************************************************************************/
/* */
/* X r d O u c U t i l s . h h */
/* */
/* (c) 2005 by the Board of Trustees of the Leland Stanford, Jr., University */
/* All Rights Reserved */
/* Produced by Andrew Hanushevsky for Stanford University under contract */
/* DE-AC02-76-SFO0515 with the Department of Energy */
/* */
/* This file is part of the XRootD software suite. */
/* */
/* XRootD is free software: you can redistribute it and/or modify it under */
/* the terms of the GNU Lesser General Public License as published by the */
/* Free Software Foundation, either version 3 of the License, or (at your */
/* option) any later version. */
/* */
/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
/* License for more details. */
/* */
/* You should have received a copy of the GNU Lesser General Public License */
/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
/* */
/* The copyright holder's institutional names and contributor's names may not */
/* be used to endorse or promote products derived from this software without */
/* specific prior written permission of the institution or contributor. */
/******************************************************************************/
#include <sys/types.h>
#include <sys/stat.h>
#include <string>
#include <unordered_set>
#include <vector>
class XrdSysError;
class XrdOucString;
class XrdOucStream;
class XrdOucUtils
{
public:
static const mode_t pathMode = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
static int argList(char *args, char **argV, int argC);
static char *bin2hex(char *inbuff, int dlen, char *buff, int blen, bool sep=true);
static int hex2bin(const char *hex, char *bin, int size);
static bool endsWith(const char *text, const char *ending, int endlen);
static char *eText(int rc, char *eBuff, int eBlen);
static int doIf(XrdSysError *eDest, XrdOucStream &Config,
const char *what, const char *hname,
const char *nname, const char *pname);
static bool findPgm(const char *pgm, XrdOucString& path);
static int fmtBytes(long long val, char *buff, int bsz);
static char *genPath(const char *path, const char *inst, const char *psfx=0);
static int genPath(char *buff, int blen, const char *path, const char *psfx=0);
static char *getFile(const char *path, int &rc, int maxsz=10240,
bool notempty=true);
static bool getGID(const char *gName, gid_t &gID);
static bool getUID(const char *uName, uid_t &uID, gid_t *gID=0);
static int GidName(gid_t gID, char *gName, int gNsz, time_t keepT=0);
static int GroupName(gid_t gID, char *gName, int gNsz);
static const char *i2bstr(char *buff, int blen, int val, bool pad=false);
static const char *HSize(size_t bytes, char* buff, int bsz);
static char *Ident(long long &mySID, char *iBuff, int iBlen,
const char *iHost, const char *iProg, const char *iName,
int Port);
static const char *InstName(int TranOpt=0);
static const char *InstName(const char *name, int Fillit=1);
static int is1of(char *val, const char **clist);
static int isFWD(const char *path, int *port=0, char *hBuff=0, int hBLen=0,
bool pTrim=false);
static int Log2(unsigned long long n);
static int Log10(unsigned long long n);
static void makeHome(XrdSysError &eDest, const char *inst);
static bool makeHome(XrdSysError &eDest, const char *inst,
const char *path, mode_t mode);
static int makePath(char *path, mode_t mode, bool reset=false);
static bool mode2mask(const char *mode, mode_t &mask);
static bool parseLib(XrdSysError &eDest, XrdOucStream &Config,
const char *libName, char *&path, char **libparm);
static char *parseHome(XrdSysError &eDest, XrdOucStream &Config, int &mode);
static int ReLink(const char *path, const char *target, mode_t mode=0);
static void Sanitize(char *instr, char subc='_');
static char *subLogfn(XrdSysError &eDest, const char *inst, char *logfn);
static void toLower(char *str);
static int Token(const char **str, char delim, char *buff, int bsz);
static void Undercover(XrdSysError &eDest, int noLog, int *pipeFD = 0);
static int UidName(uid_t uID, char *uName, int uNsz, time_t keepT=0);
static int UserName(uid_t uID, char *uName, int uNsz);
static
const char *ValPath(const char *path, mode_t allow, bool isdir);
static bool PidFile(XrdSysError &eDest, const char *path);
static int getModificationTime(const char * path, time_t & modificationTime);
static void trim(std::string & str);
static void trim(std::string_view & sv);
XrdOucUtils() {}
~XrdOucUtils() {}
};
#endif
eDest
static XrdSysError eDest(0,"crypto_")
XrdOucStream
Definition XrdOucStream.hh:47
XrdOucString
Definition XrdOucString.hh:252
XrdOucUtils::parseHome
static char * parseHome(XrdSysError &eDest, XrdOucStream &Config, int &mode)
Definition XrdOucUtils.cc:1116
XrdOucUtils::Sanitize
static void Sanitize(char *instr, char subc='_')
Definition XrdOucUtils.cc:1176
XrdOucUtils::getGID
static bool getGID(const char *gName, gid_t &gID)
Definition XrdOucUtils.cc:559
XrdOucUtils::pathMode
static const mode_t pathMode
Definition XrdOucUtils.hh:47
XrdOucUtils::HSize
static const char * HSize(size_t bytes, char *buff, int bsz)
Definition XrdOucUtils.cc:679
XrdOucUtils::isFWD
static int isFWD(const char *path, int *port=0, char *hBuff=0, int hBLen=0, bool pTrim=false)
Definition XrdOucUtils.cc:847
XrdOucUtils::UserName
static int UserName(uid_t uID, char *uName, int uNsz)
Definition XrdOucUtils.cc:1396
XrdOucUtils::Ident
static char * Ident(long long &mySID, char *iBuff, int iBlen, const char *iHost, const char *iProg, const char *iName, int Port)
Definition XrdOucUtils.cc:779
XrdOucUtils::getUID
static bool getUID(const char *uName, uid_t &uID, gid_t *gID=0)
Definition XrdOucUtils.cc:575
XrdOucUtils::getModificationTime
static int getModificationTime(const char *path, time_t &modificationTime)
Definition XrdOucUtils.cc:1478
XrdOucUtils::ValPath
static const char * ValPath(const char *path, mode_t allow, bool isdir)
Definition XrdOucUtils.cc:1420
XrdOucUtils::genPath
static char * genPath(const char *path, const char *inst, const char *psfx=0)
Definition XrdOucUtils.cc:463
XrdOucUtils::Token
static int Token(const char **str, char delim, char *buff, int bsz)
Definition XrdOucUtils.cc:1239
XrdOucUtils::ReLink
static int ReLink(const char *path, const char *target, mode_t mode=0)
Definition XrdOucUtils.cc:1152
XrdOucUtils::parseLib
static bool parseLib(XrdSysError &eDest, XrdOucStream &Config, const char *libName, char *&path, char **libparm)
Definition XrdOucUtils.cc:1066
XrdOucUtils::hex2bin
static int hex2bin(const char *hex, char *bin, int size)
Definition XrdOucUtils.cc:184
XrdOucUtils::is1of
static int is1of(char *val, const char **clist)
Definition XrdOucUtils.cc:835
XrdOucUtils::InstName
static const char * InstName(int TranOpt=0)
Definition XrdOucUtils.cc:809
XrdOucUtils::eText
static char * eText(int rc, char *eBuff, int eBlen)
Definition XrdOucUtils.cc:243
XrdOucUtils::argList
static int argList(char *args, char **argV, int argC)
Definition XrdOucUtils.cc:125
XrdOucUtils::mode2mask
static bool mode2mask(const char *mode, mode_t &mask)
Definition XrdOucUtils.cc:1025
XrdOucUtils::XrdOucUtils
XrdOucUtils()
Definition XrdOucUtils.hh:144
XrdOucUtils::GidName
static int GidName(gid_t gID, char *gName, int gNsz, time_t keepT=0)
Definition XrdOucUtils.cc:593
XrdOucUtils::UidName
static int UidName(uid_t uID, char *uName, int uNsz, time_t keepT=0)
Definition XrdOucUtils.cc:1357
XrdOucUtils::bin2hex
static char * bin2hex(char *inbuff, int dlen, char *buff, int blen, bool sep=true)
Definition XrdOucUtils.cc:164
XrdOucUtils::~XrdOucUtils
~XrdOucUtils()
Definition XrdOucUtils.hh:145
XrdOucUtils::Log10
static int Log10(unsigned long long n)
Definition XrdOucUtils.cc:910
XrdOucUtils::doIf
static int doIf(XrdSysError *eDest, XrdOucStream &Config, const char *what, const char *hname, const char *nname, const char *pname)
Definition XrdOucUtils.cc:277
XrdOucUtils::makePath
static int makePath(char *path, mode_t mode, bool reset=false)
Definition XrdOucUtils.cc:994
XrdOucUtils::GroupName
static int GroupName(gid_t gID, char *gName, int gNsz)
Definition XrdOucUtils.cc:642
XrdOucUtils::trim
static void trim(std::string &str)
Definition XrdOucUtils.cc:1487
XrdOucUtils::findPgm
static bool findPgm(const char *pgm, XrdOucString &path)
Definition XrdOucUtils.cc:400
XrdOucUtils::PidFile
static bool PidFile(XrdSysError &eDest, const char *path)
Definition XrdOucUtils.cc:1453
XrdOucUtils::i2bstr
static const char * i2bstr(char *buff, int blen, int val, bool pad=false)
Definition XrdOucUtils.cc:710
XrdOucUtils::toLower
static void toLower(char *str)
Definition XrdOucUtils.cc:1226
XrdOucUtils::fmtBytes
static int fmtBytes(long long val, char *buff, int bsz)
Definition XrdOucUtils.cc:436
XrdOucUtils::Log2
static int Log2(unsigned long long n)
Definition XrdOucUtils.cc:895
XrdOucUtils::makeHome
static void makeHome(XrdSysError &eDest, const char *inst)
Definition XrdOucUtils.cc:927
XrdOucUtils::endsWith
static bool endsWith(const char *text, const char *ending, int endlen)
Definition XrdOucUtils.cc:229
XrdOucUtils::Undercover
static void Undercover(XrdSysError &eDest, int noLog, int *pipeFD=0)
Definition XrdOucUtils.cc:1283
XrdOucUtils::getFile
static char * getFile(const char *path, int &rc, int maxsz=10240, bool notempty=true)
Definition XrdOucUtils.cc:502
XrdOucUtils::subLogfn
static char * subLogfn(XrdSysError &eDest, const char *inst, char *logfn)
Definition XrdOucUtils.cc:1198
XrdSysError
Definition XrdSysError.hh:90