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

Indicate vote/poll messages and files (with details) when listing msgs/files

Add '-v' (increase verbosity) option, used to display msg dates and timezones
... when using the the 'l' (list messages) command (to view post date/time).
Use '-vv' or '-v -v' to see timezones of messages.

The -v option is now also applicable to the 'v' (view) messages command (now
redundant with the 'V' command).

Features as requested by Nelgin as part of issue #786.

Removed day-of-week from date/times displayed. We don't need that level of
user-friendliness with this tool.
However, we are also displaying 12h/am/pm times. Some sysops probably would
prefer 24hour time, so that should be considered at some point.
parent 0fd380f8
Branches
Tags
No related merge requests found
Pipeline #6595 passed
...@@ -66,6 +66,7 @@ const char *mon[]={"Jan","Feb","Mar","Apr","May","Jun" ...@@ -66,6 +66,7 @@ const char *mon[]={"Jan","Feb","Mar","Apr","May","Jun"
/********************/ /********************/
smb_t smb; smb_t smb;
int verbosity = 0;
ulong mode=0L; ulong mode=0L;
ushort tzone=0; ushort tzone=0;
ushort xlat=XLAT_NONE; ushort xlat=XLAT_NONE;
...@@ -121,6 +122,7 @@ char *usage= ...@@ -121,6 +122,7 @@ char *usage=
" -! = wait for keypress (pause) on error\n" " -! = wait for keypress (pause) on error\n"
" -b = beep on error\n" " -b = beep on error\n"
" -r = display raw message body text (not MIME-decoded)\n" " -r = display raw message body text (not MIME-decoded)\n"
" -v = increase verbosity of console output\n"
" -C = continue after some (normally fatal) error conditions\n" " -C = continue after some (normally fatal) error conditions\n"
" -t<s> = set 'to' user name for imported message\n" " -t<s> = set 'to' user name for imported message\n"
" -n<s> = set 'to' netmail address for imported message\n" " -n<s> = set 'to' netmail address for imported message\n"
...@@ -495,6 +497,41 @@ void config(void) ...@@ -495,6 +497,41 @@ void config(void)
,beep,i,smb.last_error); ,beep,i,smb.last_error);
} }
/****************************************************************************/
/* Generates a 24 character ASCII string that represents the time_t pointer */
/* Used as a replacement for ctime() */
/****************************************************************************/
char *my_timestr(time_t intime)
{
static char str[256];
char mer[3],hour;
struct tm *gm;
gm=localtime(&intime);
if(gm==NULL) {
strcpy(str,"Invalid Time");
return(str);
}
if(gm->tm_hour>=12) {
if(gm->tm_hour==12)
hour=12;
else
hour=gm->tm_hour-12;
strcpy(mer,"pm");
}
else {
if(gm->tm_hour==0)
hour=12;
else
hour=gm->tm_hour;
strcpy(mer,"am");
}
sprintf(str,"%s %02d %4d %02d:%02d %s"
,mon[gm->tm_mon],gm->tm_mday,1900+gm->tm_year
,hour,gm->tm_min,mer);
return(str);
}
/****************************************************************************/ /****************************************************************************/
/* Lists messages' to, from, and subject */ /* Lists messages' to, from, and subject */
/****************************************************************************/ /****************************************************************************/
...@@ -527,48 +564,34 @@ void listmsgs(ulong start, ulong count) ...@@ -527,48 +564,34 @@ void listmsgs(ulong start, ulong count)
,beep,i,smb.last_error); ,beep,i,smb.last_error);
break; break;
} }
printf("%4lu/#%-4"PRIu32" %-25.25s %-25.25s %s\n" printf("%4lu/#%-4"PRIu32" ", start + l, msg.hdr.number);
,start + l, msg.hdr.number,msg.from,msg.to,msg.subj); if(verbosity > 0)
printf("%s ",my_timestr(msg.hdr.when_written.time));
if(verbosity > 1)
printf("%-9s ", smb_zonestr(msg.hdr.when_written.zone,NULL));
printf("%-25.25s", msg.from);
switch(smb_msg_type(msg.idx.attr)) {
case SMB_MSG_TYPE_FILE:
printf("*FILE %10"PRIu64" %s", smb_getfilesize(&msg.idx), msg.subj);
break;
case SMB_MSG_TYPE_BALLOT:
printf("*%-25s %04hX on msg/poll #%"PRIu32, "VOTE", msg.idx.votes, msg.idx.remsg);
break;
default:
if((msg.idx.attr&MSG_POLL_VOTE_MASK) == MSG_POLL_CLOSURE)
printf("*%-25s #%"PRIu32, "CLOSE-POLL", msg.idx.remsg);
else if(msg.idx.attr&MSG_POLL)
printf("*%-25s %s", "POLL", msg.subj);
else
printf(" %-25.25s %s", msg.to, msg.subj);
break;
}
printf("\n");
smb_freemsgmem(&msg); smb_freemsgmem(&msg);
l++; l++;
} }
} }
/****************************************************************************/
/* Generates a 24 character ASCII string that represents the time_t pointer */
/* Used as a replacement for ctime() */
/****************************************************************************/
char *my_timestr(time_t intime)
{
static char str[256];
char mer[3],hour;
struct tm *gm;
gm=localtime(&intime);
if(gm==NULL) {
strcpy(str,"Invalid Time");
return(str);
}
if(gm->tm_hour>=12) {
if(gm->tm_hour==12)
hour=12;
else
hour=gm->tm_hour-12;
strcpy(mer,"pm");
}
else {
if(gm->tm_hour==0)
hour=12;
else
hour=gm->tm_hour;
strcpy(mer,"am");
}
sprintf(str,"%s %s %02d %4d %02d:%02d %s"
,wday[gm->tm_wday],mon[gm->tm_mon],gm->tm_mday,1900+gm->tm_year
,hour,gm->tm_min,mer);
return(str);
}
/****************************************************************************/ /****************************************************************************/
/****************************************************************************/ /****************************************************************************/
void dumpindex(ulong start, ulong count) void dumpindex(ulong start, ulong count)
...@@ -1767,11 +1790,7 @@ int main(int argc, char **argv) ...@@ -1767,11 +1790,7 @@ int main(int argc, char **argv)
} }
for(x=1;x<argc && x>0;x++) { for(x=1;x<argc && x>0;x++) {
if( if(argv[x][0]=='-') {
#ifndef __unix__
argv[x][0]=='/' || /* for backwards compatibilty */
#endif
argv[x][0]=='-') {
if(IS_DIGIT(argv[x][1])) { if(IS_DIGIT(argv[x][1])) {
count=strtol(argv[x]+1,NULL,10); count=strtol(argv[x]+1,NULL,10);
continue; continue;
...@@ -1860,6 +1879,9 @@ int main(int argc, char **argv) ...@@ -1860,6 +1879,9 @@ int main(int argc, char **argv)
case 'b': case 'b':
beep="\a"; beep="\a";
break; break;
case 'v':
++verbosity;
break;
default: default:
fprintf(stderr, "\nUnknown opt '%c'\n", argv[x][j]); fprintf(stderr, "\nUnknown opt '%c'\n", argv[x][j]);
// fall-through // fall-through
...@@ -2013,7 +2035,7 @@ int main(int argc, char **argv) ...@@ -2013,7 +2035,7 @@ int main(int argc, char **argv)
break; break;
case 'v': case 'v':
case 'V': case 'V':
viewmsgs(getmsgnum(cmd+1),count,cmd[y]=='V'); viewmsgs(getmsgnum(cmd+1),count,cmd[y]=='V' || verbosity > 0);
y=strlen(cmd)-1; y=strlen(cmd)-1;
break; break;
case 'h': case 'h':
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment