Skip to content
Snippets Groups Projects
Commit 338c2710 authored by rswindell's avatar rswindell
Browse files

New @-codes: MSG_AGE (the age of the message in days, months, etc.)

@-codes can now be center-justified by using the *new* -C suffix (like -L/R).
Centered expanded values are not truncated to fit the @-code length however
(that may change).
SMB_AREAS and SMB_AREA_DESC @-codes now display "Email" and "Personal Email"
rather than a blank/empty string when the current message base is the mail base.
parent ef30a78f
Branches
Tags
No related merge requests found
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* * * *
* Copyright 2014 Rob Swindell - http://www.synchro.net/copyright.html * * Copyright Rob Swindell - http://www.synchro.net/copyright.html *
* * * *
* This program is free software; you can redistribute it and/or * * This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License * * modify it under the terms of the GNU General Public License *
...@@ -55,6 +55,7 @@ int sbbs_t::show_atcode(const char *instr) ...@@ -55,6 +55,7 @@ int sbbs_t::show_atcode(const char *instr)
int disp_len; int disp_len;
bool padded_left=false; bool padded_left=false;
bool padded_right=false; bool padded_right=false;
bool centered=false;
const char *cp; const char *cp;
SAFECOPY(str,instr); SAFECOPY(str,instr);
...@@ -73,6 +74,8 @@ int sbbs_t::show_atcode(const char *instr) ...@@ -73,6 +74,8 @@ int sbbs_t::show_atcode(const char *instr)
padded_left=true; padded_left=true;
else if((p=strstr(sp,"-R"))!=NULL) else if((p=strstr(sp,"-R"))!=NULL)
padded_right=true; padded_right=true;
else if((p=strstr(sp,"-C"))!=NULL)
centered=true;
if(p!=NULL) { if(p!=NULL) {
if(*(p+2) && isdigit(*(p+2))) if(*(p+2) && isdigit(*(p+2)))
disp_len=atoi(p+2); disp_len=atoi(p+2);
...@@ -87,7 +90,14 @@ int sbbs_t::show_atcode(const char *instr) ...@@ -87,7 +90,14 @@ int sbbs_t::show_atcode(const char *instr)
bprintf("%-*.*s",disp_len,disp_len,cp); bprintf("%-*.*s",disp_len,disp_len,cp);
else if(padded_right) else if(padded_right)
bprintf("%*.*s",disp_len,disp_len,cp); bprintf("%*.*s",disp_len,disp_len,cp);
else else if(centered) {
size_t vlen = strlen(cp);
if(vlen < disp_len) {
int left = (disp_len - vlen) / 2;
bprintf("%*s%-*s", left, "", disp_len - left, cp);
} else
bputs(cp);
} else
bputs(cp); bputs(cp);
return(len); return(len);
...@@ -969,6 +979,9 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen) ...@@ -969,6 +979,9 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
return(current_msg->subj==NULL ? nulstr : current_msg->subj); return(current_msg->subj==NULL ? nulstr : current_msg->subj);
if(!strcmp(sp,"MSG_DATE") && current_msg!=NULL) if(!strcmp(sp,"MSG_DATE") && current_msg!=NULL)
return(timestr(current_msg->hdr.when_written.time)); return(timestr(current_msg->hdr.when_written.time));
if(!strcmp(sp,"MSG_AGE") && current_msg!=NULL)
return age_of_posted_item(str, maxlen
, current_msg->hdr.when_written.time - (smb_tzutc(current_msg->hdr.when_written.zone) * 60));
if(!strcmp(sp,"MSG_TIMEZONE") && current_msg!=NULL) if(!strcmp(sp,"MSG_TIMEZONE") && current_msg!=NULL)
return(smb_zonestr(current_msg->hdr.when_written.zone,NULL)); return(smb_zonestr(current_msg->hdr.when_written.zone,NULL));
if(!strcmp(sp,"MSG_ATTR") && current_msg!=NULL) { if(!strcmp(sp,"MSG_ATTR") && current_msg!=NULL) {
...@@ -1033,6 +1046,8 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen) ...@@ -1033,6 +1046,8 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
safe_snprintf(str,maxlen,"%s %s" safe_snprintf(str,maxlen,"%s %s"
,cfg.grp[cfg.sub[smb.subnum]->grp]->sname ,cfg.grp[cfg.sub[smb.subnum]->grp]->sname
,cfg.sub[smb.subnum]->sname); ,cfg.sub[smb.subnum]->sname);
else
strncpy(str, "Email", maxlen);
return(str); return(str);
} }
if(!strcmp(sp,"SMB_AREA_DESC")) { if(!strcmp(sp,"SMB_AREA_DESC")) {
...@@ -1040,6 +1055,8 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen) ...@@ -1040,6 +1055,8 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
safe_snprintf(str,maxlen,"%s %s" safe_snprintf(str,maxlen,"%s %s"
,cfg.grp[cfg.sub[smb.subnum]->grp]->lname ,cfg.grp[cfg.sub[smb.subnum]->grp]->lname
,cfg.sub[smb.subnum]->lname); ,cfg.sub[smb.subnum]->lname);
else
strncpy(str, "Personal Email", maxlen);
return(str); return(str);
} }
if(!strcmp(sp,"SMB_GROUP")) { if(!strcmp(sp,"SMB_GROUP")) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment