2 * $Id: imap.h 1074 2008-06-04 00:08:43Z hubert@u.washington.edu $
4 * ========================================================================
5 * Copyright 2013-2020 Eduardo Chappa
6 * Copyright 2006 University of Washington
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * ========================================================================
17 #ifndef PITH_IMAP_INCLUDED
18 #define PITH_IMAP_INCLUDED
21 #include "../pith/string.h"
24 #define NETMAXPASSWD 512 /* increased from 100 due to token lengths.
25 * must be less than MAILTMPLEN
30 * struct used to keep track of password/host/user triples.
31 * The problem is we only want to try user names and passwords if
32 * we've already tried talking to this host before.
35 typedef struct _mmlogin_s
{
39 unsigned ok_novalidate
:1;
42 struct _mmlogin_s
*next
;
46 typedef struct _se_app_s
{
53 * struct to help manage mail_list calls/callbacks
55 typedef struct mm_list_s
{
58 void (*filter
)(MAILSTREAM
*, char *, int, long, void *, unsigned);
64 * return values for IMAP URL parser
66 #define URL_IMAP_MASK 0x0007
67 #define URL_IMAP_ERROR 0
68 #define URL_IMAP_IMAILBOXLIST 0x0001
69 #define URL_IMAP_IMESSAGELIST 0x0002
70 #define URL_IMAP_IMESSAGEPART 0x0004
71 #define URL_IMAP_IMBXLSTLSUB 0x0010
72 #define URL_IMAP_ISERVERONLY 0x0020
74 /* Marker for Separator of Authentication Method */
75 #define PWDAUTHSEP '\001'
78 * Exported globals setup by searching functions to tell mm_searched
79 * where to put message numbers that matched the search criteria,
80 * and to allow mm_searched to return number of matches.
82 extern MAILSTREAM
*mm_search_stream
;
83 extern long mm_search_count
;
84 extern MAILSTATUS mm_status_result
;
86 extern MM_LIST_S
*mm_list_info
;
89 extern MMLOGIN_S
*mm_login_list
;
90 extern MMLOGIN_S
*cert_failure_list
;
94 * These are declared in c-client and implemented in ../pith/imap.c
97 void mm_searched (MAILSTREAM
*stream
,unsigned long number
);
98 void mm_exists (MAILSTREAM
*stream
,unsigned long number
);
99 void mm_expunged (MAILSTREAM
*stream
,unsigned long number
);
100 void mm_flags (MAILSTREAM
*stream
,unsigned long number
);
101 void mm_list (MAILSTREAM
*stream
,int delimiter
,char *name
,long attributes
);
102 void mm_lsub (MAILSTREAM
*stream
,int delimiter
,char *name
,long attributes
);
103 void mm_status (MAILSTREAM
*stream
,char *mailbox
,MAILSTATUS
*status
);
104 void mm_dlog (char *string
);
105 void mm_critical (MAILSTREAM
*stream
);
106 void mm_nocritical (MAILSTREAM
*stream
);
107 void mm_fatal (char *string
);
111 * These are declared in c-client and must be implemented in application
114 void mm_notify (MAILSTREAM
*stream
,char *string
,long errflg
);
115 void mm_log (char *string
,long errflg
);
116 void mm_login (NETMBX
*mb
,char *user
,char *pwd
,long trial
);
117 long mm_diskerror (MAILSTREAM
*stream
,long errcode
,long serious
);
121 /* exported prototypes */
122 char *imap_referral(MAILSTREAM
*, char *, long);
123 long imap_proxycopy(MAILSTREAM
*, char *, char *, long);
124 char *cached_user_name(char *);
125 int imap_same_host(STRLIST_S
*, STRLIST_S
*);
126 int imap_same_host_auth(STRLIST_S
*, STRLIST_S
*, char *);
127 int imap_get_ssl(MMLOGIN_S
*, STRLIST_S
*, int *, int *);
128 char *imap_get_user(MMLOGIN_S
*, STRLIST_S
*);
129 int imap_get_passwd(MMLOGIN_S
*, char **, char *, STRLIST_S
*, int);
130 int imap_get_passwd_auth (MMLOGIN_S
*, char **, char *, STRLIST_S
*, int, char *);
131 void imap_set_passwd(MMLOGIN_S
**, char *, char *, STRLIST_S
*, int, int, int);
132 void imap_set_passwd_auth(MMLOGIN_S
**, char *, char *, STRLIST_S
*, int, int, int, char *);
133 void imap_flush_passwd_cache(int);
136 /* currently mandatory to implement stubs */
138 /* called by build_folder_list(), ok if it does nothing */
139 void set_read_predicted(int);
140 void mm_login_work (NETMBX
*mb
,char *user
,char **pwd
,long trial
,char *usethisprompt
, char *altuserforcache
);
141 void mm_login_method_work (NETMBX
*mb
,char *user
,void *login
,long trial
, char *method
, char *usethisprompt
, char *altuserforcache
);
143 /* this is necessary to figure out the name of the password file of the application. */
145 char *passfile_name(char *, char *, size_t);
146 #endif /* PASSFILE */
148 #endif /* PITH_IMAP_INCLUDED */