* A few improvements to the http code, which make the http_* functions not return...
[alpine.git] / pith / state.h
blob41ef1b43512f3ea4e09e0e8b7bc7048ce02aed1c
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 */
65 * HEADER_ROWS is always 2. 1 for the titlebar and 1 for the
66 * blank line after the titlebar. We should probably make it go down
67 * to 0 when the screen shrinks but instead we're just figuring out
68 * if there is enough room by looking at screen_rows.
69 * FOOTER_ROWS is either 3 or 1. Normally it is 3, 2 for the keymenu plus 1
70 * for the status line. If the NoKeyMenu command has been given, then it is 1.
72 #define HEADER_ROWS(X) ((X)->ttyo->header_rows)
73 #define FOOTER_ROWS(X) ((X)->ttyo->footer_rows)
76 /*----------------------------------------------------------------------
77 This structure sort of takes the place of global variables or perhaps
78 is the global variable. (It can be accessed globally as ps_global. One
79 advantage to this is that as soon as you see a reference to the structure
80 you know it is a global variable.
81 In general it is treated as global by the lower level and utility
82 routines, but it is not treated so by the main screen driving routines.
83 Each of them receives it as an argument and then sets ps_global to the
84 argument they received. This is sort of with the thought that things
85 might be coupled more loosely one day and that Pine might run where there
86 is more than one window and more than one instance. But we haven't kept
87 up with this convention very well.
88 ----*/
90 struct pine {
91 void (*next_screen)(struct pine *); /* See loop at end of main() for how */
92 void (*prev_screen)(struct pine *); /* these are used... */
93 void (*redrawer)(void); /* NULL means stay in current screen */
95 CONTEXT_S *context_list; /* list of user defined contexts */
96 CONTEXT_S *context_current; /* default open context */
97 CONTEXT_S *context_last; /* most recently open context */
99 SP_S s_pool; /* stream pool */
101 char inbox_name[MAXFOLDER+1];
102 char pine_pre_vers[10]; /* highest version previously run */
103 char vers_internal[10];
105 MAILSTREAM *mail_stream; /* ptr to current folder stream */
106 MSGNO_S *msgmap; /* ptr to current message map */
108 unsigned read_predicted:1;
110 char cur_folder[MAXPATH+1];
111 QUOTALIST *quota;
112 IDLIST *id;
113 char last_unambig_folder[MAXPATH+1];
114 char last_save_folder[MAXPATH+1];
115 CONTEXT_S *last_save_context;
116 ATTACH_S *atmts;
117 int atmts_allocated;
118 int remote_abook_validity; /* minutes, -1=never, 0=only on opens */
120 INDEX_COL_S *index_disp_format;
122 char *folders_dir;
124 unsigned signal_in_progress:1; /* we are handling a signal */
125 unsigned mangled_footer:1; /* footer needs repainting */
126 unsigned mangled_header:1; /* header needs repainting */
127 unsigned mangled_body:1; /* body of screen needs repainting */
128 unsigned mangled_screen:1; /* whole screen needs repainting */
130 unsigned in_init_seq:1; /* executing initial cmd list */
131 unsigned save_in_init_seq:1;
132 unsigned dont_use_init_cmds:1; /* use keyboard input when true */
134 unsigned give_fixed_warning:1; /* warn user about "fixed" vars */
135 unsigned fix_fixed_warning:1; /* offer to fix it */
137 unsigned user_says_cancel:1; /* user typed ^C to abort open */
139 unsigned unseen_in_view:1;
140 unsigned start_in_context:1; /* start fldr_scrn in current cntxt */
141 unsigned def_sort_rev:1; /* true if reverse sort is default */
142 unsigned restricted:1;
144 unsigned tcptimeout:1; /* a tcp timeout is in progress */
145 unsigned read_bail:1; /* we are coming back from a read bail! */
147 unsigned save_msg_rule:5;
148 unsigned fcc_rule:3;
149 unsigned ab_sort_rule:3;
150 unsigned color_style:3;
151 unsigned index_color_style:3;
152 unsigned titlebar_color_style:3;
153 unsigned fld_sort_rule:3;
154 unsigned inc_startup_rule:3;
155 unsigned pruning_rule:3;
156 unsigned reopen_rule:4;
157 unsigned goto_default_rule:3;
158 unsigned thread_disp_style:3;
159 unsigned thread_index_style:3;
161 unsigned full_header:2; /* display full headers */
162 /* 0 means normal */
163 /* 1 means display all quoted text */
164 /* 2 means full headers */
165 unsigned some_quoting_was_suppressed:1;
166 unsigned orig_use_fkeys:1;
167 unsigned try_to_create:1; /* Save should try mail_create */
168 unsigned low_speed:1; /* various opt's 4 low connect speed */
169 unsigned postpone_no_flow:1; /* don't set flowed when we postpone */
170 /* and don't reflow when we resume. */
171 unsigned mm_log_error:1;
172 unsigned show_new_version:1;
173 unsigned pre441:1;
174 unsigned first_time_user:1;
175 unsigned intr_pending:1; /* received SIGINT and haven't acted */
176 unsigned expunge_in_progress:1; /* don't want to re-enter c-client */
177 unsigned never_allow_changing_from:1; /* not even for roles */
178 unsigned newthread:1; /* start a new thread on composing */
180 unsigned readonly_pinerc:1;
181 unsigned view_all_except:1;
182 unsigned start_in_index:1; /* cmd line flag modified on startup */
183 unsigned noshow_error:1; /* c-client error callback controls */
184 unsigned noshow_warn:1;
185 unsigned noshow_timeout:1;
186 unsigned conceal_sensitive_debugging:1;
187 unsigned turn_off_threading_temporarily:1;
188 unsigned view_skipped_index:1;
189 unsigned a_format_contains_score:1;
190 unsigned ugly_consider_advancing_bit:1;
191 unsigned dont_count_flagchanges:1;
192 unsigned in_folder_screen:1;
193 unsigned noticed_change_in_unseen:1;
194 unsigned first_open_was_attempted:1;
195 unsigned force_prefer_plain:1;
196 unsigned force_no_prefer_plain:1;
198 unsigned painted_body_on_startup:1;
199 unsigned painted_footer_on_startup:1;
200 unsigned open_readonly_on_startup:1;
201 unsigned exit_if_no_pinerc:1;
202 unsigned pass_ctrl_chars:1;
203 unsigned pass_c1_ctrl_chars:1;
204 unsigned display_keywords_in_subject:1;
205 unsigned display_keywordinits_in_subject:1;
206 unsigned beginning_of_month:1;
207 unsigned beginning_of_year:1;
209 unsigned can_interrupt:1;
210 long int close_connection_timeout;
212 unsigned viewer_overlap:8;
213 unsigned scroll_margin:8;
214 unsigned remote_abook_history:8;
216 #if defined(DOS) || defined(OS2)
217 unsigned blank_user_id:1;
218 unsigned blank_personal_name:1;
219 unsigned blank_user_domain:1;
220 #ifdef _WINDOWS
221 unsigned update_registry:2;
222 unsigned install_flag:1;
223 #endif
224 #endif
226 unsigned debug_malloc:6;
227 unsigned debug_timestamp:1;
228 unsigned debug_flush:1;
229 unsigned debug_tcp:1;
230 unsigned debug_imap:3;
231 unsigned debug_nfiles:5;
232 unsigned debugmem:1;
233 #ifdef LOCAL_PASSWD_CACHE
234 unsigned nowrite_password_cache:1;
235 #endif
237 unsigned convert_sigs:1;
238 unsigned dump_supported_options:1;
240 unsigned noexpunge_on_close:1;
242 unsigned no_newmail_check_from_optionally_enter:1;
244 unsigned post_utf8:1;
246 unsigned start_entry; /* cmd line arg: msg # to start on */
248 bitmap_t feature_list; /* a bitmap of all the features */
249 char **feat_list_back_compat;
251 SPEC_COLOR_S *hdr_colors; /* list of configured colors for view */
252 SPEC_COLOR_S *index_token_colors; /* list of configured colors for index */
254 short init_context;
256 struct {
257 unsigned keep_attach:1;
258 unsigned strip_signature:1;
259 unsigned use_flowed:1;
260 unsigned include_header:1;
261 unsigned preserve_fields:1;
262 unsigned signature_bottom:1;
263 ACTION_S *role_chosen;
264 } reply;
266 int *initial_cmds; /* cmds to execute on startup */
267 int *free_initial_cmds; /* used to free when done */
269 char c_client_error[300]; /* when nowhow_error is set and PARSE */
271 struct ttyo *ttyo;
273 USER_S ui; /* system derived user info */
275 POST_S *post;
277 char *home_dir,
278 *hostname, /* Fully qualified hostname */
279 *localdomain, /* The (DNS) domain this host resides in */
280 *userdomain, /* The per user domain from .pinerc or */
281 *maildomain, /* Domain name for most uses */
282 #if defined(DOS) || defined(OS2)
283 *pine_dir, /* argv[0] as provided by DOS */
284 *aux_files_dir, /* User's auxiliary files directory */
285 #endif
286 #ifdef PASSFILE
287 *passfile,
288 #endif /* PASSFILE */
289 *pinerc, /* Location of user's pinerc */
290 *exceptions, /* Location of user's exceptions */
291 *pine_name; /* name we were invoked under */
292 PINERC_S *prc, /* structure for personal pinerc */
293 *post_prc, /* structure for post-loaded pinerc */
294 *pconf; /* structure for global pinerc */
296 EditWhich ew_for_except_vars;
297 EditWhich ew_for_role_take;
298 EditWhich ew_for_score_take;
299 EditWhich ew_for_filter_take;
300 EditWhich ew_for_incol_take;
301 EditWhich ew_for_other_take;
302 EditWhich ew_for_srch_take;
304 SortOrder def_sort, /* Default sort type */
305 sort_types[22];
307 int last_expire_year, last_expire_month;
309 int printer_category;
311 int status_msg_delay;
313 int active_status_interval;
315 int composer_fillcol;
317 int nmw_width;
319 int hours_to_timeout;
321 int tcp_query_timeout;
323 int inc_check_timeout;
324 int inc_check_interval; /* for local and IMAP */
325 int inc_second_check_interval; /* for other */
327 time_t check_interval_for_noncurr;
329 time_t last_nextitem_forcechk;
331 MAILSTREAM *cur_uid_stream;
332 imapuid_t cur_uid;
334 int deadlets;
336 int quote_suppression_threshold;
338 char *display_charmap; /* needs to be freed */
339 char *keyboard_charmap; /* needs to be freed */
340 void *input_cs;
342 char *posting_charmap; /* needs to be freed */
344 CONV_TABLE *conv_table;
347 * Optional tools Pine Data Engine caller might provide
349 struct {
350 char *(*display_filter)(char *, STORE_S *, gf_io_t, FILTLIST_S *);
351 char *(*display_filter_trigger)(BODY *, char *, size_t);
352 } tools;
354 KEYWORD_S *keywords;
355 SPEC_COLOR_S *kw_colors;
357 ACTION_S *default_role; /* pointer to one of regular roles */
359 char last_error[500];
360 INIT_ERR_S *init_errs;
362 PRINT_S *print;
364 #ifdef SMIME
365 int keyemptypwd; /* can we load the key without a password? */
366 char *smimedir;
367 SMIME_STUFF_S *smime;
368 char *pwdcertdir; /* path to location of certificates for password file */
369 void *pwdcert; /* this is of type PERSONAL_CERT */
370 char *pwdcertcontent; /* No comment yet */
371 void *backuppassword; /* this is of type CertList */
372 void *pwdcertlist; /* this is of type CertList */
373 #endif /* SMIME */
375 struct variable *vars;
379 /*----------------------------------------------------------------------
380 The few global variables we use in Pine Data Engine
381 ----*/
383 extern struct pine *ps_global;
385 #define SIZEOF_20KBUF (20480)
386 extern char tmp_20k_buf[];
389 /* exported prototypes */
390 struct pine *new_pine_struct(void);
391 void free_pine_struct(struct pine **);
392 void free_pinerc_strings(struct pine **);
393 void free_vars(struct pine *);
394 void free_variable_values(struct variable *);
395 PINERC_S *new_pinerc_s(char *);
396 void free_pinerc_s(PINERC_S **);
397 void free_pith_module_globals(void);
399 #endif /* PITH_STATE_INCLUDED */