1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
|
/*
* ========================================================================
* Copyright 2013-2022 Eduardo Chappa
* Copyright 2006-2008 University of Washington
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* ========================================================================
*/
/*======================================================================
state.c
Implements the Pine state management routines
====*/
#include "../pith/headers.h"
#include "../pith/state.h"
#include "../pith/conf.h"
#include "../pith/init.h"
#include "../pith/sort.h"
#include "../pith/atttype.h"
#include "../pith/util.h"
#include "../pith/mailindx.h"
#include "../pith/remote.h"
#include "../pith/list.h"
#include "../pith/smime.h"
#include "../pith/ical.h"
#include "../pith/bldaddr.h"
/*
* Globals referenced throughout pine...
*/
struct pine *ps_global; /* THE global variable! */
#ifdef DEBUG
/*
* Debug level and output file defined here, referenced globally.
* The debug file is opened and initialized below...
*/
int debug = DEFAULT_DEBUG;
#endif
/*----------------------------------------------------------------------
General use big buffer. It is used in the following places:
compose_mail: while parsing header of postponed message
append_message2: while writing header into folder
q_status_messageX: while doing printf formatting
addr_book: Used to return expanded address in. (Can only use here
because mm_log doesn't q_status on PARSE errors !)
alpine.c: When address specified on command line
init.c: When expanding variable values
and many many more...
----*/
char tmp_20k_buf[SIZEOF_20KBUF];
/*
* new_pine_struct - allocate and fill in with default values a new pine struct
*/
struct pine *
new_pine_struct(void)
{
struct pine *p;
p = (struct pine *)fs_get(sizeof (struct pine));
memset((void *) p, 0, sizeof(struct pine));
p->def_sort = SortArrival;
p->sort_types[0] = SortSubject;
p->sort_types[1] = SortArrival;
p->sort_types[2] = SortFrom;
p->sort_types[3] = SortTo;
p->sort_types[4] = SortCc;
p->sort_types[5] = SortDate;
p->sort_types[6] = SortSize;
p->sort_types[7] = SortSubject2;
p->sort_types[8] = SortScore;
p->sort_types[9] = SortThread;
p->sort_types[10] = EndofList;
#ifdef SMIME
/*
* We need to have access to p->smime even before calling
* smime_init() so that we can set do_encrypt and do_sign.
*/
p->smime = new_smime_struct();
#endif /* SMIME */
p->atmts = (ATTACH_S *) fs_get(sizeof(ATTACH_S));
p->atmts_allocated = 1;
p->atmts->description = NULL;
p->low_speed = 1;
p->init_context = -1;
/* msgno_init(&p->msgmap, 0L, SortArrival, 0);*/
init_init_vars(p);
return(p);
}
/*
* free_pine_struct -- free up allocated data in pine struct and then the
* struct itself
*/
void
free_pine_struct(struct pine **pps)
{
if(!(pps && (*pps)))
return;
if((*pps)->free_initial_cmds != NULL)
fs_give((void **) &(*pps)->free_initial_cmds);
if((*pps)->id != NULL)
mail_free_idlist(&(*pps)->id);
if((*pps)->hostname != NULL)
fs_give((void **)&(*pps)->hostname);
if((*pps)->localdomain != NULL)
fs_give((void **)&(*pps)->localdomain);
if((*pps)->ttyo != NULL)
fs_give((void **)&(*pps)->ttyo);
if((*pps)->home_dir != NULL)
fs_give((void **)&(*pps)->home_dir);
if((*pps)->folders_dir != NULL)
fs_give((void **)&(*pps)->folders_dir);
if((*pps)->html_dir != NULL)
fs_give((void **)&(*pps)->html_dir);
if((*pps)->html_dir_list != NULL)
free_html_log(&(*pps)->html_dir_list);
if((*pps)->ui.homedir)
fs_give((void **)&(*pps)->ui.homedir);
if((*pps)->ui.login)
fs_give((void **)&(*pps)->ui.login);
if((*pps)->ui.fullname)
fs_give((void **)&(*pps)->ui.fullname);
free_index_format(&(*pps)->index_disp_format);
if((*pps)->conv_table){
if((*pps)->conv_table->table)
fs_give((void **) &(*pps)->conv_table->table);
if((*pps)->conv_table->from_charset)
fs_give((void **) &(*pps)->conv_table->from_charset);
if((*pps)->conv_table->to_charset)
fs_give((void **) &(*pps)->conv_table->to_charset);
fs_give((void **)&(*pps)->conv_table);
}
if((*pps)->pinerc)
fs_give((void **)&(*pps)->pinerc);
#if defined(DOS) || defined(OS2)
if((*pps)->pine_dir)
fs_give((void **)&(*pps)->pine_dir);
if((*pps)->aux_files_dir)
fs_give((void **)&(*pps)->aux_files_dir);
#endif
if((*pps)->display_charmap)
fs_give((void **)&(*pps)->display_charmap);
if((*pps)->keyboard_charmap)
fs_give((void **)&(*pps)->keyboard_charmap);
if((*pps)->posting_charmap)
fs_give((void **)&(*pps)->posting_charmap);
#ifdef SMIME
if((*pps)->pwdcertdir)
fs_give((void **)&(*pps)->pwdcertdir);
if((*pps)->pwdcert){
PERSONAL_CERT *pc;
pc = (PERSONAL_CERT *) (*pps)->pwdcert;
free_personal_certs(&pc);
(*pps)->pwdcert = NULL;
}
if((*pps)->pwdcertlist){
CertList *cert;
cert = (CertList *) (*pps)->pwdcertlist;
free_certlist(&cert);
(*pps)->pwdcertlist = NULL;
}
if((*pps)->backuppassword){
CertList *cert;
cert = (CertList *) (*pps)->backuppassword;
free_certlist(&cert);
(*pps)->backuppassword = NULL;
}
#endif /* SMIME */
#ifdef PASSFILE
if((*pps)->passfile)
fs_give((void **)&(*pps)->passfile);
#endif /* PASSFILE */
if((*pps)->hdr_colors)
free_spec_colors(&(*pps)->hdr_colors);
if((*pps)->index_token_colors)
free_spec_colors(&(*pps)->index_token_colors);
if((*pps)->keywords)
free_keyword_list(&(*pps)->keywords);
if((*pps)->kw_colors)
free_spec_colors(&(*pps)->kw_colors);
if((*pps)->atmts){
int i;
for(i = 0; (*pps)->atmts[i].description; i++){
fs_give((void **) &(*pps)->atmts[i].description);
fs_give((void **) &(*pps)->atmts[i].number);
}
fs_give((void **) &(*pps)->atmts);
}
if((*pps)->msgmap)
msgno_give(&(*pps)->msgmap);
if((*pps)->id)
free_id(&(*pps)->id);
free_vars(*pps);
fs_give((void **) pps);
}
void
free_pinerc_strings(struct pine **pps)
{
if((*pps)->prc){
if((*pps)->prc->outstanding_pinerc_changes)
write_pinerc((*pps), Main, WRP_NONE);
if((*pps)->prc->rd)
rd_close_remdata(&(*pps)->prc->rd);
free_pinerc_s(&(*pps)->prc);
}
if((*pps)->pconf)
free_pinerc_s(&(*pps)->pconf);
if((*pps)->post_prc){
if((*pps)->post_prc->outstanding_pinerc_changes)
write_pinerc((*pps), Post, WRP_NONE);
if((*pps)->post_prc->rd)
rd_close_remdata(&(*pps)->post_prc->rd);
free_pinerc_s(&(*pps)->post_prc);
}
}
/*
* free_vars -- give back resources acquired when we defined the
* variables list
*/
void
free_vars(struct pine *ps)
{
register int i;
for(i = 0; ps && i <= V_LAST_VAR; i++)
free_variable_values(&ps->vars[i]);
}
void
free_variable_values(struct variable *var)
{
if(var){
if(var->is_list){
free_list_array(&var->current_val.l);
free_list_array(&var->main_user_val.l);
free_list_array(&var->post_user_val.l);
free_list_array(&var->global_val.l);
free_list_array(&var->fixed_val.l);
free_list_array(&var->cmdline_val.l);
}
else{
if(var->current_val.p)
fs_give((void **)&var->current_val.p);
if(var->main_user_val.p)
fs_give((void **)&var->main_user_val.p);
if(var->post_user_val.p)
fs_give((void **)&var->post_user_val.p);
if(var->global_val.p)
fs_give((void **)&var->global_val.p);
if(var->fixed_val.p)
fs_give((void **)&var->fixed_val.p);
if(var->cmdline_val.p)
fs_give((void **)&var->cmdline_val.p);
}
}
}
PINERC_S *
new_pinerc_s(char *name)
{
PINERC_S *prc = NULL;
if(name){
prc = (PINERC_S *)fs_get(sizeof(*prc));
memset((void *)prc, 0, sizeof(*prc));
prc->name = cpystr(name);
if(IS_REMOTE(name))
prc->type = RemImap;
else
prc->type = Loc;
}
return(prc);
}
void
free_pinerc_s(PINERC_S **prc)
{
if(prc && *prc){
if((*prc)->name)
fs_give((void **)&(*prc)->name);
if((*prc)->rd)
rd_free_remdata(&(*prc)->rd);
if((*prc)->pinerc_lines)
free_pinerc_lines(&(*prc)->pinerc_lines);
fs_give((void **)prc);
}
}
void
free_pith_module_globals(void)
{
free_filter_module_globals();
ical_free_all();
free_bldaddr_module_globals();
fname_to_locale(NULL);
fname_to_utf8(NULL);
}
|