* Fix not allow remote execution by adding PIPE_NOSHELL to the opening of a url by
[alpine.git] / pith / send.h
blobee3245e5d077dbdca40f18223debe328e310746c
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 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;
162 #define CAN_EDIT(x) (!((x)->never_allow_changing_from) && \
163 F_ON(F_ALLOW_CHANGING_FROM, (x)))
165 #define TONAME "To"
166 #define CCNAME "cc"
167 #define SUBJNAME "Subject"
168 #define PRIORITYNAME "X-Priority"
172 * Note, these are in the same order in the he_template and pf_template arrays.
173 * The typedef is just a way to get these variables automatically defined in order.
175 typedef enum { N_AUTHRCVD = 0
176 , N_FROM
177 , N_REPLYTO
178 , N_TO
179 , N_CC
180 , N_BCC
181 , N_NEWS
182 , N_FCC
183 , N_LCC
184 , N_ATTCH
185 , N_SUBJ
186 , N_REF
187 , N_DATE
188 , N_INREPLY
189 , N_MSGID
190 , N_PRIORITY
191 , N_USERAGENT
192 , N_NOBODY
193 , N_POSTERR
194 , N_RPLUID
195 , N_RPLMBOX
196 , N_SMTP
197 , N_NNTP
198 , N_CURPOS
199 , N_OURREPLYTO
200 , N_OURHDRS
201 , N_SENDER
202 } dummy_enum;
205 typedef struct {
206 int val;
207 char *desc;
208 } PRIORITY_S;
211 /* ugly globals we'd like to get rid of */
212 extern struct local_message_copy lmc;
213 extern char verbose_requested;
214 extern unsigned char dsn_requested;
215 extern PRIORITY_S priorities[];
216 extern PINEFIELD pf_template[];
219 /* exported protoypes */
220 int postponed_stream(MAILSTREAM **, char *, char *, int);
221 int redraft_work(MAILSTREAM **, long, ENVELOPE **, BODY **, char **, char **,
222 REPLY_S **, REDRAFT_POS_S **, PINEFIELD **, ACTION_S **, int, STORE_S *);
223 int redraft_cleanup(MAILSTREAM **, int, int);
224 void simple_header_parse(char *, char **, char **);
225 REPLY_S *build_reply_uid(char *);
226 METAENV *pine_new_env(ENVELOPE *, char **, char ***, PINEFIELD *);
227 void pine_free_env(METAENV **);
228 int check_addresses(METAENV *);
229 void update_answered_flags(REPLY_S *);
230 ADDRESS *phone_home_from(void);
231 unsigned int phone_home_hash(char *);
232 int call_mailer(METAENV *, BODY *, char **, int, void (*)(char *, int),
233 void (*)(PIPE_S *, int, void *));
234 int write_postponed(METAENV *, BODY *);
235 int commence_fcc(char *, CONTEXT_S **, int);
236 int wrapup_fcc(char *, CONTEXT_S *, METAENV *, BODY *);
237 STORE_S *open_fcc(char *, CONTEXT_S **, int, char *, char *);
238 int write_fcc(char *, CONTEXT_S *, STORE_S *, MAILSTREAM *, char *, char *);
239 BODY *first_text_8bit(BODY *);
240 ADDRESS *generate_from(void);
241 void set_mime_type_by_grope(BODY *);
242 void set_charset_possibly_to_ascii(BODY *, char *);
243 void set_parameter(PARAMETER **, char *, char *);
244 void pine_encode_body(BODY *);
245 int pine_header_line(char *, METAENV *, char *, soutr_t, TCPSTREAM *, int, int);
246 char *encode_header_value(char *, size_t, unsigned char *, char *, int);
247 int pine_address_line(char *, METAENV *, ADDRESS *, soutr_t, TCPSTREAM *, int, int);
248 long pine_rfc822_header(METAENV *, BODY *, soutr_t, TCPSTREAM *);
249 long pine_rfc822_output(METAENV *, BODY *, soutr_t, TCPSTREAM *);
250 void pine_free_body(BODY **);
251 long send_body_size(BODY *);
252 void pine_smtp_verbose_out(char *);
253 int pine_header_forbidden(char *);
254 int hdr_is_in_list(char *, PINEFIELD *);
255 int count_custom_hdrs_pf(PINEFIELD *, int);
256 int count_custom_hdrs_list(char **);
257 CustomType set_default_hdrval(PINEFIELD *, PINEFIELD *);
258 FieldType pine_header_standard(char *);
259 void customized_hdr_setup(PINEFIELD *, char **, CustomType);
260 void add_defaults_from_list(PINEFIELD *, char **);
261 PINEFIELD *parse_custom_hdrs(char **, CustomType);
262 PINEFIELD *combine_custom_headers(PINEFIELD *, PINEFIELD *);
263 void free_customs(PINEFIELD *);
264 int encode_whole_header(char *, METAENV *);
265 int news_poster(METAENV *, BODY *, char **, void (*)(PIPE_S *, int, void *));
266 PINEFIELD *set_priority_header(METAENV *header, char *value);
267 void pine_free_body_data(BODY *);
268 void free_charsetchecker(void);
269 long pine_rfc822_output_body(BODY *,soutr_t,TCPSTREAM *);
270 int pine_write_body_header(BODY *, soutr_t, TCPSTREAM *);
273 #endif /* PITH_SEND_INCLUDED */