XRootD
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 ()
XrdOucEnvSetEnv (XrdOucEnv *newEnv)
void SetEroute (XrdSysError *eroute)
void Tabs (int x=1)
int Wait4Data (int msMax=-1)

Static Public Member Functions

static XrdOucStringCapture ()
static void Capture (const char **cVec=0, bool linefeed=true)
static XrdOucStringCapture (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.

189{
190 char *cp;
191
192
193 if (ifname)
194 {myInst = strdup(ifname);
195 myInfo = new StreamInfo;
196 if (!(cp = index(myInst, ' '))) {cp = myInst; myInfo->myExec = 0;}
197 else {*cp = '\0'; cp++;
198 myInfo->myExec = (*myInst ? myInst : 0);
199 }
200 if ( (myInfo->myHost = index(cp, '@')))
201 {*(myInfo->myHost) = '\0';
202 myInfo->myHost++;
203 myInfo->myName = (*cp ? cp : 0);
204 } else {myInfo->myHost = cp; myInfo->myName = 0;}
205 } else {myInst = 0; myInfo = 0;}
206 myRsv1 = myRsv2 = 0;
207
208 FD = -1;
209 FE = -1;
210 bsize = 0;
211 buff = 0;
212 bnext = 0;
213 bleft = 0;
214 recp = 0;
215 token = 0;
216 flags = 0;
217 child = 0;
218 ecode = 0;
219 notabs = 0;
220 xcont = 1;
221 xline = 0;
222 Eroute = erobj;
223 myEnv = anEnv;
224 sawif = 0;
225 skpel = 0;
226 if (myEnv && Eroute)
227 {llBuff = (char *)malloc(llBsz);
228 llBcur = llBuff; llBok = 0; llBleft = llBsz; *llBuff = '\0';
229 Verbose= 1;
230 } else {
231 Verbose= 0;
232 llBuff = 0;
233 llBcur = 0;
234 llBleft= 0;
235 llBok = 0;
236 }
237 varVal = (myEnv ? new char[maxVLen+1] : 0);
238 llPrefix = Pfx;
239}

◆ ~XrdOucStream()

XrdOucStream::~XrdOucStream ( )
inline

Definition at line 57 of file XrdOucStream.hh.

57 {Close(); if (myInst) free(myInst);
58 if (varVal) delete [] varVal;
59 if (llBuff) free(llBuff);
60 }
void Close(int hold=0)

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.

253{
254
255 // Close the current stream. Close will handle unopened streams.
256 //
257 StreamInfo *saveInfo = myInfo; myInfo = 0;
258 Close();
259 myInfo = saveInfo;
260
261 // Allocate a new buffer for this stream
262 //
263 if (!bsz) buff = 0;
264 else if (!(buff = (char *)malloc(bsz+1)))
265 return Erq(Attach, errno, "allocate stream buffer");
266
267 // Initialize the stream
268 //
269 FD= FE = FileDescriptor;
270 bnext = buff;
271 bsize = bsz+1;
272 bleft = 0;
273 recp = 0;
274 token = 0;
275 flags = 0;
276 ecode = 0;
277 xcont = 1;
278 xline = 0;
279 sawif = 0;
280 skpel = 0;
281 if (llBuff)
282 {llBcur = llBuff; *llBuff = '\0'; llBleft = llBsz; llBok = 0;}
283 return 0;
284}
#define Erq(p, a, b)
int Attach(int FileDescriptor, int bsz=2047)

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.

246{
247 if (Attach(infd, bsz)) return -1;
248 FE = outfd;
249 return 0;
250}

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.

315{
316 return theCFG;
317}

◆ Capture() [2/3]

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

Definition at line 290 of file XrdOucStream.cc.

291{
292// Make sure we can handle this
293//
294 if (theCFG && cVec && cVec[0])
295 {if (linefeed) theCFG->append("\n# ");
296 else theCFG->append("# ");
297 int i = 0;
298 while(cVec[i]) theCFG->append(cVec[i++]);
299 theCFG->append('\n');
300 }
301}

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.

306{
307 XrdOucString *oldCFG = theCFG;
308 theCFG = newCFG;
309 return oldCFG;
310}

◆ Close()

void XrdOucStream::Close ( int hold = 0)

Definition at line 323 of file XrdOucStream.cc.

324{
325
326 // Wait for any associated process on this stream
327 //
328 if (!hold && child) Drain();
329 else child = 0;
330
331 // Close the associated file descriptor if it was open
332 //
333 if (FD >= 0) close(FD);
334 if (FE >= 0 && FE != FD) close(FE);
335
336 // Release the buffer if it was allocated.
337 //
338 if (buff) free(buff);
339
340 // Clear all data values by attaching a dummy FD
341 //
342 FD = FE = -1;
343 buff = 0;
344
345 // Check if we should echo the last line
346 //
347 if (llBuff)
348 {if (Verbose && *llBuff && llBok > 1)
349 {if (Eroute) Eroute->Say(llPrefix, llBuff);
350 if (theCFG) add2CFG(llBuff);
351 }
352 llBok = 0;
353 }
354
355 // Delete any info object we have allocated
356 //
357 if (myInfo)
358 {delete myInfo;
359 myInfo = 0;
360 }
361}
#define close(a)
Definition XrdPosix.hh:48

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.

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

◆ Drain()

int XrdOucStream::Drain ( )

Definition at line 367 of file XrdOucStream.cc.

368{
369 int Status = 0;
370
371 // Drain any outstanding processes (i.e., kill the process group)
372 //
373#ifndef WIN32
374 int retc;
375 if (child) {kill(-child, 9);
376 do {retc = waitpid(child, &Status, 0);}
377 while(retc > 0 || (retc == -1 && errno == EINTR));
378 child = 0;
379 }
380#else
381 if (child) {
382 TerminateProcess((HANDLE)child, 0);
383 child = 0;
384 }
385#endif
386 return Status;
387}

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.

394{
395 if (llBok > 1 && Verbose && llBuff)
396 {if (Eroute) Eroute->Say(llPrefix,llBuff);
397 if (theCFG) add2CFG(llBuff);
398 }
399 llBok = 0;
400}

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.

407{
408 if (llBok && Verbose && llBuff)
409 {if (Eroute) Eroute->Say(llPrefix,llBuff);
410 if (capture && theCFG) add2CFG(llBuff);
411 }
412 llBok = 0;
413}

◆ Exec() [1/2]

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

Definition at line 450 of file XrdOucStream.cc.

451{
452 int fildes[2], Child_in = -1, Child_out = -1, Child_log = -1;
453
454 // Create a pipe. Minimize file descriptor leaks.
455 //
456 if (inrd >= 0)
457 {if (pipe(fildes))
458 return Err(Exec, errno, "create input pipe for", parm[0]);
459 else {
460 fcntl(fildes[0], F_SETFD, FD_CLOEXEC);
461 Attach(fildes[0]); Child_out = fildes[1];
462 }
463
464 if (inrd)
465 {if (pipe(fildes))
466 return Err(Exec, errno, "create output pipe for", parm[0]);
467 else {
468 fcntl(fildes[1], F_SETFD, FD_CLOEXEC);
469 FE = fildes[1]; Child_in = fildes[0];
470 }
471 }
472 } else {Child_out = FD; Child_in = FE;}
473
474 // Handle the standard error file descriptor
475 //
476 if (!efd) Child_log = (Eroute ? dup(Eroute->logger()->originalFD()) : -1);
477 else if (efd > 0) Child_log = efd;
478 else if (efd == -2){Child_log = Child_out; Child_out = -1;}
479 else if (efd == -3) Child_log = Child_out;
480
481 // Fork a process first so we can pick up the next request. We also
482 // set the process group in case the child hasn't been able to do so.
483 // Make sure only one fork occurs at any one time (we are the only one).
484 //
485 forkMutex.Lock();
486 if ((child = fork()))
487 {if (child < 0)
488 {close(Child_in); close(Child_out); forkMutex.UnLock();
489 return Err(Exec, errno, "fork request process for", parm[0]);
490 }
491 close(Child_out);
492 if (inrd) close(Child_in );
493 if (!efd && Child_log >= 0) close(Child_log);
494 forkMutex.UnLock();
495 setpgid(child, child);
496 return 0;
497 }
498
499 /*****************************************************************/
500 /* C h i l d P r o c e s s */
501 /*****************************************************************/
502
503 // Redirect standard in if so requested
504 //
505 if (Child_in >= 0)
506 {if (inrd)
507 {if (dup2(Child_in, STDIN_FILENO) < 0)
508 {Erx(Exec, errno, "setting up standard in for " <<parm[0]);
509 _exit(255);
510 } else if (Child_in != Child_out) close(Child_in);
511 }
512 }
513
514 // Reassign the stream to be standard out to capture all of the output.
515 //
516 if (Child_out >= 0)
517 {if (dup2(Child_out, STDOUT_FILENO) < 0)
518 {Erx(Exec, errno, "setting up standard out for " <<parm[0]);
519 _exit(255);
520 } else if (Child_out != Child_log) close(Child_out);
521 }
522
523 // Redirect stderr of the stream if we can to avoid keeping the logfile open
524 //
525 if (Child_log >= 0)
526 {if (dup2(Child_log, STDERR_FILENO) < 0)
527 {Erx(Exec, errno, "set up standard err for " <<parm[0]);
528 _exit(255);
529 } else close(Child_log);
530 }
531
532 // Check if we need to set any envornment variables
533 //
534 if (myEnv)
535 {char **envP;
536 int i = 0;
537 if ((envP = (char **)myEnv->GetPtr("XrdEnvars**")))
538 while(envP[i]) {putenv(envP[i]); i++;}
539 }
540
541 // Set our process group (the parent should have done this by now) then
542 // invoke the command never to return
543 //
544 setpgid(0,0);
545 execv(parm[0], parm);
546 Erx(Exec, errno, "executing " <<parm[0]);
547 _exit(255);
548}
#define Err(p, a, b, c)
#define Erx(p, a, b)
int Exec(const char *, int inrd=0, int efd=0)
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.

420{
421 int j;
422 char *cmd, *origcmd, *parm[MaxARGC];
423
424 if (!theCmd)
425 return EINVAL;
426
427 // Allocate a buffer for the command as we will be modifying it
428 //
429 origcmd = cmd = (char *)malloc(strlen(theCmd)+1);
430 strcpy(cmd, theCmd);
431
432 // Construct the argv array based on passed command line.
433 //
434 for (j = 0; j < MaxARGC-1 && *cmd; j++)
435 {while(*cmd == ' ') cmd++;
436 if (!(*cmd)) break;
437 parm[j] = cmd;
438 while(*cmd && *cmd != ' ') cmd++;
439 if (*cmd) {*cmd = '\0'; cmd++;}
440 }
441 parm[j] = (char *)0;
442
443 // Continue with normal processing
444 //
445 int ret = j > 0 ? Exec(parm, inrd, efd) : EINVAL;
446 free(origcmd);
447 return ret;
448}
#define MaxARGC

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.

110{return FD;}

◆ FENum()

int XrdOucStream::FENum ( )
inline

Definition at line 111 of file XrdOucStream.hh.

111{return FE;}

◆ Flush()

void XrdOucStream::Flush ( )
inline

Definition at line 115 of file XrdOucStream.hh.

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

References fsync.

◆ GetFirstWord()

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

Definition at line 679 of file XrdOucStream.cc.

680{
681 // If in the middle of a line, flush to the end of the line. Suppress
682 // variable substitution when doing this to avoid errors.
683 //
684 if (xline)
685 {XrdOucEnv *oldEnv = SetEnv(0);
686 while(GetWord(lowcase)) {}
687 SetEnv(oldEnv);
688 }
689 return GetWord(lowcase);
690}
XrdOucEnv * SetEnv(XrdOucEnv *newEnv)
char * GetWord(int lowcase=0)

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.

555{
556 int bcnt, retc;
557 char *bp;
558
559// Check if end of message has been reached.
560//
561 if (flags & XrdOucStream_EOM) return (char *)NULL;
562
563// Find the next record in the buffer
564//
565 if (bleft > 0)
566 {recp = bnext; bcnt = bleft;
567 for (bp = bnext; bcnt--; bp++)
568 if (!*bp || *bp == '\n')
569 {if (!*bp) flags |= XrdOucStream_EOM;
570 *bp = '\0';
571 bnext = ++bp;
572 bleft = bcnt;
573 token = recp;
574 return recp;
575 }
576 else if (notabs && *bp == '\t') *bp = ' ';
577
578 // There is no next record, so move up data in the buffer.
579 //
580 bnext = stpncpy(buff, bnext, bleft);
581 }
582 else bnext = buff;
583
584// Prepare to read in more data.
585//
586 bcnt = bsize - (bnext - buff) -1;
587 bp = bnext;
588
589// Read up to the maximum number of bytes. Stop reading should we see a
590// new-line character or a null byte -- the end of a record.
591//
592 recp = token = buff; // This will always be true at this point
593 while(bcnt)
594 {do { retc = read(FD, (void *)bp, (size_t)bcnt); }
595 while (retc < 0 && errno == EINTR);
596
597 if (retc < 0) {Erp(GetLine,errno,"read request",0); return (char *)0;}
598 if (!retc)
599 {*bp = '\0';
600 flags |= XrdOucStream_EOM;
601 bnext = ++bp;
602 bleft = 0;
603 return buff;
604 }
605
606 bcnt -= retc;
607 while(retc--)
608 if (!*bp || *bp == '\n')
609 {if (!*bp) flags |= XrdOucStream_EOM;
610 else *bp = '\0';
611 bnext = ++bp;
612 bleft = retc;
613 return buff;
614 } else {
615 if (notabs && *bp == '\t') *bp = ' ';
616 bp++;
617 }
618 }
619
620// All done, force an end of record.
621//
622 Erp(GetLine, EMSGSIZE, "read full message", 0);
623 buff[bsize-1] = '\0';
624 return buff;
625}
#define XrdOucStream_EOM
#define Erp(p, a, b, c)
#define read(a, b, c)
Definition XrdPosix.hh:82
char * GetLine()

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.

697{
698 char *var;
699 int skip2fi = 0;
700
701 Echo();
702
703 if (!myInst)
704 {if (!myEnv) return add2llB(GetFirstWord(lowcase), 1);
705 else {while((var = GetFirstWord(lowcase)) && !isSet(var)) {}
706 return add2llB(var, 1);
707 }
708 }
709
710 do {if (!(var = GetFirstWord(lowcase)))
711 {if (sawif && !ecode)
712 {ecode = EINVAL;
713 if (Eroute) Eroute->Emsg("Stream", "Missing 'fi' for last 'if'.");
714 }
715 return add2llB(var, 1);
716 }
717
718 add2llB(var, 1);
719
720 if (!strcmp("continue", var))
721 {if (!docont()) return 0;
722 continue;
723 }
724
725 if ( !strcmp("if", var)) var = doif();
726 if (var && !strcmp("else", var)) var = doelse();
727 if (var && !strcmp("fi", var))
728 {if (sawif) sawif = skpel = skip2fi = 0;
729 else {if (Eroute)
730 Eroute->Emsg("Stream", "No preceding 'if' for 'fi'.");
731 ecode = EINVAL;
732 }
733 continue;
734 }
735 if (var && (!myEnv || !isSet(var))) return add2llB(var, 1);
736 } while (1);
737
738 return 0;
739}
char * GetFirstWord(int lowcase=0)

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.

810{
811 char *tp, *myBuff = theBuff;
812 int tlen;
813
814// Get remaining tokens
815//
816 theBuff[0] = '\0';
817 while ((tp = GetWord(lowcase)))
818 {tlen = strlen(tp);
819 if (tlen+1 >= Blen) return 0;
820 if (myBuff != theBuff) {*myBuff++ = ' '; Blen--;}
821 strcpy(myBuff, tp);
822 Blen -= tlen; myBuff += tlen;
823 }
824
825// All done
826//
827 add2llB(0);
828 return 1;
829}

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.

657{
658 char *tpoint;
659
660 // Get the next token
661 //
662 if (!(tpoint = GetToken(lowcase))) return tpoint;
663
664 // Skip to the first non-blank character.
665 //
666 while (*token && *token == ' ') token ++;
667 if (rest) *rest = token;
668
669
670 // All done.
671 //
672 return tpoint;
673}
char * GetToken(int lowcase=0)

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.

631 {
632 char *tpoint;
633
634 // Verify that we have a token to return;
635 //
636 if (!token) return (char *)NULL;
637
638 // Skip to the first non-blank character.
639 //
640 while (*token && *token == ' ') token ++;
641 if (!*token) {token = 0; return 0;}
642 tpoint = token;
643
644 // Find the end of the token.
645 //
646 if (lowcase) while (*token && *token != ' ')
647 {*token = (char)tolower((int)*token); token++;}
648 else while (*token && *token != ' ') {token++;}
649 if (*token) {*token = '\0'; token++;}
650
651 // All done here.
652 //
653 return tpoint;
654}

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.

746{
747 char *wp, *ep;
748
749 // A call means the first token was acceptable and we continuing to
750 // parse, hence the line is echoable.
751 //
752 if (llBok == 1) llBok = 2;
753
754 // If we have a token, return it
755 //
756 xline = 1;
757 while((wp = GetToken(lowcase)))
758 {if (!myEnv) return add2llB(wp);
759 if ((wp = vSubs(wp)) && *wp) return add2llB(wp);
760 }
761
762 // If no continuation allowed, return a null (but only once)
763 //
764 if (!xcont) {xcont = 1; xline = 0; return (char *)0;}
765
766 // Find the next non-blank non-comment line
767 //
768do {while(GetLine())
769 {// Get the first token (none if it is a blank line)
770 //
771 if (!(wp = GetToken(lowcase))) continue;
772
773 // If token starts with a pound sign, skip the line
774 //
775 if (*wp == '#') continue;
776
777 // Process continuations (last non-blank character is a back-slash)
778 //
779 ep = bnext-2;
780 while (ep >= buff && *ep == ' ') ep--;
781 if (ep < buff) continue;
782 if (*ep == '\\') {xcont = 1; *ep = '\0';}
783 else xcont = 0;
784 return add2llB((myEnv ? vSubs(wp) : wp));
785 }
786
787 if (myInfo && myInfo->fcList)
788 {if (myInfo->itFC == myInfo->fcList->end())
789 {bleft = 0;
790 flags |= XrdOucStream_EOM;
791 break;
792 }
793 const char *path = (*(myInfo->itFC)).c_str();
794 myInfo->itFC++;
795 if (!docontF(path)) break;
796 bleft = 0;
797 flags &= ~XrdOucStream_EOM;
798 } else break;
799 } while(true);
800
801 xline = 0;
802 return (char *)0;
803}

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.

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

◆ LastError()

int XrdOucStream::LastError ( )
inline

Definition at line 163 of file XrdOucStream.hh.

163{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.

167{return recp;}

◆ noEcho()

int XrdOucStream::noEcho ( )
inline

Definition at line 171 of file XrdOucStream.hh.

171{llBok = 0; return 0;}

◆ Put() [1/3]

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

Definition at line 177 of file XrdOucStream.hh.

177{return Put(data, strlen(data));}
int Put(const char *data, const int dlen)

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.

861 {
862 int dcnt = dlen, retc;
863
864 if (flags & XrdOucStream_BUSY) {ecode = ETXTBSY; return -1;}
865
866 while(dcnt)
867 {do { retc = write(FE, (const void *)data, (size_t)dlen);}
868 while (retc < 0 && errno == EINTR);
869 if (retc >= 0) dcnt -= retc;
870 else {flags |= XrdOucStream_BUSY;
871 Erp(Put, errno, "write to stream", 0);
872 flags &= ~XrdOucStream_BUSY;
873 return -1;
874 }
875 }
876 return 0;
877}
#define XrdOucStream_BUSY
#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.

879 {
880 int i, retc, dlen;
881 const char *data;
882
883 if (flags & XrdOucStream_BUSY) {ecode = ETXTBSY; return -1;}
884
885 for (i = 0; datavec[i]; i++)
886 {data = datavec[i]; dlen = dlenvec[i];
887 while(dlen)
888 {do { retc = write(FE, (const void *)data, (size_t)dlen);}
889 while (retc < 0 && errno == EINTR);
890 if (retc >= 0) {data += retc; dlen -= retc;}
891 else {flags |= XrdOucStream_BUSY;
892 Erp(Put, errno, "write to stream",0);
893 flags &= ~XrdOucStream_BUSY;
894 return -1;
895 }
896 }
897 }
898 return 0;
899}

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.

906{
907 static const int plSize = 2048;
908
909// Allocate a buffer if one is not allocated
910//
911 if (!buff)
912 {if (!(buff = (char *)malloc(plSize)))
913 return Erq(Attach, errno, "allocate stream buffer");
914 bsize = plSize;
915 }
916
917// Adjust dlen
918//
919 if (dlen <= 0) dlen = strlen(data);
920 if (dlen >= bsize) dlen = bsize-1;
921
922// Simply insert the line into the buffer, truncating if need be
923//
924 bnext = recp = token = buff; // This will always be true at this point
925 if (dlen <= 0)
926 {*buff = '\0';
927 flags |= XrdOucStream_EOM;
928 bleft = 0;
929 } else {
930 strncpy(buff, data, dlen);
931 *(buff+dlen) = 0;
932 bleft = dlen+1;
933 }
934// All done
935//
936 return 0;
937}

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.

836{
837 // Check if we can back up
838 //
839 if (!token || token == recp) return;
840
841 // Find the null byte for the token and remove it, if possible
842 //
843 while(*token && token != recp) token--;
844 if (token != recp)
845 {if (token+1 != bnext) *token = ' ';
846 token--;
847 while(*token && *token != ' ' && token != recp) token--;
848 if (token != recp) token++;
849 }
850
851 // If saving line, we must do the same for the saved line
852 //
853 if (llBuff)
854 while(llBcur != llBuff && *llBcur != ' ') {llBcur--; llBleft++;}
855}

◆ SetEnv()

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

Definition at line 191 of file XrdOucStream.hh.

192 {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.

196{Eroute = eroute;}

◆ Tabs()

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

Definition at line 201 of file XrdOucStream.hh.

201{notabs = !x;}

◆ Wait4Data()

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

Definition at line 943 of file XrdOucStream.cc.

944{
945 struct pollfd polltab = {FD, POLLIN|POLLRDNORM, 0};
946 int retc;
947
948// Wait until we can actually read something
949//
950 do {retc = poll(&polltab, 1, msMax);} while(retc < 0 && errno == EINTR);
951 if (retc != 1) return (retc ? errno : -1);
952
953// Return correct value
954//
955 return (polltab.revents & (POLLIN|POLLRDNORM) ? 0 : EIO);
956}

Referenced by XrdOssSys::MSS_Xeq().

Here is the caller graph for this function:

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