* SMIME: Change the default signature digest from sha1 to sha-256,
[alpine.git] / pith / send.h
blob3512b0f479993a3049ee99f10e7f06248a8bc97f
1 /*
2 * $Id: send.h 1142 2008-08-13 17:22:21Z hubert@u.washington.edu $
4 * ========================================================================
5 * Copyright 2006-2008 University of Washington
6 * Copyright 2013-2016 Eduardo Chappa
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_SEND_INCLUDED
18 #define PITH_SEND_INCLUDED
21 #include "../pith/context.h"
22 #include "../pith/pattern.h"
23 #include "../pith/repltype.h"
24 #include "../pith/store.h"
25 #include "../pith/osdep/pipe.h"
28 #ifndef TCPSTREAM
29 #define TCPSTREAM void
30 #endif
32 #define MIME_VER "MIME-Version: 1.0\015\012"
34 #define UNKNOWN_CHARSET "X-UNKNOWN"
36 #define OUR_HDRS_LIST "X-Our-Headers"
40 * Redraft flags...
42 #define REDRAFT_NONE 0
43 #define REDRAFT_PPND 0x01
44 #define REDRAFT_DEL 0x02
45 #define REDRAFT_HTML 0x04
49 * Child posting control structure
51 typedef struct post_s {
52 int pid; /* proc id of child doing posting */
53 int status; /* child's exit status */
54 char *fcc; /* fcc we may have copied */
55 } POST_S;
58 /*------------------------------
59 Structures and enum used to expand the envelope structure to
60 support user defined headers. PINEFIELDs are sort of used for two
61 different purposes. The main use is to store information about headers
62 in pine_send. There is a pf for every header. It is also used for the
63 related task of parsing the customized-hdrs and role->cstm headers and
64 storing information about those.
65 ----*/
67 typedef enum {FreeText, Address, Fcc,
68 Attachment, Subject, TypeUnknown} FieldType;
69 typedef enum {NoMatch = 0, /* no match for this header */
70 UseAsDef=1, /* use only if no value set yet */
71 Combine=2, /* combine if News, To, Cc, Bcc, else
72 replace existing value */
73 Replace=3} CustomType; /* replace existing value */
75 typedef struct pine_field {
76 char *name; /* field's literal name */
77 FieldType type; /* field's type */
78 unsigned canedit:1; /* allow editing of this field */
79 unsigned writehdr:1; /* write rfc822 header for field */
80 unsigned localcopy:1; /* copy to fcc or postponed */
81 unsigned rcptto:1; /* send to this if type Address */
82 unsigned posterr:1; /* posting error occured in field */
83 /* the next three fields are used only for customized-hdrs and friends */
84 unsigned standard:1; /* this hdr already in pf_template */
85 CustomType cstmtype; /* for customized-hdrs and r->cstm */
86 char *val; /* field's config'd value */
87 ADDRESS **addr; /* used if type is Address */
88 char *scratch; /* scratch pointer for Address type */
89 char **text; /* field's free text form */
90 char *textbuf; /* need to free this when done */
91 void *extdata; /* hook for extra data pointer */
92 struct pine_field *next; /* next pine field */
93 } PINEFIELD;
96 typedef struct {
97 ENVELOPE *env; /* standard c-client envelope */
98 PINEFIELD *local; /* this is all of the headers */
99 PINEFIELD *custom; /* ptr to start of custom headers */
100 PINEFIELD **sending_order; /* array giving writing order of hdrs */
101 } METAENV;
105 * Return values for check_address()
107 #define CA_OK 0 /* Address is OK */
108 #define CA_EMPTY 1 /* Address is OK, but no deliverable addrs */
109 #define CA_BAD -1 /* Address is bogus */
114 * call_mailer bigresult_f flags
116 #define CM_BR_VERBOSE 0x01
117 #define CM_BR_ERROR 0x02
121 * call_mailer flags
123 #define CM_NONE 0x00
124 #define CM_VERBOSE 0x01 /* request verbose mode */
125 #define CM_DSN_NEVER 0x02 /* request NO DSN */
126 #define CM_DSN_DELAY 0x04 /* DSN delay notification */
127 #define CM_DSN_SUCCESS 0x08 /* DSN success notification */
128 #define CM_DSN_FULL 0x10 /* DSN full notificiation */
129 #define CM_DSN_SHOW 0x20 /* show DSN result (place holder) */
132 #ifdef DEBUG_PLUS
133 #define TIME_STAMP(str, l) { \
134 struct timeval tp; \
135 struct timezone tzp; \
136 if(gettimeofday(&tp, &tzp) == 0) \
137 dprint((l, \
138 "\nKACHUNK (%s) : %.8s.%3.3ld\n", \
139 str, ctime(&tp.tv_sec) + 11, \
140 tp.tv_usec));\
142 #else /* !DEBUG_PLUS */
143 #define TIME_STAMP(str, l)
144 #endif /* !DEBUG_PLUS */
147 * Most number of errors call_mailer should report
149 #define MAX_ADDR_ERROR 2 /* Only display 2 address errors */
152 #define FCC_SOURCE CharStar
155 struct local_message_copy {
156 STORE_S *so;
157 unsigned text_only:1;
158 unsigned all_written:1;
159 unsigned text_written:1;
163 #define TONAME "To"
164 #define CCNAME "cc"
165 #define SUBJNAME "Subject"
166 #define PRIORITYNAME "X-Priority"
170 * Note, these are in the same order in the he_template and pf_template arrays.
171 * The typedef is just a way to get these variables automatically defined in order.
173 typedef enum { N_AUTHRCVD = 0
174 , N_FROM
175 , N_REPLYTO
176 , N_TO
177 , N_CC
178 , N_BCC
179 , N_NEWS
180 , N_FCC
181 , N_LCC
182 , N_ATTCH
183 , N_SUBJ
184 , N_REF
185 , N_DATE
186 , N_INREPLY
187 , N_MSGID
188 , N_PRIORITY
189 , N_USERAGENT
190 , N_NOBODY
191 , N_POSTERR
192 , N_RPLUID
193 , N_RPLMBOX
194 , N_SMTP
195 , N_NNTP
196 , N_CURPOS
197 , N_OURREPLYTO
198 , N_OURHDRS
199 , N_SENDER
200 } dummy_enum;
203 typedef struct {
204 int val;
205 char *desc;
206 } PRIORITY_S;
209 /* ugly globals we'd like to get rid of */
210 extern struct local_message_copy lmc;
211 extern char verbose_requested;
212 extern unsigned char dsn_requested;
213 extern PRIORITY_S priorities[];
214 extern PINEFIELD pf_template[];
217 /* exported protoypes */
218 int postponed_stream(MAILSTREAM **, char *, char *, int);
219 int redraft_work(MAILSTREAM **, long, ENVELOPE **, BODY **, char **, char **,
220 REPLY_S **, REDRAFT_POS_S **, PINEFIELD **, ACTION_S **, int, STORE_S *);
221 int redraft_cleanup(MAILSTREAM **, int, int);
222 void simple_header_parse(char *, char **, char **);
223 REPLY_S *build_reply_uid(char *);
224 METAENV *pine_new_env(ENVELOPE *, char **, char ***, PINEFIELD *);
225 void pine_free_env(METAENV **);
226 int check_addresses(METAENV *);
227 void update_answered_flags(REPLY_S *);
228 ADDRESS *phone_home_from(void);
229 unsigned int phone_home_hash(char *);
230 int call_mailer(METAENV *, BODY *, char **, int, void (*)(char *, int),
231 void (*)(PIPE_S *, int, void *));
232 int write_postponed(METAENV *, BODY *);
233 int commence_fcc(char *, CONTEXT_S **, int);
234 int wrapup_fcc(char *, CONTEXT_S *, METAENV *, BODY *);
235 STORE_S *open_fcc(char *, CONTEXT_S **, int, char *, char *);
236 int write_fcc(char *, CONTEXT_S *, STORE_S *, MAILSTREAM *, char *, char *);
237 BODY *first_text_8bit(BODY *);
238 ADDRESS *generate_from(void);
239 void set_mime_type_by_grope(BODY *);
240 void set_charset_possibly_to_ascii(BODY *, char *);
241 void set_parameter(PARAMETER **, char *, char *);
242 void pine_encode_body(BODY *);
243 int pine_header_line(char *, METAENV *, char *, soutr_t, TCPSTREAM *, int, int);
244 char *encode_header_value(char *, size_t, unsigned char *, char *, int);
245 int pine_address_line(char *, METAENV *, ADDRESS *, soutr_t, TCPSTREAM *, int, int);
246 long pine_rfc822_header(METAENV *, BODY *, soutr_t, TCPSTREAM *);
247 long pine_rfc822_output(METAENV *, BODY *, soutr_t, TCPSTREAM *);
248 void pine_free_body(BODY **);
249 long send_body_size(BODY *);
250 void pine_smtp_verbose_out(char *);
251 int pine_header_forbidden(char *);
252 int hdr_is_in_list(char *, PINEFIELD *);
253 int count_custom_hdrs_pf(PINEFIELD *, int);
254 int count_custom_hdrs_list(char **);
255 CustomType set_default_hdrval(PINEFIELD *, PINEFIELD *);
256 FieldType pine_header_standard(char *);
257 void customized_hdr_setup(PINEFIELD *, char **, CustomType);
258 void add_defaults_from_list(PINEFIELD *, char **);
259 PINEFIELD *parse_custom_hdrs(char **, CustomType);
260 PINEFIELD *combine_custom_headers(PINEFIELD *, PINEFIELD *);
261 void free_customs(PINEFIELD *);
262 int encode_whole_header(char *, METAENV *);
263 int news_poster(METAENV *, BODY *, char **, void (*)(PIPE_S *, int, void *));
264 PINEFIELD *set_priority_header(METAENV *header, char *value);
265 void pine_free_body_data(BODY *);
266 void free_charsetchecker(void);
267 long pine_rfc822_output_body(BODY *,soutr_t,TCPSTREAM *);
268 int pine_write_body_header(BODY *, soutr_t, TCPSTREAM *);
271 #endif /* PITH_SEND_INCLUDED */