36 #include <sys/types.h>
55 XrdFrcProxy::o2qMap XrdFrcProxy::oqMap[] =
61 int XrdFrcProxy::oqNum =
sizeof(oqMap)/
sizeof(oqMap[0]);
73 memset(Agent, 0,
sizeof(Agent));
88 intName = strdup(buff);
96 const char *Usr,
const char *Rid,
97 const char *Nop,
const char *Pop,
int Prty)
105 if (!Agent[qType])
return -ENOTSUP;
109 memset(&myReq, 0,
sizeof(myReq));
116 {
if (n + strlen(Opq) + 2 >
sizeof(myReq.
LFN))
return -ENAMETOOLONG;
117 strcpy(myReq.
LFN, Lfn); strcpy(myReq.
LFN+n+1, Opq), myReq.
Opaque = n+1;
118 }
else if (n <
int(
sizeof(myReq.
LFN))) strcpy(myReq.
LFN, Lfn);
119 else return -ENAMETOOLONG;
129 else strcpy(myReq.
User, intName);
131 else *(myReq.
ID) =
'?';
133 else *(myReq.
Notify) =
'-';
142 Agent[qType]->Add(myReq);
157 if (!Agent[qType])
return -ENOTSUP;
161 memset(&myReq, 0,
sizeof(myReq));
166 Agent[qType]->Del(myReq);
180 do{
if (!State.Active)
181 while(State.QList & opAll)
182 {
for (i = 0; i < oqNum; i++)
if (oqMap[i].oType & State.QList)
break;
183 if (i >= oqNum)
return 0;
184 State.QNow = oqMap[i].qType;
185 State.QList &= ~oqMap[i].oType;
186 if (!Agent[
int(State.QNow)])
continue;
192 if (Agent[
int(State.QNow)]->NextLFN(Buff,Bsz,i,State.Offset))
return 1;
193 else State.Prty = i+1;
195 State.Active = 0; State.Offset = 0; State.Prty = 0;
196 }
while(State.QList & opAll);
212 {
for (i = 0; i < oqNum; i++)
if (oqMap[i].oType & qType)
break;
213 if (i >= oqNum)
return Cnt;
214 qType &= ~oqMap[i].oType; n = oqMap[i].qType;
215 if (!Agent[n])
continue;
216 if (qPrty < 0) Cnt += Agent[n]->List(Items, Num);
217 else Cnt += Agent[n]->List(Items, Num, qPrty);
231 const char *configFN = getenv(
"XRDCONFIGFN"), *iName = 0;
239 if (qPath) QPath = strdup(qPath);
240 else if (!configFN) iName = insName;
241 else if (Init2(configFN))
return 0;
250 for (i = 0; i < oqNum; i++)
251 if (opX & oqMap[i].oType)
252 {Agent[oqMap[i].qType]
254 if (!Agent[oqMap[i].qType]->Start(QPath, aMode))
return 0;
266 int XrdFrcProxy::Init2(
const char *ConfigFN)
269 int cfgFD, retc, NoGo = 0;
275 if ( (cfgFD =
open(ConfigFN, O_RDONLY, 0)) < 0)
276 {
Say.
Emsg(
"Config", errno,
"open config file", ConfigFN);
279 cfgFile.Attach(cfgFD);
280 static const char *cvec[] = {
"*** frm client plugin config:", 0 };
281 cfgFile.Capture(cvec);
285 while((var = cfgFile.GetMyFirstWord()))
286 {
if (!strcmp(var,
"frm.xfr.qcheck") && qChk(cfgFile))
287 {cfgFile.Echo(); NoGo = 1;}
292 if ((retc = cfgFile.LastError()))
293 NoGo =
Say.
Emsg(
"Config", retc,
"read config file", ConfigFN);
311 if (!(val = cfgFile.
GetWord()))
312 {
Say.
Emsg(
"Config",
"qcheck time not specified");
return 1;}
316 if (*val !=
'/' && !(val = cfgFile.
GetWord()))
return 0;
321 {
Say.
Emsg(
"Config",
"qcheck path not absolute");
return 1;}
322 if (QPath) free(QPath);
int open(const char *path, int oflag,...)
int Add(char Opc, const char *Lfn, const char *Opq, const char *Usr, const char *Rid, const char *Nop, const char *Pop, int Prty=1)
int Init(int opX, const char *aPath, int aMode, const char *qPath=0)
int List(Queues &State, char *Buff, int Bsz)
XrdFrcProxy(XrdSysLogger *lP, const char *iName, int Debug=0)
int Del(char Opc, const char *Rid)
static int chkURL(const char *Url)
static int MapR2Q(char Opc, int *Flags=0)
static char * makePath(const char *iName, const char *Path, int Mode)
static int MapM2O(const char *Nop, const char *Pop)
char * GetWord(int lowcase=0)
static const char * InstName(int TranOpt=0)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
XrdSysLogger * logger(XrdSysLogger *lp=0)