/*
* we're going to all this trouble of fiddling the .imp file for
* the target mailbox because we wish to save the flags. we
* should be using upas/fs's flags instead.
*
* note. appendmb for mbox fmt wants to lock the directory.
* since the locking is intentionally broken, we could get by
* with aquiring the lock before we fire up appendmb and
* trust that he doesn't worry if he does acquire the lock.
* instead, we'll just do locking around the .imp file.
*/
static int
savemsg(char *dst, int flags, char *head, int nhead, Biobuf *b, long n, Uidplus *u)
{
char *digest, buf[Bufsize + 1], digbuf[Ndigest + 1], folder[Pathlen];
uchar shadig[SHA1dlen];
int i, fd, pid, nr, ok;
DigestState *dstate;
Mblock *ml;
int
copysaveu(Box *box, Msg *m, int i, void *vs)
{
int ok;
Uidplus *u;
u = binalloc(&parsebin, sizeof *u, 1);
ok = copysave(box, m, i, vs, u);
*uidtl = u;
uidtl = &u->next;
return ok;
}
/*
* first spool the input into a temorary file,
* and massage the input in the process.
* then save to real box.
*/
/*
* copy from bin to bout,
* map "\r\n" to "\n" and
* return the number of bytes in the mapped file.
*
* exactly n bytes must be read from the input,
* unless an input error occurs.
*/
static long
spool(Biobuf *bout, Biobuf *bin, long n)
{
int c;