Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 81e4b3be authored by rswindell's avatar rswindell

Created sbbs_t::lprintf() which calls sbbs_t::lputs() which does the magical

call to either lputs or eputs based on the node number (0 = event thread).
Created a sbbs_t::backup() wrapper for the C version which logs some helpful
debug output.
Backup the mail.hash and mail.ini file too.
Log the number of emails removed during daily maintenance.
DLL-export smb_open_sub() and smb_storage_mode() so they can be used in more
places.
parent 97c7a746
......@@ -215,6 +215,18 @@ int sbbs_t::lputs(int level, const char* str)
return ::lputs(level, str);
}
int sbbs_t::lprintf(int level, const char *fmt, ...)
{
va_list argptr;
char sbuf[1024];
va_start(argptr,fmt);
vsnprintf(sbuf,sizeof(sbuf),fmt,argptr);
sbuf[sizeof(sbuf)-1]=0;
va_end(argptr);
return(lputs(level,sbuf));
}
struct main_sock_cb_data {
bbs_startup_t *startup;
const char *protocol;
......@@ -4317,6 +4329,15 @@ void node_thread(void* arg)
thread_down();
}
bool sbbs_t::backup(const char* fname, int backup_level, bool rename)
{
if(!fexist(fname))
return false;
lprintf(LOG_DEBUG, "Backing-up %s (%lu bytes)", fname, flength(fname));
return ::backup(fname, backup_level, rename) ? true : false;
}
void sbbs_t::daily_maint(void)
{
char str[128];
......@@ -4360,6 +4381,10 @@ void sbbs_t::daily_maint(void)
backup(str,cfg.mail_backup_level,FALSE);
SAFEPRINTF(str,"%smail.sch",cfg.data_dir);
backup(str,cfg.mail_backup_level,FALSE);
SAFEPRINTF(str,"%smail.hash",cfg.data_dir);
backup(str,cfg.mail_backup_level,FALSE);
SAFEPRINTF(str,"%smail.ini",cfg.data_dir);
backup(str,cfg.mail_backup_level,FALSE);
}
lputs(LOG_INFO, "DAILY: Checking for inactive/expired user records...");
......@@ -4468,18 +4493,18 @@ void sbbs_t::daily_maint(void)
if((i=smb_locksmbhdr(&smb))!=0)
errormsg(WHERE,ERR_LOCK,smb.file,i,smb.last_error);
else
delmail(0,MAIL_ALL);
lprintf(LOG_INFO, "DAILY: Removed %d messages", delmail(0, MAIL_ALL));
}
smb_close(&smb);
}
sys_status&=~SS_DAILY;
if(cfg.sys_daily[0]) {
lputs(LOG_INFO, "DAILY: Running system event");
external(cmdstr(cfg.sys_daily,nulstr,nulstr,NULL), EX_OFFLINE);
}
status(STATUS_WFC);
lputs(LOG_INFO, "DAILY: System maintenance ended");
sys_status&=~SS_DAILY;
}
const char* DLLCALL js_ver(void)
......
......@@ -786,6 +786,7 @@ public:
/* main.cpp */
int lputs(int level, const char* str);
int lprintf(int level, const char *fmt, ...);
void printstatslog(uint node);
ulong logonstats(void);
void logoffstats(void);
......@@ -795,6 +796,7 @@ public:
bool chk_ar(const uchar * str, user_t* user, client_t* client); /* checks access requirements */
bool ar_exp(const uchar ** ptrptr, user_t*, client_t*);
void daily_maint(void);
bool backup(const char* fname, int backup_level, bool rename);
/* upload.cpp */
bool uploadfile(file_t* f);
......@@ -1098,7 +1100,8 @@ extern "C" {
DLLEXPORT BOOL DLLCALL write_chat_cfg(scfg_t* cfg, int backup_level);
DLLEXPORT BOOL DLLCALL write_xtrn_cfg(scfg_t* cfg, int backup_level);
DLLEXPORT void DLLCALL refresh_cfg(scfg_t* cfg);
DLLEXPORT int DLLCALL smb_storage_mode(scfg_t*, smb_t*);
DLLEXPORT int DLLCALL smb_open_sub(scfg_t*, smb_t*, unsigned int subnum);
/* logfile.cpp */
DLLEXPORT int DLLCALL errorlog(scfg_t* cfg, const char* host, const char* text);
......
......@@ -86,9 +86,6 @@ long aftol(char *str); /* Converts flag string to long */
char* ltoaf(long l, char *str); /* Converts long to flag string */
uchar attrstr(char *str); /* Convert ATTR string into attribute int */
int smb_storage_mode(scfg_t*, smb_t*);
int smb_open_sub(scfg_t*, smb_t*, unsigned int subnum);
#ifdef __cplusplus
}
#endif
......
......@@ -1087,12 +1087,12 @@ void DLLCALL refresh_cfg(scfg_t* cfg)
SAFEPRINTF(str,"%srecycle",cfg->ctrl_dir); ftouch(str);
}
int smb_storage_mode(scfg_t* cfg, smb_t* smb)
int DLLCALL smb_storage_mode(scfg_t* cfg, smb_t* smb)
{
if(smb->subnum == INVALID_SUB)
if(smb == NULL || smb->subnum == INVALID_SUB || (smb->status.attr&SMB_EMAIL))
return (cfg->sys_misc&SM_FASTMAIL) ? SMB_FASTALLOC : SMB_SELFPACK;
if(smb->subnum >= cfg->total_subs)
return -1;
return (smb->status.attr&SMB_HYPERALLOC) ? SMB_HYPERALLOC : SMB_FASTALLOC;
if(cfg->sub[smb->subnum]->misc&SUB_HYPER) {
smb->status.attr |= SMB_HYPERALLOC;
return SMB_HYPERALLOC;
......@@ -1102,7 +1102,7 @@ int smb_storage_mode(scfg_t* cfg, smb_t* smb)
return SMB_SELFPACK;
}
int smb_open_sub(scfg_t* cfg, smb_t* smb, unsigned int subnum)
int DLLCALL smb_open_sub(scfg_t* cfg, smb_t* smb, unsigned int subnum)
{
int retval;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment