XRootD
Loading...
Searching...
No Matches
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, const char *xtra=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 76 of file XrdOucERoute.hh.

76{}

◆ ~XrdOucERoute()

XrdOucERoute::~XrdOucERoute ( )
inline

Definition at line 78 of file XrdOucERoute.hh.

78{}

Member Function Documentation

◆ Format()

int XrdOucERoute::Format ( char * buff,
int blen,
int ecode,
const char * etxt1,
const char * etxt2 = 0,
const char * xtra = 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).
xtraOptional additional text to include on the next line
Returns
<int> The number of characters placed in the buffer less null.

Definition at line 44 of file XrdOucERoute.cc.

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

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 79 of file XrdOucERoute.cc.

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

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: