summaryrefslogtreecommitdiff
path: root/include/mailutils/sys/dotmail.h
blob: 800348bd67c6445ebc49d343088c671395b12964 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* GNU Mailutils -- a suite of utilities for electronic mail
   Copyright (C) 2019 Free Software Foundation, Inc.

   This library is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public License
   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */

#ifndef _MAILUTILS_SYS_DOTMAIL_H
#define _MAILUTILS_SYS_DOTMAIL_H

# include <mailutils/types.h>

enum mu_dotmail_hdr
  {
    mu_dotmail_hdr_status,
    mu_dotmail_hdr_x_imapbase,
    mu_dotmail_hdr_x_uid,
    MU_DOTMAIL_HDR_MAX
  } status;

struct mu_dotmail_message
{
  /* Offsets in the mailbox */
  mu_off_t message_start; /* Start of message */
  mu_off_t body_start;    /* Start of body */
  mu_off_t message_end;   /* End of message */
  /* Additional info */
  size_t body_size;       /* Number of octets in unstuffed message body */
  size_t body_lines;      /* Number of lines in message body */
  unsigned long uid;      /* IMAP-style uid.  */
  char *hdr[MU_DOTMAIL_HDR_MAX]; /* Pre-scanned headers */
  unsigned body_dot_stuffed:1;   /* True if body is dot-stuffed */
  unsigned attr_scanned:1;       /* True if attr_flags is initialized */
  unsigned body_lines_scanned:1; /* True if body_lines is initialized */
  unsigned uid_modified:1;/* UID|uidvalidity|uidnext has been modified */
  int attr_flags;         /* Packed "Status:" attribute flags */
  mu_message_t message;   /* Pointer to the message object if any */
  /* Backlink to the mailbox */
  struct mu_dotmail_mailbox *mbox; /* Mailbox */
  size_t num;             /* Number of this message in the mailbox (0-based) */
};

struct mu_dotmail_message_ref
{
  size_t orig_num;        /* Original message index */
  mu_off_t message_start; /* Start of message */
  mu_off_t body_start;    /* Start of body */
  mu_off_t message_end;   /* End of message */
  int rescan;
};

struct mu_dotmail_mailbox
{
  char *name;                /* Disk file name */
  mu_mailbox_t mailbox;      /* Associated mailbox */

  mu_off_t size;             /* Size of the mailbox.  */
  unsigned long uidvalidity; /* Uidvalidity value */
  unsigned long uidnext;     /* Expected next UID value */
  unsigned uidvalidity_scanned:1; /* True if uidvalidity is initialized */
  
  struct mu_dotmail_message **mesg; /* Array of messages */
  size_t mesg_count;       /* Number of messages in mesgv */
  size_t mesg_max;         /* Actual capacity of mesg */
};

int mu_dotmail_mailbox_init (mu_mailbox_t mailbox);
void mu_dotmail_message_free (struct mu_dotmail_message *dmsg);
int mu_dotmail_message_get (struct mu_dotmail_message *dmsg, mu_message_t *mptr);
int mu_dotmail_message_attr_load (struct mu_dotmail_message *dmsg);
int mu_dotmail_mailbox_uid_setup (struct mu_dotmail_mailbox *dmp);
int mu_dotmail_message_reconstruct (mu_stream_t dest,
				    struct mu_dotmail_message *dmsg,
				    struct mu_dotmail_message_ref *ref);

#endif  

Return to:

Send suggestions and report system problems to the System administrator.