summaryrefslogtreecommitdiff
path: root/pith/imap.h
blob: d58f4e3c865edbe5e73104c86a6630caa2da3e6d (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*
 * $Id: imap.h 1074 2008-06-04 00:08:43Z hubert@u.washington.edu $
 *
 * ========================================================================
 * Copyright 2013-2018 Eduardo Chappa
 * Copyright 2006 University of Washington
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * ========================================================================
 */

#ifndef PITH_IMAP_INCLUDED
#define PITH_IMAP_INCLUDED


#include "../pith/string.h"


#define NETMAXPASSWD 100


/*
 * struct used to keep track of password/host/user triples.
 * The problem is we only want to try user names and passwords if
 * we've already tried talking to this host before.
 * 
 */
typedef struct _mmlogin_s {
    char	   *user,
		   *passwd;
    unsigned	    altflag:1;
    unsigned	    ok_novalidate:1;
    unsigned	    warned:1;
    STRLIST_S	   *hosts;
    struct _mmlogin_s *next;
} MMLOGIN_S;


typedef	struct _se_app_s {
    char *folder;
    long  flags;
} SE_APP_S;


/*
 * struct to help manage mail_list calls/callbacks
 */
typedef	struct mm_list_s {
    MAILSTREAM	*stream;
    unsigned     options;
    void       (*filter)(MAILSTREAM *, char *, int, long, void *, unsigned);
    void	*data;
} MM_LIST_S;


/*
 * return values for IMAP URL parser
 */
#define	URL_IMAP_MASK		0x0007
#define	URL_IMAP_ERROR		0
#define	URL_IMAP_IMAILBOXLIST	0x0001
#define	URL_IMAP_IMESSAGELIST	0x0002
#define	URL_IMAP_IMESSAGEPART	0x0004
#define	URL_IMAP_IMBXLSTLSUB	0x0010
#define	URL_IMAP_ISERVERONLY	0x0020


/*
 * Exported globals setup by searching functions to tell mm_searched
 * where to put message numbers that matched the search criteria,
 * and to allow mm_searched to return number of matches.
 */
extern MAILSTREAM *mm_search_stream;
extern long        mm_search_count;
extern MAILSTATUS  mm_status_result;

extern MM_LIST_S  *mm_list_info;


extern MMLOGIN_S  *mm_login_list;
extern MMLOGIN_S  *cert_failure_list;


/*
 * These are declared in c-client and implemented in ../pith/imap.c
 */
#if 0
 void mm_searched (MAILSTREAM *stream,unsigned long number);
 void mm_exists (MAILSTREAM *stream,unsigned long number);
 void mm_expunged (MAILSTREAM *stream,unsigned long number);
 void mm_flags (MAILSTREAM *stream,unsigned long number);
 void mm_list (MAILSTREAM *stream,int delimiter,char *name,long attributes);
 void mm_lsub (MAILSTREAM *stream,int delimiter,char *name,long attributes);
 void mm_status (MAILSTREAM *stream,char *mailbox,MAILSTATUS *status);
 void mm_dlog (char *string);
 void mm_critical (MAILSTREAM *stream);
 void mm_nocritical (MAILSTREAM *stream);
 void mm_fatal (char *string);
#endif

/*
 * These are declared in c-client and must be implemented in application
 */
#if 0
 void mm_notify (MAILSTREAM *stream,char *string,long errflg);
 void mm_log (char *string,long errflg);
 void mm_login (NETMBX *mb,char *user,char *pwd,long trial);
 long mm_diskerror (MAILSTREAM *stream,long errcode,long serious);
#endif


/* exported protoypes */
char   *imap_referral(MAILSTREAM *, char *, long);
long    imap_proxycopy(MAILSTREAM *, char *, char *, long);
char   *cached_user_name(char *);
int     imap_same_host(STRLIST_S *, STRLIST_S *);
int     imap_get_ssl(MMLOGIN_S *, STRLIST_S *, int *, int *);
char   *imap_get_user(MMLOGIN_S *, STRLIST_S *);
int     imap_get_passwd(MMLOGIN_S *, char *, char *, STRLIST_S *, int);
void    imap_set_passwd(MMLOGIN_S **, char *, char *, STRLIST_S *, int, int, int);
void    imap_flush_passwd_cache(int);


/* currently mandatory to implement stubs */

/* called by build_folder_list(), ok if it does nothing */
void    set_read_predicted(int);
void    mm_login_work (NETMBX *mb,char *user,char *pwd,long trial,char *usethisprompt, char *altuserforcache);

/* this is necessary to figure out the name of the password file of the application. */
#ifdef PASSFILE
char *passfile_name(char *, char *, size_t);
#endif /* PASSFILE */

#endif /* PITH_IMAP_INCLUDED */