* Experimental: Alpine can pass an HTML message to an external web browser, by...
[alpine.git] / pith / state.h
blob3fec369107468a07e8102a81847962a1f121eaa7
1 /*
2 * $Id: state.h 1074 2008-06-04 00:08:43Z hubert@u.washington.edu $
4 * ========================================================================
5 * Copyright 2013-2020 Eduardo Chappa
6 * Copyright 2006-2008 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_STATE_INCLUDED
18 #define PITH_STATE_INCLUDED
21 #include "../pith/conftype.h"
22 #include "../pith/indxtype.h"
23 #include "../pith/bitmap.h"
24 #include "../pith/charset.h"
25 #include "../pith/context.h"
26 #include "../pith/keyword.h"
27 #include "../pith/atttype.h"
28 #include "../pith/msgno.h"
29 #include "../pith/pattern.h"
30 #include "../pith/pipe.h"
31 #include "../pith/send.h"
32 #include "../pith/sorttype.h"
33 #include "../pith/stream.h"
34 #include "../pith/color.h"
35 #include "../pith/user.h"
39 * Printing control structure
41 typedef struct print_ctrl {
42 #ifndef DOS
43 PIPE_S *pipe; /* control struct for pipe to write text */
44 FILE *fp; /* file pointer to write printed text into */
45 char *result; /* file containing print command's output */
46 #endif
47 #ifdef OS2
48 int ispipe;
49 #endif
50 int err; /* bit indicating something went awry */
51 } PRINT_S;
55 * Keeps track of display dimensions
57 struct ttyo {
58 int screen_rows,
59 screen_cols,
60 header_rows, /* number of rows for titlebar and whitespace */
61 footer_rows; /* number of rows for status and keymenu */
64 /* struct to keep track of external html files generated by Alpine */
65 typedef struct html_log_s {
66 char *dir; /* directory path */
67 time_t to_delete; /* time to delete dir */
68 struct html_log_s *next; /* pointer to next entry */
69 } HTML_LOG_S;
72 * HEADER_ROWS is always 2. 1 for the titlebar and 1 for the
73 * blank line after the titlebar. We should probably make it go down
74 * to 0 when the screen shrinks but instead we're just figuring out
75 * if there is enough room by looking at screen_rows.
76 * FOOTER_ROWS is either 3 or 1. Normally it is 3, 2 for the keymenu plus 1
77 * for the status line. If the NoKeyMenu command has been given, then it is 1.
79 #define HEADER_ROWS(X) ((X)->ttyo->header_rows)
80 #define FOOTER_ROWS(X) ((X)->ttyo->footer_rows)
83 /*----------------------------------------------------------------------
84 This structure sort of takes the place of global variables or perhaps
85 is the global variable. (It can be accessed globally as ps_global. One
86 advantage to this is that as soon as you see a reference to the structure
87 you know it is a global variable.
88 In general it is treated as global by the lower level and utility
89 routines, but it is not treated so by the main screen driving routines.
90 Each of them receives it as an argument and then sets ps_global to the
91 argument they received. This is sort of with the thought that things
92 might be coupled more loosely one day and that Pine might run where there
93 is more than one window and more than one instance. But we haven't kept
94 up with this convention very well.
95 ----*/
97 struct pine {
98 void (*next_screen)(struct pine *); /* See loop at end of main() for how */
99 void (*prev_screen)(struct pine *); /* these are used... */
100 void (*redrawer)(void); /* NULL means stay in current screen */
102 CONTEXT_S *context_list; /* list of user defined contexts */
103 CONTEXT_S *context_current; /* default open context */
104 CONTEXT_S *context_last; /* most recently open context */
106 SP_S s_pool; /* stream pool */
108 char inbox_name[MAXFOLDER+1];
109 char pine_pre_vers[10]; /* highest version previously run */
110 char vers_internal[10];
112 MAILSTREAM *mail_stream; /* ptr to current folder stream */
113 MSGNO_S *msgmap; /* ptr to current message map */
115 unsigned read_predicted:1;
117 char cur_folder[MAXPATH+1];
118 QUOTALIST *quota;
119 IDLIST *id;
120 char last_unambig_folder[MAXPATH+1];
121 char last_save_folder[MAXPATH+1];
122 CONTEXT_S *last_save_context;
123 ATTACH_S *atmts;
124 int atmts_allocated;
125 int remote_abook_validity; /* minutes, -1=never, 0=only on opens */
127 INDEX_COL_S *index_disp_format;
129 char *folders_dir;
130 char *html_dir;
132 HTML_LOG_S *html_dir_list;
133 unsigned signal_in_progress:1; /* we are handling a signal */
134 unsigned mangled_footer:1; /* footer needs repainting */
135 unsigned mangled_header:1; /* header needs repainting */
136 unsigned mangled_body:1; /* body of screen needs repainting */
137 unsigned mangled_screen:1; /* whole screen needs repainting */
139 unsigned in_init_seq:1; /* executing initial cmd list */
140 unsigned save_in_init_seq:1;
141 unsigned dont_use_init_cmds:1; /* use keyboard input when true */
143 unsigned give_fixed_warning:1; /* warn user about "fixed" vars */
144 unsigned fix_fixed_warning:1; /* offer to fix it */
146 unsigned user_says_cancel:1; /* user typed ^C to abort open */
148 unsigned unseen_in_view:1;
149 unsigned start_in_context:1; /* start fldr_scrn in current cntxt */
150 unsigned def_sort_rev:1; /* true if reverse sort is default */
151 unsigned restricted:1;
153 unsigned tcptimeout:1; /* a tcp timeout is in progress */
154 unsigned read_bail:1; /* we are coming back from a read bail! */
156 unsigned save_msg_rule:5;
157 unsigned fcc_rule:3;
158 unsigned ab_sort_rule:3;
159 unsigned color_style:3;
160 unsigned index_color_style:3;
161 unsigned titlebar_color_style:3;
162 unsigned fld_sort_rule:3;
163 unsigned inc_startup_rule:3;
164 unsigned pruning_rule:3;
165 unsigned reopen_rule:4;
166 unsigned goto_default_rule:3;
167 unsigned thread_disp_style:3;
168 unsigned thread_index_style:3;
170 unsigned full_header:2; /* display full headers */
171 /* 0 means normal */
172 /* 1 means display all quoted text */
173 /* 2 means full headers */
174 unsigned some_quoting_was_suppressed:1;
175 unsigned orig_use_fkeys:1;
176 unsigned try_to_create:1; /* Save should try mail_create */
177 unsigned low_speed:1; /* various opt's 4 low connect speed */
178 unsigned postpone_no_flow:1; /* don't set flowed when we postpone */
179 /* and don't reflow when we resume. */
180 unsigned mm_log_error:1;
181 unsigned show_new_version:1;
182 unsigned pre441:1;
183 unsigned first_time_user:1;
184 unsigned intr_pending:1; /* received SIGINT and haven't acted */
185 unsigned expunge_in_progress:1; /* don't want to re-enter c-client */
186 unsigned never_allow_changing_from:1; /* not even for roles */
187 unsigned newthread:1; /* start a new thread on composing */
189 unsigned readonly_pinerc:1;
190 unsigned view_all_except:1;
191 unsigned start_in_index:1; /* cmd line flag modified on startup */
192 unsigned noshow_error:1; /* c-client error callback controls */
193 unsigned noshow_warn:1;
194 unsigned noshow_timeout:1;
195 unsigned conceal_sensitive_debugging:1;
196 unsigned turn_off_threading_temporarily:1;
197 unsigned view_skipped_index:1;
198 unsigned a_format_contains_score:1;
199 unsigned ugly_consider_advancing_bit:1;
200 unsigned dont_count_flagchanges:1;
201 unsigned in_folder_screen:1;
202 unsigned noticed_change_in_unseen:1;
203 unsigned first_open_was_attempted:1;
204 unsigned force_prefer_plain:1;
205 unsigned force_no_prefer_plain:1;
207 unsigned painted_body_on_startup:1;
208 unsigned painted_footer_on_startup:1;
209 unsigned open_readonly_on_startup:1;
210 unsigned exit_if_no_pinerc:1;
211 unsigned pass_ctrl_chars:1;
212 unsigned pass_c1_ctrl_chars:1;
213 unsigned display_keywords_in_subject:1;
214 unsigned display_keywordinits_in_subject:1;
215 unsigned beginning_of_month:1;
216 unsigned beginning_of_year:1;
218 unsigned can_interrupt:1;
219 long int close_connection_timeout;
221 unsigned viewer_overlap:8;
222 unsigned scroll_margin:8;
223 unsigned remote_abook_history:8;
225 #if defined(DOS) || defined(OS2)
226 unsigned blank_user_id:1;
227 unsigned blank_personal_name:1;
228 unsigned blank_user_domain:1;
229 #ifdef _WINDOWS
230 unsigned update_registry:2;
231 unsigned install_flag:1;
232 #endif
233 #endif
235 unsigned debug_malloc:6;
236 unsigned debug_timestamp:1;
237 unsigned debug_flush:1;
238 unsigned debug_tcp:1;
239 unsigned debug_imap:3;
240 unsigned debug_nfiles:5;
241 unsigned debugmem:1;
242 #ifdef LOCAL_PASSWD_CACHE
243 unsigned nowrite_password_cache:1;
244 #endif
246 unsigned convert_sigs:1;
247 unsigned dump_supported_options:1;
249 unsigned noexpunge_on_close:1;
251 unsigned no_newmail_check_from_optionally_enter:1;
253 unsigned post_utf8:1;
255 unsigned start_entry; /* cmd line arg: msg # to start on */
257 bitmap_t feature_list; /* a bitmap of all the features */
258 char **feat_list_back_compat;
260 SPEC_COLOR_S *hdr_colors; /* list of configured colors for view */
261 SPEC_COLOR_S *index_token_colors; /* list of configured colors for index */
263 short init_context;
265 struct {
266 unsigned keep_attach:1;
267 unsigned strip_signature:1;
268 unsigned use_flowed:1;
269 unsigned include_header:1;
270 unsigned preserve_fields:1;
271 unsigned signature_bottom:1;
272 ACTION_S *role_chosen;
273 } reply;
275 int *initial_cmds; /* cmds to execute on startup */
276 int *free_initial_cmds; /* used to free when done */
278 char c_client_error[300]; /* when nowhow_error is set and PARSE */
280 struct ttyo *ttyo;
282 USER_S ui; /* system derived user info */
284 POST_S *post;
286 char *home_dir,
287 *hostname, /* Fully qualified hostname */
288 *localdomain, /* The (DNS) domain this host resides in */
289 *userdomain, /* The per user domain from .pinerc or */
290 *maildomain, /* Domain name for most uses */
291 #if defined(DOS) || defined(OS2)
292 *pine_dir, /* argv[0] as provided by DOS */
293 *aux_files_dir, /* User's auxiliary files directory */
294 #endif
295 #ifdef PASSFILE
296 *passfile,
297 #endif /* PASSFILE */
298 *pinerc, /* Location of user's pinerc */
299 *exceptions, /* Location of user's exceptions */
300 *pine_name; /* name we were invoked under */
301 PINERC_S *prc, /* structure for personal pinerc */
302 *post_prc, /* structure for post-loaded pinerc */
303 *pconf; /* structure for global pinerc */
305 EditWhich ew_for_except_vars;
306 EditWhich ew_for_role_take;
307 EditWhich ew_for_score_take;
308 EditWhich ew_for_filter_take;
309 EditWhich ew_for_incol_take;
310 EditWhich ew_for_other_take;
311 EditWhich ew_for_srch_take;
313 SortOrder def_sort, /* Default sort type */
314 sort_types[22];
316 int last_expire_year, last_expire_month;
318 int printer_category;
320 int status_msg_delay;
322 int active_status_interval;
324 int composer_fillcol;
326 int nmw_width;
328 int hours_to_timeout;
330 int tcp_query_timeout;
332 int inc_check_timeout;
333 int inc_check_interval; /* for local and IMAP */
334 int inc_second_check_interval; /* for other */
336 time_t check_interval_for_noncurr;
338 time_t last_nextitem_forcechk;
340 MAILSTREAM *cur_uid_stream;
341 imapuid_t cur_uid;
343 int deadlets;
345 int quote_suppression_threshold;
347 char *display_charmap; /* needs to be freed */
348 char *keyboard_charmap; /* needs to be freed */
349 void *input_cs;
351 char *posting_charmap; /* needs to be freed */
353 CONV_TABLE *conv_table;
356 * Optional tools Pine Data Engine caller might provide
358 struct {
359 char *(*display_filter)(char *, STORE_S *, gf_io_t, FILTLIST_S *);
360 char *(*display_filter_trigger)(BODY *, char *, size_t);
361 } tools;
363 KEYWORD_S *keywords;
364 SPEC_COLOR_S *kw_colors;
366 ACTION_S *default_role; /* pointer to one of regular roles */
368 char last_error[500];
369 INIT_ERR_S *init_errs;
371 PRINT_S *print;
373 #ifdef SMIME
374 int keyemptypwd; /* can we load the key without a password? */
375 char *smimedir;
376 SMIME_STUFF_S *smime;
377 char *pwdcertdir; /* path to location of certificates for password file */
378 void *pwdcert; /* this is of type PERSONAL_CERT */
379 char *pwdcertcontent; /* No comment yet */
380 void *backuppassword; /* this is of type CertList */
381 void *pwdcertlist; /* this is of type CertList */
382 #endif /* SMIME */
384 struct variable *vars;
388 /*----------------------------------------------------------------------
389 The few global variables we use in Pine Data Engine
390 ----*/
392 extern struct pine *ps_global;
394 #define SIZEOF_20KBUF (20480)
395 extern char tmp_20k_buf[];
398 /* exported prototypes */
399 struct pine *new_pine_struct(void);
400 void free_pine_struct(struct pine **);
401 void free_pinerc_strings(struct pine **);
402 void free_vars(struct pine *);
403 void free_variable_values(struct variable *);
404 PINERC_S *new_pinerc_s(char *);
405 void free_pinerc_s(PINERC_S **);
406 void free_pith_module_globals(void);
408 #endif /* PITH_STATE_INCLUDED */