Loading...
Searching...
No Matches
XrdOucArgs Class Reference

`#include <XrdOucArgs.hh>`

Collaboration diagram for XrdOucArgs:

## Public Member Functions

| XrdOucArgs (XrdSysError *erp, const char *etxt, const char *StdOpts, const char *optw=0,...)
| ~XrdOucArgs ()
char * | getarg ()
char | getopt ()
void | Set (char *arglist)
void | Set (int argc, char **argv)

## Public Attributes

char * | argval

## Detailed Description

Definition at line 41 of file XrdOucArgs.hh.

## Constructor & Destructor Documentation

## XrdOucArgs()

XrdOucArgs::XrdOucArgs | ( | XrdSysError * | erp,
|  | const char * | etxt,
|  | const char * | StdOpts,
|  | const char * | optw = 0,
|  |  | ... )

Definition at line 86 of file XrdOucArgs.cc.

: arg_stream(0)
{
va_list ap;
const char *optm;
int minl;
// Do the standard initialization
//
inStream = Argc = Aloc = 0; vopts = curopt = 0; endopts = 1;
optp = 0; eDest = erp;
epfx = strdup(etxt ? etxt : "");
// Process the valid opts
//
if (StdOpts && *StdOpts == ':') {missarg = ':'; StdOpts++;}
else missarg = '?';
vopts = strdup(StdOpts ? StdOpts : "");
// Handle list of extended options, if any
//
if (optw)
{va_start(ap, optw);
while(optw)
{minl = va_arg(ap, int);
optm = va_arg(ap, const char *);
optp = new XrdOucArgsXO(optp, optw, minl, optm);
optw = va_arg(ap, const char *);
}
va_end(ap);
}
}

## ~XrdOucArgs()

XrdOucArgs::~XrdOucArgs | ( |  | ) |

Definition at line 126 of file XrdOucArgs.cc.

{if (vopts) free(vopts);
if (optp) delete optp;
free(epfx);
}

## Member Function Documentation

## getarg()

char * XrdOucArgs::getarg | ( |  | ) |

Definition at line 136 of file XrdOucArgs.cc.

{
// Return argument from whatever source we have
//
if (inStream) return arg_stream.GetToken();
if (Aloc >= Argc) return (char *)0;
argval = Argv[Aloc++];
return argval;
}
XrdOucArgs::argval
char * argval
Definition XrdOucArgs.hh:102

References argval.

Referenced by XrdFrmAdmin::Audit(), XrdFrmAdmin::Chksum(), main(), XrdFrmAdmin::MakeLF(), XrdFrmAdmin::Mark(), XrdFrmAdmin::Mmap(), XrdFrmAdmin::Pin(), and XrdFrmAdmin::Remove().

Here is the caller graph for this function:

## getopt()

char XrdOucArgs::getopt | ( |  | ) |

Definition at line 151 of file XrdOucArgs.cc.

{
char optbuff[3] = {'-', 'x', '\0'}, *optspec, *arglist, *optname = 0;
// Check if we really have any more options
//
if (endopts) return -1;
// Get next option from whatever source we have
//
if (curopt && *curopt) curopt++;
else if (inStream)
{if ((optname = curopt = arg_stream.GetToken(&arglist)))
{if (*curopt != '-') {arg_stream.RetToken(); curopt = 0;}
else curopt++;
}
}
else if (Aloc >= Argc || *Argv[Aloc] != '-') curopt = 0;
else optname = curopt = Argv[Aloc++]+1;
// Check if we really have an option here
//
if (!curopt) {endopts = 1; return -1;}
if (!*curopt)
{if (eDest) eDest->Say(epfx, "Option letter missing after '-'.");
endopts = 1;
return '?';
}
// Check for extended options or single letter option
//
if (*curopt == ':' || *curopt == '.') optspec = 0;
else {if (optp) {optspec = *optp%curopt; curopt = 0;}
else {optspec = index(vopts, int(*curopt));
optbuff[1] = *curopt; optname = optbuff; curopt++;
}
}
if (!optspec)
{char buff[500];
if (eDest)
{sprintf(buff, "Invalid option, '%s'.", optname);
eDest->Say(epfx, buff);
}
endopts = 1;
return '?';
}
// Check if this option requires an argument
//
if (optspec[1] != ':' && optspec[1] != '.') return *optspec;
// Get the argument from whatever source we have
//
if (inStream) argval = arg_stream.GetToken();
else argval = (Aloc < Argc ? Argv[Aloc++] : 0);
// If we have a valid argument, then we are all done
//
if (argval)
{if (!*argval) argval = 0;
else if (*argval != '-') return *optspec;
}
// If argument is optional, let it go
//
if (optspec[1] == '.')
{if (argval && *argval == '-')
{if (inStream) arg_stream.RetToken();
else Aloc--;
}
argval = 0;
return *optspec;
}
// Complain about a missing argument
//
if (eDest) eDest->Say(epfx, "Value not specified for '", optname, "'.");
endopts = 1;
return missarg;
}

References argval.

Referenced by main().

Here is the caller graph for this function:

## Set() [1/2]

void XrdOucArgs::Set | ( | char * | arglist | ) |

Definition at line 236 of file XrdOucArgs.cc.

{
inStream = 1;
arg_stream.Attach(arglist);
curopt = 0;
endopts = !arg_stream.GetLine();
}

Referenced by main().

Here is the caller graph for this function:

## Set() [2/2]

void XrdOucArgs::Set | ( | int | argc,
|  | char ** | argv )

Definition at line 244 of file XrdOucArgs.cc.

{
inStream = 0;
Argc = argc; Argv = argv; Aloc = 0;
curopt = 0; endopts = 0;
endopts = !argc;
}

## Member Data Documentation

## argval

char* XrdOucArgs::argval

Definition at line 102 of file XrdOucArgs.hh.

Referenced by getarg(), getopt(), and main().

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

- XrdOucArgs.hh
- XrdOucArgs.cc