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