isync.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* isync - IMAP4 to maildir mailbox synchronizer
  2. * Copyright (C) 2000 Michael R. Elkins <me@mutt.org>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #include <stdarg.h>
  19. typedef struct
  20. {
  21. int fd;
  22. char buf[1024];
  23. int bytes;
  24. int offset;
  25. }
  26. buffer_t;
  27. typedef struct config config_t;
  28. typedef struct mailbox mailbox_t;
  29. typedef struct message message_t;
  30. struct config
  31. {
  32. char *path;
  33. char *host;
  34. int port;
  35. char *user;
  36. char *pass;
  37. char *box;
  38. char *alias;
  39. config_t *next;
  40. };
  41. /* struct representing local mailbox file */
  42. struct mailbox
  43. {
  44. char *path;
  45. message_t *msgs;
  46. unsigned int changed:1;
  47. };
  48. /* message dispositions */
  49. #define D_SEEN (1<<0)
  50. #define D_ANSWERED (1<<1)
  51. #define D_DELETED (1<<2)
  52. #define D_FLAGGED (1<<3)
  53. #define D_RECENT (1<<4)
  54. #define D_DRAFT (1<<5)
  55. #define D_MAX 6
  56. struct message
  57. {
  58. char *file;
  59. unsigned int uid;
  60. unsigned int flags;
  61. message_t *next;
  62. unsigned int processed:1; /* message has already been evaluated */
  63. unsigned int new:1; /* message is in the new/ subdir */
  64. unsigned int changed:1; /* flags changed */
  65. unsigned int dead:1; /* message doesn't exist on the server */
  66. };
  67. /* imap connection info */
  68. typedef struct
  69. {
  70. int fd; /* server socket */
  71. unsigned int count; /* # of msgs */
  72. unsigned int recent; /* # of recent messages */
  73. buffer_t *buf; /* input buffer for reading server output */
  74. message_t *msgs; /* list of messages on the server */
  75. config_t *box; /* mailbox to open */
  76. message_t *recent_msgs; /* list of recent messages - only contains
  77. * UID to be used in a FETCH FLAGS command
  78. */
  79. }
  80. imap_t;
  81. /* flags for sync_mailbox */
  82. #define SYNC_FAST (1<<0) /* don't sync flags, only fetch new msgs */
  83. #define SYNC_DELETE (1<<1) /* delete local that don't exist on server */
  84. extern config_t global;
  85. extern unsigned int Tag;
  86. extern char Hostname[256];
  87. extern int Verbose;
  88. char *next_arg (char **);
  89. int sync_mailbox (mailbox_t *, imap_t *, int);
  90. void imap_close (imap_t *);
  91. int imap_fetch_message (imap_t *, unsigned int, int);
  92. int imap_set_flags (imap_t *, unsigned int, unsigned int);
  93. int imap_expunge (imap_t *);
  94. imap_t *imap_open (config_t *, int);
  95. mailbox_t *maildir_open (const char *, int fast);
  96. int maildir_expunge (mailbox_t *, int);
  97. int maildir_sync (mailbox_t *);