XRootD
XrdOucERoute Class Reference

#include <XrdOucERoute.hh>

+ Collaboration diagram for XrdOucERoute:

Public Member Functions

 XrdOucERoute ()
 
 ~XrdOucERoute ()
 

Static Public Member Functions

static int Format (char *buff, int blen, int ecode, const char *etxt1, const char *etxt2=0)
 
static int Route (XrdSysError *elog, XrdOucStream *estrm, const char *esfx, int ecode, const char *etxt1, const char *etxt2=0)
 

Detailed Description

Definition at line 36 of file XrdOucERoute.hh.

Constructor & Destructor Documentation

◆ XrdOucERoute()

XrdOucERoute::XrdOucERoute ( )
inline

Definition at line 74 of file XrdOucERoute.hh.

74 {}

◆ ~XrdOucERoute()

XrdOucERoute::~XrdOucERoute ( )
inline

Definition at line 76 of file XrdOucERoute.hh.

76 {}

Member Function Documentation

◆ Format()

int XrdOucERoute::Format ( char *  buff,
int  blen,
int  ecode,
const char *  etxt1,
const char *  etxt2 = 0 
)
static

Format an error message into a buffer in the form of: "Unable to <etxt1> <etxt2>; <syserror[enum]>"

Parameters
buffpointer to the buffer where the msg is to be placed.
blenthe length of the buffer.
ecodethe error number associated iwth the error.
etxt1associated text token #1.
etxt2associated text token #2 (optional).
Returns
<int> The number of characters placed in the buffer less null.

Definition at line 44 of file XrdOucERoute.cc.

46 {
47  const char *esep = " ", *estr = XrdSysError::ec2text(ecode);
48  char ebuff[256];
49  int n;
50 
51 // Substitute something of no ecode translation exists
52 //
53  if (!estr) estr = "reason unknown";
54  else if (isupper(static_cast<int>(*estr)))
55  {strlcpy(ebuff, estr, sizeof(ebuff));
56  *ebuff = static_cast<char>(tolower(static_cast<int>(*estr)));
57  estr = ebuff;
58  }
59 
60 // Set format elements
61 //
62  if (!etxt2) etxt2 = esep = "";
63 
64 // Format the message
65 //
66  n = snprintf(buff, blen, "Unable to %s%s%s; %s",etxt1,esep,etxt2,estr);
67  return (n < blen ? n : blen-1);
68 }
size_t strlcpy(char *dst, const char *src, size_t sz)
static const char * ec2text(int ecode)
Definition: XrdSysError.cc:79

References XrdSysError::ec2text(), and strlcpy().

Referenced by XrdOfs::Emsg(), XrdSsiUtils::Emsg(), and Route().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Route()

int XrdOucERoute::Route ( XrdSysError elog,
XrdOucStream estrm,
const char *  esfx,
int  ecode,
const char *  etxt1,
const char *  etxt2 = 0 
)
static

Format an error message using Format() and route it as requested.

Parameters
elogpointer to the XrdSysError object to use to route the message to the log, If null, the message isn't routed there.
estrmpointer to the XrdOucStrean object which is to receive the error message text or null if none exists.
esfxThe suffix identifier to use when routing to the log.
ecodethe error number associated iwth the error.
etxt1associated text token #1.
etxt2associated text token #2 (optional).
Returns
<int> The -abs(enum) or -1 if enum is zero.

Definition at line 74 of file XrdOucERoute.cc.

77 {
78  char ebuff[2048];
79  int elen;
80 
81 // Format the error message
82 //
83  elen = Format(ebuff, sizeof(ebuff), ecode, etxt1, etxt2);
84 
85 // Route appropriately
86 //
87  if (elog) elog->Emsg(esfx, ebuff);
88  if (estrm) estrm->Put(ebuff, elen);
89 
90 // Return the error number
91 //
92  if (ecode) return (ecode < 0 ? ecode : -ecode);
93  return -1;
94 }
static int Format(char *buff, int blen, int ecode, const char *etxt1, const char *etxt2=0)
Definition: XrdOucERoute.cc:44
int Put(const char *data, const int dlen)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
Definition: XrdSysError.cc:95

References XrdSysError::Emsg(), Format(), and XrdOucStream::Put().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: