XRootD
Loading...
Searching...
No Matches
XrdFrmAdminMain.cc File Reference
#include <unistd.h>
#include <cctype>
#include <cerrno>
#include <signal.h>
#include <cstdlib>
#include <cstring>
#include <strings.h>
#include <cstdio>
#include <sys/param.h>
#include "XrdFrc/XrdFrcTrace.hh"
#include "XrdFrm/XrdFrmAdmin.hh"
#include "XrdFrm/XrdFrmConfig.hh"
#include "XrdNet/XrdNetOpts.hh"
#include "XrdNet/XrdNetSocket.hh"
#include "XrdOuc/XrdOucTokenizer.hh"
#include "XrdSys/XrdSysError.hh"
#include "XrdSys/XrdSysHeaders.hh"
#include "XrdSys/XrdSysLogger.hh"
Include dependency graph for XrdFrmAdminMain.cc:

Go to the source code of this file.

Functions

void add_history (const char *cLine)
int main (int argc, char *argv[])
char * readline (const char *prompt)
void stifle_history (int hnum)

Variables

XrdOucTrace XrdTrace & Say
static const char * XrdFrmOpts = "c:dhn:v"
static const char * XrdFrmUsage
XrdSysError XrdLog (0, "")

Function Documentation

◆ add_history()

void add_history ( const char * cLine)

Definition at line 116 of file XrdFrmAdminMain.cc.

116{}

Referenced by main().

Here is the caller graph for this function:

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 124 of file XrdFrmAdminMain.cc.

125{
127 sigset_t myset;
128 XrdOucTokenizer Request(0);
129 char *cLine = 0, *pLine = 0, *Cmd = 0, *CmdArgs = 0;
130 int IMode;
131
132// Turn off sigpipe and host a variety of others before we start any threads
133//
134 signal(SIGPIPE, SIG_IGN); // Solaris optimization
135 sigemptyset(&myset);
136 sigaddset(&myset, SIGPIPE);
137 sigaddset(&myset, SIGCHLD);
138 pthread_sigmask(SIG_BLOCK, &myset, NULL);
139
140// Perform configuration
141//
142 Say.logger(&Logger);
143 XrdLog.logger(&Logger);
144 if (!Config.Configure(argc, argv, 0)) exit(4);
145
146// We either have a command line or need to enter interactive mode
147//
148 if (Config.nextArg >= argc) IMode = 1;
149 else {Cmd = argv[Config.nextArg++];
150 Admin.setArgs(argc-Config.nextArg, &argv[Config.nextArg]);
151 IMode = 0;
152 }
153
154// Set readline history list (keep only 256 lines, max)
155//
156 if (IMode) stifle_history(256);
157
158// Process the request(s)
159//
160 do {if (IMode)
161 {if (!(cLine = readline("frm_admin> "))) Admin.Quit();
162 if (!pLine || strcmp(pLine, cLine))
163 {add_history(cLine);
164 if (pLine) free(pLine);
165 pLine = strdup(cLine);
166 }
167 Request.Attach(cLine);
168 if (!Request.GetLine() || !(Cmd=Request.GetToken(&CmdArgs)))
169 Admin.Quit();
170 Admin.setArgs(CmdArgs);
171 }
172 Admin.xeqArgs(Cmd);
173 if (cLine) free(cLine);
174 } while(IMode);
175
176// All done
177//
178 Admin.Quit();
179}
XrdOucPup XrdCmsParser::Pup & Say
static XrdSysLogger Logger
XrdSysError XrdLog(0, "")
void stifle_history(int hnum)
char * readline(const char *prompt)
void add_history(const char *cLine)
XrdFrmConfig Config
XrdFrmAdmin Admin

References add_history(), XrdFrm::Admin, XrdOucTokenizer::Attach(), XrdFrm::Config, XrdOucTokenizer::GetLine(), XrdOucTokenizer::GetToken(), Logger, readline(), Say, stifle_history(), and XrdLog.

Here is the call graph for this function:

◆ readline()

char * readline ( const char * prompt)

Definition at line 107 of file XrdFrmAdminMain.cc.

108{
109 char buff[4096];
110
111 std::cout << prompt;
112 if (!fgets(buff, 4096, stdin) || *buff == '\n' || !strlen(buff)) return 0;
113 return strdup(buff);
114}

Referenced by main().

Here is the caller graph for this function:

◆ stifle_history()

void stifle_history ( int hnum)

Definition at line 117 of file XrdFrmAdminMain.cc.

117{}

Referenced by main().

Here is the caller graph for this function:

Variable Documentation

◆ Say

XrdOucTrace XrdTrace& Say

Definition at line 97 of file XrdFrmAdminMain.cc.

◆ XrdFrmOpts

const char* XrdFrmOpts = "c:dhn:v"
static

Definition at line 33 of file XrdFrmAdminMain.cc.

◆ XrdFrmUsage

const char* XrdFrmUsage
static
Initial value:
=
" [-c <cfgfile>] [-d] [-h] [-n name] [-v] [help | cmd & opts]\n"

Definition at line 34 of file XrdFrmAdminMain.cc.

◆ XrdLog

XrdSysError XrdLog(0, "") ( 0 ,
""  )

Referenced by main().