Commit c4c9902d authored by Rob Swindell's avatar Rob Swindell

Replace ESC chars with '.' when viewing messages, support '-<count>' with 'r'.

When reading messages, circumvent ANSI-encoded messages by replacing the ESC
character (ASCII 27) with '.'. This could be made an optional behavior if
someone really wants ANSI-encoded messages to be read via smbutil.

Also, allow continuous reading of 1 or more consecutive messages using the
-<digit> option (no prompting).
parent 43260b05
Pipeline #316 passed with stage
in 18 minutes and 53 seconds
......@@ -1381,10 +1381,11 @@ int setmsgattr(smb_t* smb, ulong number, uint16_t attr)
/****************************************************************************/
/* Read messages in message base */
/****************************************************************************/
void readmsgs(ulong start)
void readmsgs(ulong start, ulong count)
{
char *inbuf;
int i,done=0,domsg=1;
ulong rd = 0;
smbmsg_t msg;
if(start)
......@@ -1426,6 +1427,8 @@ void readmsgs(ulong start)
printf("\n\n");
if((inbuf=smb_getmsgtxt(&smb,&msg, msgtxtmode))!=NULL) {
char* p;
REPLACE_CHARS(inbuf, ESC, '.', p);
printf("%s",remove_ctrl_a(inbuf, inbuf));
free(inbuf);
}
......@@ -1436,9 +1439,16 @@ void readmsgs(ulong start)
,beep,i,smb.last_error);
break;
}
smb_freemsgmem(&msg);
smb_freemsgmem(&msg);
rd++;
}
domsg=1;
if(count) {
if(rd >= count)
break;
msg.offset++;
continue;
}
printf("\nReading %s (?=Menu): ",smb.file);
switch(toupper(getch())) {
case '?':
......@@ -1816,7 +1826,7 @@ int main(int argc, char **argv)
fprintf(errfp, "\nError %d (%s) unlocking %s\n", i, smb.last_error, smb.file);
break;
case 'r':
readmsgs(getmsgnum(cmd+1));
readmsgs(getmsgnum(cmd+1), count);
y=strlen(cmd)-1;
break;
case 'R':
......
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