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 2bfd3b01 authored by rswindell's avatar rswindell

Created convenience function for opening a sub-board or mail base

"the right way", this will be used to replace a lot of copy/pasta over time.
parent 7069b1f4
......@@ -87,6 +87,7 @@ 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
}
......
......@@ -860,3 +860,30 @@ int smb_storage_mode(scfg_t* cfg, smb_t* smb)
return SMB_FASTALLOC;
return SMB_SELFPACK;
}
int smb_open_sub(scfg_t* cfg, smb_t* smb, unsigned int subnum)
{
int retval;
if(subnum != INVALID_SUB && subnum >= cfg->total_subs)
return SMB_FAILURE;
memset(smb, 0, sizeof(smb_t));
if(subnum == INVALID_SUB) {
SAFEPRINTF(smb->file, "%smail", cfg->data_dir);
smb->status.max_crcs = cfg->mail_maxcrcs;
smb->status.max_msgs = 0;
smb->status.max_age = cfg->mail_maxage;
smb->status.attr = SMB_EMAIL;
} else {
SAFEPRINTF2(smb->file, "%s%s", cfg->sub[subnum]->data_dir, cfg->sub[subnum]->code);
smb->status.max_crcs = cfg->sub[subnum]->maxcrcs;
smb->status.max_msgs = cfg->sub[subnum]->maxmsgs;
smb->status.max_age = cfg->sub[subnum]->maxage;
smb->status.attr = cfg->sub[subnum]->misc&SUB_HYPER ? SMB_HYPERALLOC :0;
}
smb->retry_time = cfg->smb_retry_time;
if((retval = smb_open(smb)) == SMB_SUCCESS)
smb->subnum = subnum;
return 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