* Implement a different way to delete a password from the cache.
[alpine.git] / pith / state.h
blob9f63d46f5a96a1a6311b94c04a01f369ed1e08ac
1 /*
2 * $Id: state.h 1074 2008-06-04 00:08:43Z hubert@u.washington.edu $
4 * ========================================================================
5 * Copyright 2013-2022 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 write_debug_file:1; /* should we write debug to a file */
134 unsigned signal_in_progress:1; /* we are handling a signal */
135 unsigned mangled_footer:1; /* footer needs repainting */
136 unsigned mangled_header:1; /* header needs repainting */
137 unsigned mangled_body:1; /* body of screen needs repainting */
138 unsigned mangled_screen:1; /* whole screen needs repainting */
140 unsigned in_init_seq:1; /* executing initial cmd list */
141 unsigned save_in_init_seq:1;
142 unsigned dont_use_init_cmds:1; /* use keyboard input when true */
144 unsigned give_fixed_warning:1; /* warn user about "fixed" vars */
145 unsigned fix_fixed_warning:1; /* offer to fix it */
147 unsigned user_says_cancel:1; /* user typed ^C to abort open */
148 unsigned in_xoauth2_auth:1; /* user is attempting xoauth2 authentication */
149 unsigned preserve_password:1; /* user is saving the password */
151 unsigned unseen_in_view:1;
152 unsigned start_in_context:1; /* start fldr_scrn in current cntxt */
153 unsigned def_sort_rev:1; /* true if reverse sort is default */
154 unsigned restricted:1;
156 unsigned tcptimeout:1; /* a tcp timeout is in progress */
157 unsigned read_bail:1; /* we are coming back from a read bail! */
159 unsigned save_msg_rule:5;
160 unsigned fcc_rule:3;
161 unsigned ab_sort_rule:3;
162 unsigned color_style:3;
163 unsigned index_color_style:3;
164 unsigned titlebar_color_style:3;
165 unsigned fld_sort_rule:3;
166 unsigned inc_startup_rule:3;
167 unsigned pruning_rule:3;
168 unsigned reopen_rule:4;
169 unsigned goto_default_rule:3;
170 unsigned thread_disp_style:3;
171 unsigned thread_index_style:3;
173 unsigned full_header:2; /* display full headers */
174 /* 0 means normal */
175 /* 1 means display all quoted text */
176 /* 2 means full headers */
177 unsigned some_quoting_was_suppressed:1;
178 unsigned orig_use_fkeys:1;
179 unsigned try_to_create:1; /* Save should try mail_create */
180 unsigned low_speed:1; /* various opt's 4 low connect speed */
181 unsigned postpone_no_flow:1; /* don't set flowed when we postpone */
182 /* and don't reflow when we resume. */
183 unsigned mm_log_error:1;
184 unsigned show_new_version:1;
185 unsigned pre441:1;
186 unsigned first_time_user:1;
187 unsigned intr_pending:1; /* received SIGINT and haven't acted */
188 unsigned expunge_in_progress:1; /* don't want to re-enter c-client */
189 unsigned never_allow_changing_from:1; /* not even for roles */
190 unsigned newthread:1; /* start a new thread on composing */
192 unsigned readonly_pinerc:1;
193 unsigned view_all_except:1;
194 unsigned start_in_index:1; /* cmd line flag modified on startup */
195 unsigned noshow_error:1; /* c-client error callback controls */
196 unsigned noshow_warn:1;
197 unsigned noshow_timeout:1;
198 unsigned conceal_sensitive_debugging:1;
199 unsigned turn_off_threading_temporarily:1;
200 unsigned view_skipped_index:1;
201 unsigned a_format_contains_score:1;
202 unsigned ugly_consider_advancing_bit:1;
203 unsigned dont_count_flagchanges:1;
204 unsigned in_folder_screen:1;
205 unsigned noticed_change_in_unseen:1;
206 unsigned first_open_was_attempted:1;
207 unsigned force_prefer_plain:1;
208 unsigned force_no_prefer_plain:1;
210 unsigned painted_body_on_startup:1;
211 unsigned painted_footer_on_startup:1;
212 unsigned open_readonly_on_startup:1;
213 unsigned exit_if_no_pinerc:1;
214 unsigned pass_ctrl_chars:1;
215 unsigned pass_c1_ctrl_chars:1;
216 unsigned display_keywords_in_subject:1;
217 unsigned display_keywordinits_in_subject:1;
218 unsigned beginning_of_month:1;
219 unsigned beginning_of_year:1;
221 unsigned can_interrupt:1;
222 long int close_connection_timeout;
224 unsigned viewer_overlap:8;
225 unsigned scroll_margin:8;
226 unsigned remote_abook_history:8;
228 #if defined(DOS) || defined(OS2)
229 unsigned blank_user_id:1;
230 unsigned blank_personal_name:1;
231 unsigned blank_user_domain:1;
232 #ifdef _WINDOWS
233 unsigned update_registry:2;
234 unsigned install_flag:1;
235 #endif
236 #endif
238 unsigned debug_malloc:6;
239 unsigned debug_timestamp:1;
240 unsigned debug_flush:1;
241 unsigned debug_tcp:1;
242 unsigned debug_http:1;
243 unsigned debug_imap:3;
244 unsigned debug_nfiles:5;
245 unsigned debugmem:1;
246 #ifdef LOCAL_PASSWD_CACHE
247 unsigned nowrite_password_cache:1;
248 #endif
250 unsigned convert_sigs:1;
251 unsigned dump_supported_options:1;
253 unsigned noexpunge_on_close:1;
255 unsigned no_newmail_check_from_optionally_enter:1;
257 unsigned post_utf8:1;
259 unsigned start_entry; /* cmd line arg: msg # to start on */
261 bitmap_t feature_list; /* a bitmap of all the features */
262 char **feat_list_back_compat;
264 SPEC_COLOR_S *hdr_colors; /* list of configured colors for view */
265 SPEC_COLOR_S *index_token_colors; /* list of configured colors for index */
267 short init_context;
269 struct {
270 unsigned keep_attach:1;
271 unsigned strip_signature:1;
272 unsigned use_flowed:1;
273 unsigned include_header:1;
274 unsigned preserve_fields:1;
275 unsigned signature_bottom:1;
276 ACTION_S *role_chosen;
277 } reply;
279 int *initial_cmds; /* cmds to execute on startup */
280 int *free_initial_cmds; /* used to free when done */
282 char c_client_error[300]; /* when nowhow_error is set and PARSE */
284 struct ttyo *ttyo;
286 USER_S ui; /* system derived user info */
288 POST_S *post;
290 char *home_dir,
291 *hostname, /* Fully qualified hostname */
292 *localdomain, /* The (DNS) domain this host resides in */
293 *userdomain, /* The per user domain from .pinerc or */
294 *maildomain, /* Domain name for most uses */
295 #if defined(DOS) || defined(OS2)
296 *pine_dir, /* argv[0] as provided by DOS */
297 *aux_files_dir, /* User's auxiliary files directory */
298 #endif
299 #ifdef PASSFILE
300 *passfile,
301 #endif /* PASSFILE */
302 *pinerc, /* Location of user's pinerc */
303 *exceptions, /* Location of user's exceptions */
304 *pine_name; /* name we were invoked under */
305 PINERC_S *prc, /* structure for personal pinerc */
306 *post_prc, /* structure for post-loaded pinerc */
307 *pconf; /* structure for global pinerc */
309 EditWhich ew_for_except_vars;
310 EditWhich ew_for_role_take;
311 EditWhich ew_for_score_take;
312 EditWhich ew_for_filter_take;
313 EditWhich ew_for_incol_take;
314 EditWhich ew_for_other_take;
315 EditWhich ew_for_srch_take;
317 SortOrder def_sort, /* Default sort type */
318 sort_types[22];
320 int last_expire_year, last_expire_month;
322 int printer_category;
324 int status_msg_delay;
326 int active_status_interval;
328 int composer_fillcol;
330 int nmw_width;
332 int hours_to_timeout;
334 int tcp_query_timeout;
336 int inc_check_timeout;
337 int inc_check_interval; /* for local and IMAP */
338 int inc_second_check_interval; /* for other */
340 time_t check_interval_for_noncurr;
342 time_t last_nextitem_forcechk;
344 MAILSTREAM *cur_uid_stream;
345 imapuid_t cur_uid;
347 int deadlets;
349 int quote_suppression_threshold;
351 char *display_charmap; /* needs to be freed */
352 char *keyboard_charmap; /* needs to be freed */
353 void *input_cs;
355 char *posting_charmap; /* needs to be freed */
357 CONV_TABLE *conv_table;
360 * Optional tools Pine Data Engine caller might provide
362 struct {
363 char *(*display_filter)(char *, STORE_S *, gf_o_t, FILTLIST_S *);
364 char *(*display_filter_trigger)(BODY *, char *, size_t);
365 } tools;
367 KEYWORD_S *keywords;
368 SPEC_COLOR_S *kw_colors;
370 ACTION_S *default_role; /* pointer to one of regular roles */
372 char last_error[500];
373 INIT_ERR_S *init_errs;
375 PRINT_S *print;
377 #ifdef SMIME
378 int keyemptypwd; /* can we load the key without a password? */
379 char *smimedir;
380 SMIME_STUFF_S *smime;
381 char *pwdcertdir; /* path to location of certificates for password file */
382 void *pwdcert; /* this is of type PERSONAL_CERT */
383 char *pwdcertcontent; /* No comment yet */
384 void *backuppassword; /* this is of type CertList */
385 void *pwdcertlist; /* this is of type CertList */
386 #endif /* SMIME */
388 struct variable *vars;
392 /*----------------------------------------------------------------------
393 The few global variables we use in Pine Data Engine
394 ----*/
396 extern struct pine *ps_global;
398 #define SIZEOF_20KBUF (20480)
399 extern char tmp_20k_buf[];
402 /* exported prototypes */
403 struct pine *new_pine_struct(void);
404 void free_pine_struct(struct pine **);
405 void free_pinerc_strings(struct pine **);
406 void free_vars(struct pine *);
407 void free_variable_values(struct variable *);
408 PINERC_S *new_pinerc_s(char *);
409 void free_pinerc_s(PINERC_S **);
410 void free_pith_module_globals(void);
412 #endif /* PITH_STATE_INCLUDED */