Skip to content
Snippets Groups Projects
Commit 2ef79cb1 authored by rswindell's avatar rswindell
Browse files

Don't "manage the HASH file" unless either max_msgs or max_crcs is set

(if both are zero, that implies infinite hash storage - why not).
Display message attr value in the 'r'ead mode.
Added 'D'elete message (toggle Delete attribute) in 'r'ead mode.
parent bc2eda0f
No related branches found
No related tags found
No related merge requests found
...@@ -651,7 +651,7 @@ void maint(void) ...@@ -651,7 +651,7 @@ void maint(void)
,beep,i,smb.last_error); ,beep,i,smb.last_error);
return; return;
} }
if(smb_open_hash(&smb) == SMB_SUCCESS) if((smb.status.max_msgs || smb.status.max_crcs) && smb_open_hash(&smb) == SMB_SUCCESS)
{ {
ulong max_hashes=0; ulong max_hashes=0;
...@@ -1067,7 +1067,7 @@ void packmsgs(ulong packable) ...@@ -1067,7 +1067,7 @@ void packmsgs(ulong packable)
if(!fread(&msg.idx,1,sizeof(idxrec_t),smb.sid_fp)) if(!fread(&msg.idx,1,sizeof(idxrec_t),smb.sid_fp))
break; break;
if(msg.idx.attr&MSG_DELETE) { if(msg.idx.attr&MSG_DELETE) {
printf("\nDeleted index.\n"); printf("\nDeleted index %lu: msg number %lu\n", l,(ulong) msg.idx.number);
continue; continue;
} }
i=smb_lockmsghdr(&smb,&msg); i=smb_lockmsghdr(&smb,&msg);
...@@ -1292,6 +1292,33 @@ void delmsgs(void) ...@@ -1292,6 +1292,33 @@ void delmsgs(void)
printf("\nDone.\n\n"); printf("\nDone.\n\n");
} }
int setmsgattr(smb_t* smb, ulong number, uint16_t attr)
{
int i;
smbmsg_t msg;
ZERO_VAR(msg);
if((i = smb_locksmbhdr(smb) != SMB_SUCCESS))
return i;
msg.hdr.number=number;
do {
if((i=smb_getmsgidx(smb, &msg))!=SMB_SUCCESS) /* Message is deleted */
break;
if((i=smb_lockmsghdr(smb, &msg))!=SMB_SUCCESS)
break;
if((i=smb_getmsghdr(smb, &msg))!=SMB_SUCCESS)
break;
msg.hdr.attr = attr;
i=smb_putmsg(smb, &msg);
} while(0);
smb_freemsgmem(&msg);
smb_unlockmsghdr(smb, &msg);
smb_unlocksmbhdr(smb);
return i;
}
/****************************************************************************/ /****************************************************************************/
/* Read messages in message base */ /* Read messages in message base */
/****************************************************************************/ /****************************************************************************/
...@@ -1320,11 +1347,13 @@ void readmsgs(ulong start) ...@@ -1320,11 +1347,13 @@ void readmsgs(ulong start)
if(i) { if(i) {
fprintf(errfp,"\n%s!smb_getmsghdr returned %d: %s\n" fprintf(errfp,"\n%s!smb_getmsghdr returned %d: %s\n"
,beep,i,smb.last_error); ,beep,i,smb.last_error);
smb_unlockmsghdr(&smb, &msg);
break; break;
} }
printf("\n%"PRIu32" (%d)\n",msg.hdr.number,msg.offset+1); printf("\n%"PRIu32" (%d)\n",msg.hdr.number,msg.offset+1);
printf("Subj : %s\n",msg.subj); printf("Subj : %s\n",msg.subj);
printf("Attr : %04hX\n", msg.hdr.attr);
printf("To : %s",msg.to); printf("To : %s",msg.to);
if(msg.to_net.type) if(msg.to_net.type)
printf(" (%s)",smb_netaddr(&msg.to_net)); printf(" (%s)",smb_netaddr(&msg.to_net));
...@@ -1360,6 +1389,7 @@ void readmsgs(ulong start) ...@@ -1360,6 +1389,7 @@ void readmsgs(ulong start)
"(L)ist messages\n" "(L)ist messages\n"
"(T)en more titles\n" "(T)en more titles\n"
"(V)iew message headers\n" "(V)iew message headers\n"
"(D)elete message\n"
"(Q)uit\n" "(Q)uit\n"
"(+/-) Forward/Backward\n" "(+/-) Forward/Backward\n"
"\n"); "\n");
...@@ -1393,6 +1423,10 @@ void readmsgs(ulong start) ...@@ -1393,6 +1423,10 @@ void readmsgs(ulong start)
viewmsgs(1,-1, FALSE); viewmsgs(1,-1, FALSE);
domsg=0; domsg=0;
break; break;
case 'D':
printf("Deleting message\n");
setmsgattr(&smb, msg.hdr.number, msg.hdr.attr^MSG_DELETE);
break;
case CR: case CR:
case '+': case '+':
printf("Next\n"); printf("Next\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment