2 * $Id: imap.h 1074 2008-06-04 00:08:43Z hubert@u.washington.edu $
4 * ========================================================================
5 * Copyright 2013-2022 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;
41 unsigned ignore_this
:1; /* internal flag */
43 struct _mmlogin_s
*next
;
47 typedef struct _se_app_s
{
54 * struct to help manage mail_list calls/callbacks
56 typedef struct mm_list_s
{
59 void (*filter
)(MAILSTREAM
*, char *, int, long, void *, unsigned);
65 * return values for IMAP URL parser
67 #define URL_IMAP_MASK 0x0007
68 #define URL_IMAP_ERROR 0
69 #define URL_IMAP_IMAILBOXLIST 0x0001
70 #define URL_IMAP_IMESSAGELIST 0x0002
71 #define URL_IMAP_IMESSAGEPART 0x0004
72 #define URL_IMAP_IMBXLSTLSUB 0x0010
73 #define URL_IMAP_ISERVERONLY 0x0020
75 /* Marker for Separator of Authentication Method */
76 #define PWDAUTHSEP '\001'
79 * Exported globals setup by searching functions to tell mm_searched
80 * where to put message numbers that matched the search criteria,
81 * and to allow mm_searched to return number of matches.
83 extern MAILSTREAM
*mm_search_stream
;
84 extern long mm_search_count
;
85 extern MAILSTATUS mm_status_result
;
87 extern MM_LIST_S
*mm_list_info
;
90 extern MMLOGIN_S
*mm_login_list
;
91 extern MMLOGIN_S
*cert_failure_list
;
95 * These are declared in c-client and implemented in ../pith/imap.c
98 void mm_searched (MAILSTREAM
*stream
,unsigned long number
);
99 void mm_exists (MAILSTREAM
*stream
,unsigned long number
);
100 void mm_expunged (MAILSTREAM
*stream
,unsigned long number
);
101 void mm_flags (MAILSTREAM
*stream
,unsigned long number
);
102 void mm_list (MAILSTREAM
*stream
,int delimiter
,char *name
,long attributes
);
103 void mm_lsub (MAILSTREAM
*stream
,int delimiter
,char *name
,long attributes
);
104 void mm_status (MAILSTREAM
*stream
,char *mailbox
,MAILSTATUS
*status
);
105 void mm_dlog (char *string
);
106 void mm_critical (MAILSTREAM
*stream
);
107 void mm_nocritical (MAILSTREAM
*stream
);
108 void mm_fatal (char *string
);
112 * These are declared in c-client and must be implemented in application
115 void mm_notify (MAILSTREAM
*stream
,char *string
,long errflg
);
116 void mm_log (char *string
,long errflg
);
117 void mm_login (NETMBX
*mb
,char *user
,char *pwd
,long trial
);
118 long mm_diskerror (MAILSTREAM
*stream
,long errcode
,long serious
);
122 /* exported prototypes */
123 char *imap_referral(MAILSTREAM
*, char *, long);
124 long imap_proxycopy(MAILSTREAM
*, char *, char *, long);
125 char *cached_user_name(char *);
126 int imap_same_host(STRLIST_S
*, STRLIST_S
*);
127 int imap_same_host_auth(STRLIST_S
*, STRLIST_S
*, char *);
128 int imap_get_ssl(MMLOGIN_S
*, STRLIST_S
*, int *, int *);
129 char *imap_get_user(MMLOGIN_S
*, STRLIST_S
*);
130 int imap_get_passwd(MMLOGIN_S
*, char **, char *, STRLIST_S
*, int);
131 int imap_get_passwd_auth (MMLOGIN_S
*, char **, char *, STRLIST_S
*, int, char *);
132 void imap_set_passwd(MMLOGIN_S
**, char *, char *, STRLIST_S
*, int, int, int);
133 void imap_set_passwd_auth(MMLOGIN_S
**, char *, char *, STRLIST_S
*, int, int, int, char *);
134 void imap_flush_passwd_cache(int);
135 void imap_delete_passwd_auth (MMLOGIN_S
**, char *, STRLIST_S
*, int, char *);
136 void imap_delete_passwd (MMLOGIN_S
**, char *, STRLIST_S
*, int);
139 /* currently mandatory to implement stubs */
141 /* called by build_folder_list(), ok if it does nothing */
142 void set_read_predicted(int);
143 void mm_login_work (NETMBX
*mb
,char *user
,char **pwd
,long trial
,char *usethisprompt
, char *altuserforcache
);
144 void mm_login_method_work (NETMBX
*mb
,char *user
,void *login
,long trial
, char *method
, char *usethisprompt
, char *altuserforcache
);
146 /* this is necessary to figure out the name of the password file of the application. */
148 char *passfile_name(char *, char *, size_t);
149 #endif /* PASSFILE */
151 #endif /* PITH_IMAP_INCLUDED */