2 * ========================================================================
3 * Copyright 2006 University of Washington
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * ========================================================================
27 #include "../c-client-dll/mail.h"
28 #include "../c-client-dll/rfc822.h"
29 #include "../c-client-dll/osdep.h"
30 #include "../c-client-dll/smtp.h"
31 #include "../c-client-dll/misc.h"
35 #define PERSONAL_NAME 1
39 #define FEATURE_LIST 5
40 #define CHARACTER_SET 6
41 #define FOLDER_COLLECTIONS 7
42 #define PMAPI_SEND_BEHAVIOR 8
44 #define PMAPI_SUPPRESS_DIALOGS 10
45 #define PMAPI_STRICT_NO_DIALOG 11
49 #define PMSB_ALWAYS_PROMPT 0
50 #define PMSB_ALWAYS_SEND 1
51 #define PMSB_NEVER_SEND 2
55 #define errBufSize 300 /* for buffers to sprintf %.200s error messages into */
58 #define MSDEBUG ms_global && ms_global->debug
61 #define PINERC_FILE "tmpmapiuwpinerc"
62 #define ErrorBox(msg,parm){ \
63 char buf[errBufSize]; \
64 sprintf(buf, msg, parm); \
66 } /* a macro so parm can be a pointer or a value as per % format */
67 #define DEBUG_WRITE(msg, parm) { if(MSDEBUG) fprintf(ms_global->dfd,msg,parm);}
70 #define PROTO(args) args
72 #define PROTO(args) ()
75 /* used for pine pwd file */
78 #define TABSZ (LASTCH - FIRSTCH + 1)
81 typedef struct rc_entry
{
91 typedef struct rc_feat
{
96 typedef struct STRLIST
{
101 typedef struct file_struct
{
103 struct file_struct
*next
;
106 typedef enum {RecipDesc
, Message
} BufType
;
108 typedef struct mbuffer_list
{
110 int arraysize
; /* should always be 1 unless it's one of those silly arrays */
112 struct mbuffer_list
*next
;
115 typedef struct strbuffer
{
117 unsigned long cur_bytes
;
118 unsigned long increment
;
119 unsigned long bufsize
;
122 typedef struct dlg_edits
{
127 typedef struct pw_cache
{
132 struct pw_cache
*next
;
135 typedef struct sessionl
{
139 MAILSTREAM
*open_stream
;
140 char *currently_open
;
142 unsigned dlg_cancel
:1;
143 unsigned int mapi_logon_ui
:1;
144 unsigned int check_stream
:1;
145 /* int passfile_checked; */
148 lpMapiMessage FAR lpm
;
150 unsigned long session_number
;
151 struct sessionl
*next
;
154 typedef struct mapi_global
{
166 rc_entry_s
*prcvars
[NUMPRCVARS
];
167 rc_feat_s
*prcfeats
[NUMPRCFEATS
];
168 int pmapi_send_behavior
;
169 int pmapi_suppress_dialogs
;
170 int pmapi_strict_no_dialog
;
171 sessionlist_s
*sessionlist
;
172 sessionlist_s
*cs
; /* the current session, used for logins */
173 unsigned long next_session
;
174 unsigned long attach_no
;
175 unsigned long attached
;
176 MBUFFER_LIST_S
*mapi_bufs
;
181 extern struct mapi_global
*ms_global
;
183 void ErrorBoxFunc(char *msg
);
184 char *quote(char *old
);
185 char *mstrdup(char *old
);
186 int msprint(char *str
);
187 int msprint1(char *str
, void *arg1
);
188 int msprint_message_structure(lpMapiMessage lpm
);
189 int msprint_recipient_structure(lpMapiRecipDesc lmrd
, int mapi_orig_is_unexpected
);
190 int msprint_file_structure(lpMapiFileDesc lmfd
);
192 int est_size(ADDRESS
*a
);
193 int send_documents(char *files
, char sep
);
194 unsigned long send_msg_nodlg(LHANDLE lhSession
, ULONG ulUIParam
,
195 lpMapiMessage lpMessage
, FLAGS flFlags
, ULONG ulReserved
);
196 ADDRESS
*mapirecip2address(lpMapiRecipDesc lpmrd
);
197 long pmapi_soutr(STRBUFFER_S
*s
, char *str
);
198 char *TmpCopy(char *srcFile
, int is_pinerc
);
199 sessionlist_s
*new_sessionlist();
200 sessionlist_s
*free_sessionlist_node(sessionlist_s
*cs
);
201 sessionlist_s
*get_session(unsigned long num
);
202 lpMapiRecipDesc
new_MapiRecipDesc(int arraysize
);
203 void free_MapiRecipDesc(lpMapiRecipDesc buf
, int arraysize
);
204 lpMapiMessage
new_MapiMessage(int arraysize
);
205 void free_MapiMessage(lpMapiMessage buf
, int arraysize
);
206 int new_mbuffer(void *buf
, int arraysize
, BufType type
);
207 int free_mbuffer(void *buf
);
208 int InitPineSpecific(sessionlist_s
*cs
);
209 MAILSTREAM
*mapi_mail_open(sessionlist_s
*cs
, MAILSTREAM
*stream
, char *name
, long options
);
210 MAILSTREAM
*check_mailstream(sessionlist_s
*cs
);
211 unsigned long convert_to_msgno(char *msgid
);
212 int fetch_structure_and_attachments(long msgno
, long flags
,
213 FLAGS MAPIflags
, sessionlist_s
*cs
);
214 char *message_structure_to_mailto_url(lpMapiMessage lpm
);
215 ULONG FAR PASCAL
MAPISendMail(LHANDLE lhSession
, ULONG ulUIParam
, lpMapiMessage lpMessage
,
216 FLAGS flFlags
, ULONG ulReserved
);
217 ULONG FAR PASCAL
MAPILogon(ULONG ulUIParam
, LPTSTR lpszProfileName
, LPTSTR lpszPassword
,
218 FLAGS flFlags
, ULONG ulReserved
, LPLHANDLE lplhSession
);
219 ULONG FAR PASCAL
MAPILogoff (LHANDLE lhSession
, ULONG ulUIParam
, FLAGS flFlags
, ULONG ulReserved
);
220 ULONG FAR PASCAL
MAPIFindNext (LHANDLE lhSession
, ULONG ulUIParam
, LPSTR lpszMessageType
,
221 LPSTR lpszSeedMessageID
, FLAGS flFlags
, ULONG ulReserved
,
222 LPSTR lpszMessageID
);
223 ULONG FAR PASCAL
MAPIReadMail(LHANDLE lhSession
, ULONG ulUIParam
, LPSTR lpszMessageID
,
224 FLAGS flFlags
, ULONG ulReserved
, lpMapiMessage FAR
*lppMessage
);
225 ULONG FAR PASCAL
MAPIAddress(LHANDLE lhSession
, ULONG ulUIParam
, LPTSTR lpszCaption
,
226 ULONG nEditFields
, LPTSTR lpszLabels
, ULONG nRecips
,
227 lpMapiRecipDesc lpRecips
, FLAGS flFlags
, ULONG ulReserved
,
228 LPULONG lpnNewRecips
, lpMapiRecipDesc FAR
* lppNewRecips
);
229 ULONG FAR PASCAL
MAPIDeleteMail(LHANDLE lhSession
, ULONG ulUIParam
, LPTSTR lpszMessageID
,
230 FLAGS flFlags
, ULONG ulReserved
);
231 ULONG FAR PASCAL
MAPIDetails(LHANDLE lhSession
, ULONG ulUIParam
, lpMapiRecipDesc lpRecip
,
232 FLAGS flFlags
, ULONG ulReserved
);
233 ULONG FAR PASCAL
MAPIFreeBuffer(LPVOID pv
);
234 ULONG FAR PASCAL
MAPIResolveName(LHANDLE lhSession
, ULONG ulUIParam
, LPTSTR lpszName
,
235 FLAGS flFlags
, ULONG ulReserved
, lpMapiRecipDesc FAR
* lppRecip
);
236 ULONG FAR PASCAL
MAPISaveMail(LHANDLE lhSession
, ULONG ulUIParam
, lpMapiMessage lpMessage
,
237 FLAGS flFlags
, ULONG ulReserved
, LPTSTR lpszMessageID
);
238 ULONG FAR PASCAL
MAPISendDocuments(ULONG ulUIParam
, LPTSTR lpszDelimChar
, LPTSTR lpszFullPaths
,
239 LPTSTR lpszFileNames
, ULONG ulReserved
);
242 char *rfc1522_encode
PROTO((char *, size_t, unsigned char *, char *));
243 void get_pair
PROTO((char *, char **, char **, int, int));
244 void removing_leading_and_trailing_white_space
PROTO((char *));