www.pudn.com > DTMS.rar > WRITEPTR.C
#include "mail.h"
/* Write a chain ptr field somewhere in the index file:
* the free list, the hash table, or in an index record. */
void
_mail_writeptr(MAIL *mail, off_t offset, off_t ptrval)
{
char asciiptr[PTR_SZ + 1];
if (ptrval < 0 || ptrval > PTR_MAX)
err_quit("invalid ptr: %d", ptrval);
sprintf(asciiptr, "%*d", PTR_SZ, ptrval);
if (lseek(mail->idxfd, offset, SEEK_SET) == -1)
err_dump("lseek error to ptr field");
if (write(mail->idxfd, asciiptr, PTR_SZ) != PTR_SZ)
err_dump("write error of ptr field");
}