?? dodelete.c
字號:
#include "mail.h"/* Delete the current record specified by the mail structure. * This function is called by mail_delete() and mail_store(), * after the record has been located by _mail_find(). */int_mail_dodelete(MAIL *mail){ int i; char *ptr; off_t freeptr, saveptr; /* Set data buffer to all blanks */ for (ptr = mail->datbuf, i = 0; i < mail->datlen - 1; i++) *ptr++ = ' '; *ptr = 0; /* null terminate for _mail_writedat() */ /* Set key to blanks */ ptr = mail->idxbuf; while (*ptr) *ptr++ = ' '; /* We have to lock the free list */ if (writew_lock(mail->idxfd, FREE_OFF, SEEK_SET, 1) < 0) err_dump("writew_lock error"); /* Write the data record with all blanks */ _mail_writedat(mail, mail->datbuf, mail->datoff, SEEK_SET); /* Read the free list pointer. Its value becomes the chain ptr field of the deleted index record. This means the deleted record becomes the head of the free list. */ freeptr = _mail_readptr(mail, FREE_OFF); /* Save the contents of index record chain ptr, before it's rewritten by _mail_writeidx(). */ saveptr = mail->ptrval; /* Rewrite the index record. This also rewrites the length of the index record, the data offset, and the data length, none of which has changed, but that's OK. */ _mail_writeidx(mail,NULL, mail->idxoff, SEEK_SET, freeptr); /* Write the new free list pointer */ _mail_writeptr(mail, FREE_OFF, mail->idxoff); /* Rewrite the chain ptr that pointed to this record being deleted. Recall that _mail_find() sets mail->ptroff to point to this chain ptr. We set this chain ptr to the contents of the deleted record's chain ptr, saveptr, which can be either zero or nonzero. */ _mail_writeptr(mail, mail->ptroff, saveptr); if (un_lock(mail->idxfd, FREE_OFF, SEEK_SET, 1) < 0) err_dump("un_lock error"); return(0);}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -