Skip to content
Snippets Groups Projects
Commit 9b62df14 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Add Monthly fixed (system-wide) event

True, a sysop could add/configure a monthly timed event instead, but that
requires more configuration. Fixed events are nice in their simplicity.

This is intended for running the new Synchronet trashman utility, but could be
used for anything that's simple to execute and the sysop:
- doesn't care which node/instance of sbbs it runs from
- doesn't care exactly what time the event runs
- doesn't need the assorted options available for timed events
parent 58f9d475
No related branches found
No related tags found
No related merge requests found
......@@ -626,10 +626,12 @@ uint sbbs_t::logonstats()
if((tm.tm_mday>update_tm.tm_mday && tm.tm_mon==update_tm.tm_mon)
|| tm.tm_mon>update_tm.tm_mon || tm.tm_year>update_tm.tm_year) {
safe_snprintf(msg, sizeof(msg), "New Day - Prev: %s ",timestr(stats.date));
sys_status |= SS_NEW_DAY;
if(tm.tm_mon != update_tm.tm_mon)
sys_status |= SS_NEW_MONTH;
safe_snprintf(msg, sizeof(msg), "New Day%s - Prev: %s "
,(sys_status & SS_NEW_MONTH) ? " and Month" :"", timestr(stats.date));
logline(LOG_NOTICE, "!=", msg);
sys_status|=SS_DAILY; /* New Day !!! */
safe_snprintf(path, sizeof(path), "%slogon.lst",cfg.data_dir); /* Truncate logon list (LEGACY) */
int file;
if((file=nopen(path,O_TRUNC|O_CREAT|O_WRONLY))==-1) {
......
......@@ -4842,6 +4842,14 @@ void sbbs_t::daily_maint(void)
online = false;
lprintf(result ? LOG_ERR : LOG_INFO, "Daily event: '%s' returned %d", cmd, result);
}
if((sys_status & SS_NEW_MONTH) && cfg.sys_monthly[0]) {
lputs(LOG_INFO, "DAILY: Running monthly event");
const char* cmd = cmdstr(cfg.sys_monthly,nulstr,nulstr,NULL);
online = ON_LOCAL;
int result = external(cmd, EX_OFFLINE);
online = false;
lprintf(result ? LOG_ERR : LOG_INFO, "Monthly event: '%s' returned %d", cmd, result);
}
lputs(LOG_INFO, "DAILY: System maintenance ended");
sys_status&=~SS_DAILY;
}
......
......@@ -617,7 +617,8 @@ typedef enum { /* Values for xtrn_t.event */
#define SS_USERON (1<<3) /* A User is logged on to the BBS */
#define SS_LCHAT (1<<4) /* Local chat in progress */
#define SS_ANSCAP (1<<6) /* Capture ANSI codes too */
#define SS_DAILY (1<<9) /* Execute System Daily Event on logoff */
#define SS_NEW_MONTH (1<<8) // Execute System Monthly Event
#define SS_NEW_DAY (1<<9) // Execute System Daily Event
#define SS_INUEDIT (1<<10) /* Inside Alt-Useredit section */
#define SS_ABORT (1<<11) /* Global abort input or output flag */
#define SS_SYSPAGE (1<<12) /* Paging sysop */
......@@ -637,6 +638,8 @@ typedef enum { /* Values for xtrn_t.event */
#define SS_QWKLOGON (1<<30) /* QWK logon */
#define SS_FASTLOGON (1U<<31)/* Fast logon */
#define SS_DAILY (SS_NEW_DAY | SS_NEW_MONTH)
/* Bits in 'mode' for getkey and getstr */
#define K_NONE 0 /* Use as a place holder for no mode flags */
#define K_UPPER (1<<0) /* Converts all letters to upper case */
......
......@@ -329,12 +329,13 @@ void fevents_cfg()
snprintf(opt[i++],MAX_OPLN,"%-32.32s%s","Logon Event",cfg.sys_logon);
snprintf(opt[i++],MAX_OPLN,"%-32.32s%s","Logout Event",cfg.sys_logout);
snprintf(opt[i++],MAX_OPLN,"%-32.32s%s","Daily Event",cfg.sys_daily);
snprintf(opt[i++],MAX_OPLN,"%-32.32s%s","Monthly Event",cfg.sys_monthly);
opt[i][0]=0;
uifc.helpbuf=
"`External Events:`\n"
"\n"
"From this menu, you can configure the logon and logout events, and the\n"
"system daily event.\n"
"system daily and monthly (off-line) events.\n"
;
switch(uifc.list(WIN_ACT|WIN_SAV|WIN_CHE|WIN_BOT|WIN_RHT,0,0,60,&event_dflt,0
,"Fixed Events",opt)) {
......@@ -385,6 +386,18 @@ void fevents_cfg()
uifc.input(WIN_MID|WIN_SAV,0,0,"Daily Event"
,cfg.sys_daily,sizeof(cfg.sys_daily)-1,K_EDIT);
break;
case 3:
uifc.helpbuf=
"`Monthly Event:`\n"
"\n"
"Enter a command line for a program that will run once each new month.\n"
SCFG_CMDLINE_PREFIX_HELP
SCFG_CMDLINE_SPEC_HELP
;
uifc.input(WIN_MID|WIN_SAV,0,0,"Monthly Event"
,cfg.sys_monthly,sizeof(cfg.sys_monthly)-1,K_EDIT);
break;
}
}
......
......@@ -465,6 +465,7 @@ typedef struct
enum date_fmt sys_date_fmt;
char sys_date_sep;
bool sys_date_verbal;
char sys_monthly[LEN_CMD+1]; /* Monthly event */
char sys_daily[LEN_CMD+1]; /* Daily event */
char sys_logon[LEN_CMD+1]; /* Logon event */
char sys_logout[LEN_CMD+1]; /* Logoff event */
......
......@@ -138,6 +138,7 @@ bool read_main_cfg(scfg_t* cfg, char* error, size_t maxerrlen)
SAFECOPY(cfg->sys_logon, iniGetString(ini, "logon_event", "cmd", "", value));
SAFECOPY(cfg->sys_logout, iniGetString(ini, "logout_event", "cmd", "", value));
SAFECOPY(cfg->sys_daily, iniGetString(ini, "daily_event", "cmd", "", value));
SAFECOPY(cfg->sys_monthly, iniGetString(ini, "monthly_event", "cmd", "", value));
named_str_list_t** sections = iniParseSections(ini);
......
......@@ -203,6 +203,7 @@ bool write_main_cfg(scfg_t* cfg)
iniSetString(&ini, "logon_event", "cmd", cfg->sys_logon, NULL);
iniSetString(&ini, "logout_event", "cmd", cfg->sys_logout, NULL);
iniSetString(&ini, "daily_event", "cmd", cfg->sys_daily, NULL);
iniSetString(&ini, "monthly_event", "cmd", cfg->sys_monthly, NULL);
{
const char* name = "expired";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment