Loading...
Searching...
No Matches
XrdOucStream Class Reference

`#include <XrdOucStream.hh>`

Collaboration diagram for XrdOucStream:

## Public Member Functions

| XrdOucStream (XrdSysError *erobj=0, const char *ifname=0, XrdOucEnv *anEnv=0, const char *Pfx=0)
| ~XrdOucStream ()
int | Attach (int FileDescriptor, int bsz=2047)
int | AttachIO (int infd, int outfd, int bsz=2047)
void | Close (int hold=0)
int | Detach ()
int | Drain ()
void | Echo ()
void | Echo (bool capture)
int | Exec (char **, int inrd=0, int efd=0)
int | Exec (const char *, int inrd=0, int efd=0)
int | FDNum ()
int | FENum ()
void | Flush ()
char * | GetFirstWord (int lowcase=0)
char * | GetLine ()
char * | GetMyFirstWord (int lowcase=0)
int | GetRest (char *theBuf, int Blen, int lowcase=0)
char * | GetToken (char **rest, int lowcase=0)
char * | GetToken (int lowcase=0)
char * | GetWord (int lowcase=0)
int | isAlive ()
int | LastError ()
char * | LastLine ()
int | noEcho ()
int | Put (const char *data)
int | Put (const char *data, const int dlen)
int | Put (const char *data[], const int dlen[])
int | PutLine (const char *data, int dlen=0)
void | RetToken ()
XrdOucEnv * | SetEnv (XrdOucEnv *newEnv)
void | SetEroute (XrdSysError *eroute)
void | Tabs (int x=1)
int | Wait4Data (int msMax=-1)

## Static Public Member Functions

static XrdOucString * | Capture ()
static void | Capture (const char **cVec=0, bool linefeed=true)
static XrdOucString * | Capture (XrdOucString *cfObj)

## Detailed Description

Definition at line 46 of file XrdOucStream.hh.

## Constructor & Destructor Documentation

## XrdOucStream()

XrdOucStream::XrdOucStream | ( | XrdSysError * | erobj = 0,
|  | const char * | ifname = 0,
|  | XrdOucEnv * | anEnv = 0,
|  | const char * | Pfx = 0 )

Definition at line 187 of file XrdOucStream.cc.

{
char *cp;
if (ifname)
{myInst = strdup(ifname);
myInfo = new StreamInfo;
if (!(cp = index(myInst, ' '))) {cp = myInst; myInfo->myExec = 0;}
else {*cp = '\0'; cp++;
myInfo->myExec = (*myInst ? myInst : 0);
}
if ( (myInfo->myHost = index(cp, '@')))
{*(myInfo->myHost) = '\0';
myInfo->myHost++;
myInfo->myName = (*cp ? cp : 0);
} else {myInfo->myHost = cp; myInfo->myName = 0;}
} else {myInst = 0; myInfo = 0;}
myRsv1 = myRsv2 = 0;
FD = -1;
FE = -1;
bsize = 0;
buff = 0;
bnext = 0;
bleft = 0;
recp = 0;
token = 0;
flags = 0;
child = 0;
ecode = 0;
notabs = 0;
xcont = 1;
xline = 0;
Eroute = erobj;
myEnv = anEnv;
sawif = 0;
skpel = 0;
if (myEnv && Eroute)
{llBuff = (char *)malloc(llBsz);
llBcur = llBuff; llBok = 0; llBleft = llBsz; *llBuff = '\0';
Verbose= 1;
} else {
Verbose= 0;
llBuff = 0;
llBcur = 0;
llBleft= 0;
llBok = 0;
}
varVal = (myEnv ? new char[maxVLen+1] : 0);
llPrefix = Pfx;
}

## ~XrdOucStream()

XrdOucStream::~XrdOucStream | ( |  | ) |

inline

Definition at line 57 of file XrdOucStream.hh.

{Close(); if (myInst) free(myInst);
if (varVal) delete [] varVal;
if (llBuff) free(llBuff);
}
XrdOucStream::Close
void Close(int hold=0)
Definition XrdOucStream.cc:323

References Close().

Here is the call graph for this function:

## Member Function Documentation

## Attach()

int XrdOucStream::Attach | ( | int | FileDescriptor,
|  | int | bsz = 2047 )

Definition at line 252 of file XrdOucStream.cc.

{
// Close the current stream. Close will handle unopened streams.
//
StreamInfo *saveInfo = myInfo; myInfo = 0;
Close();
myInfo = saveInfo;
// Allocate a new buffer for this stream
//
if (!bsz) buff = 0;
else if (!(buff = (char *)malloc(bsz+1)))
return Erq(Attach, errno, "allocate stream buffer");
// Initialize the stream
//
FD= FE = FileDescriptor;
bnext = buff;
bsize = bsz+1;
bleft = 0;
recp = 0;
token = 0;
flags = 0;
ecode = 0;
xcont = 1;
xline = 0;
sawif = 0;
skpel = 0;
if (llBuff)
{llBcur = llBuff; *llBuff = '\0'; llBleft = llBsz; llBok = 0;}
return 0;
}
Erq
#define Erq(p, a, b)
Definition XrdOucStream.cc:80
XrdOucStream::Attach
int Attach(int FileDescriptor, int bsz=2047)
Definition XrdOucStream.cc:252

References Attach(), Close(), and Erq.

Referenced by Attach(), AttachIO(), Macaroons::Handler::Config(), XrdSsiSfsConfig::Configure(), XrdVomsMapfile::Configure(), Exec(), XrdFrcCID::Init(), main(), XrdOssCache::MapDevs(), XrdFrmXfrDaemon::Pong(), PutLine(), and XrdFrmXfrAgent::Start().

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

## AttachIO()

int XrdOucStream::AttachIO | ( | int | infd,
|  | int | outfd,
|  | int | bsz = 2047 )

Definition at line 245 of file XrdOucStream.cc.

{
if (Attach(infd, bsz)) return -1;
FE = outfd;
return 0;
}

References Attach().

Here is the call graph for this function:

## Capture() [1/3]

XrdOucString * XrdOucStream::Capture | ( |  | ) |

static

Definition at line 314 of file XrdOucStream.cc.

{
return theCFG;
}

## Capture() [2/3]

void XrdOucStream::Capture | ( | const char ** | cVec = 0,
|  | bool | linefeed = true )

static

Definition at line 290 of file XrdOucStream.cc.

{
// Make sure we can handle this
//
if (theCFG && cVec && cVec[0])
{if (linefeed) theCFG->append("\n# ");
else theCFG->append("# ");
int i = 0;
while(cVec[i]) theCFG->append(cVec[i++]);
theCFG->append('\n');
}
}

Referenced by Macaroons::Handler::Config(), and XrdSsiSfsConfig::Configure().

Here is the caller graph for this function:

## Capture() [3/3]

XrdOucString * XrdOucStream::Capture | ( | XrdOucString * | cfObj | ) |

static

Definition at line 305 of file XrdOucStream.cc.

{
XrdOucString *oldCFG = theCFG;
theCFG = newCFG;
return oldCFG;
}

## Close()

void XrdOucStream::Close | ( | int | hold = 0 | ) |

Definition at line 323 of file XrdOucStream.cc.

{
// Wait for any associated process on this stream
//
if (!hold && child) Drain();
else child = 0;
// Close the associated file descriptor if it was open
//
if (FD >= 0) close(FD);
if (FE >= 0 && FE != FD) close(FE);
// Release the buffer if it was allocated.
//
if (buff) free(buff);
// Clear all data values by attaching a dummy FD
//
FD = FE = -1;
buff = 0;
// Check if we should echo the last line
//
if (llBuff)
{if (Verbose && *llBuff && llBok > 1)
{if (Eroute) Eroute->Say(llPrefix, llBuff);
if (theCFG) add2CFG(llBuff);
}
llBok = 0;
}
// Delete any info object we have allocated
//
if (myInfo)
{delete myInfo;
myInfo = 0;
}
}
close
#define close(a)
Definition XrdPosix.hh:48
XrdOucStream::Drain
int Drain()
Definition XrdOucStream.cc:367

References close, and Drain().

Referenced by ~XrdOucStream(), Attach(), XrdSsiSfsConfig::Configure(), and XrdFrcCID::Init().

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

## Detach()

int XrdOucStream::Detach | ( |  | ) |

inline

Definition at line 76 of file XrdOucStream.hh.

{int oldFD = FD; FD = FE = -1; return oldFD;}

## Drain()

int XrdOucStream::Drain | ( |  | ) |

Definition at line 367 of file XrdOucStream.cc.

{
int Status = 0;
// Drain any outstanding processes (i.e., kill the process group)
//
#ifndef WIN32
int retc;
if (child) {kill(-child, 9);
do {retc = waitpid(child, &Status, 0);}
while(retc > 0 || (retc == -1 && errno == EINTR));
child = 0;
}
#else
if (child) {
TerminateProcess((HANDLE)child, 0);
child = 0;
}
#endif
return Status;
}

Referenced by Close(), and XrdOucProg::RunDone().

Here is the caller graph for this function:

## Echo() [1/2]

void XrdOucStream::Echo | ( |  | ) |

Definition at line 393 of file XrdOucStream.cc.

{
if (llBok > 1 && Verbose && llBuff)
{if (Eroute) Eroute->Say(llPrefix,llBuff);
if (theCFG) add2CFG(llBuff);
}
llBok = 0;
}

Referenced by Macaroons::Handler::Config(), XrdCmsConfig::ConfigXeq(), and GetMyFirstWord().

Here is the caller graph for this function:

## Echo() [2/2]

void XrdOucStream::Echo | ( | bool | capture | ) |

Definition at line 406 of file XrdOucStream.cc.

{
if (llBok && Verbose && llBuff)
{if (Eroute) Eroute->Say(llPrefix,llBuff);
if (capture && theCFG) add2CFG(llBuff);
}
llBok = 0;
}

## Exec() [1/2]

int XrdOucStream::Exec | ( | char ** | parm,
|  | int | inrd = 0,
|  | int | efd = 0 )

Definition at line 450 of file XrdOucStream.cc.

{
int fildes[2], Child_in = -1, Child_out = -1, Child_log = -1;
// Create a pipe. Minimize file descriptor leaks.
//
if (inrd >= 0)
{if (pipe(fildes))
return Err(Exec, errno, "create input pipe for", parm[0]);
else {
fcntl(fildes[0], F_SETFD, FD_CLOEXEC);
Attach(fildes[0]); Child_out = fildes[1];
}
if (inrd)
{if (pipe(fildes))
return Err(Exec, errno, "create output pipe for", parm[0]);
else {
fcntl(fildes[1], F_SETFD, FD_CLOEXEC);
FE = fildes[1]; Child_in = fildes[0];
}
}
} else {Child_out = FD; Child_in = FE;}
// Handle the standard error file descriptor
//
if (!efd) Child_log = (Eroute ? dup(Eroute->logger()->originalFD()) : -1);
else if (efd > 0) Child_log = efd;
else if (efd == -2){Child_log = Child_out; Child_out = -1;}
else if (efd == -3) Child_log = Child_out;
// Fork a process first so we can pick up the next request. We also
// set the process group in case the child hasn't been able to do so.
// Make sure only one fork occurs at any one time (we are the only one).
//
forkMutex.Lock();
if ((child = fork()))
{if (child < 0)
{close(Child_in); close(Child_out); forkMutex.UnLock();
return Err(Exec, errno, "fork request process for", parm[0]);
}
close(Child_out);
if (inrd) close(Child_in );
if (!efd && Child_log >= 0) close(Child_log);
forkMutex.UnLock();
setpgid(child, child);
return 0;
}
/*****************************************************************/
/* C h i l d P r o c e s s */
/*****************************************************************/
// Redirect standard in if so requested
//
if (Child_in >= 0)
{if (inrd)
{if (dup2(Child_in, STDIN_FILENO) < 0)
{Erx(Exec, errno, "setting up standard in for " <<parm[0]);
_exit(255);
} else if (Child_in != Child_out) close(Child_in);
}
}
// Reassign the stream to be standard out to capture all of the output.
//
if (Child_out >= 0)
{if (dup2(Child_out, STDOUT_FILENO) < 0)
{Erx(Exec, errno, "setting up standard out for " <<parm[0]);
_exit(255);
} else if (Child_out != Child_log) close(Child_out);
}
// Redirect stderr of the stream if we can to avoid keeping the logfile open
//
if (Child_log >= 0)
{if (dup2(Child_log, STDERR_FILENO) < 0)
{Erx(Exec, errno, "set up standard err for " <<parm[0]);
_exit(255);
} else close(Child_log);
}
// Check if we need to set any envornment variables
//
if (myEnv)
{char **envP;
int i = 0;
if ((envP = (char **)myEnv->GetPtr("XrdEnvars**")))
while(envP[i]) {putenv(envP[i]); i++;}
}
// Set our process group (the parent should have done this by now) then
// invoke the command never to return
//
setpgid(0,0);
execv(parm[0], parm);
Erx(Exec, errno, "executing " <<parm[0]);
_exit(255);
}
Err
#define Err(p, a, b, c)
Definition XrdNetSocket.cc:81
Erx
#define Erx(p, a, b)
Definition XrdOucStream.cc:86
XrdOucStream::Exec
int Exec(const char *, int inrd=0, int efd=0)
Definition XrdOucStream.cc:419
XrdProxy::envP
XrdOucEnv * envP
Definition XrdPss.cc:109

References Attach(), close, Err, Erx, Exec(), and XrdOucEnv::GetPtr().

Here is the call graph for this function:

## Exec() [2/2]

int XrdOucStream::Exec | ( | const char * | theCmd,
|  | int | inrd = 0,
|  | int | efd = 0 )

Definition at line 419 of file XrdOucStream.cc.

{
int j;
char *cmd, *origcmd, *parm[MaxARGC];
if (!theCmd)
return EINVAL;
// Allocate a buffer for the command as we will be modifying it
//
origcmd = cmd = (char *)malloc(strlen(theCmd)+1);
strcpy(cmd, theCmd);
// Construct the argv array based on passed command line.
//
for (j = 0; j < MaxARGC-1 && *cmd; j++)
{while(*cmd == ' ') cmd++;
if (!(*cmd)) break;
parm[j] = cmd;
while(*cmd && *cmd != ' ') cmd++;
if (*cmd) {*cmd = '\0'; cmd++;}
}
parm[j] = (char *)0;
// Continue with normal processing
//
int ret = j > 0 ? Exec(parm, inrd, efd) : EINVAL;
free(origcmd);
return ret;
}
MaxARGC
#define MaxARGC
Definition XrdOucStream.cc:71

References Exec(), and MaxARGC.

Referenced by Exec(), Exec(), and XrdOucProg::Run().

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

## FDNum()

int XrdOucStream::FDNum | ( |  | ) |

inline

Definition at line 110 of file XrdOucStream.hh.

{return FD;}

## FENum()

int XrdOucStream::FENum | ( |  | ) |

inline

Definition at line 111 of file XrdOucStream.hh.

{return FE;}

## Flush()

void XrdOucStream::Flush | ( |  | ) |

inline

Definition at line 115 of file XrdOucStream.hh.

{fsync(FD); if (FE != FD) fsync(FE);}
fsync
#define fsync(a)
Definition XrdPosix.hh:64

References fsync.

## GetFirstWord()

char * XrdOucStream::GetFirstWord | ( | int | lowcase = 0 | ) |

Definition at line 679 of file XrdOucStream.cc.

{
// If in the middle of a line, flush to the end of the line. Suppress
// variable substitution when doing this to avoid errors.
//
if (xline)
{XrdOucEnv *oldEnv = SetEnv(0);
while(GetWord(lowcase)) {}
SetEnv(oldEnv);
}
return GetWord(lowcase);
}
XrdOucStream::SetEnv
XrdOucEnv * SetEnv(XrdOucEnv *newEnv)
Definition XrdOucStream.hh:191
XrdOucStream::GetWord
char * GetWord(int lowcase=0)
Definition XrdOucStream.cc:745

References GetWord(), and SetEnv().

Referenced by GetMyFirstWord().

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

## GetLine()

char * XrdOucStream::GetLine | ( |  | ) |

Definition at line 554 of file XrdOucStream.cc.

{
int bcnt, retc;
char *bp;
// Check if end of message has been reached.
//
if (flags & XrdOucStream_EOM) return (char *)NULL;
// Find the next record in the buffer
//
if (bleft > 0)
{recp = bnext; bcnt = bleft;
for (bp = bnext; bcnt--; bp++)
if (!*bp || *bp == '\n')
{if (!*bp) flags |= XrdOucStream_EOM;
*bp = '\0';
bnext = ++bp;
bleft = bcnt;
token = recp;
return recp;
}
else if (notabs && *bp == '\t') *bp = ' ';
// There is no next record, so move up data in the buffer.
//
bnext = stpncpy(buff, bnext, bleft);
}
else bnext = buff;
// Prepare to read in more data.
//
bcnt = bsize - (bnext - buff) -1;
bp = bnext;
// Read up to the maximum number of bytes. Stop reading should we see a
// new-line character or a null byte -- the end of a record.
//
recp = token = buff; // This will always be true at this point
while(bcnt)
{do { retc = read(FD, (void *)bp, (size_t)bcnt); }
while (retc < 0 && errno == EINTR);
if (retc < 0) {Erp(GetLine,errno,"read request",0); return (char *)0;}
if (!retc)
{*bp = '\0';
flags |= XrdOucStream_EOM;
bnext = ++bp;
bleft = 0;
return buff;
}
bcnt -= retc;
while(retc--)
if (!*bp || *bp == '\n')
{if (!*bp) flags |= XrdOucStream_EOM;
else *bp = '\0';
bnext = ++bp;
bleft = retc;
return buff;
} else {
if (notabs && *bp == '\t') *bp = ' ';
bp++;
}
}
// All done, force an end of record.
//
Erp(GetLine, EMSGSIZE, "read full message", 0);
buff[bsize-1] = '\0';
return buff;
}
XrdOucStream_EOM
#define XrdOucStream_EOM
Definition XrdOucStream.cc:72
Erp
#define Erp(p, a, b, c)
Definition XrdOucStream.cc:82
read
#define read(a, b, c)
Definition XrdPosix.hh:82
XrdOucStream::GetLine
char * GetLine()
Definition XrdOucStream.cc:554

References Erp, GetLine(), read, and XrdOucStream_EOM.

Referenced by GetLine(), GetWord(), XrdFrcCID::Init(), main(), XrdOssCache::MapDevs(), XrdOssSys::MSS_Readdir(), XrdOssSys::MSS_Xeq(), XrdFrmXfrDaemon::Pong(), XrdOfsPrepGPIReal::PrepGRun::Run(), XrdOucProg::Run(), XrdOucProg::Run(), XrdOucProg::Run(), and XrdFrmXfrAgent::Start().

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

## GetMyFirstWord()

char * XrdOucStream::GetMyFirstWord | ( | int | lowcase = 0 | ) |

Definition at line 696 of file XrdOucStream.cc.

{
char *var;
int skip2fi = 0;
Echo();
if (!myInst)
{if (!myEnv) return add2llB(GetFirstWord(lowcase), 1);
else {while((var = GetFirstWord(lowcase)) && !isSet(var)) {}
return add2llB(var, 1);
}
}
do {if (!(var = GetFirstWord(lowcase)))
{if (sawif && !ecode)
{ecode = EINVAL;
if (Eroute) Eroute->Emsg("Stream", "Missing 'fi' for last 'if'.");
}
return add2llB(var, 1);
}
add2llB(var, 1);
if (!strcmp("continue", var))
{if (!docont()) return 0;
continue;
}
if ( !strcmp("if", var)) var = doif();
if (var && !strcmp("else", var)) var = doelse();
if (var && !strcmp("fi", var))
{if (sawif) sawif = skpel = skip2fi = 0;
else {if (Eroute)
Eroute->Emsg("Stream", "No preceding 'if' for 'fi'.");
ecode = EINVAL;
}
continue;
}
if (var && (!myEnv || !isSet(var))) return add2llB(var, 1);
} while (1);
return 0;
}
XrdOucStream::Echo
void Echo()
Definition XrdOucStream.cc:393
XrdOucStream::GetFirstWord
char * GetFirstWord(int lowcase=0)
Definition XrdOucStream.cc:679

References Echo(), and GetFirstWord().

Referenced by Macaroons::Handler::Config(), and XrdVomsMapfile::Configure().

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

## GetRest()

int XrdOucStream::GetRest | ( | char * | theBuf,
|  | int | Blen,
|  | int | lowcase = 0 )

Definition at line 809 of file XrdOucStream.cc.

{
char *tp, *myBuff = theBuff;
int tlen;
// Get remaining tokens
//
theBuff[0] = '\0';
while ((tp = GetWord(lowcase)))
{tlen = strlen(tp);
if (tlen+1 >= Blen) return 0;
if (myBuff != theBuff) {*myBuff++ = ' '; Blen--;}
strcpy(myBuff, tp);
Blen -= tlen; myBuff += tlen;
}
// All done
//
add2llB(0);
return 1;
}

References GetWord().

Here is the call graph for this function:

## GetToken() [1/2]

char * XrdOucStream::GetToken | ( | char ** | rest,
|  | int | lowcase = 0 )

Definition at line 656 of file XrdOucStream.cc.

{
char *tpoint;
// Get the next token
//
if (!(tpoint = GetToken(lowcase))) return tpoint;
// Skip to the first non-blank character.
//
while (*token && *token == ' ') token ++;
if (rest) *rest = token;
// All done.
//
return tpoint;
}
XrdOucStream::GetToken
char * GetToken(int lowcase=0)
Definition XrdOucStream.cc:631

References GetToken().

Here is the call graph for this function:

## GetToken() [2/2]

char * XrdOucStream::GetToken | ( | int | lowcase = 0 | ) |

Definition at line 631 of file XrdOucStream.cc.

{
char *tpoint;
// Verify that we have a token to return;
//
if (!token) return (char *)NULL;
// Skip to the first non-blank character.
//
while (*token && *token == ' ') token ++;
if (!*token) {token = 0; return 0;}
tpoint = token;
// Find the end of the token.
//
if (lowcase) while (*token && *token != ' ')
{*token = (char)tolower((int)*token); token++;}
else while (*token && *token != ' ') {token++;}
if (*token) {*token = '\0'; token++;}
// All done here.
//
return tpoint;
}

Referenced by GetToken(), GetWord(), main(), XrdOssCache::MapDevs(), XrdFrmXfrDaemon::Pong(), and XrdFrmXfrAgent::Process().

Here is the caller graph for this function:

## GetWord()

char * XrdOucStream::GetWord | ( | int | lowcase = 0 | ) |

Definition at line 745 of file XrdOucStream.cc.

{
char *wp, *ep;
// A call means the first token was acceptable and we continuing to
// parse, hence the line is echoable.
//
if (llBok == 1) llBok = 2;
// If we have a token, return it
//
xline = 1;
while((wp = GetToken(lowcase)))
{if (!myEnv) return add2llB(wp);
if ((wp = vSubs(wp)) && *wp) return add2llB(wp);
}
// If no continuation allowed, return a null (but only once)
//
if (!xcont) {xcont = 1; xline = 0; return (char *)0;}
// Find the next non-blank non-comment line
//
do {while(GetLine())
{// Get the first token (none if it is a blank line)
//
if (!(wp = GetToken(lowcase))) continue;
// If token starts with a pound sign, skip the line
//
if (*wp == '#') continue;
// Process continuations (last non-blank character is a back-slash)
//
ep = bnext-2;
while (ep >= buff && *ep == ' ') ep--;
if (ep < buff) continue;
if (*ep == '\\') {xcont = 1; *ep = '\0';}
else xcont = 0;
return add2llB((myEnv ? vSubs(wp) : wp));
}
if (myInfo && myInfo->fcList)
{if (myInfo->itFC == myInfo->fcList->end())
{bleft = 0;
flags |= XrdOucStream_EOM;
break;
}
const char *path = (*(myInfo->itFC)).c_str();
myInfo->itFC++;
if (!docontF(path)) break;
bleft = 0;
flags &= ~XrdOucStream_EOM;
} else break;
} while(true);
xline = 0;
return (char *)0;
}

References GetLine(), GetToken(), and XrdOucStream_EOM.

Referenced by XrdVomsMapfile::Configure(), GetFirstWord(), GetRest(), XrdCmsUtils::ParseManPort(), and xonmissing().

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

## isAlive()

int XrdOucStream::isAlive | ( |  | ) |

inline

Definition at line 156 of file XrdOucStream.hh.

{return (child ? kill(child,0) == 0 : 0);}

## LastError()

int XrdOucStream::LastError | ( |  | ) |

inline

Definition at line 163 of file XrdOucStream.hh.

{int n = ecode; ecode = 0; return n;}

Referenced by XrdSsiSfsConfig::Configure(), XrdFrcCID::Init(), XrdOssSys::MSS_Readdir(), and XrdOucProg::Run().

Here is the caller graph for this function:

## LastLine()

char * XrdOucStream::LastLine | ( |  | ) |

inline

Definition at line 167 of file XrdOucStream.hh.

{return recp;}

## noEcho()

int XrdOucStream::noEcho | ( |  | ) |

inline

Definition at line 171 of file XrdOucStream.hh.

{llBok = 0; return 0;}

## Put() [1/3]

int XrdOucStream::Put | ( | const char * | data | ) |

inline

Definition at line 177 of file XrdOucStream.hh.

{return Put(data, strlen(data));}
XrdOucStream::Put
int Put(const char *data, const int dlen)
Definition XrdOucStream.cc:861

References Put().

Referenced by Put().

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

## Put() [2/3]

int XrdOucStream::Put | ( | const char * | data,
|  | const int | dlen )

Definition at line 861 of file XrdOucStream.cc.

{
int dcnt = dlen, retc;
if (flags & XrdOucStream_BUSY) {ecode = ETXTBSY; return -1;}
while(dcnt)
{do { retc = write(FE, (const void *)data, (size_t)dlen);}
while (retc < 0 && errno == EINTR);
if (retc >= 0) dcnt -= retc;
else {flags |= XrdOucStream_BUSY;
Erp(Put, errno, "write to stream", 0);
flags &= ~XrdOucStream_BUSY;
return -1;
}
}
return 0;
}
XrdOucStream_BUSY
#define XrdOucStream_BUSY
Definition XrdOucStream.cc:73
write
#define write(a, b, c)
Definition XrdPosix.hh:115

References Erp, Put(), write, and XrdOucStream_BUSY.

Referenced by Put(), Put(), and XrdOucERoute::Route().

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

## Put() [3/3]

int XrdOucStream::Put | ( | const char * | data[],
|  | const int | dlen[] )

Definition at line 879 of file XrdOucStream.cc.

{
int i, retc, dlen;
const char *data;
if (flags & XrdOucStream_BUSY) {ecode = ETXTBSY; return -1;}
for (i = 0; datavec[i]; i++)
{data = datavec[i]; dlen = dlenvec[i];
while(dlen)
{do { retc = write(FE, (const void *)data, (size_t)dlen);}
while (retc < 0 && errno == EINTR);
if (retc >= 0) {data += retc; dlen -= retc;}
else {flags |= XrdOucStream_BUSY;
Erp(Put, errno, "write to stream",0);
flags &= ~XrdOucStream_BUSY;
return -1;
}
}
}
return 0;
}

References Erp, Put(), write, and XrdOucStream_BUSY.

Here is the call graph for this function:

## PutLine()

int XrdOucStream::PutLine | ( | const char * | data,
|  | int | dlen = 0 )

Definition at line 905 of file XrdOucStream.cc.

{
static const int plSize = 2048;
// Allocate a buffer if one is not allocated
//
if (!buff)
{if (!(buff = (char *)malloc(plSize)))
return Erq(Attach, errno, "allocate stream buffer");
bsize = plSize;
}
// Adjust dlen
//
if (dlen <= 0) dlen = strlen(data);
if (dlen >= bsize) dlen = bsize-1;
// Simply insert the line into the buffer, truncating if need be
//
bnext = recp = token = buff; // This will always be true at this point
if (dlen <= 0)
{*buff = '\0';
flags |= XrdOucStream_EOM;
bleft = 0;
} else {
strncpy(buff, data, dlen);
*(buff+dlen) = 0;
bleft = dlen+1;
}
// All done
//
return 0;
}

References Attach(), Erq, and XrdOucStream_EOM.

Here is the call graph for this function:

## RetToken()

void XrdOucStream::RetToken | ( |  | ) |

Definition at line 835 of file XrdOucStream.cc.

{
// Check if we can back up
//
if (!token || token == recp) return;
// Find the null byte for the token and remove it, if possible
//
while(*token && token != recp) token--;
if (token != recp)
{if (token+1 != bnext) *token = ' ';
token--;
while(*token && *token != ' ' && token != recp) token--;
if (token != recp) token++;
}
// If saving line, we must do the same for the saved line
//
if (llBuff)
while(llBcur != llBuff && *llBcur != ' ') {llBcur--; llBleft++;}
}

## SetEnv()

XrdOucEnv * XrdOucStream::SetEnv | ( | XrdOucEnv * | newEnv | ) |

inline

Definition at line 191 of file XrdOucStream.hh.

{XrdOucEnv *oldEnv = myEnv; myEnv = newEnv; return oldEnv;}

Referenced by GetFirstWord(), and XrdOucProg::Run().

Here is the caller graph for this function:

## SetEroute()

void XrdOucStream::SetEroute | ( | XrdSysError * | eroute | ) |

inline

Definition at line 196 of file XrdOucStream.hh.

{Eroute = eroute;}

## Tabs()

void XrdOucStream::Tabs | ( | int | x = 1 | ) |

inline

Definition at line 201 of file XrdOucStream.hh.

{notabs = !x;}

## Wait4Data()

int XrdOucStream::Wait4Data | ( | int | msMax = -1 | ) |

Definition at line 943 of file XrdOucStream.cc.

{
struct pollfd polltab = {FD, POLLIN|POLLRDNORM, 0};
int retc;
// Wait until we can actually read something
//
do {retc = poll(&polltab, 1, msMax);} while(retc < 0 && errno == EINTR);
if (retc != 1) return (retc ? errno : -1);
// Return correct value
//
return (polltab.revents & (POLLIN|POLLRDNORM) ? 0 : EIO);
}

Referenced by XrdOssSys::MSS_Xeq().

Here is the caller graph for this function:

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

- XrdOucStream.hh
- XrdOucStream.cc