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 0868c5d9 authored by rswindell's avatar rswindell

@-code changes:

Expanded codes will not *not* go beyond the terminal column width (minus 1).
If you need the old/wrap behavior, add a "-W" modifier to your @-code.
If a length value is specified with -W, it is ignored.

- MSG_TO, MSG_FROM, MSG_SUBJECT now reflect the header values passed
  to sbbs_t::show_msghdr(), JS bbs.show_msg_header() and not necessarily the
  actual stored (e.g. MIME-encoded) header values.

New codes:
- MSG_CC - reflect a message's CC list, if it has one
- DATETIMEZONE - combines DATETIME and TIMEZONE in one string
parent f3dfd635
......@@ -56,6 +56,7 @@ int sbbs_t::show_atcode(const char *instr)
bool padded_right=false;
bool centered=false;
bool zero_padded=false;
bool truncated = true;
const char *cp;
SAFECOPY(str,instr);
......@@ -78,9 +79,12 @@ int sbbs_t::show_atcode(const char *instr)
centered=true;
else if((p=strstr(sp,"-Z"))!=NULL)
zero_padded=true;
else if((p=strstr(sp,"-W"))!=NULL) /* wrap */
truncated = false;
if(p!=NULL) {
if(*(p+2) && isdigit(*(p+2)))
disp_len=atoi(p+2);
char* lp = p + 2;
if(*lp && isdigit(*lp))
disp_len=atoi(lp);
*p=0;
}
......@@ -88,6 +92,17 @@ int sbbs_t::show_atcode(const char *instr)
if(cp==NULL)
return(0);
if(p==NULL || truncated == false)
disp_len = strlen(cp);
if(truncated) {
if(column + disp_len > cols - 1) {
if(column >= cols - 1)
disp_len = 0;
else
disp_len = (cols - 1) - column;
}
}
if(padded_left)
bprintf("%-*.*s",disp_len,disp_len,cp);
else if(padded_right)
......@@ -106,7 +121,7 @@ int sbbs_t::show_atcode(const char *instr)
else
bprintf("%.*s", disp_len, cp);
} else
bputs(cp);
bprintf("%.*s", disp_len, cp);
return(len);
}
......@@ -289,6 +304,12 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
if(!strcmp(sp,"DATETIME"))
return(timestr(time(NULL)));
if(!strcmp(sp,"DATETIMEZONE")) {
char zone[32];
safe_snprintf(str, maxlen, "%s %s", timestr(time(NULL)), smb_zonestr(sys_timezone(&cfg),zone));
return str;
}
if(!strcmp(sp,"TMSG")) {
l=0;
for(i=0;i<cfg.total_subs;i++)
......@@ -1013,21 +1034,19 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
}
/* Message header codes */
if(!strcmp(sp,"MSG_TO") && current_msg!=NULL) {
if(current_msg->to==NULL)
return(nulstr);
if(!strcmp(sp,"MSG_TO") && current_msg!=NULL && current_msg_to!=NULL) {
if(current_msg->to_ext!=NULL)
safe_snprintf(str,maxlen,"%s #%s",current_msg->to,current_msg->to_ext);
safe_snprintf(str,maxlen,"%s #%s",current_msg_to,current_msg->to_ext);
else if(current_msg->to_net.addr != NULL) {
char tmp[128];
safe_snprintf(str,maxlen,"%s (%s)",current_msg->to
safe_snprintf(str,maxlen,"%s (%s)",current_msg_to
,smb_netaddrstr(&current_msg->to_net,tmp));
} else
return(current_msg->to);
return(current_msg_to);
return(str);
}
if(!strcmp(sp,"MSG_TO_NAME") && current_msg!=NULL)
return(current_msg->to==NULL ? nulstr : current_msg->to);
if(!strcmp(sp,"MSG_TO_NAME") && current_msg_to!=NULL)
return(current_msg_to);
if(!strcmp(sp,"MSG_TO_EXT") && current_msg!=NULL) {
if(current_msg->to_ext==NULL)
return(nulstr);
......@@ -1043,27 +1062,25 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
return nulstr;
return(smb_nettype((enum smb_net_type)current_msg->to_net.type));
}
if(!strcmp(sp,"MSG_FROM") && current_msg!=NULL) {
if(current_msg->from==NULL)
return(nulstr);
if(!strcmp(sp,"MSG_CC") && current_msg!=NULL)
return(current_msg->cc_list == NULL ? nulstr : current_msg->cc_list);
if(!strcmp(sp,"MSG_FROM") && current_msg != NULL && current_msg_from != NULL) {
if(current_msg->hdr.attr&MSG_ANONYMOUS && !SYSOP)
return(text[Anonymous]);
if(current_msg->from_ext!=NULL)
safe_snprintf(str,maxlen,"%s #%s",current_msg->from,current_msg->from_ext);
safe_snprintf(str,maxlen,"%s #%s",current_msg_from,current_msg->from_ext);
else if(current_msg->from_net.addr != NULL) {
char tmp[128];
safe_snprintf(str,maxlen,"%s (%s)",current_msg->from
safe_snprintf(str,maxlen,"%s (%s)",current_msg_from
,smb_netaddrstr(&current_msg->from_net,tmp));
} else
return(current_msg->from);
return(current_msg_from);
return(str);
}
if(!strcmp(sp,"MSG_FROM_NAME") && current_msg!=NULL) {
if(current_msg->from==NULL)
return(nulstr);
if(!strcmp(sp,"MSG_FROM_NAME") && current_msg_from!=NULL) {
if(current_msg->hdr.attr&MSG_ANONYMOUS && !SYSOP)
return(text[Anonymous]);
return(current_msg->from);
return(current_msg_from);
}
if(!strcmp(sp,"MSG_FROM_EXT") && current_msg!=NULL) {
if(!(current_msg->hdr.attr&MSG_ANONYMOUS) || SYSOP)
......@@ -1082,8 +1099,8 @@ const char* sbbs_t::atcode(char* sp, char* str, size_t maxlen)
return nulstr;
return(smb_nettype((enum smb_net_type)current_msg->from_net.type));
}
if(!strcmp(sp,"MSG_SUBJECT") && current_msg!=NULL)
return(current_msg->subj==NULL ? nulstr : current_msg->subj);
if(!strcmp(sp,"MSG_SUBJECT") && current_msg_subj != NULL)
return(current_msg_subj);
if(!strcmp(sp,"MSG_SUMMARY") && current_msg!=NULL)
return(current_msg->summary==NULL ? nulstr : current_msg->summary);
if(!strcmp(sp,"MSG_TAGS") && current_msg!=NULL)
......
......@@ -129,8 +129,18 @@ void sbbs_t::show_msghdr(smb_t* smb, smbmsg_t* msg, const char* subject, const c
if(smb != NULL)
this->smb = *smb; // Needed for @-codes and JS bbs.smb_* properties
if(msg != NULL)
if(msg != NULL) {
current_msg = msg; // Needed for @-codes and JS bbs.msg_* properties
current_msg_subj = msg->subj;
current_msg_from = msg->from;
current_msg_to = msg->to;
}
if(subject != NULL)
current_msg_subj = subject;
if(from != NULL)
current_msg_from = from;
if(to != NULL)
current_msg_to = to;
attr(LIGHTGRAY);
if(!tos) {
......@@ -141,13 +151,13 @@ void sbbs_t::show_msghdr(smb_t* smb, smbmsg_t* msg, const char* subject, const c
}
msghdr_tos = tos;
if(!menu("msghdr", P_NOERROR)) {
bprintf(text[MsgSubj], subject == NULL ? msg->subj : subject);
bprintf(text[MsgSubj], current_msg_subj);
if(msg->tags && *msg->tags)
bprintf(text[MsgTags], msg->tags);
if(msg->hdr.attr)
show_msgattr(msg);
if(to != NULL || msg->to_list != NULL || (msg->to && *msg->to)) {
bprintf(text[MsgTo], to == NULL ? (msg->to_list == NULL ? msg->to : msg->to_list) : to);
if(current_msg_to != NULL && *current_msg_to != 0) {
bprintf(text[MsgTo], current_msg_to);
if(msg->to_net.addr!=NULL)
bprintf(text[MsgToNet],smb_netaddrstr(&msg->to_net,str));
if(msg->to_ext)
......@@ -155,11 +165,11 @@ void sbbs_t::show_msghdr(smb_t* smb, smbmsg_t* msg, const char* subject, const c
}
if(msg->cc_list != NULL)
bprintf(text[MsgCarbonCopyList], msg->cc_list);
if((from != NULL || msg->from != NULL) && (!(msg->hdr.attr&MSG_ANONYMOUS) || SYSOP)) {
bprintf(text[MsgFrom], from == NULL ? msg->from : from);
if(current_msg_from != NULL && (!(msg->hdr.attr&MSG_ANONYMOUS) || SYSOP)) {
bprintf(text[MsgFrom], current_msg_from);
if(msg->from_ext)
bprintf(text[MsgFromExt],msg->from_ext);
if(msg->from_net.addr!=NULL && (msg->from == NULL || strchr(msg->from,'@')==NULL))
if(msg->from_net.addr!=NULL && (current_msg_from == NULL || strchr(current_msg_from,'@')==NULL))
bprintf(text[MsgFromNet],smb_netaddrstr(&msg->from_net,str));
}
if(!(msg->hdr.attr&MSG_POLL) && (msg->upvotes || msg->downvotes))
......@@ -181,6 +191,9 @@ void sbbs_t::show_msghdr(smb_t* smb, smbmsg_t* msg, const char* subject, const c
,timestr(*(time32_t *)msg->hfield_dat[i]));
}
this->smb = saved_smb;
current_msg_subj = NULL;
current_msg_from = NULL;
current_msg_to = NULL;
}
/****************************************************************************/
......
......@@ -551,10 +551,10 @@ static JSBool js_bbs_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
/* Currently Displayed Message Header (sbbs.current_msg) */
case BBS_PROP_MSG_TO:
if(sbbs->current_msg==NULL || sbbs->current_msg->to==NULL)
if(sbbs->current_msg_to==NULL)
p=nulstr;
else
p=sbbs->current_msg->to;
p=sbbs->current_msg_to;
break;
case BBS_PROP_MSG_TO_EXT:
if(sbbs->current_msg==NULL || sbbs->current_msg->to_ext==NULL)
......@@ -573,10 +573,10 @@ static JSBool js_bbs_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
val=sbbs->current_msg->to_agent;
break;
case BBS_PROP_MSG_FROM:
if(sbbs->current_msg==NULL || sbbs->current_msg->from==NULL)
if(sbbs->current_msg_from==NULL)
p=nulstr;
else
p=sbbs->current_msg->from;
p=sbbs->current_msg_from;
break;
case BBS_PROP_MSG_FROM_EXT:
if(sbbs->current_msg==NULL || sbbs->current_msg->from_ext==NULL)
......@@ -618,10 +618,10 @@ static JSBool js_bbs_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
break;
case BBS_PROP_MSG_SUBJECT:
if(sbbs->current_msg==NULL || sbbs->current_msg->subj==NULL)
if(sbbs->current_msg_subj==NULL)
p=nulstr;
else
p=sbbs->current_msg->subj;
p=sbbs->current_msg_subj;
break;
case BBS_PROP_MSG_DATE:
if(sbbs->current_msg!=NULL)
......
......@@ -3421,6 +3421,9 @@ sbbs_t::sbbs_t(ushort node_num, union xp_sockaddr *addr, size_t addr_len, const
nodefile_fp=NULL;
node_ext_fp=NULL;
current_msg=NULL;
current_msg_subj=NULL;
current_msg_from=NULL;
current_msg_to=NULL;
current_file=NULL;
mnestr=NULL;
......
......@@ -542,6 +542,9 @@ public:
csi_t main_csi; /* Main Command Shell Image */
smbmsg_t* current_msg; /* For message header @-codes */
const char* current_msg_subj;
const char* current_msg_from;
const char* current_msg_to;
file_t* current_file;
/* Global command shell variables */
......
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