summaryrefslogtreecommitdiffstats
path: root/imap/imapscanclient.h
blob: 373bc83320d100dfe22504ab6068d85fbddccf5d (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
86
87
88
89
90
91
92
93
94
95
#ifndef	imapscanclient_h
#define	imapscanclient_h

#include "config.h"
#include "maildir/maildirkeywords.h"

/*
** Copyright 1998 - 2003 Double Precision, Inc.
** See COPYING for distribution information.
*/

/*
** Stuff we want to know about an individual message in the maildir.
*/

struct imapscanmessageinfo {
	unsigned long uid;	/* See RFC 2060 */
	char *filename;
	struct libmail_kwMessage *keywordMsg; /* If not NULL - keywords */
	char recentflag;
	char changedflags;	/* Set by imapscan_open */
	char copiedflag;	/* This message was copied to another folder */

	char storeflag;  /* Used by imap_addRemoveKeywords() */

	char err8bitflag;       /* Invalid 8 bit header error was reported */
	/* When reading keywords, hash messages by filename */

	struct imapscanmessageinfo *firstBucket, *nextBucket;

	} ;

/*
** Stuff we want to know about the maildir.
*/

struct imapscaninfo {
	unsigned long nmessages;	/* # of messages */
	unsigned long uidv;		/* See RFC 2060 */
	unsigned long left_unseen;
	unsigned long nextuid;

	struct libmail_kwHashtable *keywordList; /* All defined keywords */

	struct imapscanmessageinfo *msgs;
	struct maildirwatch *watcher;
	} ;

/*
** In imapscan_maildir, move the following msgs to cur.
*/

struct uidplus_info {
	struct uidplus_info *next;
	char *tmpfilename;
	char *curfilename;

	char *tmpkeywords;
	char *newkeywords;

	unsigned long uid; /* Initialized by imapscan_maildir2 */
	unsigned long old_uid; /* Initialized by do_copy() */

	time_t mtime;
} ;


void imapscan_init(struct imapscaninfo *p);
void imapscan_copy(struct imapscaninfo *a,
		   struct imapscaninfo *b);

int imapscan_maildir(struct imapscaninfo *, const char *, int, int,
		     struct uidplus_info *);
void imapscan_free(struct imapscaninfo *);

int imapscan_openfile(const char *, struct imapscaninfo *, unsigned);


struct libmail_kwMessage *imapscan_createKeyword(struct imapscaninfo *,
					      unsigned long n);

int imapscan_updateKeywords(const char *filename,
			    struct libmail_kwMessage *newKeywords);

int imapscan_restoreKeywordSnapshot(FILE *, struct imapscaninfo *);
int imapscan_saveKeywordSnapshot(FILE *fp, struct imapscaninfo *);

int imapmaildirlock(struct imapscaninfo *scaninfo,
		    const char *maildir,
		    int (*func)(void *),
		    void *void_arg);

char *readline(unsigned, FILE *);

#endif