- added 'sicscron list' and 'dolater list' command
This commit is contained in:
17
event.h
17
event.h
@ -1,5 +1,5 @@
|
||||
|
||||
#line 103 "event.w"
|
||||
#line 98 "event.w"
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
E V E N T
|
||||
@ -14,15 +14,15 @@
|
||||
#ifndef SICSEVENT
|
||||
#define SICSEVENT
|
||||
|
||||
#line 14 "event.w"
|
||||
#line 13 "event.w"
|
||||
|
||||
int Text2Event(char *pText);
|
||||
|
||||
#line 116 "event.w"
|
||||
#line 111 "event.w"
|
||||
|
||||
|
||||
|
||||
#line 21 "event.w"
|
||||
#line 20 "event.w"
|
||||
|
||||
#define VALUECHANGE 0
|
||||
#define MOTDRIVE 1
|
||||
@ -45,22 +45,21 @@
|
||||
#define STATUS 18
|
||||
#define POSITION 19
|
||||
#define HDBVAL 20
|
||||
#define STSTART 21
|
||||
#define STEND 22
|
||||
|
||||
#line 118 "event.w"
|
||||
#line 113 "event.w"
|
||||
|
||||
|
||||
/*--------------- Signals for the Signalfunction of each task ------------*/
|
||||
|
||||
#line 87 "event.w"
|
||||
#line 80 "event.w"
|
||||
|
||||
#define SICSINT 300
|
||||
#define SICSBROADCAST 301
|
||||
#define TOKENGRAB 302
|
||||
#define TOKENRELEASE 303
|
||||
#define COMLOG 304
|
||||
#define CRONLIST 305
|
||||
|
||||
#line 121 "event.w"
|
||||
#line 116 "event.w"
|
||||
|
||||
#endif
|
||||
|
10
event.tex
10
event.tex
@ -17,7 +17,7 @@ $\langle$eFunc {\footnotesize ?}$\rangle\equiv$
|
||||
\begin{list}{}{} \item
|
||||
\mbox{}\verb@@\\
|
||||
\mbox{}\verb@ int Text2Event(char *pText);@\\
|
||||
\mbox{}\verb@@$\diamond$
|
||||
\mbox{}\verb@@$\Diamond$
|
||||
\end{list}
|
||||
\vspace{-1ex}
|
||||
\footnotesize\addtolength{\baselineskip}{-1ex}
|
||||
@ -56,7 +56,7 @@ $\langle$VE {\footnotesize ?}$\rangle\equiv$
|
||||
\mbox{}\verb@#define STATUS 18@\\
|
||||
\mbox{}\verb@#define POSITION 19@\\
|
||||
\mbox{}\verb@#define HDBVAL 20@\\
|
||||
\mbox{}\verb@@$\diamond$
|
||||
\mbox{}\verb@@$\Diamond$
|
||||
\end{list}
|
||||
\vspace{-1ex}
|
||||
\footnotesize\addtolength{\baselineskip}{-1ex}
|
||||
@ -113,7 +113,8 @@ $\langle$VSIG {\footnotesize ?}$\rangle\equiv$
|
||||
\mbox{}\verb@#define TOKENGRAB 302@\\
|
||||
\mbox{}\verb@#define TOKENRELEASE 303@\\
|
||||
\mbox{}\verb@#define COMLOG 304@\\
|
||||
\mbox{}\verb@@$\diamond$
|
||||
\mbox{}\verb@#define CRONLIST 305@\\
|
||||
\mbox{}\verb@@$\Diamond$
|
||||
\end{list}
|
||||
\vspace{-1ex}
|
||||
\footnotesize\addtolength{\baselineskip}{-1ex}
|
||||
@ -130,6 +131,7 @@ data is the string to send.
|
||||
\item[TOKENGRAB] A connection has successfully grabbed the control token.
|
||||
\item[TOKENRELEASE] A connection has released the control token.
|
||||
\item[COMLOG] A command log message. This is to implement listen mode to the command log.
|
||||
\item[CRONLIST] Tell the cron tasks to inform about themselves.
|
||||
\end{description}
|
||||
\begin{flushleft} \small
|
||||
\begin{minipage}{\linewidth} \label{scrap4}
|
||||
@ -156,7 +158,7 @@ data is the string to send.
|
||||
\mbox{}\verb@/*--------------- Signals for the Signalfunction of each task ------------*/@\\
|
||||
\mbox{}\verb@@$\langle$VSIG {\footnotesize ?}$\rangle$\verb@ @\\
|
||||
\mbox{}\verb@#endif@\\
|
||||
\mbox{}\verb@@$\diamond$
|
||||
\mbox{}\verb@@$\Diamond$
|
||||
\end{list}
|
||||
\vspace{-2ex}
|
||||
\end{minipage}\\[4ex]
|
||||
|
2
event.w
2
event.w
@ -83,6 +83,7 @@ possible codes are defined.
|
||||
#define TOKENGRAB 302
|
||||
#define TOKENRELEASE 303
|
||||
#define COMLOG 304
|
||||
#define CRONLIST 305
|
||||
@}
|
||||
\begin{description}
|
||||
\item[SICSINT] An interrupt has ocurred. The signal data is the interrupt
|
||||
@ -92,6 +93,7 @@ data is the string to send.
|
||||
\item[TOKENGRAB] A connection has successfully grabbed the control token.
|
||||
\item[TOKENRELEASE] A connection has released the control token.
|
||||
\item[COMLOG] A command log message. This is to implement listen mode to the command log.
|
||||
\item[CRONLIST] Tell the cron tasks to inform about themselves.
|
||||
\end{description}
|
||||
@o event.h -d @{
|
||||
/*----------------------------------------------------------------------------
|
||||
|
43
sicscron.c
43
sicscron.c
@ -27,6 +27,11 @@
|
||||
Statistics *stat;
|
||||
} Cron, *pCron;
|
||||
|
||||
typedef struct {
|
||||
SConnection *pCon;
|
||||
int dolater;
|
||||
} CronListData;
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
static void KillCron(void *pData)
|
||||
{
|
||||
@ -92,15 +97,32 @@
|
||||
{
|
||||
pCron self = (pCron)pData;
|
||||
int *iInt;
|
||||
|
||||
struct tm tm;
|
||||
char datim[24];
|
||||
CronListData *data;
|
||||
|
||||
if(iID == SICSINT)
|
||||
{
|
||||
iInt = (int *)pSigData;
|
||||
if(*iInt >= eEndServer)
|
||||
{
|
||||
{
|
||||
self->iEnd = 0;
|
||||
}
|
||||
}
|
||||
if(iID == CRONLIST) {
|
||||
data = pSigData;
|
||||
if (self->iEnd == 2 && data->dolater) {
|
||||
tm = *localtime(&self->tNext);
|
||||
strftime(datim, sizeof datim, "%Y-%m-%d %T", &tm);
|
||||
SCPrintf(data->pCon, eStatus, "%s %s", datim,
|
||||
self->pCommand);
|
||||
} else if (self->iEnd == 1 && !data->dolater) {
|
||||
tm = *localtime(&self->tNext);
|
||||
strftime(datim, sizeof datim, "%Y-%m-%d %T", &tm);
|
||||
SCPrintf(data->pCon, eStatus, "%s %8d %s", datim,
|
||||
self->iInterval, self->pCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------*/
|
||||
int MakeCron(SConnection *pCon, SicsInterp *pSics, void *pData,
|
||||
@ -109,6 +131,7 @@
|
||||
pCron pNew = NULL;
|
||||
int iVal, iRet, rights;
|
||||
char *cmd;
|
||||
CronListData data;
|
||||
|
||||
/* need user priv. */
|
||||
if(!SCMatchRights(pCon,usUser))
|
||||
@ -116,6 +139,19 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (argc == 2 && strcasecmp(argv[1], "list") == 0) {
|
||||
if (strcasecmp(argv[0], "dolater") == 0) {
|
||||
data.dolater = 1;
|
||||
SCPrintf(pCon, eError, "Date Time Command");
|
||||
} else {
|
||||
data.dolater = 0;
|
||||
SCPrintf(pCon, eError, "Date Time Interval Command");
|
||||
}
|
||||
data.pCon = pCon;
|
||||
TaskSignal(pServ->pTasker, CRONLIST, &data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* enough arguments? */
|
||||
if(argc < 3)
|
||||
{
|
||||
@ -153,12 +189,13 @@
|
||||
/* transfer the rights to the dummy connection */
|
||||
SCSetRights(pNew->pCon, rights);
|
||||
}
|
||||
pNew->iInterval = iVal;
|
||||
pNew->pCommand = cmd;
|
||||
pNew->tNext = time(NULL) + iVal;
|
||||
if (strcasecmp(argv[0], "dolater") == 0) {
|
||||
pNew->iInterval = -1;
|
||||
pNew->iEnd = 2;
|
||||
} else {
|
||||
pNew->iInterval = iVal;
|
||||
pNew->iEnd = 1;
|
||||
}
|
||||
pNew->stat = StatisticsNew(cmd);
|
||||
|
Reference in New Issue
Block a user