XRootD
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, "")
 
XrdOucTraceXrdXrootdTrace
 

Function Documentation

◆ add_history()

void add_history ( const char *  cLine)

Definition at line 117 of file XrdFrmAdminMain.cc.

117 {}

Referenced by main().

+ Here is the caller graph for this function:

◆ main()

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

Definition at line 125 of file XrdFrmAdminMain.cc.

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

References add_history(), XrdCms::Admin, XrdOucTokenizer::Attach(), XrdCms::Config, XrdOucTokenizer::GetLine(), XrdOucTokenizer::GetToken(), XrdGlobal::Logger, XrdSysError::logger(), readline(), XrdFrc::Say, stifle_history(), XrdLog, and XrdXrootdTrace.

+ Here is the call graph for this function:

◆ readline()

char* readline ( const char *  prompt)

Definition at line 108 of file XrdFrmAdminMain.cc.

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

Referenced by main().

+ Here is the caller graph for this function:

◆ stifle_history()

void stifle_history ( int  hnum)

Definition at line 118 of file XrdFrmAdminMain.cc.

118 {}

Referenced by main().

+ Here is the caller graph for this function:

Variable Documentation

◆ Say

XrdOucTrace XrdTrace& Say

Definition at line 98 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, "") ( ,
""   
)

◆ XrdXrootdTrace

XrdOucTrace* XrdXrootdTrace

Definition at line 96 of file XrdFrmAdminMain.cc.

Referenced by main().