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