NeoMutt  2024-04-25-34-g585158
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
graphviz.c
Go to the documentation of this file.
1
29#include "config.h"
30#include <stdbool.h>
31#include <stdio.h>
32#include <string.h>
33#include <sys/stat.h>
34#include <time.h>
35#include "mutt/lib.h"
36#include "address/lib.h"
37#include "config/lib.h"
38#include "email/lib.h"
39#include "core/lib.h"
40#include "conn/lib.h"
41#include "lib.h"
42#include "attach/lib.h"
43#include "compmbox/lib.h"
44#include "imap/lib.h"
45#include "maildir/lib.h"
46#include "mbox/lib.h"
47#include "ncrypt/lib.h"
48#include "nntp/lib.h"
49#include "pattern/lib.h"
50#include "pop/lib.h"
51#include "imap/adata.h" // IWYU pragma: keep
52#include "imap/mdata.h" // IWYU pragma: keep
53#include "imap/private.h" // IWYU pragma: keep
54#include "maildir/edata.h" // IWYU pragma: keep
55#include "maildir/mdata.h" // IWYU pragma: keep
56#include "mview.h"
57#include "nntp/adata.h" // IWYU pragma: keep
58#include "nntp/mdata.h" // IWYU pragma: keep
59#include "pop/adata.h" // IWYU pragma: keep
60#include "pop/private.h" // IWYU pragma: keep
61#ifdef USE_NOTMUCH
62#include "notmuch/lib.h"
63#include "notmuch/adata.h" // IWYU pragma: keep
64#include "notmuch/mdata.h" // IWYU pragma: keep
65#include "notmuch/private.h" // IWYU pragma: keep
66#endif
67
68// #define GV_HIDE_MVIEW
69#define GV_HIDE_MVIEW_CONTENTS
70// #define GV_HIDE_MBOX
71// #define GV_HIDE_NEOMUTT
72// #define GV_HIDE_CONFIG
73// #define GV_HIDE_ADATA
74// #define GV_HIDE_MDATA
75// #define GV_HIDE_BODY_CONTENT
76// #define GV_HIDE_ENVELOPE
77
78void dot_email(FILE *fp, struct Email *e, struct ListHead *links);
79void dot_envelope(FILE *fp, struct Envelope *env, struct ListHead *links);
80void dot_patternlist(FILE *fp, struct PatternList *pl, struct ListHead *links);
81void dot_expando_node_tree(FILE *fp, struct ExpandoNode *node, struct ListHead *links);
82
83void dot_type_bool(FILE *fp, const char *name, bool val)
84{
85 static const char *values[] = { "false", "true" };
86 fprintf(fp, "\t\t<tr>\n");
87 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\">%s</td>\n", name);
88 fprintf(fp, "\t\t\t<td border=\"0\">=</td>\n");
89 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\">%s</td>\n", values[val]);
90 fprintf(fp, "\t\t</tr>\n");
91}
92
93#ifndef GV_HIDE_ADATA
94void dot_type_char(FILE *fp, const char *name, char ch)
95{
96 fprintf(fp, "\t\t<tr>\n");
97 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\">%s</td>\n", name);
98 fprintf(fp, "\t\t\t<td border=\"0\">=</td>\n");
99 if (ch == '\0')
100 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\">NUL</td>\n");
101 else
102 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\">'%c'</td>\n", ch);
103 fprintf(fp, "\t\t</tr>\n");
104}
105#endif
106
107void dot_type_date(char *buf, size_t buflen, time_t timestamp)
108{
109 mutt_date_localtime_format(buf, buflen, "%Y-%m-%d %H:%M:%S", timestamp);
110}
111
112void dot_type_file(FILE *fp, const char *name, FILE *struct_fp)
113{
114 fprintf(fp, "\t\t<tr>\n");
115 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\">%s</td>\n", name);
116 fprintf(fp, "\t\t\t<td border=\"0\">=</td>\n");
117 if (struct_fp)
118 {
119 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\">%p (%d)</td>\n",
120 (void *) struct_fp, fileno(struct_fp));
121 }
122 else
123 {
124 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\">NULL</td>\n");
125 }
126 fprintf(fp, "\t\t</tr>\n");
127}
128
129void dot_type_number(FILE *fp, const char *name, int num)
130{
131 fprintf(fp, "\t\t<tr>\n");
132 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\">%s</td>\n", name);
133 fprintf(fp, "\t\t\t<td border=\"0\">=</td>\n");
134 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\">%d</td>\n", num);
135 fprintf(fp, "\t\t</tr>\n");
136}
137
139{
140 for (int i = buf_len(buf) - 1; i >= 0; i--)
141 {
142 if (buf_at(buf, i) == '<')
143 buf_inline_replace(buf, i, 1, "&lt;");
144 else if (buf_at(buf, i) == '>')
145 buf_inline_replace(buf, i, 1, "&gt;");
146 else if (buf_at(buf, 1) == '&')
147 buf_inline_replace(buf, i, 1, "&amp;");
148 }
149}
150
151void dot_type_string(FILE *fp, const char *name, const char *str, bool force)
152{
153 if ((!str || (str[0] == '\0')) && !force)
154 return;
155
156 struct Buffer *buf = buf_new(str);
157
158 if (!buf_is_empty(buf))
160
161 bool quoted = ((buf_at(buf, 0) != '[') && (buf_at(buf, 0) != '*'));
162
163 fprintf(fp, "\t\t<tr>\n");
164 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\">%s</td>\n", name);
165 fprintf(fp, "\t\t\t<td border=\"0\">=</td>\n");
166 if (quoted)
167 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\">\"%s\"</td>\n", buf_string(buf));
168 else
169 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\">%s</td>\n", buf_string(buf));
170 fprintf(fp, "\t\t</tr>\n");
171
172 buf_free(&buf);
173}
174
175#ifndef GV_HIDE_MDATA
176void dot_type_umask(char *buf, size_t buflen, int umask)
177{
178 snprintf(buf, buflen, "0%03o", umask);
179}
180#endif
181
182void dot_ptr_name(char *buf, size_t buflen, const void *ptr)
183{
184 snprintf(buf, buflen, "obj_%p", ptr);
185}
186
187void dot_ptr(FILE *fp, const char *name, void *ptr, const char *colour)
188{
189 fprintf(fp, "\t\t<tr>\n");
190 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\">%s</td>\n", name);
191 fprintf(fp, "\t\t\t<td border=\"0\">=</td>\n");
192 if (colour && ptr)
193 {
194 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\" bgcolor=\"%s\">%p</td>\n",
195 colour, ptr);
196 }
197 else
198 {
199 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\">%p</td>\n", ptr);
200 }
201 fprintf(fp, "\t\t</tr>\n");
202}
203
204void dot_add_link(struct ListHead *links, void *src, void *dst, const char *label,
205 const char *short_label, bool back, const char *colour)
206{
207 if (!src || !dst)
208 return;
209 if (!colour)
210 colour = "#c0c0c0";
211
212 char obj1[64] = { 0 };
213 char obj2[64] = { 0 };
214 char text[512] = { 0 };
215 char lstr[128] = { 0 };
216 char sstr[128] = { 0 };
217
218 dot_ptr_name(obj1, sizeof(obj1), src);
219 dot_ptr_name(obj2, sizeof(obj2), dst);
220
221 if (label)
222 snprintf(lstr, sizeof(lstr), "edgetooltip=\"%s\"", label);
223
224 if (short_label)
225 snprintf(sstr, sizeof(sstr), "label=\"%s\"", short_label);
226
227 snprintf(text, sizeof(text), "%s -> %s [ %s %s %s color=\"%s\" ]", obj1, obj2,
228 back ? "dir=back" : "", lstr, sstr, colour);
230}
231
232void dot_graph_header(FILE *fp)
233{
234 fprintf(fp, "digraph neomutt\n");
235 fprintf(fp, "{\n\n");
236
237 fprintf(fp, "\tgraph [\n");
238 fprintf(fp, "\t\trankdir=\"TB\"\n");
239 fprintf(fp, "\t\tnodesep=\"0.5\"\n");
240 fprintf(fp, "\t\tranksep=\"0.5\"\n");
241 fprintf(fp, "\t];\n");
242 fprintf(fp, "\n");
243 fprintf(fp, "\tnode [\n");
244 fprintf(fp, "\t\tshape=\"plain\"\n");
245 fprintf(fp, "\t];\n");
246 fprintf(fp, "\n");
247 fprintf(fp, "\tedge [\n");
248 fprintf(fp, "\t\tpenwidth=\"4.5\"\n");
249 fprintf(fp, "\t\tarrowsize=\"1.0\"\n");
250 fprintf(fp, "\t\tcolor=\"#c0c0c0\"\n");
251 fprintf(fp, "\t];\n");
252 fprintf(fp, "\n");
253}
254
255void dot_graph_footer(FILE *fp, struct ListHead *links)
256{
257 fprintf(fp, "\n");
258 struct ListNode *np = NULL;
259 STAILQ_FOREACH(np, links, entries)
260 {
261 fprintf(fp, "\t%s;\n", np->data);
262 }
263 fprintf(fp, "\n}\n");
264}
265
266void dot_object_header(FILE *fp, const void *ptr, const char *name, const char *colour)
267{
268 char obj[64] = { 0 };
269 dot_ptr_name(obj, sizeof(obj), ptr);
270
271 if (!colour)
272 colour = "#ffff80";
273
274 fprintf(fp, "\t%s [\n", obj);
275 fprintf(fp, "\t\tlabel=<<table cellspacing=\"0\" border=\"1\" rows=\"*\" "
276 "color=\"#d0d0d0\">\n");
277 fprintf(fp, "\t\t<tr>\n");
278 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\" bgcolor=\"%s\" port=\"top\" colspan=\"3\"><font color=\"#000000\" point-size=\"20\"><b>%s</b></font> <font point-size=\"12\">(%p)</font></td>\n",
279 colour, name, ptr);
280 fprintf(fp, "\t\t</tr>\n");
281}
282
283void dot_object_footer(FILE *fp)
284{
285 fprintf(fp, "\t\t</table>>\n");
286 fprintf(fp, "\t];\n");
287 fprintf(fp, "\n");
288}
289
290void dot_node(FILE *fp, void *ptr, const char *name, const char *colour)
291{
292 char obj[64] = { 0 };
293 dot_ptr_name(obj, sizeof(obj), ptr);
294
295 fprintf(fp, "\t%s [\n", obj);
296 fprintf(fp, "\t\tlabel=<<table cellspacing=\"0\" border=\"1\" rows=\"*\" "
297 "color=\"#d0d0d0\">\n");
298 fprintf(fp, "\t\t<tr>\n");
299 fprintf(fp, "\t\t\t<td border=\"0\" bgcolor=\"%s\" port=\"top\"><font color=\"#000000\" point-size=\"20\"><b>%s</b></font></td>\n",
300 colour, name);
301 fprintf(fp, "\t\t</tr>\n");
303}
304
305void dot_node_link(FILE *fp, void *ptr, const char *name, void *link, const char *colour)
306{
307 char obj[64] = { 0 };
308 dot_ptr_name(obj, sizeof(obj), ptr);
309
310 fprintf(fp, "\t%s [\n", obj);
311 fprintf(fp, "\t\tlabel=<<table cellspacing=\"0\" border=\"1\" rows=\"*\" "
312 "color=\"#d0d0d0\">\n");
313 fprintf(fp, "\t\t<tr>\n");
314 fprintf(fp, "\t\t\t<td border=\"0\" bgcolor=\"%s\" port=\"top\"><font color=\"#000000\" point-size=\"20\"><b>%s</b></font></td>\n",
315 colour, name);
316 fprintf(fp, "\t\t</tr>\n");
317
318 fprintf(fp, "\t\t<tr>\n");
319 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\" bgcolor=\"%s\">%p</td>\n", colour, link);
320 fprintf(fp, "\t\t</tr>\n");
321
323}
324
325void dot_path_fs(char *buf, size_t buflen, const char *path)
326{
327 if (!path)
328 {
329 buf[0] = '\0';
330 return;
331 }
332
333 const char *slash = strrchr(path, '/');
334 if (slash)
335 slash++;
336 else
337 slash = path;
338
339 mutt_str_copy(buf, slash, buflen);
340}
341
342void dot_path_imap(char *buf, size_t buflen, const char *path)
343{
344 char tmp[1024] = { 0 };
345 mutt_str_copy(tmp, path, sizeof(tmp));
346
347 struct Url *u = url_parse(tmp);
348
349 if (u->path && (u->path[0] != '\0'))
350 mutt_str_copy(buf, u->path, buflen);
351 else
352 snprintf(buf, buflen, "%s:%s", u->host, u->user);
353
354 url_free(&u);
355}
356
357#ifndef GV_HIDE_CONFIG
358void dot_config(FILE *fp, const char *name, int type, struct ConfigSubset *sub,
359 struct ListHead *links)
360{
361 if (!sub)
362 return;
363
364 struct Buffer *value = buf_pool_get();
365 dot_object_header(fp, (void *) name, "Config", "#ffff80");
366 dot_type_string(fp, "scope", sub->name, true);
367
368 if (sub->name)
369 {
370 char scope[256];
371 snprintf(scope, sizeof(scope), "%s:", sub->name);
372
373 struct HashElem **list = get_elem_list(sub->cs);
374 for (size_t i = 0; list[i]; i++)
375 {
376 struct HashElem *item = list[i];
377 if ((item->type & type) == 0)
378 continue;
379
380 const char *iname = item->key.strkey;
381 size_t slen = strlen(scope);
382 if (mutt_str_startswith(iname, scope) != 0)
383 {
384 if (strchr(iname + slen, ':'))
385 continue;
386 if ((DTYPE(item->type) == DT_STRING) && (item->type & D_SENSITIVE))
387 {
388 dot_type_string(fp, iname + slen, "***", true);
389 }
390 else
391 {
392 buf_reset(value);
393 cs_subset_he_string_get(sub, item, value);
394 dot_type_string(fp, iname + slen, buf_string(value), true);
395 }
396 }
397 }
398 FREE(&list);
399 }
400 else
401 {
402 struct HashElem **list = get_elem_list(sub->cs);
403 int i = 0;
404 for (; list[i]; i++)
405 ; // do nothing
406
407 dot_type_number(fp, "count", i);
408 FREE(&list);
409 }
410
412 buf_pool_release(&value);
413}
414#endif
415
416void dot_comp(FILE *fp, struct CompressInfo *ci, struct ListHead *links)
417{
418 dot_object_header(fp, ci, "CompressInfo", "#c0c060");
419 dot_type_string(fp, "append", ci->cmd_append->string, true);
420 dot_type_string(fp, "close", ci->cmd_close->string, true);
421 dot_type_string(fp, "open", ci->cmd_open->string, true);
423}
424
425void dot_mailbox_type(FILE *fp, const char *name, enum MailboxType type)
426{
427 const char *typestr = NULL;
428
429 switch (type)
430 {
431 case MUTT_MBOX:
432 typestr = "MBOX";
433 break;
434 case MUTT_MMDF:
435 typestr = "MMDF";
436 break;
437 case MUTT_MH:
438 typestr = "MH";
439 break;
440 case MUTT_MAILDIR:
441 typestr = "MAILDIR";
442 break;
443 case MUTT_NNTP:
444 typestr = "NNTP";
445 break;
446 case MUTT_IMAP:
447 typestr = "IMAP";
448 break;
449 case MUTT_NOTMUCH:
450 typestr = "NOTMUCH";
451 break;
452 case MUTT_POP:
453 typestr = "POP";
454 break;
455 case MUTT_COMPRESSED:
456 typestr = "COMPRESSED";
457 break;
458 default:
459 typestr = "UNKNOWN";
460 }
461
462 fprintf(fp, "\t\t<tr>\n");
463 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\">%s</td>\n", name);
464 fprintf(fp, "\t\t\t<td border=\"0\">=</td>\n");
465 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\">%s</td>\n", typestr);
466 fprintf(fp, "\t\t</tr>\n");
467}
468
469#ifndef GV_HIDE_MDATA
470void dot_mailbox_imap(FILE *fp, struct ImapMboxData *mdata, struct ListHead *links)
471{
472 dot_object_header(fp, mdata, "ImapMboxData", "#60c060");
473 dot_type_string(fp, "name", mdata->name, true);
474 dot_type_string(fp, "munge_name", mdata->munge_name, true);
475 dot_type_string(fp, "real_name", mdata->real_name, true);
477}
478
479void dot_mailbox_maildir(FILE *fp, struct MaildirMboxData *mdata, struct ListHead *links)
480{
481 char buf[64] = { 0 };
482
483 dot_object_header(fp, mdata, "MaildirMboxData", "#60c060");
484
485 dot_type_date(buf, sizeof(buf), mdata->mtime_cur.tv_sec);
486 dot_type_string(fp, "mtime_cur", buf, true);
487
488 dot_type_umask(buf, sizeof(buf), mdata->umask);
489 dot_type_string(fp, "umask", buf, true);
491}
492
493void dot_mailbox_mbox(FILE *fp, struct MboxAccountData *mdata, struct ListHead *links)
494{
495 char buf[64] = { 0 };
496
497 dot_object_header(fp, mdata, "MboxAccountData", "#60c060");
498 dot_ptr(fp, "fp", mdata->fp, NULL);
499
500 dot_type_date(buf, sizeof(buf), mdata->atime.tv_sec);
501 dot_type_string(fp, "atime", buf, true);
502
504}
505
506void dot_mailbox_nntp(FILE *fp, struct NntpMboxData *mdata, struct ListHead *links)
507{
508 dot_object_header(fp, mdata, "NntpMboxData", "#60c060");
509 dot_type_string(fp, "group", mdata->group, true);
510 dot_type_string(fp, "desc", mdata->desc, true);
511
512 dot_type_number(fp, "first_message", mdata->first_message);
513 dot_type_number(fp, "last_message", mdata->last_message);
514 dot_type_number(fp, "last_loaded", mdata->last_loaded);
515 dot_type_number(fp, "last_cached", mdata->last_cached);
516 dot_type_number(fp, "unread", mdata->unread);
517
518 dot_type_bool(fp, "subscribed", mdata->subscribed);
519 dot_type_bool(fp, "has_new_mail", mdata->has_new_mail);
520 dot_type_bool(fp, "allowed", mdata->allowed);
521 dot_type_bool(fp, "deleted", mdata->deleted);
522
524}
525
526#ifdef USE_NOTMUCH
527void dot_mailbox_notmuch(FILE *fp, struct NmMboxData *mdata, struct ListHead *links)
528{
529 dot_object_header(fp, mdata, "NmMboxData", "#60c060");
530 dot_type_number(fp, "db_limit", mdata->db_limit);
532}
533#endif
534
535void dot_mailbox_pop(FILE *fp, struct PopAccountData *adata, struct ListHead *links)
536{
537 dot_object_header(fp, adata, "PopAccountData", "#60c060");
538 dot_ptr(fp, "conn", adata->conn, "#ff8080");
540}
541#endif
542
543void dot_mailbox(FILE *fp, struct Mailbox *m, struct ListHead *links)
544{
545 char buf[64] = { 0 };
546
547 dot_object_header(fp, m, "Mailbox", "#80ff80");
548 dot_mailbox_type(fp, "type", m->type);
549 dot_type_string(fp, "name", m->name, false);
550
551 if ((m->type == MUTT_IMAP) || (m->type == MUTT_POP))
552 {
553 dot_path_imap(buf, sizeof(buf), buf_string(&m->pathbuf));
554 dot_type_string(fp, "pathbuf", buf, true);
555 dot_path_imap(buf, sizeof(buf), m->realpath);
556 dot_type_string(fp, "realpath", buf, true);
557 }
558 else
559 {
560 dot_path_fs(buf, sizeof(buf), buf_string(&m->pathbuf));
561 dot_type_string(fp, "pathbuf", buf, true);
562 dot_path_fs(buf, sizeof(buf), m->realpath);
563 dot_type_string(fp, "realpath", buf, true);
564 }
565
566#ifdef GV_HIDE_MDATA
567 dot_ptr(fp, "mdata", m->mdata, NULL);
568#endif
569 dot_ptr(fp, "account", m->account, "#80ffff");
570 dot_type_number(fp, "opened", m->opened);
571
572 dot_type_number(fp, "msg_count", m->msg_count);
573 // dot_type_number(fp, "msg_unread", m->msg_unread);
574 // dot_type_number(fp, "msg_flagged", m->msg_flagged);
575 // dot_type_number(fp, "msg_new", m->msg_new);
576 // dot_type_number(fp, "msg_deleted", m->msg_deleted);
577 // dot_type_number(fp, "msg_tagged", m->msg_tagged);
578
579 dot_ptr(fp, "emails", m->emails, NULL);
580 dot_type_number(fp, "email_max", m->email_max);
581 dot_ptr(fp, "v2r", m->v2r, NULL);
582 dot_type_number(fp, "vcount", m->vcount);
583
585
586 // dot_add_link(links, m, m->mdata, NULL, NULL, false, NULL);
587
588#ifndef GV_HIDE_MDATA
589 if (m->mdata)
590 {
591 if (m->type == MUTT_MAILDIR)
592 dot_mailbox_maildir(fp, m->mdata, links);
593 else if (m->type == MUTT_IMAP)
594 dot_mailbox_imap(fp, m->mdata, links);
595 else if (m->type == MUTT_POP)
596 dot_mailbox_pop(fp, m->mdata, links);
597 else if (m->type == MUTT_MBOX)
598 dot_mailbox_mbox(fp, m->mdata, links);
599 else if (m->type == MUTT_NNTP)
600 dot_mailbox_nntp(fp, m->mdata, links);
601#ifdef USE_NOTMUCH
602 else if (m->type == MUTT_NOTMUCH)
603 dot_mailbox_notmuch(fp, m->mdata, links);
604#endif
605
606 dot_add_link(links, m, m->mdata, "Mailbox->mdata", NULL, false, NULL);
607 }
608#endif
609
610 if (m->compress_info)
611 {
612 dot_comp(fp, m->compress_info, links);
613 dot_add_link(links, m, m->compress_info, "Mailbox->compress_info", NULL, false, NULL);
614 }
615
616#ifndef GV_HIDE_CONFIG
617 if (m->name)
618 {
619 dot_config(fp, m->name, 0, m->sub, links);
620 dot_add_link(links, m, m->name, "Mailbox Config", NULL, false, NULL);
621 }
622#endif
623}
624
625void dot_mailbox_node(FILE *fp, struct MailboxNode *mn, struct ListHead *links)
626{
627 dot_node(fp, mn, "MN", "#80ff80");
628
629 dot_mailbox(fp, mn->mailbox, links);
630
631 dot_add_link(links, mn, mn->mailbox, "MailboxNode->mailbox", NULL, false, NULL);
632
633 struct Buffer *buf = buf_pool_get();
634
635 char name[256] = { 0 };
636 buf_addstr(buf, "{ rank=same ");
637
638 dot_ptr_name(name, sizeof(name), mn);
639 buf_add_printf(buf, "%s ", name);
640
641 dot_ptr_name(name, sizeof(name), mn->mailbox);
642 buf_add_printf(buf, "%s ", name);
643
644#ifndef GV_HIDE_MDATA
645 if (mn->mailbox->mdata)
646 {
647 dot_ptr_name(name, sizeof(name), mn->mailbox->mdata);
648 buf_add_printf(buf, "%s ", name);
649 }
650#endif
651
652#ifndef GV_HIDE_CONFIG
653 if (mn->mailbox->name)
654 {
655 dot_ptr_name(name, sizeof(name), mn->mailbox->name);
656 buf_add_printf(buf, "%s ", name);
657 }
658#endif
659
660 buf_addstr(buf, "}");
661
663 buf_pool_release(&buf);
664}
665
666void dot_mailbox_list(FILE *fp, struct MailboxList *ml, struct ListHead *links, bool abbr)
667{
668 struct MailboxNode *prev = NULL;
669 struct MailboxNode *np = NULL;
670 STAILQ_FOREACH(np, ml, entries)
671 {
672 if (abbr)
673 dot_node_link(fp, np, "MN", np->mailbox, "#80ff80");
674 else
675 dot_mailbox_node(fp, np, links);
676 if (prev)
677 dot_add_link(links, prev, np, "MailboxNode->next", NULL, false, NULL);
678 prev = np;
679 }
680}
681
682#ifndef GV_HIDE_ADATA
683void dot_connection(FILE *fp, struct Connection *c, struct ListHead *links)
684{
685 dot_object_header(fp, c, "Connection", "#ff8080");
686 // dot_ptr(fp, "sockdata", c->sockdata, "#60c0c0");
687 dot_type_number(fp, "fd", c->fd);
689
690 dot_object_header(fp, c->inbuf, "ConnAccount", "#ff8080");
691 dot_type_string(fp, "user", c->account.user, true);
692 dot_type_string(fp, "host", c->account.host, true);
693 dot_type_number(fp, "port", c->account.port);
695
696 dot_add_link(links, c, c->inbuf, "Connection.ConnAccount", NULL, false, NULL);
697}
698
699void dot_account_imap(FILE *fp, struct ImapAccountData *adata, struct ListHead *links)
700{
701 dot_object_header(fp, adata, "ImapAccountData", "#60c0c0");
702 // dot_type_string(fp, "mbox_name", adata->mbox_name, true);
703 // dot_type_string(fp, "login", adata->conn->account.login, true);
704 dot_type_string(fp, "user", adata->conn->account.user, true);
705 dot_type_string(fp, "pass", adata->conn->account.pass[0] ? "***" : "", true);
706 dot_type_number(fp, "port", adata->conn->account.port);
707 // dot_ptr(fp, "conn", adata->conn, "#ff8080");
708 dot_type_bool(fp, "unicode", adata->unicode);
709 dot_type_bool(fp, "qresync", adata->qresync);
710 dot_type_char(fp, "seqid", adata->seqid);
711 dot_ptr(fp, "mailbox", adata->mailbox, "#80ff80");
713
714 if (adata->conn)
715 {
716 dot_connection(fp, adata->conn, links);
717 dot_add_link(links, adata, adata->conn, "ImapAccountData->conn", NULL, false, NULL);
718 }
719}
720
721void dot_account_mbox(FILE *fp, struct MboxAccountData *adata, struct ListHead *links)
722{
723 char buf[64] = { 0 };
724
725 dot_object_header(fp, adata, "MboxAccountData", "#60c0c0");
726 dot_ptr(fp, "fp", adata->fp, NULL);
727
728 dot_type_date(buf, sizeof(buf), adata->atime.tv_sec);
729 dot_type_string(fp, "atime", buf, true);
730 dot_type_bool(fp, "locked", adata->locked);
731 dot_type_bool(fp, "append", adata->append);
732
734}
735
736void dot_account_nntp(FILE *fp, struct NntpAccountData *adata, struct ListHead *links)
737{
738 dot_object_header(fp, adata, "NntpAccountData", "#60c0c0");
739 dot_type_number(fp, "groups_num", adata->groups_num);
740
741 dot_type_bool(fp, "hasCAPABILITIES", adata->hasCAPABILITIES);
742 dot_type_bool(fp, "hasSTARTTLS", adata->hasSTARTTLS);
743 dot_type_bool(fp, "hasDATE", adata->hasDATE);
744 dot_type_bool(fp, "hasLIST_NEWSGROUPS", adata->hasLIST_NEWSGROUPS);
745 dot_type_bool(fp, "hasXGTITLE", adata->hasXGTITLE);
746 dot_type_bool(fp, "hasLISTGROUP", adata->hasLISTGROUP);
747 dot_type_bool(fp, "hasLISTGROUPrange", adata->hasLISTGROUPrange);
748 dot_type_bool(fp, "hasOVER", adata->hasOVER);
749 dot_type_bool(fp, "hasXOVER", adata->hasXOVER);
750 dot_type_bool(fp, "cacheable", adata->cacheable);
751 dot_type_bool(fp, "newsrc_modified", adata->newsrc_modified);
752
753 dot_type_string(fp, "authenticators", adata->authenticators, true);
754 dot_type_string(fp, "overview_fmt", adata->overview_fmt, true);
755 dot_type_string(fp, "newsrc_file", adata->newsrc_file, true);
756 dot_type_file(fp, "newsrc_fp", adata->fp_newsrc);
757
758 dot_type_number(fp, "groups_num", adata->groups_num);
759 dot_type_number(fp, "groups_max", adata->groups_max);
760
761 char buf[128];
762 dot_type_date(buf, sizeof(buf), adata->mtime);
763 dot_type_string(fp, "mtime", buf, true);
764 dot_type_date(buf, sizeof(buf), adata->newgroups_time);
765 dot_type_string(fp, "newgroups_time", buf, true);
766 dot_type_date(buf, sizeof(buf), adata->check_time);
767 dot_type_string(fp, "check_time", buf, true);
768
770
771 if (adata->conn)
772 {
773 dot_connection(fp, adata->conn, links);
774 dot_add_link(links, adata, adata->conn, "NntpAccountData->conn", NULL, false, NULL);
775 }
776}
777
778#ifdef USE_NOTMUCH
779void dot_account_notmuch(FILE *fp, struct NmAccountData *adata, struct ListHead *links)
780{
781 dot_object_header(fp, adata, "NmAccountData", "#60c0c0");
782 dot_ptr(fp, "db", adata->db, NULL);
784}
785#endif
786
787void dot_account_pop(FILE *fp, struct PopAccountData *adata, struct ListHead *links)
788{
789 char buf[64] = { 0 };
790
791 dot_object_header(fp, adata, "PopAccountData", "#60c0c0");
792
793 dot_type_date(buf, sizeof(buf), adata->check_time);
794 dot_type_string(fp, "check_time", buf, true);
795
796 dot_type_string(fp, "login", adata->conn->account.login, true);
797 dot_type_string(fp, "user", adata->conn->account.user, true);
798 dot_type_string(fp, "pass", adata->conn->account.pass[0] ? "***" : "", true);
799 dot_type_number(fp, "port", adata->conn->account.port);
800 // dot_ptr(fp, "conn", adata->conn, "#ff8080");
802
803 dot_connection(fp, adata->conn, links);
804 dot_add_link(links, adata, adata->conn, "PopAccountData->conn", NULL, false, NULL);
805}
806#endif
807
808void dot_account(FILE *fp, struct Account *a, struct ListHead *links)
809{
810 dot_object_header(fp, a, "Account", "#80ffff");
811 dot_mailbox_type(fp, "type", a->type);
812 dot_type_string(fp, "name", a->name, true);
813 // dot_ptr(fp, "adata", a->adata, "#60c0c0");
815
816#ifndef GV_HIDE_ADATA
817 if (a->adata)
818 {
819 if (a->type == MUTT_IMAP)
820 dot_account_imap(fp, a->adata, links);
821 else if (a->type == MUTT_POP)
822 dot_account_pop(fp, a->adata, links);
823 else if (a->type == MUTT_MBOX)
824 dot_account_mbox(fp, a->adata, links);
825 else if (a->type == MUTT_NNTP)
826 dot_account_nntp(fp, a->adata, links);
827#ifdef USE_NOTMUCH
828 else if (a->type == MUTT_NOTMUCH)
829 dot_account_notmuch(fp, a->adata, links);
830#endif
831
832 dot_add_link(links, a, a->adata, "Account->adata", NULL, false, NULL);
833 }
834#endif
835
836#ifndef GV_HIDE_CONFIG
837 if (a->name)
838 {
839 dot_config(fp, a->name, 0, a->sub, links);
840 dot_add_link(links, a, a->name, "Config", NULL, false, NULL);
841
842 char name[256] = { 0 };
843 struct Buffer *buf = buf_pool_get();
844
845 buf_addstr(buf, "{ rank=same ");
846
847 dot_ptr_name(name, sizeof(name), a);
848 buf_add_printf(buf, "%s ", name);
849
850 dot_ptr_name(name, sizeof(name), a->name);
851 buf_add_printf(buf, "%s ", name);
852
853 buf_addstr(buf, "}");
855 buf_pool_release(&buf);
856 }
857#endif
858
859 struct MailboxNode *first = STAILQ_FIRST(&a->mailboxes);
860 dot_add_link(links, a, first, "Account->mailboxes", NULL, false, NULL);
861 dot_mailbox_list(fp, &a->mailboxes, links, false);
862}
863
864void dot_account_list(FILE *fp, struct AccountList *al, struct ListHead *links)
865{
866 struct Account *prev = NULL;
867 struct Account *np = NULL;
868 TAILQ_FOREACH(np, al, entries)
869 {
870#ifdef GV_HIDE_MBOX
871 if (np->type == MUTT_MBOX)
872 continue;
873#endif
874 dot_account(fp, np, links);
875 if (prev)
876 dot_add_link(links, prev, np, "Account->next", NULL, false, NULL);
877
878 prev = np;
879 }
880}
881
882#ifndef GV_HIDE_MVIEW
883void dot_mview(FILE *fp, struct MailboxView *mv, struct ListHead *links)
884{
885 dot_object_header(fp, mv, "MailboxView", "#ff80ff");
886 dot_ptr(fp, "mailbox", mv->mailbox, "#80ff80");
887#ifdef GV_HIDE_MVIEW_CONTENTS
888 dot_type_number(fp, "vsize", mv->vsize);
889 dot_type_string(fp, "pattern", mv->pattern, true);
890 dot_type_bool(fp, "collapsed", mv->collapsed);
891#endif
893}
894#endif
895
896void dump_graphviz(const char *title, struct MailboxView *mv)
897{
898 char name[256] = { 0 };
899 struct ListHead links = STAILQ_HEAD_INITIALIZER(links);
900
901 time_t now = time(NULL);
902 if (title)
903 {
904 char date[128];
905 mutt_date_localtime_format(date, sizeof(date), "%T", now);
906 snprintf(name, sizeof(name), "%s-%s.gv", date, title);
907 }
908 else
909 {
910 mutt_date_localtime_format(name, sizeof(name), "%T.gv", now);
911 }
912
913 umask(022);
914 FILE *fp = fopen(name, "w");
915 if (!fp)
916 return;
917
919
920#ifndef GV_HIDE_NEOMUTT
921 dot_node(fp, NeoMutt, "NeoMutt", "#ffa500");
923 "NeoMutt->accounts", NULL, false, NULL);
924#ifndef GV_HIDE_CONFIG
925 dot_config(fp, (const char *) NeoMutt->sub, 0, NeoMutt->sub, &links);
926 dot_add_link(&links, NeoMutt, NeoMutt->sub, "NeoMutt Config", NULL, false, NULL);
927 struct Buffer *buf = buf_pool_get();
928 char obj1[64] = { 0 };
929 char obj2[64] = { 0 };
930 dot_ptr_name(obj1, sizeof(obj1), NeoMutt);
931 dot_ptr_name(obj2, sizeof(obj2), NeoMutt->sub);
932 buf_printf(buf, "{ rank=same %s %s }", obj1, obj2);
933 mutt_list_insert_tail(&links, buf_strdup(buf));
934 buf_pool_release(&buf);
935#endif
936#endif
937
938 dot_account_list(fp, &NeoMutt->accounts, &links);
939
940#ifndef GV_HIDE_MVIEW
941 if (mv)
942 dot_mview(fp, mv, &links);
943
944#ifndef GV_HIDE_NEOMUTT
945 /* Globals */
946 fprintf(fp, "\t{ rank=same ");
947 if (mv)
948 {
949 dot_ptr_name(name, sizeof(name), mv);
950 fprintf(fp, "%s ", name);
951 }
952 dot_ptr_name(name, sizeof(name), NeoMutt);
953 fprintf(fp, "%s ", name);
954 fprintf(fp, "}\n");
955#endif
956#endif
957
958 fprintf(fp, "\t{ rank=same ");
959 struct Account *np = NULL;
960 TAILQ_FOREACH(np, &NeoMutt->accounts, entries)
961 {
962#ifdef GV_HIDE_MBOX
963 if (np->type == MUTT_MBOX)
964 continue;
965#endif
966 dot_ptr_name(name, sizeof(name), np);
967 fprintf(fp, "%s ", name);
968 }
969 fprintf(fp, "}\n");
970
971 dot_graph_footer(fp, &links);
972 fclose(fp);
973 mutt_list_free(&links);
974}
975
976#ifndef GV_HIDE_BODY_CONTENT
977void dot_parameter_list(FILE *fp, const char *name, const struct ParameterList *pl)
978{
979 if (!pl)
980 return;
981 if (TAILQ_EMPTY(pl))
982 return;
983
984 dot_object_header(fp, pl, "ParameterList", "#00ff00");
985
986 struct Parameter *np = NULL;
987 TAILQ_FOREACH(np, pl, entries)
988 {
989 dot_type_string(fp, np->attribute, np->value, false);
990 }
991
993}
994
995void dot_content(FILE *fp, struct Content *cont, struct ListHead *links)
996{
997 struct Buffer *buf = buf_pool_get();
998
999 dot_object_header(fp, cont, "Content", "#800080");
1000
1001 dot_type_number(fp, "hibin", cont->hibin);
1002 dot_type_number(fp, "lobin", cont->lobin);
1003 dot_type_number(fp, "nulbin", cont->nulbin);
1004 dot_type_number(fp, "crlf", cont->crlf);
1005 dot_type_number(fp, "ascii", cont->ascii);
1006 dot_type_number(fp, "linemax", cont->linemax);
1007
1008#define ADD_BOOL(F) add_flag(buf, cont->F, #F)
1009 ADD_BOOL(space);
1010 ADD_BOOL(binary);
1011 ADD_BOOL(from);
1012 ADD_BOOL(dot);
1013 ADD_BOOL(cr);
1014#undef ADD_BOOL
1015
1017
1018 buf_pool_release(&buf);
1019}
1020#endif
1021
1022void dot_attach_ptr(FILE *fp, struct AttachPtr *aptr, struct ListHead *links)
1023{
1024 if (!aptr)
1025 return;
1026
1027 dot_object_header(fp, aptr, "AttachPtr", "#ff0000");
1028
1029 dot_type_file(fp, "fp", aptr->fp);
1030
1031 dot_type_string(fp, "parent_type", name_content_type(aptr->parent_type), false);
1032
1033 dot_type_number(fp, "level", aptr->level);
1034 dot_type_number(fp, "num", aptr->num);
1035
1036 dot_type_bool(fp, "unowned", aptr->unowned);
1037 dot_type_bool(fp, "collapsed", aptr->collapsed);
1038 dot_type_bool(fp, "decrypted", aptr->decrypted);
1039
1041
1042 dot_add_link(links, aptr->body, aptr, "AttachPtr->body", NULL, true, NULL);
1043}
1044
1045void dot_body(FILE *fp, struct Body *b, struct ListHead *links, bool link_next)
1046{
1047 struct Buffer *buf = buf_pool_get();
1048
1049 dot_object_header(fp, b, "Body", "#2020ff");
1050
1051 char file[256];
1052 dot_path_fs(file, sizeof(file), b->filename);
1053 dot_type_string(fp, "file", file, false);
1054
1055 dot_type_string(fp, "charset", b->charset, false);
1056 dot_type_string(fp, "description", b->description, false);
1057 dot_type_string(fp, "d_filename", b->d_filename, false);
1058 dot_type_string(fp, "form_name", b->form_name, false);
1059 dot_type_string(fp, "language", b->language, false);
1060 dot_type_string(fp, "subtype", b->subtype, false);
1061 dot_type_string(fp, "xtype", b->xtype, false);
1062
1063 dot_type_string(fp, "type", name_content_type(b->type), true);
1064 dot_type_string(fp, "encoding", name_content_encoding(b->encoding), true);
1065 dot_type_string(fp, "disposition", name_content_disposition(b->disposition), true);
1066
1067 if (b->stamp != 0)
1068 {
1069 char arr[64];
1070 dot_type_date(arr, sizeof(arr), b->stamp);
1071 dot_type_string(fp, "stamp", arr, true);
1072 }
1073
1074#define ADD_BOOL(F) add_flag(buf, b->F, #F)
1075 ADD_BOOL(attach_qualifies);
1076 ADD_BOOL(badsig);
1077 ADD_BOOL(deleted);
1078 ADD_BOOL(force_charset);
1079 ADD_BOOL(goodsig);
1080#ifdef USE_AUTOCRYPT
1081 ADD_BOOL(is_autocrypt);
1082#endif
1083 ADD_BOOL(noconv);
1084 ADD_BOOL(tagged);
1085 ADD_BOOL(unlink);
1086 ADD_BOOL(use_disp);
1087 ADD_BOOL(warnsig);
1088#undef ADD_BOOL
1089 dot_type_string(fp, "bools", buf_is_empty(buf) ? "[NONE]" : buf_string(buf), true);
1090
1091 dot_type_number(fp, "attach_count", b->attach_count);
1092 dot_type_number(fp, "hdr_offset", b->hdr_offset);
1093 dot_type_number(fp, "length", b->length);
1094 dot_type_number(fp, "offset", b->offset);
1095
1096 dot_ptr(fp, "aptr", b->aptr, "#3bcbc4");
1097
1098#ifdef GV_HIDE_BODY_CONTENT
1099 if (!TAILQ_EMPTY(&b->parameter))
1100 {
1101 struct Parameter *param = TAILQ_FIRST(&b->parameter);
1102 if (mutt_str_equal(param->attribute, "boundary"))
1103 {
1104 dot_type_string(fp, "boundary", param->value, false);
1105 }
1106 }
1107#endif
1108
1110
1111#ifndef GV_HIDE_BODY_CONTENT
1112 if (!TAILQ_EMPTY(&b->parameter))
1113 {
1114 dot_parameter_list(fp, "parameter", &b->parameter);
1115 dot_add_link(links, b, &b->parameter, "Body->mime_headers", NULL, false, NULL);
1116 }
1117#endif
1118
1119#ifndef GV_HIDE_ENVELOPE
1120 if (b->mime_headers)
1121 {
1122 dot_envelope(fp, b->mime_headers, links);
1123 dot_add_link(links, b, b->mime_headers, "Body->mime_headers", NULL, false, NULL);
1124 }
1125#endif
1126
1127 if (b->email)
1128 {
1129 dot_email(fp, b->email, links);
1130 dot_add_link(links, b, b->email, "Body->email", NULL, false, NULL);
1131 }
1132
1133 if (b->parts)
1134 {
1135 if (!b->email)
1136 dot_body(fp, b->parts, links, true);
1137 dot_add_link(links, b, b->parts, "Body->parts", NULL, false, "#ff0000");
1138 }
1139
1140 if (b->next && link_next)
1141 {
1142 char name[256] = { 0 };
1143 buf_reset(buf);
1144
1145 buf_addstr(buf, "{ rank=same ");
1146
1147 dot_ptr_name(name, sizeof(name), b);
1148 buf_add_printf(buf, "%s ", name);
1149
1150 for (; b->next; b = b->next)
1151 {
1152 dot_body(fp, b->next, links, false);
1153 dot_add_link(links, b, b->next, "Body->next", NULL, false, "#008000");
1154
1155 dot_ptr_name(name, sizeof(name), b->next);
1156 buf_add_printf(buf, "%s ", name);
1157 }
1158
1159 buf_addstr(buf, "}");
1160 mutt_list_insert_tail(links, buf_strdup(buf));
1161 }
1162 else
1163 {
1164#ifndef GV_HIDE_BODY_CONTENT
1165 if (b->content)
1166 {
1167 dot_content(fp, b->content, links);
1168 dot_add_link(links, b, b->content, "Body->content", NULL, false, NULL);
1169 }
1170#endif
1171
1172 // if (b->aptr)
1173 // {
1174 // dot_attach_ptr(fp, b->aptr, links);
1175 // dot_add_link(links, b, b->aptr, "Body->aptr", NULL, false, NULL);
1176 // }
1177 }
1178
1179 buf_pool_release(&buf);
1180}
1181
1182#ifndef GV_HIDE_ENVELOPE
1183void dot_list_head(FILE *fp, const char *name, const struct ListHead *list)
1184{
1185 if (!list || !name)
1186 return;
1187 if (STAILQ_EMPTY(list))
1188 return;
1189
1190 struct Buffer *buf = buf_pool_get();
1191
1192 struct ListNode *np = NULL;
1193 STAILQ_FOREACH(np, list, entries)
1194 {
1195 if (!buf_is_empty(buf))
1196 buf_addch(buf, ',');
1197 buf_addstr(buf, np->data);
1198 }
1199
1200 dot_type_string(fp, name, buf_string(buf), false);
1201 buf_pool_release(&buf);
1202}
1203
1204void dot_addr_list(FILE *fp, const char *name, const struct AddressList *al,
1205 struct ListHead *links)
1206{
1207 if (!al)
1208 return;
1209 if (TAILQ_EMPTY(al))
1210 return;
1211
1212 struct Buffer *buf = buf_pool_get();
1213 mutt_addrlist_write(al, buf, true);
1214 dot_type_string(fp, name, buf_string(buf), false);
1215 buf_pool_release(&buf);
1216}
1217
1218void dot_envelope(FILE *fp, struct Envelope *env, struct ListHead *links)
1219{
1220 struct Buffer *buf = buf_pool_get();
1221
1222 dot_object_header(fp, env, "Envelope", "#ffff00");
1223
1224#define ADD_FLAG(F) add_flag(buf, (env->changed & F), #F)
1229#undef ADD_BOOL
1230 dot_type_string(fp, "changed", buf_is_empty(buf) ? "[NONE]" : buf_string(buf), true);
1231
1232#define ADDR_LIST(AL) dot_addr_list(fp, #AL, &env->AL, links)
1233 ADDR_LIST(return_path);
1234 ADDR_LIST(from);
1235 ADDR_LIST(to);
1236 ADDR_LIST(cc);
1237 ADDR_LIST(bcc);
1238 ADDR_LIST(sender);
1239 ADDR_LIST(reply_to);
1240 ADDR_LIST(mail_followup_to);
1241 ADDR_LIST(x_original_to);
1242#undef ADDR_LIST
1243
1244 dot_type_string(fp, "date", env->date, false);
1245 dot_type_string(fp, "disp_subj", env->disp_subj, false);
1246 dot_type_string(fp, "followup_to", env->followup_to, false);
1247 dot_type_string(fp, "list_post", env->list_post, false);
1248 dot_type_string(fp, "list_subscribe", env->list_subscribe, false);
1249 dot_type_string(fp, "list_unsubscribe", env->list_unsubscribe, false);
1250 dot_type_string(fp, "message_id", env->message_id, false);
1251 dot_type_string(fp, "newsgroups", env->newsgroups, false);
1252 dot_type_string(fp, "organization", env->organization, false);
1253 dot_type_string(fp, "real_subj", env->real_subj, false);
1254 dot_type_string(fp, "spam", buf_string(&env->spam), false);
1255 dot_type_string(fp, "subject", env->subject, false);
1256 dot_type_string(fp, "supersedes", env->supersedes, false);
1257 dot_type_string(fp, "xref", env->xref, false);
1258 dot_type_string(fp, "x_comment_to", env->x_comment_to, false);
1259 dot_type_string(fp, "x_label", env->x_label, false);
1260
1261 if (0)
1262 {
1263 dot_list_head(fp, "references", &env->references);
1264 dot_list_head(fp, "in_reply_to", &env->in_reply_to);
1265 dot_list_head(fp, "userhdrs", &env->userhdrs);
1266 }
1267
1268#ifdef USE_AUTOCRYPT
1269 dot_ptr(fp, "autocrypt", env->autocrypt, NULL);
1270 dot_ptr(fp, "autocrypt_gossip", env->autocrypt_gossip, NULL);
1271#endif
1272
1274
1275 buf_pool_release(&buf);
1276}
1277#endif
1278
1279void dot_email(FILE *fp, struct Email *e, struct ListHead *links)
1280{
1281 struct Buffer *buf = buf_pool_get();
1282 char arr[256];
1283
1284 dot_object_header(fp, e, "Email", "#ff80ff");
1285
1286 dot_type_string(fp, "path", e->path, true);
1287
1288#define ADD_BOOL(F) add_flag(buf, e->F, #F)
1289 ADD_BOOL(active);
1290 ADD_BOOL(attach_del);
1291 ADD_BOOL(attach_valid);
1292 ADD_BOOL(changed);
1293 ADD_BOOL(collapsed);
1294 ADD_BOOL(deleted);
1295 ADD_BOOL(display_subject);
1296 ADD_BOOL(expired);
1297 ADD_BOOL(flagged);
1298 ADD_BOOL(matched);
1299 ADD_BOOL(mime);
1300 ADD_BOOL(old);
1301 ADD_BOOL(purge);
1302 ADD_BOOL(quasi_deleted);
1303 ADD_BOOL(read);
1304 ADD_BOOL(recip_valid);
1305 ADD_BOOL(replied);
1306 ADD_BOOL(searched);
1307 ADD_BOOL(subject_changed);
1308 ADD_BOOL(superseded);
1309 ADD_BOOL(tagged);
1310 ADD_BOOL(threaded);
1311 ADD_BOOL(trash);
1312 ADD_BOOL(visible);
1313#undef ADD_BOOL
1314 dot_type_string(fp, "bools", buf_is_empty(buf) ? "[NONE]" : buf_string(buf), true);
1315
1316 buf_reset(buf);
1317#define ADD_BOOL(F) add_flag(buf, (e->security & F), #F)
1332#undef ADD_BOOL
1333 dot_type_string(fp, "security", buf_is_empty(buf) ? "[NONE]" : buf_string(buf), true);
1334
1335 dot_type_number(fp, "num_hidden", e->num_hidden);
1336 dot_type_number(fp, "offset", e->offset);
1337 dot_type_number(fp, "lines", e->lines);
1338 dot_type_number(fp, "index", e->index);
1339 dot_type_number(fp, "msgno", e->msgno);
1340 dot_type_number(fp, "vnum", e->vnum);
1341 dot_type_number(fp, "score", e->score);
1342 dot_type_number(fp, "attach_total", e->attach_total);
1343
1344 // struct MaildirEmailData *edata = maildir_edata_get(e);
1345 // if (edata)
1346 // dot_type_string(fp, "maildir_flags", edata->maildir_flags, false);
1347
1348 if (e->date_sent != 0)
1349 {
1350 char zone[32];
1351 dot_type_date(arr, sizeof(arr), e->date_sent);
1352 snprintf(zone, sizeof(zone), " (%c%02u%02u)", e->zoccident ? '-' : '+',
1353 e->zhours, e->zminutes);
1354 struct Buffer *date = buf_pool_get();
1355 buf_printf(date, "%s%s", arr, zone);
1356 dot_type_string(fp, "date_sent", buf_string(date), false);
1357 buf_pool_release(&date);
1358 }
1359
1360 if (e->received != 0)
1361 {
1362 dot_type_date(arr, sizeof(arr), e->received);
1363 dot_type_string(fp, "received", arr, false);
1364 }
1365
1367
1368 if (e->body)
1369 {
1370 dot_body(fp, e->body, links, true);
1371 dot_add_link(links, e, e->body, "Email->body", NULL, false, NULL);
1372 }
1373
1374#ifndef GV_HIDE_ENVELOPE
1375 if (e->env)
1376 {
1377 dot_envelope(fp, e->env, links);
1378 dot_add_link(links, e, e->env, "Email->env", NULL, false, NULL);
1379
1380 buf_reset(buf);
1381 buf_addstr(buf, "{ rank=same ");
1382
1383 dot_ptr_name(arr, sizeof(arr), e);
1384 buf_add_printf(buf, "%s ", arr);
1385
1386 dot_ptr_name(arr, sizeof(arr), e->env);
1387 buf_add_printf(buf, "%s ", arr);
1388
1389 buf_addstr(buf, "}");
1390
1391 mutt_list_insert_tail(links, buf_strdup(buf));
1392 }
1393#endif
1394
1395 // struct TagList tags;
1396
1397 buf_pool_release(&buf);
1398}
1399
1401{
1402 char name[256] = { 0 };
1403 struct ListHead links = STAILQ_HEAD_INITIALIZER(links);
1404
1405 time_t now = time(NULL);
1406 mutt_date_localtime_format(name, sizeof(name), "%T-email.gv", now);
1407
1408 umask(022);
1409 FILE *fp = fopen(name, "w");
1410 if (!fp)
1411 return;
1412
1413 dot_graph_header(fp);
1414
1415 dot_body(fp, b, &links, true);
1416
1417 dot_graph_footer(fp, &links);
1418 fclose(fp);
1419 mutt_list_free(&links);
1420}
1421
1422void dump_graphviz_email(struct Email *e, const char *title)
1423{
1424 char name[256] = { 0 };
1425 struct ListHead links = STAILQ_HEAD_INITIALIZER(links);
1426
1427 if (!title)
1428 title = "email";
1429
1430 char format[64];
1431 snprintf(format, sizeof(format), "%%T-%s.gv", title);
1432
1433 time_t now = time(NULL);
1434 mutt_date_localtime_format(name, sizeof(name), format, now);
1435
1436 umask(022);
1437 FILE *fp = fopen(name, "w");
1438 if (!fp)
1439 return;
1440
1441 dot_graph_header(fp);
1442
1443 dot_email(fp, e, &links);
1444
1445 dot_graph_footer(fp, &links);
1446 fclose(fp);
1447 mutt_list_free(&links);
1448}
1449
1450void dot_attach_ptr2(FILE *fp, struct AttachPtr *aptr, struct ListHead *links)
1451{
1452 if (!aptr)
1453 return;
1454
1455 dot_object_header(fp, aptr, "AttachPtr", "#3bcbc4");
1456
1457 dot_ptr(fp, "body", aptr->body, "#2020ff");
1458 dot_type_file(fp, "fp", aptr->fp);
1459
1460 dot_type_string(fp, "parent_type", name_content_type(aptr->parent_type), false);
1461 dot_type_number(fp, "level", aptr->level);
1462 dot_type_number(fp, "num", aptr->num);
1463 dot_type_bool(fp, "unowned", aptr->unowned);
1464 dot_type_bool(fp, "collapsed", aptr->collapsed);
1465 dot_type_bool(fp, "decrypted", aptr->decrypted);
1466
1467 // dot_type_string(fp, "tree", aptr->tree, false);
1468
1470}
1471
1472void dot_array_actx_idx(FILE *fp, struct AttachPtr **idx, short idxlen,
1473 short idxmax, struct ListHead *links)
1474{
1475 dot_object_header(fp, idx, "AttachCtx-&gt;idx", "#9347de");
1476
1477 dot_type_number(fp, "idxlen", idxlen);
1478 dot_type_number(fp, "idxmax", idxmax);
1479
1480 char arr[32];
1481 for (size_t i = 0; i < idxmax; i++)
1482 {
1483 snprintf(arr, sizeof(arr), "idx[%zu]", i);
1484 dot_ptr(fp, arr, idx[i], "#3bcbc4");
1485 }
1486
1488
1489 for (size_t i = 0; i < idxlen; i++)
1490 {
1491 dot_attach_ptr2(fp, idx[i], links);
1492 dot_add_link(links, idx, idx[i], "AttachCtx-&gt;idx", NULL, false, NULL);
1493 }
1494}
1495
1496void dot_array_actx_v2r(FILE *fp, short *v2r, short vcount, struct ListHead *links)
1497{
1498 dot_object_header(fp, v2r, "AttachCtx-&gt;v2r", "#9347de");
1499
1500 dot_type_number(fp, "vcount", vcount);
1501
1502 char arr[32];
1503 for (size_t i = 0; i < vcount; i++)
1504 {
1505 snprintf(arr, sizeof(arr), "v2r[%zu]", i);
1506 dot_type_number(fp, arr, v2r[i]);
1507 }
1508
1510}
1511
1512void dot_array_actx_fp_idx(FILE *fp, FILE **fp_idx, short fp_len, short fp_max,
1513 struct ListHead *links)
1514{
1515 dot_object_header(fp, fp_idx, "AttachCtx-&gt;fp_idx", "#f86e28");
1516
1517 dot_type_number(fp, "fp_len", fp_len);
1518 dot_type_number(fp, "fp_max", fp_max);
1519
1520 char arr[32];
1521 for (size_t i = 0; i < fp_max; i++)
1522 {
1523 snprintf(arr, sizeof(arr), "fp_idx[%zu]", i);
1524 dot_type_file(fp, arr, fp_idx[i]);
1525 }
1526
1528}
1529
1530void dot_array_actx_body_idx(FILE *fp, struct Body **body_idx, short body_len,
1531 short body_max, struct ListHead *links)
1532{
1533 dot_object_header(fp, body_idx, "AttachCtx-&gt;body_idx", "#4ff270");
1534
1535 dot_type_number(fp, "body_len", body_len);
1536 dot_type_number(fp, "body_max", body_max);
1537
1538 char arr[32];
1539 for (size_t i = 0; i < body_max; i++)
1540 {
1541 snprintf(arr, sizeof(arr), "body_idx[%zu]", i);
1542 dot_ptr(fp, arr, body_idx[i], "#2020ff");
1543 }
1544
1546
1547 for (size_t i = 0; i < body_max; i++)
1548 {
1549 if (!body_idx[i])
1550 continue;
1551 dot_body(fp, body_idx[i], links, true);
1552 dot_add_link(links, body_idx, body_idx[i], "AttachCtx->Body", NULL, false, "#008000");
1553 }
1554}
1555
1556void dot_attach_ctx(FILE *fp, struct AttachCtx *actx, struct ListHead *links)
1557{
1558 dot_object_header(fp, actx, "AttachCtx", "#9347de");
1559
1560 dot_ptr(fp, "email", actx->email, "#ff80ff");
1561 dot_type_file(fp, "fp_root", actx->fp_root);
1562
1564
1565 if (actx->idx)
1566 {
1567 dot_array_actx_idx(fp, actx->idx, actx->idxlen, actx->idxmax, links);
1568 dot_add_link(links, actx, actx->idx, "AttachCtx-&gt;idx", NULL, false, NULL);
1569 }
1570
1571 if (actx->v2r)
1572 {
1573 dot_array_actx_v2r(fp, actx->v2r, actx->vcount, links);
1574 dot_add_link(links, actx, actx->v2r, "AttachCtx-&gt;v2r", NULL, false, NULL);
1575 }
1576
1577 if (actx->fp_idx)
1578 {
1579 dot_array_actx_fp_idx(fp, actx->fp_idx, actx->fp_len, actx->fp_max, links);
1580 dot_add_link(links, actx, actx->fp_idx, "AttachCtx-&gt;fp_idx", NULL, false, NULL);
1581 }
1582
1583 if (actx->body_idx)
1584 {
1585 dot_array_actx_body_idx(fp, actx->body_idx, actx->body_len, actx->body_max, links);
1586 dot_add_link(links, actx, actx->body_idx, "AttachCtx-&gt;body_idx", NULL, false, NULL);
1587 }
1588}
1589
1591{
1592 char name[256] = { 0 };
1593 struct ListHead links = STAILQ_HEAD_INITIALIZER(links);
1594
1595 time_t now = time(NULL);
1596 mutt_date_localtime_format(name, sizeof(name), "%T-actx.gv", now);
1597
1598 umask(022);
1599 FILE *fp = fopen(name, "w");
1600 if (!fp)
1601 return;
1602
1603 dot_graph_header(fp);
1604
1605 dot_attach_ctx(fp, actx, &links);
1606
1607 dot_graph_footer(fp, &links);
1608 fclose(fp);
1609 mutt_list_free(&links);
1610}
1611
1612const char *pattern_type_name(int type)
1613{
1614 static struct Mapping PatternNames[] = {
1615 // clang-format off
1616 { "address", MUTT_PAT_ADDRESS },
1617 { "AND", MUTT_PAT_AND },
1618 { "bcc", MUTT_PAT_BCC },
1619 { "body", MUTT_PAT_BODY },
1620 { "broken", MUTT_PAT_BROKEN },
1621 { "cc", MUTT_PAT_CC },
1622 { "children", MUTT_PAT_CHILDREN },
1623 { "collapsed", MUTT_PAT_COLLAPSED },
1624 { "crypt_encrypt", MUTT_PAT_CRYPT_ENCRYPT },
1625 { "crypt_sign", MUTT_PAT_CRYPT_SIGN },
1626 { "crypt_verified", MUTT_PAT_CRYPT_VERIFIED },
1627 { "date", MUTT_PAT_DATE },
1628 { "date_received", MUTT_PAT_DATE_RECEIVED },
1629 { "driver_tags", MUTT_PAT_DRIVER_TAGS },
1630 { "duplicated", MUTT_PAT_DUPLICATED },
1631 { "from", MUTT_PAT_FROM },
1632 { "header", MUTT_PAT_HEADER },
1633 { "hormel", MUTT_PAT_HORMEL },
1634 { "id", MUTT_PAT_ID },
1635 { "id_external", MUTT_PAT_ID_EXTERNAL },
1636 { "list", MUTT_PAT_LIST },
1637 { "message", MUTT_PAT_MESSAGE },
1638 { "mimeattach", MUTT_PAT_MIMEATTACH },
1639 { "mimetype", MUTT_PAT_MIMETYPE },
1640 { "newsgroups", MUTT_PAT_NEWSGROUPS },
1641 { "OR", MUTT_PAT_OR },
1642 { "parent", MUTT_PAT_PARENT },
1643 { "personal_from", MUTT_PAT_PERSONAL_FROM },
1644 { "personal_recip", MUTT_PAT_PERSONAL_RECIP },
1645 { "pgp_key", MUTT_PAT_PGP_KEY },
1646 { "recipient", MUTT_PAT_RECIPIENT },
1647 { "reference", MUTT_PAT_REFERENCE },
1648 { "score", MUTT_PAT_SCORE },
1649 { "sender", MUTT_PAT_SENDER },
1650 { "serversearch", MUTT_PAT_SERVERSEARCH },
1651 { "size", MUTT_PAT_SIZE },
1652 { "subject", MUTT_PAT_SUBJECT },
1653 { "subscribed_list", MUTT_PAT_SUBSCRIBED_LIST },
1654 { "thread", MUTT_PAT_THREAD },
1655 { "to", MUTT_PAT_TO },
1656 { "unreferenced", MUTT_PAT_UNREFERENCED },
1657 { "whole_msg", MUTT_PAT_WHOLE_MSG },
1658 { "xlabel", MUTT_PAT_XLABEL },
1659 { NULL, 0 },
1660 // clang-format on
1661 };
1662
1663 return mutt_map_get_name(type, PatternNames);
1664}
1665
1666void dot_pattern(FILE *fp, struct Pattern *pat, struct ListHead *links)
1667{
1668 struct Buffer *buf = buf_pool_get();
1669 dot_object_header(fp, pat, "Pattern", "#c040c0");
1670
1671 dot_type_string(fp, "op", pattern_type_name(pat->op), true);
1672 if ((pat->min != 0) || (pat->max != 0))
1673 {
1674 dot_type_number(fp, "min", pat->min);
1675 dot_type_number(fp, "max", pat->max);
1676 }
1677
1678#define ADD_BOOL(F) add_flag(buf, pat->F, #F)
1679 ADD_BOOL(pat_not);
1680 ADD_BOOL(all_addr);
1681 ADD_BOOL(string_match);
1682 ADD_BOOL(group_match);
1683 ADD_BOOL(ign_case);
1684 ADD_BOOL(is_alias);
1685 ADD_BOOL(dynamic);
1686 ADD_BOOL(sendmode);
1687 ADD_BOOL(is_multi);
1688#undef ADD_BOOL
1689 dot_type_string(fp, "flags", buf_is_empty(buf) ? "[NONE]" : buf_string(buf), true);
1690
1691 if (pat->group_match)
1692 {
1693 // struct Group *group; ///< Address group if group_match is set
1694 }
1695 else if (pat->string_match)
1696 {
1697 dot_type_string(fp, "str", pat->p.str, true);
1698 }
1699 else if (pat->is_multi)
1700 {
1701 // struct ListHead multi_cases; ///< Multiple strings for ~I pattern
1702 }
1703 else
1704 {
1705 if (pat->p.regex)
1706 {
1707 dot_ptr(fp, "regex", pat->p.regex, NULL);
1708 dot_type_string(fp, "pattern", pat->raw_pattern, true);
1709 }
1710 }
1711
1713
1714 if (pat->child)
1715 {
1716 dot_patternlist(fp, pat->child, links);
1717 struct Pattern *first = SLIST_FIRST(pat->child);
1718 dot_add_link(links, pat, first, "Pattern->child", NULL, false, "#00ff00");
1719 }
1720 buf_pool_release(&buf);
1721}
1722
1723void dot_patternlist(FILE *fp, struct PatternList *pl, struct ListHead *links)
1724{
1725 struct Buffer *buf = buf_pool_get();
1726
1727 char name[256] = { 0 };
1728 buf_addstr(buf, "{ rank=same ");
1729
1730 struct Pattern *prev = NULL;
1731 struct Pattern *np = NULL;
1732 SLIST_FOREACH(np, pl, entries)
1733 {
1734 dot_pattern(fp, np, links);
1735 if (prev)
1736 dot_add_link(links, prev, np, "PatternList->next", NULL, false, "#ff0000");
1737 prev = np;
1738
1739 dot_ptr_name(name, sizeof(name), np);
1740 buf_add_printf(buf, "%s ", name);
1741 }
1742
1743 buf_addstr(buf, "}");
1744
1745 mutt_list_insert_tail(links, buf_strdup(buf));
1746 buf_pool_release(&buf);
1747}
1748
1749void dump_graphviz_patternlist(struct PatternList *pl)
1750{
1751 char name[256] = { 0 };
1752 struct ListHead links = STAILQ_HEAD_INITIALIZER(links);
1753
1754 time_t now = time(NULL);
1755 mutt_date_localtime_format(name, sizeof(name), "%T-pattern.gv", now);
1756
1757 umask(022);
1758 FILE *fp = fopen(name, "w");
1759 if (!fp)
1760 return;
1761
1762 dot_graph_header(fp);
1763
1764 dot_patternlist(fp, pl, &links);
1765
1766 dot_graph_footer(fp, &links);
1767 fclose(fp);
1768 mutt_list_free(&links);
1769}
1770
1771void dot_expando_node_empty(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
1772{
1773 dot_object_header(fp, node, "Empty", "#ffffff");
1774 // dot_type_string(fp, "type", "ENT_EMPTY", true);
1776}
1777
1778void dot_expando_node_text(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
1779{
1780 struct Buffer *buf = buf_pool_get();
1781 dot_object_header(fp, node, "Text", "#ffff80");
1782 // dot_type_string(fp, "type", "ENT_TEXT", true);
1783
1784 if (node->start && node->end)
1785 {
1786 size_t len = node->end - node->start;
1787 char text[64] = { 0 };
1788 mutt_strn_copy(text, node->start, len, sizeof(text));
1789 dot_type_string(fp, "text", text, true);
1790 }
1791
1793
1794 buf_pool_release(&buf);
1795}
1796
1797void dot_expando_node_pad(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
1798{
1799 struct Buffer *buf = buf_pool_get();
1800 dot_object_header(fp, node, "Pad", "#80ffff");
1801 // dot_type_string(fp, "type", "ENT_PADDING", true);
1802
1803 struct NodePaddingPrivate *priv = node->ndata;
1804 char *pad = "UNKNOWN";
1805 switch (priv->pad_type)
1806 {
1807 case EPT_FILL_EOL:
1808 pad = "EPT_FILL_EOL";
1809 break;
1810 case EPT_HARD_FILL:
1811 pad = "EPT_HARD_FILL";
1812 break;
1813 case EPT_SOFT_FILL:
1814 pad = "EPT_SOFT_FILL";
1815 break;
1816 }
1817 dot_type_string(fp, "type", pad, true);
1818
1819 if (node->start && node->end)
1820 {
1821 size_t len = node->end - node->start;
1822 char text[64] = { 0 };
1823 mutt_strn_copy(text, node->start, len, sizeof(text));
1824 dot_type_string(fp, "char", text, true);
1825 }
1826
1828
1829 struct ExpandoNode *left = node_get_child(node, ENP_LEFT);
1830 if (left)
1831 {
1832 dot_expando_node_tree(fp, left, links);
1833 dot_add_link(links, node, left, "Pad->left", "left", false, "#80ff80");
1834 }
1835
1836 struct ExpandoNode *right = node_get_child(node, ENP_RIGHT);
1837 if (right)
1838 {
1839 dot_expando_node_tree(fp, right, links);
1840 dot_add_link(links, node, right, "Pad->right", "right", false, "#ff8080");
1841 }
1842
1843 buf_pool_release(&buf);
1844}
1845
1846void dot_expando_node_condition(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
1847{
1848 struct Buffer *buf = buf_pool_get();
1849 dot_object_header(fp, node, "Condition", "#ff8080");
1850 // dot_type_string(fp, "type", "ENT_CONDITION", true);
1851
1852 if (node->start && node->end)
1853 {
1854 size_t len = node->end - node->start;
1855
1856 char str[64] = { 0 };
1857 mutt_strn_copy(str, node->start, len, sizeof(str));
1858 dot_type_string(fp, "string", str, true);
1859 }
1860
1862
1863 struct ExpandoNode *condition = node_get_child(node, ENC_CONDITION);
1864 struct ExpandoNode *if_true_tree = node_get_child(node, ENC_TRUE);
1865 struct ExpandoNode *if_false_tree = node_get_child(node, ENC_FALSE);
1866
1867 dot_expando_node_tree(fp, condition, links);
1868 dot_add_link(links, node, condition, "Condition->condition", "condition", false, "#ff80ff");
1869 if (if_true_tree)
1870 {
1871 dot_expando_node_tree(fp, if_true_tree, links);
1872 dot_add_link(links, node, if_true_tree, "Condition->true", "true", false, "#80ff80");
1873 }
1874 if (if_false_tree)
1875 {
1876 dot_expando_node_tree(fp, if_false_tree, links);
1877 dot_add_link(links, node, if_false_tree, "Condition->false", "false", false, "#ff8080");
1878 }
1879
1880 buf_pool_release(&buf);
1881}
1882
1884 struct ListHead *links)
1885{
1886 struct Buffer *buf = buf_pool_get();
1887 dot_object_header(fp, node, "CondBool", "#c0c0ff");
1888 // dot_type_string(fp, "type", "ENT_CONDBOOL", true);
1889 dot_type_string(fp, "did", name_expando_domain(node->did), true);
1890 dot_type_string(fp, "uid", name_expando_uid(node->did, node->uid), true);
1891
1892 if (node->start && node->end)
1893 {
1894 size_t len = node->end - node->start;
1895
1896 char str[64] = { 0 };
1897 mutt_strn_copy(str, node->start, len, sizeof(str));
1898 dot_type_string(fp, "string", str, true);
1899 }
1900
1902
1903 buf_pool_release(&buf);
1904}
1905
1907 struct ListHead *links)
1908{
1909 struct Buffer *buf = buf_pool_get();
1910 dot_object_header(fp, node, "CondDate", "#c0c0ff");
1911 // dot_type_string(fp, "type", "ENT_CONDDATE", true);
1912 dot_type_string(fp, "did", name_expando_domain(node->did), true);
1913 dot_type_string(fp, "uid", name_expando_uid(node->did, node->uid), true);
1914
1915 if (node->start && node->end)
1916 {
1917 size_t len = node->end - node->start;
1918
1919 char str[64] = { 0 };
1920 mutt_strn_copy(str, node->start, len, sizeof(str));
1921 dot_type_string(fp, "string", str, true);
1922 }
1923
1924 struct NodeCondDatePrivate *priv = node->ndata;
1925 if (priv)
1926 {
1927 dot_type_number(fp, "count", priv->count);
1928 dot_type_char(fp, "period", priv->period);
1929 }
1930
1932
1933 buf_pool_release(&buf);
1934}
1935
1936void dot_format(FILE *fp, struct ExpandoFormat *fmt)
1937{
1938 if (!fmt)
1939 return;
1940
1941 dot_type_number(fp, "min_cols", fmt->min_cols);
1942 dot_type_number(fp, "max_cols", fmt->max_cols);
1943
1944 char *just = "UNKNOWN";
1945 switch (fmt->justification)
1946 {
1947 case JUSTIFY_LEFT:
1948 just = "JUSTIFY_LEFT";
1949 break;
1950 case JUSTIFY_CENTER:
1951 just = "JUSTIFY_CENTER";
1952 break;
1953 case JUSTIFY_RIGHT:
1954 just = "JUSTIFY_RIGHT";
1955 break;
1956 }
1957 dot_type_string(fp, "justification", just, true);
1958 dot_type_char(fp, "leader", fmt->leader);
1959}
1960
1961void dot_expando_node_container(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
1962{
1963 struct Buffer *buf = buf_pool_get();
1964 dot_object_header(fp, node, "Container", "#80ffff");
1965 // dot_type_string(fp, "type", "ENT_CONTAINER", true);
1966
1967 dot_format(fp, node->format);
1968
1970
1971 struct ExpandoNode **enp = NULL;
1972 ARRAY_FOREACH(enp, &node->children)
1973 {
1974 struct ExpandoNode *child = *enp;
1975
1976 dot_expando_node_tree(fp, child, links);
1977 dot_add_link(links, node, child, "Node->child", "child", false, "#80ff80");
1978 }
1979
1980 buf_pool_release(&buf);
1981}
1982
1983void dot_expando_node_expando(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
1984{
1985 struct Buffer *buf = buf_pool_get();
1986 dot_object_header(fp, node, "Expando", "#80ff80");
1987
1988 // dot_type_number(fp, "type", node->type);
1989 dot_type_string(fp, "did", name_expando_domain(node->did), true);
1990 dot_type_string(fp, "uid", name_expando_uid(node->did, node->uid), true);
1991
1992 if (node->start && node->end)
1993 {
1994 size_t len = node->end - node->start;
1995
1996 char str[64] = { 0 };
1997 mutt_strn_copy(str, node->start, len, sizeof(str));
1998 dot_type_string(fp, "string", str, true);
1999 }
2000
2001 dot_format(fp, node->format);
2002
2004
2005 buf_pool_release(&buf);
2006}
2007
2008void dot_expando_node(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
2009{
2010 struct Buffer *buf = buf_pool_get();
2011 dot_object_header(fp, node, "UNKNOWN", "#ff0000");
2012
2013 dot_type_number(fp, "type", node->type);
2014 dot_type_number(fp, "did", node->did);
2015 dot_type_number(fp, "uid", node->uid);
2016
2017 if (node->start && node->end)
2018 {
2019 size_t len = node->end - node->start;
2020
2021 char str[64] = { 0 };
2022 mutt_strn_copy(str, node->start, len, sizeof(str));
2023 dot_type_string(fp, "string", str, true);
2024 }
2025
2027
2028 buf_pool_release(&buf);
2029}
2030
2031void dot_expando_node_tree(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
2032{
2033 struct Buffer *buf = buf_pool_get();
2034
2035 char name[256] = { 0 };
2036 buf_addstr(buf, "{ rank=same ");
2037
2038 struct ExpandoNode *prev = NULL;
2039 for (; node; node = node->next)
2040 {
2041 switch (node->type)
2042 {
2043 case ENT_CONDITION:
2044 dot_expando_node_condition(fp, node, links);
2045 break;
2046 case ENT_CONDBOOL:
2047 dot_expando_node_conditional_bool(fp, node, links);
2048 break;
2049 case ENT_CONDDATE:
2050 dot_expando_node_conditional_date(fp, node, links);
2051 break;
2052 case ENT_CONTAINER:
2053 dot_expando_node_container(fp, node, links);
2054 break;
2055 case ENT_EMPTY:
2056 dot_expando_node_empty(fp, node, links);
2057 break;
2058 case ENT_EXPANDO:
2059 dot_expando_node_expando(fp, node, links);
2060 break;
2061 case ENT_PADDING:
2062 dot_expando_node_pad(fp, node, links);
2063 break;
2064 case ENT_TEXT:
2065 dot_expando_node_text(fp, node, links);
2066 break;
2067 default:
2068 dot_expando_node(fp, node, links);
2069 break;
2070 }
2071
2072 if (prev)
2073 dot_add_link(links, prev, node, "ExpandoNode->next", NULL, false, "#808080");
2074 prev = node;
2075
2076 dot_ptr_name(name, sizeof(name), node);
2077 buf_add_printf(buf, "%s ", name);
2078 }
2079
2080 buf_addstr(buf, "}");
2081
2082 mutt_list_insert_tail(links, buf_strdup(buf));
2083 buf_pool_release(&buf);
2084}
2085
2087{
2088 char name[256] = { 0 };
2089 struct ListHead links = STAILQ_HEAD_INITIALIZER(links);
2090
2091 time_t now = time(NULL);
2092 mutt_date_localtime_format(name, sizeof(name), "%T-expando.gv", now);
2093
2094 umask(022);
2095 FILE *fp = fopen(name, "w");
2096 if (!fp)
2097 return;
2098
2099 dot_graph_header(fp);
2100
2101 dot_expando_node_tree(fp, node, &links);
2102
2103 dot_graph_footer(fp, &links);
2104 fclose(fp);
2105 mutt_list_free(&links);
2106}
size_t mutt_addrlist_write(const struct AddressList *al, struct Buffer *buf, bool display)
Write an Address to a buffer.
Definition: address.c:1206
Email Address Handling.
#define ARRAY_FOREACH(elem, head)
Iterate over all elements of the array.
Definition: array.h:212
GUI display the mailboxes in a side panel.
int buf_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
Definition: buffer.c:161
int buf_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
Definition: buffer.c:204
size_t buf_len(const struct Buffer *buf)
Calculate the length of a Buffer.
Definition: buffer.c:491
void buf_reset(struct Buffer *buf)
Reset an existing Buffer.
Definition: buffer.c:76
bool buf_is_empty(const struct Buffer *buf)
Is the Buffer empty?
Definition: buffer.c:291
char buf_at(const struct Buffer *buf, size_t offset)
Return the character at the given offset.
Definition: buffer.c:670
void buf_free(struct Buffer **ptr)
Deallocates a buffer.
Definition: buffer.c:319
void buf_inline_replace(struct Buffer *buf, size_t pos, size_t len, const char *str)
Definition: buffer.c:770
struct Buffer * buf_new(const char *str)
Allocate a new Buffer.
Definition: buffer.c:304
size_t buf_addch(struct Buffer *buf, char c)
Add a single character to a Buffer.
Definition: buffer.c:241
size_t buf_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Definition: buffer.c:226
char * buf_strdup(const struct Buffer *buf)
Copy a Buffer's string.
Definition: buffer.c:571
static const char * buf_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
Definition: buffer.h:96
Compressed mbox local mailbox type.
Convenience wrapper for the config headers.
Connection Library.
Convenience wrapper for the core headers.
MailboxType
Supported mailbox formats.
Definition: mailbox.h:41
@ MUTT_NOTMUCH
'Notmuch' (virtual) Mailbox type
Definition: mailbox.h:51
@ MUTT_MMDF
'mmdf' Mailbox type
Definition: mailbox.h:46
@ MUTT_POP
'POP3' Mailbox type
Definition: mailbox.h:52
@ MUTT_MH
'MH' Mailbox type
Definition: mailbox.h:47
@ MUTT_NNTP
'NNTP' (Usenet) Mailbox type
Definition: mailbox.h:49
@ MUTT_IMAP
'IMAP' Mailbox type
Definition: mailbox.h:50
@ MUTT_MBOX
'mbox' Mailbox type
Definition: mailbox.h:45
@ MUTT_COMPRESSED
Compressed file Mailbox type.
Definition: mailbox.h:53
@ MUTT_MAILDIR
'Maildir' Mailbox type
Definition: mailbox.h:48
const char * name_content_encoding(enum ContentEncoding enc)
Definition: names.c:65
const char * name_content_type(enum ContentType type)
Definition: names.c:47
const char * name_content_disposition(enum ContentDisposition disp)
Definition: names.c:80
const char * name_expando_uid(enum ExpandoDomain did, int uid)
const char * name_expando_domain(enum ExpandoDomain did)
Definition: names_expando.c:86
Structs that make up an email.
#define MUTT_ENV_CHANGED_SUBJECT
Protected header update.
Definition: envelope.h:37
#define MUTT_ENV_CHANGED_XLABEL
X-Label edited.
Definition: envelope.h:36
#define MUTT_ENV_CHANGED_IRT
In-Reply-To changed to link/break threads.
Definition: envelope.h:34
#define MUTT_ENV_CHANGED_REFS
References changed to break thread.
Definition: envelope.h:35
@ JUSTIFY_RIGHT
Right justify the text.
Definition: format.h:36
@ JUSTIFY_LEFT
Left justify the text.
Definition: format.h:34
@ JUSTIFY_CENTER
Centre the text.
Definition: format.h:35
void dot_array_actx_idx(FILE *fp, struct AttachPtr **idx, short idxlen, short idxmax, struct ListHead *links)
Definition: graphviz.c:1472
void dot_mailbox_pop(FILE *fp, struct PopAccountData *adata, struct ListHead *links)
Definition: graphviz.c:535
void dot_ptr_name(char *buf, size_t buflen, const void *ptr)
Definition: graphviz.c:182
void dot_parameter_list(FILE *fp, const char *name, const struct ParameterList *pl)
Definition: graphviz.c:977
void dot_graph_header(FILE *fp)
Definition: graphviz.c:232
void dot_account_pop(FILE *fp, struct PopAccountData *adata, struct ListHead *links)
Definition: graphviz.c:787
void dot_object_footer(FILE *fp)
Definition: graphviz.c:283
void dot_path_fs(char *buf, size_t buflen, const char *path)
Definition: graphviz.c:325
void dump_graphviz_body(struct Body *b)
Definition: graphviz.c:1400
void dot_addr_list(FILE *fp, const char *name, const struct AddressList *al, struct ListHead *links)
Definition: graphviz.c:1204
void dot_mailbox_imap(FILE *fp, struct ImapMboxData *mdata, struct ListHead *links)
Definition: graphviz.c:470
void dot_comp(FILE *fp, struct CompressInfo *ci, struct ListHead *links)
Definition: graphviz.c:416
void dot_expando_node_empty(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
Definition: graphviz.c:1771
void dot_mailbox_type(FILE *fp, const char *name, enum MailboxType type)
Definition: graphviz.c:425
void dot_attach_ptr2(FILE *fp, struct AttachPtr *aptr, struct ListHead *links)
Definition: graphviz.c:1450
void dot_type_date(char *buf, size_t buflen, time_t timestamp)
Definition: graphviz.c:107
void dot_array_actx_v2r(FILE *fp, short *v2r, short vcount, struct ListHead *links)
Definition: graphviz.c:1496
void dot_type_number(FILE *fp, const char *name, int num)
Definition: graphviz.c:129
void dot_expando_node_pad(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
Definition: graphviz.c:1797
#define ADDR_LIST(AL)
void dot_email(FILE *fp, struct Email *e, struct ListHead *links)
Definition: graphviz.c:1279
void dot_type_char(FILE *fp, const char *name, char ch)
Definition: graphviz.c:94
void dot_account_list(FILE *fp, struct AccountList *al, struct ListHead *links)
Definition: graphviz.c:864
void dot_account_mbox(FILE *fp, struct MboxAccountData *adata, struct ListHead *links)
Definition: graphviz.c:721
void dot_type_file(FILE *fp, const char *name, FILE *struct_fp)
Definition: graphviz.c:112
void dump_graphviz(const char *title, struct MailboxView *mv)
Definition: graphviz.c:896
void dot_format(FILE *fp, struct ExpandoFormat *fmt)
Definition: graphviz.c:1936
void dot_type_bool(FILE *fp, const char *name, bool val)
Definition: graphviz.c:83
void dot_list_head(FILE *fp, const char *name, const struct ListHead *list)
Definition: graphviz.c:1183
void dot_config(FILE *fp, const char *name, int type, struct ConfigSubset *sub, struct ListHead *links)
Definition: graphviz.c:358
void dot_array_actx_body_idx(FILE *fp, struct Body **body_idx, short body_len, short body_max, struct ListHead *links)
Definition: graphviz.c:1530
void dot_account_imap(FILE *fp, struct ImapAccountData *adata, struct ListHead *links)
Definition: graphviz.c:699
void dot_patternlist(FILE *fp, struct PatternList *pl, struct ListHead *links)
Definition: graphviz.c:1723
void dot_type_umask(char *buf, size_t buflen, int umask)
Definition: graphviz.c:176
void dot_graph_footer(FILE *fp, struct ListHead *links)
Definition: graphviz.c:255
void dot_mailbox_node(FILE *fp, struct MailboxNode *mn, struct ListHead *links)
Definition: graphviz.c:625
void dot_mview(FILE *fp, struct MailboxView *mv, struct ListHead *links)
Definition: graphviz.c:883
void dot_account(FILE *fp, struct Account *a, struct ListHead *links)
Definition: graphviz.c:808
void dot_connection(FILE *fp, struct Connection *c, struct ListHead *links)
Definition: graphviz.c:683
void dot_mailbox_mbox(FILE *fp, struct MboxAccountData *mdata, struct ListHead *links)
Definition: graphviz.c:493
void dot_node_link(FILE *fp, void *ptr, const char *name, void *link, const char *colour)
Definition: graphviz.c:305
void dot_expando_node_tree(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
Definition: graphviz.c:2031
void dot_type_string(FILE *fp, const char *name, const char *str, bool force)
Definition: graphviz.c:151
void dot_expando_node(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
Definition: graphviz.c:2008
void dot_account_notmuch(FILE *fp, struct NmAccountData *adata, struct ListHead *links)
Definition: graphviz.c:779
void dump_graphviz_expando_node(struct ExpandoNode *node)
Definition: graphviz.c:2086
void dot_array_actx_fp_idx(FILE *fp, FILE **fp_idx, short fp_len, short fp_max, struct ListHead *links)
Definition: graphviz.c:1512
void dot_attach_ctx(FILE *fp, struct AttachCtx *actx, struct ListHead *links)
Definition: graphviz.c:1556
void dot_path_imap(char *buf, size_t buflen, const char *path)
Definition: graphviz.c:342
void dot_node(FILE *fp, void *ptr, const char *name, const char *colour)
Definition: graphviz.c:290
void dot_expando_node_container(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
Definition: graphviz.c:1961
void dot_mailbox_notmuch(FILE *fp, struct NmMboxData *mdata, struct ListHead *links)
Definition: graphviz.c:527
void dot_pattern(FILE *fp, struct Pattern *pat, struct ListHead *links)
Definition: graphviz.c:1666
void dot_content(FILE *fp, struct Content *cont, struct ListHead *links)
Definition: graphviz.c:995
#define ADD_FLAG(F)
void dot_account_nntp(FILE *fp, struct NntpAccountData *adata, struct ListHead *links)
Definition: graphviz.c:736
void dot_attach_ptr(FILE *fp, struct AttachPtr *aptr, struct ListHead *links)
Definition: graphviz.c:1022
void dot_mailbox_list(FILE *fp, struct MailboxList *ml, struct ListHead *links, bool abbr)
Definition: graphviz.c:666
void dot_ptr(FILE *fp, const char *name, void *ptr, const char *colour)
Definition: graphviz.c:187
#define ADD_BOOL(F)
void dot_add_link(struct ListHead *links, void *src, void *dst, const char *label, const char *short_label, bool back, const char *colour)
Definition: graphviz.c:204
const char * pattern_type_name(int type)
Definition: graphviz.c:1612
void dot_object_header(FILE *fp, const void *ptr, const char *name, const char *colour)
Definition: graphviz.c:266
void dump_graphviz_patternlist(struct PatternList *pl)
Definition: graphviz.c:1749
void dot_envelope(FILE *fp, struct Envelope *env, struct ListHead *links)
Definition: graphviz.c:1218
void dot_expando_node_conditional_date(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
Definition: graphviz.c:1906
void dump_graphviz_attach_ctx(struct AttachCtx *actx)
Definition: graphviz.c:1590
void dot_expando_node_conditional_bool(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
Definition: graphviz.c:1883
void dot_mailbox(FILE *fp, struct Mailbox *m, struct ListHead *links)
Definition: graphviz.c:543
void dot_expando_node_text(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
Definition: graphviz.c:1778
void dot_type_string_escape(struct Buffer *buf)
Definition: graphviz.c:138
void dot_expando_node_condition(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
Definition: graphviz.c:1846
void dot_expando_node_expando(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
Definition: graphviz.c:1983
void dot_mailbox_maildir(FILE *fp, struct MaildirMboxData *mdata, struct ListHead *links)
Definition: graphviz.c:479
void dot_mailbox_nntp(FILE *fp, struct NntpMboxData *mdata, struct ListHead *links)
Definition: graphviz.c:506
void dump_graphviz_email(struct Email *e, const char *title)
Definition: graphviz.c:1422
void dot_body(FILE *fp, struct Body *b, struct ListHead *links, bool link_next)
Definition: graphviz.c:1045
static int pad(FILE *fp, int col, int i)
Write some padding to a file.
Definition: help.c:199
Imap-specific Account data.
IMAP network mailbox.
Imap-specific Mailbox data.
Shared constants/structs that are private to IMAP.
struct ListNode * mutt_list_insert_tail(struct ListHead *h, char *s)
Append a string to the end of a List.
Definition: list.c:64
void mutt_list_free(struct ListHead *h)
Free a List AND its strings.
Definition: list.c:122
Maildir-specific Email data.
Maildir local mailbox type.
Maildir-specific Mailbox data.
const char * mutt_map_get_name(int val, const struct Mapping *map)
Lookup a string for a constant.
Definition: mapping.c:42
#define FREE(x)
Definition: memory.h:45
size_t mutt_date_localtime_format(char *buf, size_t buflen, const char *format, time_t t)
Format localtime.
Definition: date.c:950
Convenience wrapper for the library headers.
static const char * timestamp(time_t stamp)
Create a YYYY-MM-DD HH:MM:SS timestamp.
Definition: logging.c:78
char * mutt_str_dup(const char *str)
Copy a string, safely.
Definition: string.c:254
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:661
char * mutt_strn_copy(char *dest, const char *src, size_t len, size_t dsize)
Copy a sub-string into a buffer.
Definition: string.c:361
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
Definition: string.c:231
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:582
View of a Mailbox.
API for encryption/signing of emails.
#define SEC_INLINE
Email has an inline signature.
Definition: lib.h:85
#define SEC_AUTOCRYPT
(Autocrypt) Message will be, or was Autocrypt encrypt+signed
Definition: lib.h:87
#define SEC_OPPENCRYPT
Opportunistic encrypt mode.
Definition: lib.h:86
#define PGP_TRADITIONAL_CHECKED
Email has a traditional (inline) signature.
Definition: lib.h:92
#define SEC_GOODSIGN
Email has a valid signature.
Definition: lib.h:80
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: lib.h:90
#define SEC_SIGNOPAQUE
Email has an opaque signature (encrypted)
Definition: lib.h:83
#define SEC_BADSIGN
Email has a bad signature.
Definition: lib.h:81
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: lib.h:91
#define SEC_PARTSIGN
Not all parts of the email is signed.
Definition: lib.h:82
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:78
#define SEC_AUTOCRYPT_OVERRIDE
(Autocrypt) Indicates manual set/unset of encryption
Definition: lib.h:88
#define SEC_SIGN
Email is signed.
Definition: lib.h:79
#define SEC_KEYBLOCK
Email has a key attached.
Definition: lib.h:84
Nntp-specific Account data.
Usenet network mailbox type; talk to an NNTP server.
Nntp-specific Mailbox data.
struct ExpandoNode * node_get_child(const struct ExpandoNode *node, int index)
Get a child of an ExpandoNode.
Definition: node.c:99
@ ENT_EXPANDO
Expando, e.g. 'n'.
Definition: node.h:39
@ ENT_CONTAINER
Container for other nodes.
Definition: node.h:44
@ ENT_CONDITION
True/False condition.
Definition: node.h:41
@ ENT_TEXT
Plain text.
Definition: node.h:38
@ ENT_CONDDATE
True/False date condition.
Definition: node.h:43
@ ENT_EMPTY
Empty.
Definition: node.h:37
@ ENT_CONDBOOL
True/False boolean condition.
Definition: node.h:42
@ ENT_PADDING
Padding: soft, hard, EOL.
Definition: node.h:40
@ ENC_CONDITION
Index of Condition Node.
@ ENC_FALSE
Index of False Node.
@ ENC_TRUE
Index of True Node.
@ ENP_LEFT
Index of Left-Hand Nodes.
Definition: node_padding.h:56
@ ENP_RIGHT
Index of Right-Hand Nodes.
Definition: node_padding.h:57
@ EPT_FILL_EOL
Fill to the end-of-line.
Definition: node_padding.h:44
@ EPT_SOFT_FILL
Soft-fill: right-hand-side will be truncated.
Definition: node_padding.h:46
@ EPT_HARD_FILL
Hard-fill: left-hand-side will be truncated.
Definition: node_padding.h:45
Notmuch-specific Account data.
Notmuch virtual mailbox type.
Notmuch-specific Mailbox data.
Notmuch private types.
Match patterns to emails.
@ MUTT_PAT_HEADER
Pattern matches email's header.
Definition: lib.h:156
@ MUTT_PAT_WHOLE_MSG
Pattern matches raw email text.
Definition: lib.h:158
@ MUTT_PAT_BROKEN
Message is part of a broken thread.
Definition: lib.h:152
@ MUTT_PAT_ID_EXTERNAL
Message-Id is among results from an external query.
Definition: lib.h:154
@ MUTT_PAT_OR
Either pattern can match.
Definition: lib.h:138
@ MUTT_PAT_CHILDREN
Pattern matches a child email.
Definition: lib.h:141
@ MUTT_PAT_PARENT
Pattern matches parent.
Definition: lib.h:140
@ MUTT_PAT_REFERENCE
Pattern matches 'References:' or 'In-Reply-To:' field.
Definition: lib.h:163
@ MUTT_PAT_FROM
Pattern matches 'From:' field.
Definition: lib.h:147
@ MUTT_PAT_DRIVER_TAGS
Pattern matches message tags.
Definition: lib.h:176
@ MUTT_PAT_COLLAPSED
Thread is collapsed.
Definition: lib.h:145
@ MUTT_PAT_CRYPT_VERIFIED
Message is crypographically verified.
Definition: lib.h:171
@ MUTT_PAT_HORMEL
Pattern matches email's spam score.
Definition: lib.h:157
@ MUTT_PAT_SUBJECT
Pattern matches 'Subject:' field.
Definition: lib.h:146
@ MUTT_PAT_LIST
Email is on mailing list.
Definition: lib.h:165
@ MUTT_PAT_NEWSGROUPS
Pattern matches newsgroup.
Definition: lib.h:179
@ MUTT_PAT_PERSONAL_RECIP
Email is addressed to the user.
Definition: lib.h:167
@ MUTT_PAT_CC
Pattern matches 'Cc:' field.
Definition: lib.h:143
@ MUTT_PAT_SUBSCRIBED_LIST
Email is on subscribed mailing list.
Definition: lib.h:166
@ MUTT_PAT_SERVERSEARCH
Server-side pattern matches.
Definition: lib.h:175
@ MUTT_PAT_RECIPIENT
User is a recipient of the email.
Definition: lib.h:164
@ MUTT_PAT_CRYPT_ENCRYPT
Message is encrypted.
Definition: lib.h:172
@ MUTT_PAT_UNREFERENCED
Message is unreferenced in the thread.
Definition: lib.h:151
@ MUTT_PAT_CRYPT_SIGN
Message is signed.
Definition: lib.h:170
@ MUTT_PAT_MESSAGE
Pattern matches message number.
Definition: lib.h:160
@ MUTT_PAT_AND
Both patterns must match.
Definition: lib.h:137
@ MUTT_PAT_DATE
Pattern matches 'Date:' field.
Definition: lib.h:148
@ MUTT_PAT_XLABEL
Pattern matches keyword/label.
Definition: lib.h:174
@ MUTT_PAT_SCORE
Pattern matches email's score.
Definition: lib.h:161
@ MUTT_PAT_MIMEATTACH
Pattern matches number of attachments.
Definition: lib.h:177
@ MUTT_PAT_DUPLICATED
Duplicate message.
Definition: lib.h:150
@ MUTT_PAT_PERSONAL_FROM
Email is from the user.
Definition: lib.h:168
@ MUTT_PAT_TO
Pattern matches 'To:' field.
Definition: lib.h:142
@ MUTT_PAT_BCC
Pattern matches 'Bcc:' field.
Definition: lib.h:144
@ MUTT_PAT_SENDER
Pattern matches sender.
Definition: lib.h:159
@ MUTT_PAT_DATE_RECEIVED
Pattern matches date received.
Definition: lib.h:149
@ MUTT_PAT_ADDRESS
Pattern matches any address field.
Definition: lib.h:169
@ MUTT_PAT_MIMETYPE
Pattern matches MIME type.
Definition: lib.h:178
@ MUTT_PAT_PGP_KEY
Message has PGP key.
Definition: lib.h:173
@ MUTT_PAT_ID
Pattern matches email's Message-Id.
Definition: lib.h:153
@ MUTT_PAT_THREAD
Pattern matches email thread.
Definition: lib.h:139
@ MUTT_PAT_SIZE
Pattern matches email's size.
Definition: lib.h:162
@ MUTT_PAT_BODY
Pattern matches email's body.
Definition: lib.h:155
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:81
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:94
Pop-specific Account data.
POP network mailbox.
POP network mailbox.
#define SLIST_FOREACH(var, head, field)
Definition: queue.h:231
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:725
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:324
#define STAILQ_FIRST(head)
Definition: queue.h:350
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:352
#define TAILQ_FIRST(head)
Definition: queue.h:723
#define STAILQ_EMPTY(head)
Definition: queue.h:348
#define SLIST_FIRST(head)
Definition: queue.h:229
#define TAILQ_EMPTY(head)
Definition: queue.h:721
Key value store.
A group of associated Mailboxes.
Definition: account.h:36
enum MailboxType type
Type of Mailboxes this Account contains.
Definition: account.h:37
char * name
Name of Account.
Definition: account.h:38
struct ConfigSubset * sub
Inherited config items.
Definition: account.h:39
void * adata
Private data (for Mailbox backends)
Definition: account.h:42
struct MailboxList mailboxes
List of Mailboxes.
Definition: account.h:40
A set of attachments.
Definition: attach.h:65
short vcount
The number of virtual attachments.
Definition: attach.h:74
short body_len
Number of Body parts.
Definition: attach.h:81
FILE * fp_root
Used by recvattach for updating.
Definition: attach.h:67
short fp_max
Size of FILE array.
Definition: attach.h:78
struct Email * email
Used by recvattach for updating.
Definition: attach.h:66
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:69
struct Body ** body_idx
Extra struct Body* used for decryption.
Definition: attach.h:80
short fp_len
Number of FILE handles.
Definition: attach.h:77
short body_max
Size of Body array.
Definition: attach.h:82
FILE ** fp_idx
Extra FILE* used for decryption.
Definition: attach.h:76
short idxmax
Size of attachment array.
Definition: attach.h:71
short idxlen
Number of attachmentes.
Definition: attach.h:70
short * v2r
Mapping from virtual to real attachment.
Definition: attach.h:73
An email to which things will be attached.
Definition: attach.h:37
struct Body * body
Attachment.
Definition: attach.h:38
bool collapsed
Group is collapsed.
Definition: attach.h:46
int num
Attachment index number.
Definition: attach.h:43
int level
Nesting depth of attachment.
Definition: attach.h:42
FILE * fp
Used in the recvattach menu.
Definition: attach.h:39
bool unowned
Don't unlink on detach.
Definition: attach.h:44
bool decrypted
Not part of message as stored in the email->body.
Definition: attach.h:45
int parent_type
Type of parent attachment, e.g. TYPE_MULTIPART.
Definition: attach.h:40
The body of an email.
Definition: body.h:36
char * language
content-language (RFC8255)
Definition: body.h:77
char * d_filename
filename to be used for the content-disposition header If NULL, filename is used instead.
Definition: body.h:56
struct Body * parts
parts of a multipart or message/rfc822
Definition: body.h:72
LOFF_T offset
offset where the actual data begins
Definition: body.h:52
signed short attach_count
Number of attachments.
Definition: body.h:90
char * xtype
content-type if x-unknown
Definition: body.h:61
time_t stamp
Time stamp of last encoding update.
Definition: body.h:76
struct Envelope * mime_headers
Memory hole protected headers.
Definition: body.h:75
LOFF_T length
length (in bytes) of attachment
Definition: body.h:53
char * charset
Send mode: charset of attached file as stored on disk.
Definition: body.h:78
struct ParameterList parameter
Parameters of the content-type.
Definition: body.h:62
struct AttachPtr * aptr
Menu information, used in recvattach.c.
Definition: body.h:74
struct Email * email
header information for message/rfc822
Definition: body.h:73
char * description
content-description
Definition: body.h:55
unsigned int disposition
content-disposition, ContentDisposition
Definition: body.h:42
struct Content * content
Detailed info about the content of the attachment.
Definition: body.h:69
struct Body * next
next attachment in the list
Definition: body.h:71
char * subtype
content-type subtype
Definition: body.h:60
unsigned int encoding
content-transfer-encoding, ContentEncoding
Definition: body.h:41
long hdr_offset
Offset in stream where the headers begin.
Definition: body.h:80
char * form_name
Content-Disposition form-data name param.
Definition: body.h:59
unsigned int type
content-type primary type, ContentType
Definition: body.h:40
char * filename
When sending a message, this is the file to which this structure refers.
Definition: body.h:58
String manipulation buffer.
Definition: buffer.h:36
Private data for compress.
Definition: lib.h:58
struct Expando * cmd_open
open-hook command
Definition: lib.h:61
struct Expando * cmd_append
append-hook command
Definition: lib.h:59
struct Expando * cmd_close
close-hook command
Definition: lib.h:60
A set of inherited config items.
Definition: subset.h:47
const char * name
Scope name of Subset.
Definition: subset.h:48
struct ConfigSet * cs
Parent ConfigSet.
Definition: subset.h:51
char login[128]
Login name.
Definition: connaccount.h:55
char user[128]
Username.
Definition: connaccount.h:56
char pass[256]
Password.
Definition: connaccount.h:57
char host[128]
Server to login to.
Definition: connaccount.h:54
unsigned short port
Port to connect to.
Definition: connaccount.h:58
char inbuf[1024]
Buffer for incoming traffic.
Definition: connection.h:51
struct ConnAccount account
Account details: username, password, etc.
Definition: connection.h:49
int fd
Socket file descriptor.
Definition: connection.h:53
Info about an attachment.
Definition: content.h:36
long crlf
\r and \n characters
Definition: content.h:40
long hibin
8-bit characters
Definition: content.h:37
long ascii
Number of ascii chars.
Definition: content.h:41
long nulbin
Null characters (0x0)
Definition: content.h:39
long linemax
Length of the longest line in the file.
Definition: content.h:42
long lobin
Unprintable 7-bit chars (eg., control chars)
Definition: content.h:38
The envelope/body of an email.
Definition: email.h:39
unsigned int zminutes
Minutes away from UTC.
Definition: email.h:57
struct Envelope * env
Envelope information.
Definition: email.h:68
int lines
How many lines in the body of this message?
Definition: email.h:62
struct Body * body
List of MIME parts.
Definition: email.h:69
size_t num_hidden
Number of hidden messages in this view (only valid when collapsed is set)
Definition: email.h:126
bool zoccident
True, if west of UTC, False if east.
Definition: email.h:58
LOFF_T offset
Where in the stream does this message begin?
Definition: email.h:71
short attach_total
Number of qualifying attachments in message, if attach_valid.
Definition: email.h:118
unsigned int zhours
Hours away from UTC.
Definition: email.h:56
time_t date_sent
Time when the message was sent (UTC)
Definition: email.h:60
int vnum
Virtual message number.
Definition: email.h:117
int score
Message score.
Definition: email.h:116
int msgno
Number displayed to the user.
Definition: email.h:114
char * path
Path of Email (for local Mailboxes)
Definition: email.h:70
int index
The absolute (unsorted) message number.
Definition: email.h:113
time_t received
Time when the message was placed in the mailbox.
Definition: email.h:61
The header of an Email.
Definition: envelope.h:57
struct ListHead userhdrs
user defined headers
Definition: envelope.h:85
char * supersedes
Supersedes header.
Definition: envelope.h:74
char * list_subscribe
This stores a mailto URL, or nothing.
Definition: envelope.h:68
char *const subject
Email's subject.
Definition: envelope.h:70
char * followup_to
List of 'followup-to' fields.
Definition: envelope.h:80
char * message_id
Message ID.
Definition: envelope.h:73
char * x_comment_to
List of 'X-comment-to' fields.
Definition: envelope.h:81
struct AutocryptHeader * autocrypt_gossip
Autocrypt Gossip header.
Definition: envelope.h:88
char * newsgroups
List of newsgroups.
Definition: envelope.h:78
struct ListHead references
message references (in reverse order)
Definition: envelope.h:83
struct AutocryptHeader * autocrypt
Autocrypt header.
Definition: envelope.h:87
struct Buffer spam
Spam header.
Definition: envelope.h:82
struct ListHead in_reply_to
in-reply-to header content
Definition: envelope.h:84
char * xref
List of cross-references.
Definition: envelope.h:79
char * organization
Organisation header.
Definition: envelope.h:77
char * x_label
X-Label.
Definition: envelope.h:76
char * list_post
This stores a mailto URL, or nothing.
Definition: envelope.h:67
char *const real_subj
Offset of the real subject.
Definition: envelope.h:71
char * date
Sent date.
Definition: envelope.h:75
char * disp_subj
Display subject (modified copy of subject)
Definition: envelope.h:72
char * list_unsubscribe
This stores a mailto URL, or nothing.
Definition: envelope.h:69
Formatting information for an Expando.
Definition: node.h:53
char leader
Leader character, 0 or space.
Definition: node.h:57
enum FormatJustify justification
Justification: left, centre, right.
Definition: node.h:56
int min_cols
Minimum number of screen columns.
Definition: node.h:54
int max_cols
Maximum number of screen columns.
Definition: node.h:55
Basic Expando Node.
Definition: node.h:69
int uid
Unique ID, e.g. ED_EMA_SIZE.
Definition: node.h:73
void * ndata
Private node data.
Definition: node.h:82
struct ExpandoFormat * format
Formatting info.
Definition: node.h:75
const char * end
End of string data.
Definition: node.h:80
struct ExpandoNode * next
Linked list.
Definition: node.h:71
int did
Domain ID, e.g. ED_EMAIL.
Definition: node.h:72
enum ExpandoNodeType type
Type of Node, e.g. ENT_EXPANDO.
Definition: node.h:70
const char * start
Start of string data.
Definition: node.h:79
struct ExpandoNodeArray children
Children nodes.
Definition: node.h:77
const char * string
Pointer to the parsed string.
Definition: expando.h:42
The item stored in a Hash Table.
Definition: hash.h:43
union HashKey key
Key representing the data.
Definition: hash.h:45
int type
Type of data stored in Hash Table, e.g. DT_STRING.
Definition: hash.h:44
IMAP-specific Account data -.
Definition: adata.h:40
bool qresync
true, if QRESYNC is successfully ENABLE'd
Definition: adata.h:63
unsigned char seqid
tag sequence prefix
Definition: adata.h:56
bool unicode
If true, we can send UTF-8, and the server will use UTF8 rather than mUTF7.
Definition: adata.h:62
struct Mailbox * mailbox
Current selected mailbox.
Definition: adata.h:76
struct Connection * conn
Connection to IMAP server.
Definition: adata.h:41
IMAP-specific Mailbox data -.
Definition: mdata.h:40
char * real_name
Original Mailbox name, e.g.: INBOX can be just \0.
Definition: mdata.h:43
char * munge_name
Munged version of the mailbox name.
Definition: mdata.h:42
char * name
Mailbox name.
Definition: mdata.h:41
A List node for strings.
Definition: list.h:35
char * data
String.
Definition: list.h:36
List of Mailboxes.
Definition: mailbox.h:166
struct Mailbox * mailbox
Mailbox in the list.
Definition: mailbox.h:167
View of a Mailbox.
Definition: mview.h:40
bool collapsed
Are all threads collapsed?
Definition: mview.h:49
off_t vsize
Size (in bytes) of the messages shown.
Definition: mview.h:41
struct Mailbox * mailbox
Current Mailbox.
Definition: mview.h:51
char * pattern
Limit pattern string.
Definition: mview.h:42
A mailbox.
Definition: mailbox.h:79
int vcount
The number of virtual messages.
Definition: mailbox.h:99
char * realpath
Used for duplicate detection, context comparison, and the sidebar.
Definition: mailbox.h:81
int * v2r
Mapping from virtual to real msgno.
Definition: mailbox.h:98
int msg_count
Total number of messages.
Definition: mailbox.h:88
int email_max
Size of emails array.
Definition: mailbox.h:97
enum MailboxType type
Mailbox type.
Definition: mailbox.h:102
void * mdata
Driver specific data.
Definition: mailbox.h:132
struct Email ** emails
Array of Emails.
Definition: mailbox.h:96
char * name
A short name for the Mailbox.
Definition: mailbox.h:82
struct Buffer pathbuf
Path of the Mailbox.
Definition: mailbox.h:80
struct Account * account
Account that owns this Mailbox.
Definition: mailbox.h:127
int opened
Number of times mailbox is opened.
Definition: mailbox.h:128
void * compress_info
Compressed mbox module private data.
Definition: mailbox.h:121
struct ConfigSubset * sub
Inherited config items.
Definition: mailbox.h:83
Maildir-specific Mailbox data -.
Definition: mdata.h:35
struct timespec mtime_cur
Timestamp of the 'cur' dir.
Definition: mdata.h:37
mode_t umask
umask to use when creating files
Definition: mdata.h:38
Mapping between user-readable string and a constant.
Definition: mapping.h:33
Mbox-specific Account data -.
Definition: lib.h:49
FILE * fp
Mailbox file.
Definition: lib.h:50
bool append
mailbox is opened in append mode
Definition: lib.h:56
bool locked
is the mailbox locked?
Definition: lib.h:55
struct timespec atime
File's last-access time.
Definition: lib.h:52
Container for Accounts, Notifications.
Definition: neomutt.h:41
struct AccountList accounts
List of all Accounts.
Definition: neomutt.h:46
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:45
Notmuch-specific Account data -.
Definition: adata.h:35
notmuch_database_t * db
Connection to Notmuch database.
Definition: adata.h:36
Notmuch-specific Mailbox data -.
Definition: mdata.h:35
int db_limit
Maximum number of results to return.
Definition: mdata.h:38
NNTP-specific Account data -.
Definition: adata.h:36
time_t newgroups_time
Definition: adata.h:56
bool newsrc_modified
Definition: adata.h:49
bool hasXOVER
Server supports XOVER command.
Definition: adata.h:45
struct Connection * conn
Connection to NNTP Server.
Definition: adata.h:62
char * authenticators
Definition: adata.h:52
char * overview_fmt
Definition: adata.h:53
bool hasXGTITLE
Server supports XGTITLE command.
Definition: adata.h:41
unsigned int groups_num
Definition: adata.h:58
bool hasCAPABILITIES
Server supports CAPABILITIES command.
Definition: adata.h:37
bool hasSTARTTLS
Server supports STARTTLS command.
Definition: adata.h:38
bool hasLISTGROUPrange
Server supports LISTGROUPrange command.
Definition: adata.h:43
time_t check_time
Definition: adata.h:57
time_t mtime
Definition: adata.h:55
unsigned int groups_max
Definition: adata.h:59
bool hasLISTGROUP
Server supports LISTGROUP command.
Definition: adata.h:42
FILE * fp_newsrc
Definition: adata.h:50
bool cacheable
Definition: adata.h:48
bool hasOVER
Server supports OVER command.
Definition: adata.h:44
char * newsrc_file
Definition: adata.h:51
bool hasDATE
Server supports DATE command.
Definition: adata.h:39
bool hasLIST_NEWSGROUPS
Server supports LIST_NEWSGROUPS command.
Definition: adata.h:40
NNTP-specific Mailbox data -.
Definition: mdata.h:34
anum_t last_cached
Definition: mdata.h:40
bool deleted
Definition: mdata.h:45
bool allowed
Definition: mdata.h:44
anum_t last_message
Definition: mdata.h:38
char * group
Name of newsgroup.
Definition: mdata.h:35
char * desc
Description of newsgroup.
Definition: mdata.h:36
anum_t unread
Definition: mdata.h:41
anum_t last_loaded
Definition: mdata.h:39
bool has_new_mail
Definition: mdata.h:43
anum_t first_message
Definition: mdata.h:37
bool subscribed
Definition: mdata.h:42
Private data for a Conditional Date.
Definition: node_conddate.h:33
int count
Number of 'units' to count.
Definition: node_conddate.h:34
char period
Units, e.g. 'd' Day or 'm' Month.
Definition: node_conddate.h:35
Private data for a Padding Node.
Definition: node_padding.h:64
enum ExpandoPadType pad_type
Padding type.
Definition: node_padding.h:65
Attribute associated with a MIME part.
Definition: parameter.h:33
char * attribute
Parameter name.
Definition: parameter.h:34
char * value
Parameter value.
Definition: parameter.h:35
A simple (non-regex) pattern.
Definition: lib.h:77
bool group_match
Check a group of Addresses.
Definition: lib.h:82
union Pattern::@1 p
struct PatternList * child
Arguments to logical operation.
Definition: lib.h:90
long min
Minimum for range checks.
Definition: lib.h:88
bool string_match
Check a string for a match.
Definition: lib.h:81
regex_t * regex
Compiled regex, for non-pattern matching.
Definition: lib.h:92
char * str
String, if string_match is set.
Definition: lib.h:94
long max
Maximum for range checks.
Definition: lib.h:89
short op
Operation, e.g. MUTT_PAT_SCORE.
Definition: lib.h:78
bool is_multi
Multiple case (only for ~I pattern now)
Definition: lib.h:87
POP-specific Account data -.
Definition: adata.h:37
time_t check_time
Definition: adata.h:51
struct Connection * conn
Connection to POP server.
Definition: adata.h:38
A parsed URL proto://user:password@host:port/path?a=1&b=2
Definition: url.h:69
char * user
Username.
Definition: url.h:71
char * host
Host.
Definition: url.h:73
char * path
Path.
Definition: url.h:75
time_t tv_sec
Number of seconds since the epoch.
Definition: file.h:52
int cs_subset_he_string_get(const struct ConfigSubset *sub, struct HashElem *he, struct Buffer *result)
Get a config item as a string.
Definition: subset.c:332
struct HashElem ** get_elem_list(struct ConfigSet *cs)
Create a sorted list of all config items.
Definition: subset.c:79
#define DTYPE(t)
Definition: types.h:50
@ DT_STRING
a string
Definition: types.h:45
#define D_SENSITIVE
Contains sensitive value, e.g. password.
Definition: types.h:81
const char * strkey
String key.
Definition: hash.h:35
struct Url * url_parse(const char *src)
Fill in Url.
Definition: url.c:239
void url_free(struct Url **ptr)
Free the contents of a URL.
Definition: url.c:124