NeoMutt  2025-01-09-117-gace867
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 HashElemArray hea = get_elem_list(sub->cs, GEL_ALL_CONFIG);
375 struct HashElem **hep = NULL;
376 ARRAY_FOREACH(hep, &hea)
377 {
378 struct HashElem *item = *hep;
379 if ((item->type & type) == 0)
380 continue;
381
382 const char *iname = item->key.strkey;
383 size_t slen = strlen(scope);
384 if (mutt_str_startswith(iname, scope) != 0)
385 {
386 if (strchr(iname + slen, ':'))
387 continue;
388 if ((CONFIG_TYPE(item->type) == DT_STRING) && (item->type & D_SENSITIVE))
389 {
390 dot_type_string(fp, iname + slen, "***", true);
391 }
392 else
393 {
394 buf_reset(value);
395 cs_subset_he_string_get(sub, item, value);
396 dot_type_string(fp, iname + slen, buf_string(value), true);
397 }
398 }
399 }
400 ARRAY_FREE(&hea);
401 }
402 else
403 {
404 struct HashElemArray hea = get_elem_list(sub->cs, GEL_ALL_CONFIG);
405 dot_type_number(fp, "count", ARRAY_SIZE(&hea));
406 ARRAY_FREE(&hea);
407 }
408
410 buf_pool_release(&value);
411}
412#endif
413
414void dot_comp(FILE *fp, struct CompressInfo *ci, struct ListHead *links)
415{
416 dot_object_header(fp, ci, "CompressInfo", "#c0c060");
417 dot_type_string(fp, "append", ci->cmd_append->string, true);
418 dot_type_string(fp, "close", ci->cmd_close->string, true);
419 dot_type_string(fp, "open", ci->cmd_open->string, true);
421}
422
423void dot_mailbox_type(FILE *fp, const char *name, enum MailboxType type)
424{
425 const char *typestr = NULL;
426
427 switch (type)
428 {
429 case MUTT_MBOX:
430 typestr = "MBOX";
431 break;
432 case MUTT_MMDF:
433 typestr = "MMDF";
434 break;
435 case MUTT_MH:
436 typestr = "MH";
437 break;
438 case MUTT_MAILDIR:
439 typestr = "MAILDIR";
440 break;
441 case MUTT_NNTP:
442 typestr = "NNTP";
443 break;
444 case MUTT_IMAP:
445 typestr = "IMAP";
446 break;
447 case MUTT_NOTMUCH:
448 typestr = "NOTMUCH";
449 break;
450 case MUTT_POP:
451 typestr = "POP";
452 break;
453 case MUTT_COMPRESSED:
454 typestr = "COMPRESSED";
455 break;
456 default:
457 typestr = "UNKNOWN";
458 }
459
460 fprintf(fp, "\t\t<tr>\n");
461 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\">%s</td>\n", name);
462 fprintf(fp, "\t\t\t<td border=\"0\">=</td>\n");
463 fprintf(fp, "\t\t\t<td border=\"0\" align=\"left\">%s</td>\n", typestr);
464 fprintf(fp, "\t\t</tr>\n");
465}
466
467#ifndef GV_HIDE_MDATA
468void dot_mailbox_imap(FILE *fp, struct ImapMboxData *mdata, struct ListHead *links)
469{
470 dot_object_header(fp, mdata, "ImapMboxData", "#60c060");
471 dot_type_string(fp, "name", mdata->name, true);
472 dot_type_string(fp, "munge_name", mdata->munge_name, true);
473 dot_type_string(fp, "real_name", mdata->real_name, true);
475}
476
477void dot_mailbox_maildir(FILE *fp, struct MaildirMboxData *mdata, struct ListHead *links)
478{
479 char buf[64] = { 0 };
480
481 dot_object_header(fp, mdata, "MaildirMboxData", "#60c060");
482
483 dot_type_date(buf, sizeof(buf), mdata->mtime_cur.tv_sec);
484 dot_type_string(fp, "mtime_cur", buf, true);
485
486 dot_type_umask(buf, sizeof(buf), mdata->umask);
487 dot_type_string(fp, "umask", buf, true);
489}
490
491void dot_mailbox_mbox(FILE *fp, struct MboxAccountData *mdata, struct ListHead *links)
492{
493 char buf[64] = { 0 };
494
495 dot_object_header(fp, mdata, "MboxAccountData", "#60c060");
496 dot_ptr(fp, "fp", mdata->fp, NULL);
497
498 dot_type_date(buf, sizeof(buf), mdata->atime.tv_sec);
499 dot_type_string(fp, "atime", buf, true);
500
502}
503
504void dot_mailbox_nntp(FILE *fp, struct NntpMboxData *mdata, struct ListHead *links)
505{
506 dot_object_header(fp, mdata, "NntpMboxData", "#60c060");
507 dot_type_string(fp, "group", mdata->group, true);
508 dot_type_string(fp, "desc", mdata->desc, true);
509
510 dot_type_number(fp, "first_message", mdata->first_message);
511 dot_type_number(fp, "last_message", mdata->last_message);
512 dot_type_number(fp, "last_loaded", mdata->last_loaded);
513 dot_type_number(fp, "last_cached", mdata->last_cached);
514 dot_type_number(fp, "unread", mdata->unread);
515
516 dot_type_bool(fp, "subscribed", mdata->subscribed);
517 dot_type_bool(fp, "has_new_mail", mdata->has_new_mail);
518 dot_type_bool(fp, "allowed", mdata->allowed);
519 dot_type_bool(fp, "deleted", mdata->deleted);
520
522}
523
524#ifdef USE_NOTMUCH
525void dot_mailbox_notmuch(FILE *fp, struct NmMboxData *mdata, struct ListHead *links)
526{
527 dot_object_header(fp, mdata, "NmMboxData", "#60c060");
528 dot_type_number(fp, "db_limit", mdata->db_limit);
530}
531#endif
532
533void dot_mailbox_pop(FILE *fp, struct PopAccountData *adata, struct ListHead *links)
534{
535 dot_object_header(fp, adata, "PopAccountData", "#60c060");
536 dot_ptr(fp, "conn", adata->conn, "#ff8080");
538}
539#endif
540
541void dot_mailbox(FILE *fp, struct Mailbox *m, struct ListHead *links)
542{
543 char buf[64] = { 0 };
544
545 dot_object_header(fp, m, "Mailbox", "#80ff80");
546 dot_mailbox_type(fp, "type", m->type);
547 dot_type_string(fp, "name", m->name, false);
548
549 if ((m->type == MUTT_IMAP) || (m->type == MUTT_POP))
550 {
551 dot_path_imap(buf, sizeof(buf), buf_string(&m->pathbuf));
552 dot_type_string(fp, "pathbuf", buf, true);
553 dot_path_imap(buf, sizeof(buf), m->realpath);
554 dot_type_string(fp, "realpath", buf, true);
555 }
556 else
557 {
558 dot_path_fs(buf, sizeof(buf), buf_string(&m->pathbuf));
559 dot_type_string(fp, "pathbuf", buf, true);
560 dot_path_fs(buf, sizeof(buf), m->realpath);
561 dot_type_string(fp, "realpath", buf, true);
562 }
563
564#ifdef GV_HIDE_MDATA
565 dot_ptr(fp, "mdata", m->mdata, NULL);
566#endif
567 dot_ptr(fp, "account", m->account, "#80ffff");
568 dot_type_number(fp, "opened", m->opened);
569
570 dot_type_number(fp, "msg_count", m->msg_count);
571 // dot_type_number(fp, "msg_unread", m->msg_unread);
572 // dot_type_number(fp, "msg_flagged", m->msg_flagged);
573 // dot_type_number(fp, "msg_new", m->msg_new);
574 // dot_type_number(fp, "msg_deleted", m->msg_deleted);
575 // dot_type_number(fp, "msg_tagged", m->msg_tagged);
576
577 dot_ptr(fp, "emails", m->emails, NULL);
578 dot_type_number(fp, "email_max", m->email_max);
579 dot_ptr(fp, "v2r", m->v2r, NULL);
580 dot_type_number(fp, "vcount", m->vcount);
581
583
584 // dot_add_link(links, m, m->mdata, NULL, NULL, false, NULL);
585
586#ifndef GV_HIDE_MDATA
587 if (m->mdata)
588 {
589 if (m->type == MUTT_MAILDIR)
590 dot_mailbox_maildir(fp, m->mdata, links);
591 else if (m->type == MUTT_IMAP)
592 dot_mailbox_imap(fp, m->mdata, links);
593 else if (m->type == MUTT_POP)
594 dot_mailbox_pop(fp, m->mdata, links);
595 else if (m->type == MUTT_MBOX)
596 dot_mailbox_mbox(fp, m->mdata, links);
597 else if (m->type == MUTT_NNTP)
598 dot_mailbox_nntp(fp, m->mdata, links);
599#ifdef USE_NOTMUCH
600 else if (m->type == MUTT_NOTMUCH)
601 dot_mailbox_notmuch(fp, m->mdata, links);
602#endif
603
604 dot_add_link(links, m, m->mdata, "Mailbox->mdata", NULL, false, NULL);
605 }
606#endif
607
608 if (m->compress_info)
609 {
610 dot_comp(fp, m->compress_info, links);
611 dot_add_link(links, m, m->compress_info, "Mailbox->compress_info", NULL, false, NULL);
612 }
613
614#ifndef GV_HIDE_CONFIG
615 if (m->name)
616 {
617 dot_config(fp, m->name, 0, m->sub, links);
618 dot_add_link(links, m, m->name, "Mailbox Config", NULL, false, NULL);
619 }
620#endif
621}
622
623void dot_mailbox_node(FILE *fp, struct MailboxNode *mn, struct ListHead *links)
624{
625 dot_node(fp, mn, "MN", "#80ff80");
626
627 dot_mailbox(fp, mn->mailbox, links);
628
629 dot_add_link(links, mn, mn->mailbox, "MailboxNode->mailbox", NULL, false, NULL);
630
631 struct Buffer *buf = buf_pool_get();
632
633 char name[256] = { 0 };
634 buf_addstr(buf, "{ rank=same ");
635
636 dot_ptr_name(name, sizeof(name), mn);
637 buf_add_printf(buf, "%s ", name);
638
639 dot_ptr_name(name, sizeof(name), mn->mailbox);
640 buf_add_printf(buf, "%s ", name);
641
642#ifndef GV_HIDE_MDATA
643 if (mn->mailbox->mdata)
644 {
645 dot_ptr_name(name, sizeof(name), mn->mailbox->mdata);
646 buf_add_printf(buf, "%s ", name);
647 }
648#endif
649
650#ifndef GV_HIDE_CONFIG
651 if (mn->mailbox->name)
652 {
653 dot_ptr_name(name, sizeof(name), mn->mailbox->name);
654 buf_add_printf(buf, "%s ", name);
655 }
656#endif
657
658 buf_addstr(buf, "}");
659
661 buf_pool_release(&buf);
662}
663
664void dot_mailbox_list(FILE *fp, struct MailboxList *ml, struct ListHead *links, bool abbr)
665{
666 struct MailboxNode *prev = NULL;
667 struct MailboxNode *np = NULL;
668 STAILQ_FOREACH(np, ml, entries)
669 {
670 if (abbr)
671 dot_node_link(fp, np, "MN", np->mailbox, "#80ff80");
672 else
673 dot_mailbox_node(fp, np, links);
674 if (prev)
675 dot_add_link(links, prev, np, "MailboxNode->next", NULL, false, NULL);
676 prev = np;
677 }
678}
679
680#ifndef GV_HIDE_ADATA
681void dot_connection(FILE *fp, struct Connection *c, struct ListHead *links)
682{
683 dot_object_header(fp, c, "Connection", "#ff8080");
684 // dot_ptr(fp, "sockdata", c->sockdata, "#60c0c0");
685 dot_type_number(fp, "fd", c->fd);
687
688 dot_object_header(fp, c->inbuf, "ConnAccount", "#ff8080");
689 dot_type_string(fp, "user", c->account.user, true);
690 dot_type_string(fp, "host", c->account.host, true);
691 dot_type_number(fp, "port", c->account.port);
693
694 dot_add_link(links, c, c->inbuf, "Connection.ConnAccount", NULL, false, NULL);
695}
696
697void dot_account_imap(FILE *fp, struct ImapAccountData *adata, struct ListHead *links)
698{
699 dot_object_header(fp, adata, "ImapAccountData", "#60c0c0");
700 // dot_type_string(fp, "mbox_name", adata->mbox_name, true);
701 // dot_type_string(fp, "login", adata->conn->account.login, true);
702 dot_type_string(fp, "user", adata->conn->account.user, true);
703 dot_type_string(fp, "pass", adata->conn->account.pass[0] ? "***" : "", true);
704 dot_type_number(fp, "port", adata->conn->account.port);
705 // dot_ptr(fp, "conn", adata->conn, "#ff8080");
706 dot_type_bool(fp, "unicode", adata->unicode);
707 dot_type_bool(fp, "qresync", adata->qresync);
708 dot_type_char(fp, "seqid", adata->seqid);
709 dot_ptr(fp, "mailbox", adata->mailbox, "#80ff80");
711
712 if (adata->conn)
713 {
714 dot_connection(fp, adata->conn, links);
715 dot_add_link(links, adata, adata->conn, "ImapAccountData->conn", NULL, false, NULL);
716 }
717}
718
719void dot_account_mbox(FILE *fp, struct MboxAccountData *adata, struct ListHead *links)
720{
721 char buf[64] = { 0 };
722
723 dot_object_header(fp, adata, "MboxAccountData", "#60c0c0");
724 dot_ptr(fp, "fp", adata->fp, NULL);
725
726 dot_type_date(buf, sizeof(buf), adata->atime.tv_sec);
727 dot_type_string(fp, "atime", buf, true);
728 dot_type_bool(fp, "locked", adata->locked);
729 dot_type_bool(fp, "append", adata->append);
730
732}
733
734void dot_account_nntp(FILE *fp, struct NntpAccountData *adata, struct ListHead *links)
735{
736 dot_object_header(fp, adata, "NntpAccountData", "#60c0c0");
737 dot_type_number(fp, "groups_num", adata->groups_num);
738
739 dot_type_bool(fp, "hasCAPABILITIES", adata->hasCAPABILITIES);
740 dot_type_bool(fp, "hasSTARTTLS", adata->hasSTARTTLS);
741 dot_type_bool(fp, "hasDATE", adata->hasDATE);
742 dot_type_bool(fp, "hasLIST_NEWSGROUPS", adata->hasLIST_NEWSGROUPS);
743 dot_type_bool(fp, "hasXGTITLE", adata->hasXGTITLE);
744 dot_type_bool(fp, "hasLISTGROUP", adata->hasLISTGROUP);
745 dot_type_bool(fp, "hasLISTGROUPrange", adata->hasLISTGROUPrange);
746 dot_type_bool(fp, "hasOVER", adata->hasOVER);
747 dot_type_bool(fp, "hasXOVER", adata->hasXOVER);
748 dot_type_bool(fp, "cacheable", adata->cacheable);
749 dot_type_bool(fp, "newsrc_modified", adata->newsrc_modified);
750
751 dot_type_string(fp, "authenticators", adata->authenticators, true);
752 dot_type_string(fp, "overview_fmt", adata->overview_fmt, true);
753 dot_type_string(fp, "newsrc_file", adata->newsrc_file, true);
754 dot_type_file(fp, "newsrc_fp", adata->fp_newsrc);
755
756 dot_type_number(fp, "groups_num", adata->groups_num);
757 dot_type_number(fp, "groups_max", adata->groups_max);
758
759 char buf[128];
760 dot_type_date(buf, sizeof(buf), adata->mtime);
761 dot_type_string(fp, "mtime", buf, true);
762 dot_type_date(buf, sizeof(buf), adata->newgroups_time);
763 dot_type_string(fp, "newgroups_time", buf, true);
764 dot_type_date(buf, sizeof(buf), adata->check_time);
765 dot_type_string(fp, "check_time", buf, true);
766
768
769 if (adata->conn)
770 {
771 dot_connection(fp, adata->conn, links);
772 dot_add_link(links, adata, adata->conn, "NntpAccountData->conn", NULL, false, NULL);
773 }
774}
775
776#ifdef USE_NOTMUCH
777void dot_account_notmuch(FILE *fp, struct NmAccountData *adata, struct ListHead *links)
778{
779 dot_object_header(fp, adata, "NmAccountData", "#60c0c0");
780 dot_ptr(fp, "db", adata->db, NULL);
782}
783#endif
784
785void dot_account_pop(FILE *fp, struct PopAccountData *adata, struct ListHead *links)
786{
787 char buf[64] = { 0 };
788
789 dot_object_header(fp, adata, "PopAccountData", "#60c0c0");
790
791 dot_type_date(buf, sizeof(buf), adata->check_time);
792 dot_type_string(fp, "check_time", buf, true);
793
794 dot_type_string(fp, "login", adata->conn->account.login, true);
795 dot_type_string(fp, "user", adata->conn->account.user, true);
796 dot_type_string(fp, "pass", adata->conn->account.pass[0] ? "***" : "", true);
797 dot_type_number(fp, "port", adata->conn->account.port);
798 // dot_ptr(fp, "conn", adata->conn, "#ff8080");
800
801 dot_connection(fp, adata->conn, links);
802 dot_add_link(links, adata, adata->conn, "PopAccountData->conn", NULL, false, NULL);
803}
804#endif
805
806void dot_account(FILE *fp, struct Account *a, struct ListHead *links)
807{
808 dot_object_header(fp, a, "Account", "#80ffff");
809 dot_mailbox_type(fp, "type", a->type);
810 dot_type_string(fp, "name", a->name, true);
811 // dot_ptr(fp, "adata", a->adata, "#60c0c0");
813
814#ifndef GV_HIDE_ADATA
815 if (a->adata)
816 {
817 if (a->type == MUTT_IMAP)
818 dot_account_imap(fp, a->adata, links);
819 else if (a->type == MUTT_POP)
820 dot_account_pop(fp, a->adata, links);
821 else if (a->type == MUTT_MBOX)
822 dot_account_mbox(fp, a->adata, links);
823 else if (a->type == MUTT_NNTP)
824 dot_account_nntp(fp, a->adata, links);
825#ifdef USE_NOTMUCH
826 else if (a->type == MUTT_NOTMUCH)
827 dot_account_notmuch(fp, a->adata, links);
828#endif
829
830 dot_add_link(links, a, a->adata, "Account->adata", NULL, false, NULL);
831 }
832#endif
833
834#ifndef GV_HIDE_CONFIG
835 if (a->name)
836 {
837 dot_config(fp, a->name, 0, a->sub, links);
838 dot_add_link(links, a, a->name, "Config", NULL, false, NULL);
839
840 char name[256] = { 0 };
841 struct Buffer *buf = buf_pool_get();
842
843 buf_addstr(buf, "{ rank=same ");
844
845 dot_ptr_name(name, sizeof(name), a);
846 buf_add_printf(buf, "%s ", name);
847
848 dot_ptr_name(name, sizeof(name), a->name);
849 buf_add_printf(buf, "%s ", name);
850
851 buf_addstr(buf, "}");
853 buf_pool_release(&buf);
854 }
855#endif
856
857 struct MailboxNode *first = STAILQ_FIRST(&a->mailboxes);
858 dot_add_link(links, a, first, "Account->mailboxes", NULL, false, NULL);
859 dot_mailbox_list(fp, &a->mailboxes, links, false);
860}
861
862void dot_account_list(FILE *fp, struct AccountList *al, struct ListHead *links)
863{
864 struct Account *prev = NULL;
865 struct Account *np = NULL;
866 TAILQ_FOREACH(np, al, entries)
867 {
868#ifdef GV_HIDE_MBOX
869 if (np->type == MUTT_MBOX)
870 continue;
871#endif
872 dot_account(fp, np, links);
873 if (prev)
874 dot_add_link(links, prev, np, "Account->next", NULL, false, NULL);
875
876 prev = np;
877 }
878}
879
880#ifndef GV_HIDE_MVIEW
881void dot_mview(FILE *fp, struct MailboxView *mv, struct ListHead *links)
882{
883 dot_object_header(fp, mv, "MailboxView", "#ff80ff");
884 dot_ptr(fp, "mailbox", mv->mailbox, "#80ff80");
885#ifdef GV_HIDE_MVIEW_CONTENTS
886 dot_type_number(fp, "vsize", mv->vsize);
887 dot_type_string(fp, "pattern", mv->pattern, true);
888 dot_type_bool(fp, "collapsed", mv->collapsed);
889#endif
891}
892#endif
893
894void dump_graphviz(const char *title, struct MailboxView *mv)
895{
896 char name[256] = { 0 };
897 struct ListHead links = STAILQ_HEAD_INITIALIZER(links);
898
899 time_t now = time(NULL);
900 if (title)
901 {
902 char date[128];
903 mutt_date_localtime_format(date, sizeof(date), "%T", now);
904 snprintf(name, sizeof(name), "%s-%s.gv", date, title);
905 }
906 else
907 {
908 mutt_date_localtime_format(name, sizeof(name), "%T.gv", now);
909 }
910
911 umask(022);
912 FILE *fp = fopen(name, "w");
913 if (!fp)
914 return;
915
917
918#ifndef GV_HIDE_NEOMUTT
919 dot_node(fp, NeoMutt, "NeoMutt", "#ffa500");
921 "NeoMutt->accounts", NULL, false, NULL);
922#ifndef GV_HIDE_CONFIG
923 dot_config(fp, (const char *) NeoMutt->sub, 0, NeoMutt->sub, &links);
924 dot_add_link(&links, NeoMutt, NeoMutt->sub, "NeoMutt Config", NULL, false, NULL);
925 struct Buffer *buf = buf_pool_get();
926 char obj1[64] = { 0 };
927 char obj2[64] = { 0 };
928 dot_ptr_name(obj1, sizeof(obj1), NeoMutt);
929 dot_ptr_name(obj2, sizeof(obj2), NeoMutt->sub);
930 buf_printf(buf, "{ rank=same %s %s }", obj1, obj2);
931 mutt_list_insert_tail(&links, buf_strdup(buf));
932 buf_pool_release(&buf);
933#endif
934#endif
935
936 dot_account_list(fp, &NeoMutt->accounts, &links);
937
938#ifndef GV_HIDE_MVIEW
939 if (mv)
940 dot_mview(fp, mv, &links);
941
942#ifndef GV_HIDE_NEOMUTT
943 /* Globals */
944 fprintf(fp, "\t{ rank=same ");
945 if (mv)
946 {
947 dot_ptr_name(name, sizeof(name), mv);
948 fprintf(fp, "%s ", name);
949 }
950 dot_ptr_name(name, sizeof(name), NeoMutt);
951 fprintf(fp, "%s ", name);
952 fprintf(fp, "}\n");
953#endif
954#endif
955
956 fprintf(fp, "\t{ rank=same ");
957 struct Account *np = NULL;
958 TAILQ_FOREACH(np, &NeoMutt->accounts, entries)
959 {
960#ifdef GV_HIDE_MBOX
961 if (np->type == MUTT_MBOX)
962 continue;
963#endif
964 dot_ptr_name(name, sizeof(name), np);
965 fprintf(fp, "%s ", name);
966 }
967 fprintf(fp, "}\n");
968
969 dot_graph_footer(fp, &links);
970 fclose(fp);
971 mutt_list_free(&links);
972}
973
974#ifndef GV_HIDE_BODY_CONTENT
975void dot_parameter_list(FILE *fp, const char *name, const struct ParameterList *pl)
976{
977 if (!pl)
978 return;
979 if (TAILQ_EMPTY(pl))
980 return;
981
982 dot_object_header(fp, pl, "ParameterList", "#00ff00");
983
984 struct Parameter *np = NULL;
985 TAILQ_FOREACH(np, pl, entries)
986 {
987 dot_type_string(fp, np->attribute, np->value, false);
988 }
989
991}
992
993void dot_content(FILE *fp, struct Content *cont, struct ListHead *links)
994{
995 struct Buffer *buf = buf_pool_get();
996
997 dot_object_header(fp, cont, "Content", "#800080");
998
999 dot_type_number(fp, "hibin", cont->hibin);
1000 dot_type_number(fp, "lobin", cont->lobin);
1001 dot_type_number(fp, "nulbin", cont->nulbin);
1002 dot_type_number(fp, "crlf", cont->crlf);
1003 dot_type_number(fp, "ascii", cont->ascii);
1004 dot_type_number(fp, "linemax", cont->linemax);
1005
1006#define ADD_BOOL(F) add_flag(buf, cont->F, #F)
1007 ADD_BOOL(space);
1008 ADD_BOOL(binary);
1009 ADD_BOOL(from);
1010 ADD_BOOL(dot);
1011 ADD_BOOL(cr);
1012#undef ADD_BOOL
1013
1015
1016 buf_pool_release(&buf);
1017}
1018#endif
1019
1020void dot_attach_ptr(FILE *fp, struct AttachPtr *aptr, struct ListHead *links)
1021{
1022 if (!aptr)
1023 return;
1024
1025 dot_object_header(fp, aptr, "AttachPtr", "#ff0000");
1026
1027 dot_type_file(fp, "fp", aptr->fp);
1028
1029 dot_type_string(fp, "parent_type", name_content_type(aptr->parent_type), false);
1030
1031 dot_type_number(fp, "level", aptr->level);
1032 dot_type_number(fp, "num", aptr->num);
1033
1034 dot_type_bool(fp, "unowned", aptr->unowned);
1035 dot_type_bool(fp, "collapsed", aptr->collapsed);
1036 dot_type_bool(fp, "decrypted", aptr->decrypted);
1037
1039
1040 dot_add_link(links, aptr->body, aptr, "AttachPtr->body", NULL, true, NULL);
1041}
1042
1043void dot_body(FILE *fp, struct Body *b, struct ListHead *links, bool link_next)
1044{
1045 struct Buffer *buf = buf_pool_get();
1046
1047 dot_object_header(fp, b, "Body", "#2020ff");
1048
1049 char file[256];
1050 dot_path_fs(file, sizeof(file), b->filename);
1051 dot_type_string(fp, "file", file, false);
1052
1053 dot_type_string(fp, "charset", b->charset, false);
1054 dot_type_string(fp, "description", b->description, false);
1055 dot_type_string(fp, "d_filename", b->d_filename, false);
1056 dot_type_string(fp, "form_name", b->form_name, false);
1057 dot_type_string(fp, "language", b->language, false);
1058 dot_type_string(fp, "subtype", b->subtype, false);
1059 dot_type_string(fp, "xtype", b->xtype, false);
1060
1061 dot_type_string(fp, "type", name_content_type(b->type), true);
1062 dot_type_string(fp, "encoding", name_content_encoding(b->encoding), true);
1063 dot_type_string(fp, "disposition", name_content_disposition(b->disposition), true);
1064
1065 if (b->stamp != 0)
1066 {
1067 char arr[64];
1068 dot_type_date(arr, sizeof(arr), b->stamp);
1069 dot_type_string(fp, "stamp", arr, true);
1070 }
1071
1072#define ADD_BOOL(F) add_flag(buf, b->F, #F)
1073 ADD_BOOL(attach_qualifies);
1074 ADD_BOOL(badsig);
1075 ADD_BOOL(deleted);
1076 ADD_BOOL(force_charset);
1077 ADD_BOOL(goodsig);
1078#ifdef USE_AUTOCRYPT
1079 ADD_BOOL(is_autocrypt);
1080#endif
1081 ADD_BOOL(noconv);
1082 ADD_BOOL(tagged);
1083 ADD_BOOL(unlink);
1084 ADD_BOOL(use_disp);
1085 ADD_BOOL(warnsig);
1086#undef ADD_BOOL
1087 dot_type_string(fp, "bools", buf_is_empty(buf) ? "[NONE]" : buf_string(buf), true);
1088
1089 dot_type_number(fp, "attach_count", b->attach_count);
1090 dot_type_number(fp, "hdr_offset", b->hdr_offset);
1091 dot_type_number(fp, "length", b->length);
1092 dot_type_number(fp, "offset", b->offset);
1093
1094 dot_ptr(fp, "aptr", b->aptr, "#3bcbc4");
1095
1096#ifdef GV_HIDE_BODY_CONTENT
1097 if (!TAILQ_EMPTY(&b->parameter))
1098 {
1099 struct Parameter *param = TAILQ_FIRST(&b->parameter);
1100 if (mutt_str_equal(param->attribute, "boundary"))
1101 {
1102 dot_type_string(fp, "boundary", param->value, false);
1103 }
1104 }
1105#endif
1106
1108
1109#ifndef GV_HIDE_BODY_CONTENT
1110 if (!TAILQ_EMPTY(&b->parameter))
1111 {
1112 dot_parameter_list(fp, "parameter", &b->parameter);
1113 dot_add_link(links, b, &b->parameter, "Body->mime_headers", NULL, false, NULL);
1114 }
1115#endif
1116
1117#ifndef GV_HIDE_ENVELOPE
1118 if (b->mime_headers)
1119 {
1120 dot_envelope(fp, b->mime_headers, links);
1121 dot_add_link(links, b, b->mime_headers, "Body->mime_headers", NULL, false, NULL);
1122 }
1123#endif
1124
1125 if (b->email)
1126 {
1127 dot_email(fp, b->email, links);
1128 dot_add_link(links, b, b->email, "Body->email", NULL, false, NULL);
1129 }
1130
1131 if (b->parts)
1132 {
1133 if (!b->email)
1134 dot_body(fp, b->parts, links, true);
1135 dot_add_link(links, b, b->parts, "Body->parts", NULL, false, "#ff0000");
1136 }
1137
1138 if (b->next && link_next)
1139 {
1140 char name[256] = { 0 };
1141 buf_reset(buf);
1142
1143 buf_addstr(buf, "{ rank=same ");
1144
1145 dot_ptr_name(name, sizeof(name), b);
1146 buf_add_printf(buf, "%s ", name);
1147
1148 for (; b->next; b = b->next)
1149 {
1150 dot_body(fp, b->next, links, false);
1151 dot_add_link(links, b, b->next, "Body->next", NULL, false, "#008000");
1152
1153 dot_ptr_name(name, sizeof(name), b->next);
1154 buf_add_printf(buf, "%s ", name);
1155 }
1156
1157 buf_addstr(buf, "}");
1158 mutt_list_insert_tail(links, buf_strdup(buf));
1159 }
1160 else
1161 {
1162#ifndef GV_HIDE_BODY_CONTENT
1163 if (b->content)
1164 {
1165 dot_content(fp, b->content, links);
1166 dot_add_link(links, b, b->content, "Body->content", NULL, false, NULL);
1167 }
1168#endif
1169
1170 // if (b->aptr)
1171 // {
1172 // dot_attach_ptr(fp, b->aptr, links);
1173 // dot_add_link(links, b, b->aptr, "Body->aptr", NULL, false, NULL);
1174 // }
1175 }
1176
1177 buf_pool_release(&buf);
1178}
1179
1180#ifndef GV_HIDE_ENVELOPE
1181void dot_list_head(FILE *fp, const char *name, const struct ListHead *list)
1182{
1183 if (!list || !name)
1184 return;
1185 if (STAILQ_EMPTY(list))
1186 return;
1187
1188 struct Buffer *buf = buf_pool_get();
1189
1190 struct ListNode *np = NULL;
1191 STAILQ_FOREACH(np, list, entries)
1192 {
1193 if (!buf_is_empty(buf))
1194 buf_addch(buf, ',');
1195 buf_addstr(buf, np->data);
1196 }
1197
1198 dot_type_string(fp, name, buf_string(buf), false);
1199 buf_pool_release(&buf);
1200}
1201
1202void dot_addr_list(FILE *fp, const char *name, const struct AddressList *al,
1203 struct ListHead *links)
1204{
1205 if (!al)
1206 return;
1207 if (TAILQ_EMPTY(al))
1208 return;
1209
1210 struct Buffer *buf = buf_pool_get();
1211 mutt_addrlist_write(al, buf, true);
1212 dot_type_string(fp, name, buf_string(buf), false);
1213 buf_pool_release(&buf);
1214}
1215
1216void dot_envelope(FILE *fp, struct Envelope *env, struct ListHead *links)
1217{
1218 struct Buffer *buf = buf_pool_get();
1219
1220 dot_object_header(fp, env, "Envelope", "#ffff00");
1221
1222#define ADD_FLAG(F) add_flag(buf, (env->changed & F), #F)
1227#undef ADD_BOOL
1228 dot_type_string(fp, "changed", buf_is_empty(buf) ? "[NONE]" : buf_string(buf), true);
1229
1230#define ADDR_LIST(AL) dot_addr_list(fp, #AL, &env->AL, links)
1231 ADDR_LIST(return_path);
1232 ADDR_LIST(from);
1233 ADDR_LIST(to);
1234 ADDR_LIST(cc);
1235 ADDR_LIST(bcc);
1236 ADDR_LIST(sender);
1237 ADDR_LIST(reply_to);
1238 ADDR_LIST(mail_followup_to);
1239 ADDR_LIST(x_original_to);
1240#undef ADDR_LIST
1241
1242 dot_type_string(fp, "date", env->date, false);
1243 dot_type_string(fp, "disp_subj", env->disp_subj, false);
1244 dot_type_string(fp, "followup_to", env->followup_to, false);
1245 dot_type_string(fp, "list_post", env->list_post, false);
1246 dot_type_string(fp, "list_subscribe", env->list_subscribe, false);
1247 dot_type_string(fp, "list_unsubscribe", env->list_unsubscribe, false);
1248 dot_type_string(fp, "message_id", env->message_id, false);
1249 dot_type_string(fp, "newsgroups", env->newsgroups, false);
1250 dot_type_string(fp, "organization", env->organization, false);
1251 dot_type_string(fp, "real_subj", env->real_subj, false);
1252 dot_type_string(fp, "spam", buf_string(&env->spam), false);
1253 dot_type_string(fp, "subject", env->subject, false);
1254 dot_type_string(fp, "supersedes", env->supersedes, false);
1255 dot_type_string(fp, "xref", env->xref, false);
1256 dot_type_string(fp, "x_comment_to", env->x_comment_to, false);
1257 dot_type_string(fp, "x_label", env->x_label, false);
1258
1259 if (0)
1260 {
1261 dot_list_head(fp, "references", &env->references);
1262 dot_list_head(fp, "in_reply_to", &env->in_reply_to);
1263 dot_list_head(fp, "userhdrs", &env->userhdrs);
1264 }
1265
1266#ifdef USE_AUTOCRYPT
1267 dot_ptr(fp, "autocrypt", env->autocrypt, NULL);
1268 dot_ptr(fp, "autocrypt_gossip", env->autocrypt_gossip, NULL);
1269#endif
1270
1272
1273 buf_pool_release(&buf);
1274}
1275#endif
1276
1277void dot_email(FILE *fp, struct Email *e, struct ListHead *links)
1278{
1279 struct Buffer *buf = buf_pool_get();
1280 char arr[256];
1281
1282 dot_object_header(fp, e, "Email", "#ff80ff");
1283
1284 dot_type_string(fp, "path", e->path, true);
1285
1286#define ADD_BOOL(F) add_flag(buf, e->F, #F)
1287 ADD_BOOL(active);
1288 ADD_BOOL(attach_del);
1289 ADD_BOOL(attach_valid);
1290 ADD_BOOL(changed);
1291 ADD_BOOL(collapsed);
1292 ADD_BOOL(deleted);
1293 ADD_BOOL(display_subject);
1294 ADD_BOOL(expired);
1295 ADD_BOOL(flagged);
1296 ADD_BOOL(matched);
1297 ADD_BOOL(mime);
1298 ADD_BOOL(old);
1299 ADD_BOOL(purge);
1300 ADD_BOOL(quasi_deleted);
1301 ADD_BOOL(read);
1302 ADD_BOOL(recip_valid);
1303 ADD_BOOL(replied);
1304 ADD_BOOL(searched);
1305 ADD_BOOL(subject_changed);
1306 ADD_BOOL(superseded);
1307 ADD_BOOL(tagged);
1308 ADD_BOOL(threaded);
1309 ADD_BOOL(trash);
1310 ADD_BOOL(visible);
1311#undef ADD_BOOL
1312 dot_type_string(fp, "bools", buf_is_empty(buf) ? "[NONE]" : buf_string(buf), true);
1313
1314 buf_reset(buf);
1315#define ADD_BOOL(F) add_flag(buf, (e->security & F), #F)
1330#undef ADD_BOOL
1331 dot_type_string(fp, "security", buf_is_empty(buf) ? "[NONE]" : buf_string(buf), true);
1332
1333 dot_type_number(fp, "num_hidden", e->num_hidden);
1334 dot_type_number(fp, "offset", e->offset);
1335 dot_type_number(fp, "lines", e->lines);
1336 dot_type_number(fp, "index", e->index);
1337 dot_type_number(fp, "msgno", e->msgno);
1338 dot_type_number(fp, "vnum", e->vnum);
1339 dot_type_number(fp, "score", e->score);
1340 dot_type_number(fp, "attach_total", e->attach_total);
1341
1342 // struct MaildirEmailData *edata = maildir_edata_get(e);
1343 // if (edata)
1344 // dot_type_string(fp, "maildir_flags", edata->maildir_flags, false);
1345
1346 if (e->date_sent != 0)
1347 {
1348 char zone[32];
1349 dot_type_date(arr, sizeof(arr), e->date_sent);
1350 snprintf(zone, sizeof(zone), " (%c%02u%02u)", e->zoccident ? '-' : '+',
1351 e->zhours, e->zminutes);
1352 struct Buffer *date = buf_pool_get();
1353 buf_printf(date, "%s%s", arr, zone);
1354 dot_type_string(fp, "date_sent", buf_string(date), false);
1355 buf_pool_release(&date);
1356 }
1357
1358 if (e->received != 0)
1359 {
1360 dot_type_date(arr, sizeof(arr), e->received);
1361 dot_type_string(fp, "received", arr, false);
1362 }
1363
1365
1366 if (e->body)
1367 {
1368 dot_body(fp, e->body, links, true);
1369 dot_add_link(links, e, e->body, "Email->body", NULL, false, NULL);
1370 }
1371
1372#ifndef GV_HIDE_ENVELOPE
1373 if (e->env)
1374 {
1375 dot_envelope(fp, e->env, links);
1376 dot_add_link(links, e, e->env, "Email->env", NULL, false, NULL);
1377
1378 buf_reset(buf);
1379 buf_addstr(buf, "{ rank=same ");
1380
1381 dot_ptr_name(arr, sizeof(arr), e);
1382 buf_add_printf(buf, "%s ", arr);
1383
1384 dot_ptr_name(arr, sizeof(arr), e->env);
1385 buf_add_printf(buf, "%s ", arr);
1386
1387 buf_addstr(buf, "}");
1388
1389 mutt_list_insert_tail(links, buf_strdup(buf));
1390 }
1391#endif
1392
1393 // struct TagList tags;
1394
1395 buf_pool_release(&buf);
1396}
1397
1399{
1400 char name[256] = { 0 };
1401 struct ListHead links = STAILQ_HEAD_INITIALIZER(links);
1402
1403 time_t now = time(NULL);
1404 mutt_date_localtime_format(name, sizeof(name), "%T-email.gv", now);
1405
1406 umask(022);
1407 FILE *fp = fopen(name, "w");
1408 if (!fp)
1409 return;
1410
1411 dot_graph_header(fp);
1412
1413 dot_body(fp, b, &links, true);
1414
1415 dot_graph_footer(fp, &links);
1416 fclose(fp);
1417 mutt_list_free(&links);
1418}
1419
1420void dump_graphviz_email(struct Email *e, const char *title)
1421{
1422 char name[256] = { 0 };
1423 struct ListHead links = STAILQ_HEAD_INITIALIZER(links);
1424
1425 if (!title)
1426 title = "email";
1427
1428 char format[64];
1429 snprintf(format, sizeof(format), "%%T-%s.gv", title);
1430
1431 time_t now = time(NULL);
1432 mutt_date_localtime_format(name, sizeof(name), format, now);
1433
1434 umask(022);
1435 FILE *fp = fopen(name, "w");
1436 if (!fp)
1437 return;
1438
1439 dot_graph_header(fp);
1440
1441 dot_email(fp, e, &links);
1442
1443 dot_graph_footer(fp, &links);
1444 fclose(fp);
1445 mutt_list_free(&links);
1446}
1447
1448void dot_attach_ptr2(FILE *fp, struct AttachPtr *aptr, struct ListHead *links)
1449{
1450 if (!aptr)
1451 return;
1452
1453 dot_object_header(fp, aptr, "AttachPtr", "#3bcbc4");
1454
1455 dot_ptr(fp, "body", aptr->body, "#2020ff");
1456 dot_type_file(fp, "fp", aptr->fp);
1457
1458 dot_type_string(fp, "parent_type", name_content_type(aptr->parent_type), false);
1459 dot_type_number(fp, "level", aptr->level);
1460 dot_type_number(fp, "num", aptr->num);
1461 dot_type_bool(fp, "unowned", aptr->unowned);
1462 dot_type_bool(fp, "collapsed", aptr->collapsed);
1463 dot_type_bool(fp, "decrypted", aptr->decrypted);
1464
1465 // dot_type_string(fp, "tree", aptr->tree, false);
1466
1468}
1469
1470void dot_array_actx_idx(FILE *fp, struct AttachPtr **idx, short idxlen,
1471 short idxmax, struct ListHead *links)
1472{
1473 dot_object_header(fp, idx, "AttachCtx-&gt;idx", "#9347de");
1474
1475 dot_type_number(fp, "idxlen", idxlen);
1476 dot_type_number(fp, "idxmax", idxmax);
1477
1478 char arr[32];
1479 for (size_t i = 0; i < idxmax; i++)
1480 {
1481 snprintf(arr, sizeof(arr), "idx[%zu]", i);
1482 dot_ptr(fp, arr, idx[i], "#3bcbc4");
1483 }
1484
1486
1487 for (size_t i = 0; i < idxlen; i++)
1488 {
1489 dot_attach_ptr2(fp, idx[i], links);
1490 dot_add_link(links, idx, idx[i], "AttachCtx-&gt;idx", NULL, false, NULL);
1491 }
1492}
1493
1494void dot_array_actx_v2r(FILE *fp, short *v2r, short vcount, struct ListHead *links)
1495{
1496 dot_object_header(fp, v2r, "AttachCtx-&gt;v2r", "#9347de");
1497
1498 dot_type_number(fp, "vcount", vcount);
1499
1500 char arr[32];
1501 for (size_t i = 0; i < vcount; i++)
1502 {
1503 snprintf(arr, sizeof(arr), "v2r[%zu]", i);
1504 dot_type_number(fp, arr, v2r[i]);
1505 }
1506
1508}
1509
1510void dot_array_actx_fp_idx(FILE *fp, FILE **fp_idx, short fp_len, short fp_max,
1511 struct ListHead *links)
1512{
1513 dot_object_header(fp, fp_idx, "AttachCtx-&gt;fp_idx", "#f86e28");
1514
1515 dot_type_number(fp, "fp_len", fp_len);
1516 dot_type_number(fp, "fp_max", fp_max);
1517
1518 char arr[32];
1519 for (size_t i = 0; i < fp_max; i++)
1520 {
1521 snprintf(arr, sizeof(arr), "fp_idx[%zu]", i);
1522 dot_type_file(fp, arr, fp_idx[i]);
1523 }
1524
1526}
1527
1528void dot_array_actx_body_idx(FILE *fp, struct Body **body_idx, short body_len,
1529 short body_max, struct ListHead *links)
1530{
1531 dot_object_header(fp, body_idx, "AttachCtx-&gt;body_idx", "#4ff270");
1532
1533 dot_type_number(fp, "body_len", body_len);
1534 dot_type_number(fp, "body_max", body_max);
1535
1536 char arr[32];
1537 for (size_t i = 0; i < body_max; i++)
1538 {
1539 snprintf(arr, sizeof(arr), "body_idx[%zu]", i);
1540 dot_ptr(fp, arr, body_idx[i], "#2020ff");
1541 }
1542
1544
1545 for (size_t i = 0; i < body_max; i++)
1546 {
1547 if (!body_idx[i])
1548 continue;
1549 dot_body(fp, body_idx[i], links, true);
1550 dot_add_link(links, body_idx, body_idx[i], "AttachCtx->Body", NULL, false, "#008000");
1551 }
1552}
1553
1554void dot_attach_ctx(FILE *fp, struct AttachCtx *actx, struct ListHead *links)
1555{
1556 dot_object_header(fp, actx, "AttachCtx", "#9347de");
1557
1558 dot_ptr(fp, "email", actx->email, "#ff80ff");
1559 dot_type_file(fp, "fp_root", actx->fp_root);
1560
1562
1563 if (actx->idx)
1564 {
1565 dot_array_actx_idx(fp, actx->idx, actx->idxlen, actx->idxmax, links);
1566 dot_add_link(links, actx, actx->idx, "AttachCtx-&gt;idx", NULL, false, NULL);
1567 }
1568
1569 if (actx->v2r)
1570 {
1571 dot_array_actx_v2r(fp, actx->v2r, actx->vcount, links);
1572 dot_add_link(links, actx, actx->v2r, "AttachCtx-&gt;v2r", NULL, false, NULL);
1573 }
1574
1575 if (actx->fp_idx)
1576 {
1577 dot_array_actx_fp_idx(fp, actx->fp_idx, actx->fp_len, actx->fp_max, links);
1578 dot_add_link(links, actx, actx->fp_idx, "AttachCtx-&gt;fp_idx", NULL, false, NULL);
1579 }
1580
1581 if (actx->body_idx)
1582 {
1583 dot_array_actx_body_idx(fp, actx->body_idx, actx->body_len, actx->body_max, links);
1584 dot_add_link(links, actx, actx->body_idx, "AttachCtx-&gt;body_idx", NULL, false, NULL);
1585 }
1586}
1587
1589{
1590 char name[256] = { 0 };
1591 struct ListHead links = STAILQ_HEAD_INITIALIZER(links);
1592
1593 time_t now = time(NULL);
1594 mutt_date_localtime_format(name, sizeof(name), "%T-actx.gv", now);
1595
1596 umask(022);
1597 FILE *fp = fopen(name, "w");
1598 if (!fp)
1599 return;
1600
1601 dot_graph_header(fp);
1602
1603 dot_attach_ctx(fp, actx, &links);
1604
1605 dot_graph_footer(fp, &links);
1606 fclose(fp);
1607 mutt_list_free(&links);
1608}
1609
1610const char *pattern_type_name(int type)
1611{
1612 static struct Mapping PatternNames[] = {
1613 // clang-format off
1614 { "address", MUTT_PAT_ADDRESS },
1615 { "AND", MUTT_PAT_AND },
1616 { "bcc", MUTT_PAT_BCC },
1617 { "body", MUTT_PAT_BODY },
1618 { "broken", MUTT_PAT_BROKEN },
1619 { "cc", MUTT_PAT_CC },
1620 { "children", MUTT_PAT_CHILDREN },
1621 { "collapsed", MUTT_PAT_COLLAPSED },
1622 { "crypt_encrypt", MUTT_PAT_CRYPT_ENCRYPT },
1623 { "crypt_sign", MUTT_PAT_CRYPT_SIGN },
1624 { "crypt_verified", MUTT_PAT_CRYPT_VERIFIED },
1625 { "date", MUTT_PAT_DATE },
1626 { "date_received", MUTT_PAT_DATE_RECEIVED },
1627 { "driver_tags", MUTT_PAT_DRIVER_TAGS },
1628 { "duplicated", MUTT_PAT_DUPLICATED },
1629 { "from", MUTT_PAT_FROM },
1630 { "header", MUTT_PAT_HEADER },
1631 { "hormel", MUTT_PAT_HORMEL },
1632 { "id", MUTT_PAT_ID },
1633 { "id_external", MUTT_PAT_ID_EXTERNAL },
1634 { "list", MUTT_PAT_LIST },
1635 { "message", MUTT_PAT_MESSAGE },
1636 { "mimeattach", MUTT_PAT_MIMEATTACH },
1637 { "mimetype", MUTT_PAT_MIMETYPE },
1638 { "newsgroups", MUTT_PAT_NEWSGROUPS },
1639 { "OR", MUTT_PAT_OR },
1640 { "parent", MUTT_PAT_PARENT },
1641 { "personal_from", MUTT_PAT_PERSONAL_FROM },
1642 { "personal_recip", MUTT_PAT_PERSONAL_RECIP },
1643 { "pgp_key", MUTT_PAT_PGP_KEY },
1644 { "recipient", MUTT_PAT_RECIPIENT },
1645 { "reference", MUTT_PAT_REFERENCE },
1646 { "score", MUTT_PAT_SCORE },
1647 { "sender", MUTT_PAT_SENDER },
1648 { "serversearch", MUTT_PAT_SERVERSEARCH },
1649 { "size", MUTT_PAT_SIZE },
1650 { "subject", MUTT_PAT_SUBJECT },
1651 { "subscribed_list", MUTT_PAT_SUBSCRIBED_LIST },
1652 { "thread", MUTT_PAT_THREAD },
1653 { "to", MUTT_PAT_TO },
1654 { "unreferenced", MUTT_PAT_UNREFERENCED },
1655 { "whole_msg", MUTT_PAT_WHOLE_MSG },
1656 { "xlabel", MUTT_PAT_XLABEL },
1657 { NULL, 0 },
1658 // clang-format on
1659 };
1660
1661 return mutt_map_get_name(type, PatternNames);
1662}
1663
1664void dot_pattern(FILE *fp, struct Pattern *pat, struct ListHead *links)
1665{
1666 struct Buffer *buf = buf_pool_get();
1667 dot_object_header(fp, pat, "Pattern", "#c040c0");
1668
1669 dot_type_string(fp, "op", pattern_type_name(pat->op), true);
1670 if ((pat->min != 0) || (pat->max != 0))
1671 {
1672 dot_type_number(fp, "min", pat->min);
1673 dot_type_number(fp, "max", pat->max);
1674 }
1675
1676#define ADD_BOOL(F) add_flag(buf, pat->F, #F)
1677 ADD_BOOL(pat_not);
1678 ADD_BOOL(all_addr);
1679 ADD_BOOL(string_match);
1680 ADD_BOOL(group_match);
1681 ADD_BOOL(ign_case);
1682 ADD_BOOL(is_alias);
1683 ADD_BOOL(dynamic);
1684 ADD_BOOL(sendmode);
1685 ADD_BOOL(is_multi);
1686#undef ADD_BOOL
1687 dot_type_string(fp, "flags", buf_is_empty(buf) ? "[NONE]" : buf_string(buf), true);
1688
1689 if (pat->group_match)
1690 {
1691 // struct Group *group; ///< Address group if group_match is set
1692 }
1693 else if (pat->string_match)
1694 {
1695 dot_type_string(fp, "str", pat->p.str, true);
1696 }
1697 else if (pat->is_multi)
1698 {
1699 // struct ListHead multi_cases; ///< Multiple strings for ~I pattern
1700 }
1701 else
1702 {
1703 if (pat->p.regex)
1704 {
1705 dot_ptr(fp, "regex", pat->p.regex, NULL);
1706 dot_type_string(fp, "pattern", pat->raw_pattern, true);
1707 }
1708 }
1709
1711
1712 if (pat->child)
1713 {
1714 dot_patternlist(fp, pat->child, links);
1715 struct Pattern *first = SLIST_FIRST(pat->child);
1716 dot_add_link(links, pat, first, "Pattern->child", NULL, false, "#00ff00");
1717 }
1718 buf_pool_release(&buf);
1719}
1720
1721void dot_patternlist(FILE *fp, struct PatternList *pl, struct ListHead *links)
1722{
1723 struct Buffer *buf = buf_pool_get();
1724
1725 char name[256] = { 0 };
1726 buf_addstr(buf, "{ rank=same ");
1727
1728 struct Pattern *prev = NULL;
1729 struct Pattern *np = NULL;
1730 SLIST_FOREACH(np, pl, entries)
1731 {
1732 dot_pattern(fp, np, links);
1733 if (prev)
1734 dot_add_link(links, prev, np, "PatternList->next", NULL, false, "#ff0000");
1735 prev = np;
1736
1737 dot_ptr_name(name, sizeof(name), np);
1738 buf_add_printf(buf, "%s ", name);
1739 }
1740
1741 buf_addstr(buf, "}");
1742
1743 mutt_list_insert_tail(links, buf_strdup(buf));
1744 buf_pool_release(&buf);
1745}
1746
1747void dump_graphviz_patternlist(struct PatternList *pl)
1748{
1749 char name[256] = { 0 };
1750 struct ListHead links = STAILQ_HEAD_INITIALIZER(links);
1751
1752 time_t now = time(NULL);
1753 mutt_date_localtime_format(name, sizeof(name), "%T-pattern.gv", now);
1754
1755 umask(022);
1756 FILE *fp = fopen(name, "w");
1757 if (!fp)
1758 return;
1759
1760 dot_graph_header(fp);
1761
1762 dot_patternlist(fp, pl, &links);
1763
1764 dot_graph_footer(fp, &links);
1765 fclose(fp);
1766 mutt_list_free(&links);
1767}
1768
1769void dot_format(FILE *fp, struct ExpandoFormat *fmt)
1770{
1771 if (!fmt)
1772 return;
1773
1774 dot_type_number(fp, "min_cols", fmt->min_cols);
1775 dot_type_number(fp, "max_cols", fmt->max_cols);
1776
1777 char *just = "UNKNOWN";
1778 switch (fmt->justification)
1779 {
1780 case JUSTIFY_LEFT:
1781 just = "JUSTIFY_LEFT";
1782 break;
1783 case JUSTIFY_CENTER:
1784 just = "JUSTIFY_CENTER";
1785 break;
1786 case JUSTIFY_RIGHT:
1787 just = "JUSTIFY_RIGHT";
1788 break;
1789 }
1790 dot_type_string(fp, "justification", just, true);
1791 dot_type_char(fp, "leader", fmt->leader);
1792}
1793
1794void dot_expando_node_empty(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
1795{
1796 dot_object_header(fp, node, "Empty", "#ffffff");
1797 // dot_type_string(fp, "type", "ENT_EMPTY", true);
1799}
1800
1801void dot_expando_node_text(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
1802{
1803 struct Buffer *buf = buf_pool_get();
1804 dot_object_header(fp, node, "Text", "#ffff80");
1805 // dot_type_string(fp, "type", "ENT_TEXT", true);
1806 dot_type_string(fp, "text", node->text, false);
1807
1809
1810 buf_pool_release(&buf);
1811}
1812
1813void dot_expando_node_pad(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
1814{
1815 struct Buffer *buf = buf_pool_get();
1816 dot_object_header(fp, node, "Pad", "#80ffff");
1817 // dot_type_string(fp, "type", "ENT_PADDING", true);
1818
1819 struct NodePaddingPrivate *priv = node->ndata;
1820 char *pad = "UNKNOWN";
1821 switch (priv->pad_type)
1822 {
1823 case EPT_FILL_EOL:
1824 pad = "EPT_FILL_EOL";
1825 break;
1826 case EPT_HARD_FILL:
1827 pad = "EPT_HARD_FILL";
1828 break;
1829 case EPT_SOFT_FILL:
1830 pad = "EPT_SOFT_FILL";
1831 break;
1832 }
1833 dot_type_string(fp, "type", pad, true);
1834 dot_type_string(fp, "char", node->text, false);
1835
1837
1838 struct ExpandoNode *left = node_get_child(node, ENP_LEFT);
1839 if (left)
1840 {
1841 dot_expando_node(fp, left, links);
1842 dot_add_link(links, node, left, "Pad->left", "left", false, "#80ff80");
1843 }
1844
1845 struct ExpandoNode *right = node_get_child(node, ENP_RIGHT);
1846 if (right)
1847 {
1848 dot_expando_node(fp, right, links);
1849 dot_add_link(links, node, right, "Pad->right", "right", false, "#ff8080");
1850 }
1851
1852 buf_pool_release(&buf);
1853}
1854
1855void dot_expando_node_condition(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
1856{
1857 struct Buffer *buf = buf_pool_get();
1858 dot_object_header(fp, node, "Condition", "#ff8080");
1859 // dot_type_string(fp, "type", "ENT_CONDITION", true);
1860 dot_type_string(fp, "text", node->text, false);
1861 dot_format(fp, node->format);
1862
1864
1865 struct ExpandoNode *node_cond = node_get_child(node, ENC_CONDITION);
1866 struct ExpandoNode *node_true = node_get_child(node, ENC_TRUE);
1867 struct ExpandoNode *node_false = node_get_child(node, ENC_FALSE);
1868
1869 dot_expando_node(fp, node_cond, links);
1870 dot_add_link(links, node, node_cond, "Condition->condition", "condition", false, "#ff80ff");
1871 if (node_true)
1872 {
1873 dot_expando_node(fp, node_true, links);
1874 dot_add_link(links, node, node_true, "Condition->true", "true", false, "#80ff80");
1875 }
1876 if (node_false)
1877 {
1878 dot_expando_node(fp, node_false, links);
1879 dot_add_link(links, node, node_false, "Condition->false", "false", false, "#ff8080");
1880 }
1881
1882 buf_pool_release(&buf);
1883}
1884
1886 struct ListHead *links)
1887{
1888 struct Buffer *buf = buf_pool_get();
1889 dot_object_header(fp, node, "CondBool", "#c0c0ff");
1890 // dot_type_string(fp, "type", "ENT_CONDBOOL", true);
1891 dot_type_string(fp, "did", name_expando_domain(node->did), true);
1892 dot_type_string(fp, "uid", name_expando_uid(node->did, node->uid), true);
1893 dot_type_string(fp, "text", node->text, false);
1894
1896
1897 buf_pool_release(&buf);
1898}
1899
1901 struct ListHead *links)
1902{
1903 struct Buffer *buf = buf_pool_get();
1904 dot_object_header(fp, node, "CondDate", "#c0c0ff");
1905 // dot_type_string(fp, "type", "ENT_CONDDATE", true);
1906 dot_type_string(fp, "did", name_expando_domain(node->did), true);
1907 dot_type_string(fp, "uid", name_expando_uid(node->did, node->uid), true);
1908 dot_type_string(fp, "text", node->text, false);
1909
1910 struct NodeCondDatePrivate *priv = node->ndata;
1911 if (priv)
1912 {
1913 dot_type_number(fp, "count", priv->count);
1914 dot_type_char(fp, "period", priv->period);
1915 }
1916
1918
1919 buf_pool_release(&buf);
1920}
1921
1922void dot_expando_node_container(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
1923{
1924 dot_object_header(fp, node, "Container", "#80ffff");
1925 // dot_type_string(fp, "type", "ENT_CONTAINER", true);
1926 dot_type_number(fp, "children", ARRAY_SIZE(&node->children));
1927 dot_format(fp, node->format);
1929
1930 struct ExpandoNode **enp = NULL;
1931 enp = ARRAY_FIRST(&node->children);
1932 if (!enp)
1933 return;
1934
1935 struct ExpandoNode *child = *enp;
1936 dot_add_link(links, node, child, "Node->children", "children", false, "#80ff80");
1937
1938 char name[256] = { 0 };
1939 struct Buffer *rank = buf_pool_get();
1940 buf_addstr(rank, "{ rank=same ");
1941
1942 struct ExpandoNode *prev = NULL;
1943 ARRAY_FOREACH(enp, &node->children)
1944 {
1945 child = *enp;
1946
1947 dot_expando_node(fp, child, links);
1948 if (prev)
1949 {
1950 dot_add_link(links, prev, child, "Node->next", "next", false, "#80ff80");
1951 }
1952 prev = child;
1953
1954 dot_ptr_name(name, sizeof(name), child);
1955 buf_add_printf(rank, "%s ", name);
1956 }
1957
1958 buf_addstr(rank, "}");
1959 mutt_list_insert_tail(links, buf_strdup(rank));
1960 buf_pool_release(&rank);
1961}
1962
1963void dot_expando_node_expando(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
1964{
1965 struct Buffer *buf = buf_pool_get();
1966 dot_object_header(fp, node, "Expando", "#80ff80");
1967
1968 // dot_type_number(fp, "type", node->type);
1969 dot_type_string(fp, "did", name_expando_domain(node->did), true);
1970 dot_type_string(fp, "uid", name_expando_uid(node->did, node->uid), true);
1971 dot_type_string(fp, "text", node->text, false);
1972
1973 dot_format(fp, node->format);
1974
1976
1977 buf_pool_release(&buf);
1978}
1979
1980void dot_expando_node_unknown(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
1981{
1982 struct Buffer *buf = buf_pool_get();
1983 dot_object_header(fp, node, "UNKNOWN", "#ff0000");
1984
1985 dot_type_number(fp, "type", node->type);
1986 dot_type_number(fp, "did", node->did);
1987 dot_type_number(fp, "uid", node->uid);
1988 dot_type_string(fp, "text", node->text, false);
1989
1991
1992 buf_pool_release(&buf);
1993}
1994
1995void dot_expando_node(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
1996{
1997 switch (node->type)
1998 {
1999 case ENT_CONDITION:
2000 dot_expando_node_condition(fp, node, links);
2001 break;
2002 case ENT_CONDBOOL:
2003 dot_expando_node_conditional_bool(fp, node, links);
2004 break;
2005 case ENT_CONDDATE:
2006 dot_expando_node_conditional_date(fp, node, links);
2007 break;
2008 case ENT_CONTAINER:
2009 dot_expando_node_container(fp, node, links);
2010 break;
2011 case ENT_EMPTY:
2012 dot_expando_node_empty(fp, node, links);
2013 break;
2014 case ENT_EXPANDO:
2015 dot_expando_node_expando(fp, node, links);
2016 break;
2017 case ENT_PADDING:
2018 dot_expando_node_pad(fp, node, links);
2019 break;
2020 case ENT_TEXT:
2021 dot_expando_node_text(fp, node, links);
2022 break;
2023 default:
2024 dot_expando_node_unknown(fp, node, links);
2025 break;
2026 }
2027}
2028
2030{
2031 char name[256] = { 0 };
2032 struct ListHead links = STAILQ_HEAD_INITIALIZER(links);
2033
2034 time_t now = time(NULL);
2035 mutt_date_localtime_format(name, sizeof(name), "%T-expando.gv", now);
2036
2037 umask(022);
2038 FILE *fp = fopen(name, "w");
2039 if (!fp)
2040 return;
2041
2042 dot_graph_header(fp);
2043
2044 dot_expando_node(fp, node, &links);
2045
2046 dot_graph_footer(fp, &links);
2047 fclose(fp);
2048 mutt_list_free(&links);
2049}
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:214
#define ARRAY_SIZE(head)
The number of elements stored.
Definition: array.h:87
#define ARRAY_FREE(head)
Release all memory.
Definition: array.h:204
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:668
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:768
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:1470
void dot_mailbox_pop(FILE *fp, struct PopAccountData *adata, struct ListHead *links)
Definition: graphviz.c:533
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:975
void dot_expando_node_unknown(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
Definition: graphviz.c:1980
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:785
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:1398
void dot_addr_list(FILE *fp, const char *name, const struct AddressList *al, struct ListHead *links)
Definition: graphviz.c:1202
void dot_mailbox_imap(FILE *fp, struct ImapMboxData *mdata, struct ListHead *links)
Definition: graphviz.c:468
void dot_comp(FILE *fp, struct CompressInfo *ci, struct ListHead *links)
Definition: graphviz.c:414
void dot_expando_node_empty(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
Definition: graphviz.c:1794
void dot_mailbox_type(FILE *fp, const char *name, enum MailboxType type)
Definition: graphviz.c:423
void dot_attach_ptr2(FILE *fp, struct AttachPtr *aptr, struct ListHead *links)
Definition: graphviz.c:1448
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:1494
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:1813
#define ADDR_LIST(AL)
void dot_email(FILE *fp, struct Email *e, struct ListHead *links)
Definition: graphviz.c:1277
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:862
void dot_account_mbox(FILE *fp, struct MboxAccountData *adata, struct ListHead *links)
Definition: graphviz.c:719
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:894
void dot_format(FILE *fp, struct ExpandoFormat *fmt)
Definition: graphviz.c:1769
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:1181
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:1528
void dot_account_imap(FILE *fp, struct ImapAccountData *adata, struct ListHead *links)
Definition: graphviz.c:697
void dot_patternlist(FILE *fp, struct PatternList *pl, struct ListHead *links)
Definition: graphviz.c:1721
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:623
void dot_mview(FILE *fp, struct MailboxView *mv, struct ListHead *links)
Definition: graphviz.c:881
void dot_account(FILE *fp, struct Account *a, struct ListHead *links)
Definition: graphviz.c:806
void dot_connection(FILE *fp, struct Connection *c, struct ListHead *links)
Definition: graphviz.c:681
void dot_mailbox_mbox(FILE *fp, struct MboxAccountData *mdata, struct ListHead *links)
Definition: graphviz.c:491
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:1995
void dot_account_notmuch(FILE *fp, struct NmAccountData *adata, struct ListHead *links)
Definition: graphviz.c:777
void dump_graphviz_expando_node(struct ExpandoNode *node)
Definition: graphviz.c:2029
void dot_array_actx_fp_idx(FILE *fp, FILE **fp_idx, short fp_len, short fp_max, struct ListHead *links)
Definition: graphviz.c:1510
void dot_attach_ctx(FILE *fp, struct AttachCtx *actx, struct ListHead *links)
Definition: graphviz.c:1554
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:1922
void dot_mailbox_notmuch(FILE *fp, struct NmMboxData *mdata, struct ListHead *links)
Definition: graphviz.c:525
void dot_pattern(FILE *fp, struct Pattern *pat, struct ListHead *links)
Definition: graphviz.c:1664
void dot_content(FILE *fp, struct Content *cont, struct ListHead *links)
Definition: graphviz.c:993
#define ADD_FLAG(F)
void dot_account_nntp(FILE *fp, struct NntpAccountData *adata, struct ListHead *links)
Definition: graphviz.c:734
void dot_attach_ptr(FILE *fp, struct AttachPtr *aptr, struct ListHead *links)
Definition: graphviz.c:1020
void dot_mailbox_list(FILE *fp, struct MailboxList *ml, struct ListHead *links, bool abbr)
Definition: graphviz.c:664
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:1610
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:1747
void dot_envelope(FILE *fp, struct Envelope *env, struct ListHead *links)
Definition: graphviz.c:1216
void dot_expando_node_conditional_date(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
Definition: graphviz.c:1900
void dump_graphviz_attach_ctx(struct AttachCtx *actx)
Definition: graphviz.c:1588
void dot_expando_node_conditional_bool(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
Definition: graphviz.c:1885
void dot_mailbox(FILE *fp, struct Mailbox *m, struct ListHead *links)
Definition: graphviz.c:541
void dot_expando_node_text(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
Definition: graphviz.c:1801
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:1855
void dot_expando_node_expando(FILE *fp, struct ExpandoNode *node, struct ListHead *links)
Definition: graphviz.c:1963
void dot_mailbox_maildir(FILE *fp, struct MaildirMboxData *mdata, struct ListHead *links)
Definition: graphviz.c:477
void dot_mailbox_nntp(FILE *fp, struct NntpMboxData *mdata, struct ListHead *links)
Definition: graphviz.c:504
void dump_graphviz_email(struct Email *e, const char *title)
Definition: graphviz.c:1420
void dot_body(FILE *fp, struct Body *b, struct ListHead *links, bool link_next)
Definition: graphviz.c:1043
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
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:254
bool mutt_str_equal(const char *a, const char *b)
Compare two strings.
Definition: string.c:661
size_t mutt_str_startswith(const char *str, const char *prefix)
Check whether a string starts with a prefix.
Definition: string.c:231
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Definition: string.c:582
View of a Mailbox.
API for encryption/signing of emails.
#define SEC_INLINE
Email has an inline signature.
Definition: lib.h:91
#define SEC_AUTOCRYPT
(Autocrypt) Message will be, or was Autocrypt encrypt+signed
Definition: lib.h:93
#define SEC_OPPENCRYPT
Opportunistic encrypt mode.
Definition: lib.h:92
#define PGP_TRADITIONAL_CHECKED
Email has a traditional (inline) signature.
Definition: lib.h:98
#define SEC_GOODSIGN
Email has a valid signature.
Definition: lib.h:86
#define APPLICATION_PGP
Use PGP to encrypt/sign.
Definition: lib.h:96
#define SEC_SIGNOPAQUE
Email has an opaque signature (encrypted)
Definition: lib.h:89
#define SEC_BADSIGN
Email has a bad signature.
Definition: lib.h:87
#define APPLICATION_SMIME
Use SMIME to encrypt/sign.
Definition: lib.h:97
#define SEC_PARTSIGN
Not all parts of the email is signed.
Definition: lib.h:88
#define SEC_ENCRYPT
Email is encrypted.
Definition: lib.h:84
#define SEC_AUTOCRYPT_OVERRIDE
(Autocrypt) Indicates manual set/unset of encryption
Definition: lib.h:94
#define SEC_SIGN
Email is signed.
Definition: lib.h:85
#define SEC_KEYBLOCK
Email has a key attached.
Definition: lib.h:90
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:57
@ ENP_RIGHT
Index of Right-Hand Nodes.
Definition: node_padding.h:58
@ EPT_FILL_EOL
Fill to the end-of-line.
Definition: node_padding.h:45
@ EPT_SOFT_FILL
Soft-fill: right-hand-side will be truncated.
Definition: node_padding.h:47
@ EPT_HARD_FILL
Hard-fill: left-hand-side will be truncated.
Definition: node_padding.h:46
Notmuch-specific Account data.
Notmuch virtual mailbox type.
Notmuch-specific Mailbox data.
Notmuch private types.
Match patterns to emails.
@ MUTT_PAT_HEADER
Pattern matches email's header.
Definition: lib.h:156
@ MUTT_PAT_WHOLE_MSG
Pattern matches raw email text.
Definition: lib.h:158
@ MUTT_PAT_BROKEN
Message is part of a broken thread.
Definition: lib.h:152
@ MUTT_PAT_ID_EXTERNAL
Message-Id is among results from an external query.
Definition: lib.h:154
@ MUTT_PAT_OR
Either pattern can match.
Definition: lib.h:138
@ MUTT_PAT_CHILDREN
Pattern matches a child email.
Definition: lib.h:141
@ MUTT_PAT_PARENT
Pattern matches parent.
Definition: lib.h:140
@ MUTT_PAT_REFERENCE
Pattern matches 'References:' or 'In-Reply-To:' field.
Definition: lib.h:163
@ MUTT_PAT_FROM
Pattern matches 'From:' field.
Definition: lib.h:147
@ MUTT_PAT_DRIVER_TAGS
Pattern matches message tags.
Definition: lib.h:176
@ MUTT_PAT_COLLAPSED
Thread is collapsed.
Definition: lib.h:145
@ MUTT_PAT_CRYPT_VERIFIED
Message is crypographically verified.
Definition: lib.h:171
@ MUTT_PAT_HORMEL
Pattern matches email's spam score.
Definition: lib.h:157
@ MUTT_PAT_SUBJECT
Pattern matches 'Subject:' field.
Definition: lib.h:146
@ MUTT_PAT_LIST
Email is on mailing list.
Definition: lib.h:165
@ MUTT_PAT_NEWSGROUPS
Pattern matches newsgroup.
Definition: lib.h:179
@ MUTT_PAT_PERSONAL_RECIP
Email is addressed to the user.
Definition: lib.h:167
@ MUTT_PAT_CC
Pattern matches 'Cc:' field.
Definition: lib.h:143
@ MUTT_PAT_SUBSCRIBED_LIST
Email is on subscribed mailing list.
Definition: lib.h:166
@ MUTT_PAT_SERVERSEARCH
Server-side pattern matches.
Definition: lib.h:175
@ MUTT_PAT_RECIPIENT
User is a recipient of the email.
Definition: lib.h:164
@ MUTT_PAT_CRYPT_ENCRYPT
Message is encrypted.
Definition: lib.h:172
@ MUTT_PAT_UNREFERENCED
Message is unreferenced in the thread.
Definition: lib.h:151
@ MUTT_PAT_CRYPT_SIGN
Message is signed.
Definition: lib.h:170
@ MUTT_PAT_MESSAGE
Pattern matches message number.
Definition: lib.h:160
@ MUTT_PAT_AND
Both patterns must match.
Definition: lib.h:137
@ MUTT_PAT_DATE
Pattern matches 'Date:' field.
Definition: lib.h:148
@ MUTT_PAT_XLABEL
Pattern matches keyword/label.
Definition: lib.h:174
@ MUTT_PAT_SCORE
Pattern matches email's score.
Definition: lib.h:161
@ MUTT_PAT_MIMEATTACH
Pattern matches number of attachments.
Definition: lib.h:177
@ MUTT_PAT_DUPLICATED
Duplicate message.
Definition: lib.h:150
@ MUTT_PAT_PERSONAL_FROM
Email is from the user.
Definition: lib.h:168
@ MUTT_PAT_TO
Pattern matches 'To:' field.
Definition: lib.h:142
@ MUTT_PAT_BCC
Pattern matches 'Bcc:' field.
Definition: lib.h:144
@ MUTT_PAT_SENDER
Pattern matches sender.
Definition: lib.h:159
@ MUTT_PAT_DATE_RECEIVED
Pattern matches date received.
Definition: lib.h:149
@ MUTT_PAT_ADDRESS
Pattern matches any address field.
Definition: lib.h:169
@ MUTT_PAT_MIMETYPE
Pattern matches MIME type.
Definition: lib.h:178
@ MUTT_PAT_PGP_KEY
Message has PGP key.
Definition: lib.h:173
@ MUTT_PAT_ID
Pattern matches email's Message-Id.
Definition: lib.h:153
@ MUTT_PAT_THREAD
Pattern matches email thread.
Definition: lib.h:139
@ MUTT_PAT_SIZE
Pattern matches email's size.
Definition: lib.h:162
@ MUTT_PAT_BODY
Pattern matches email's body.
Definition: lib.h:155
struct Buffer * buf_pool_get(void)
Get a Buffer from the pool.
Definition: pool.c:82
void buf_pool_release(struct Buffer **ptr)
Return a Buffer to the pool.
Definition: pool.c:96
Pop-specific Account data.
POP network mailbox.
POP network mailbox.
#define SLIST_FOREACH(var, head, field)
Definition: queue.h:229
#define TAILQ_FOREACH(var, head, field)
Definition: queue.h:782
#define STAILQ_HEAD_INITIALIZER(head)
Definition: queue.h:324
#define STAILQ_FIRST(head)
Definition: queue.h:388
#define STAILQ_FOREACH(var, head, field)
Definition: queue.h:390
#define TAILQ_FIRST(head)
Definition: queue.h:780
#define STAILQ_EMPTY(head)
Definition: queue.h:382
#define SLIST_FIRST(head)
Definition: queue.h:227
#define TAILQ_EMPTY(head)
Definition: queue.h:778
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:63
short vcount
The number of virtual attachments.
Definition: attach.h:72
short body_len
Number of Body parts.
Definition: attach.h:79
FILE * fp_root
Used by recvattach for updating.
Definition: attach.h:65
short fp_max
Size of FILE array.
Definition: attach.h:76
struct Email * email
Used by recvattach for updating.
Definition: attach.h:64
struct AttachPtr ** idx
Array of attachments.
Definition: attach.h:67
struct Body ** body_idx
Extra struct Body* used for decryption.
Definition: attach.h:78
short fp_len
Number of FILE handles.
Definition: attach.h:75
short body_max
Size of Body array.
Definition: attach.h:80
FILE ** fp_idx
Extra FILE* used for decryption.
Definition: attach.h:74
short idxmax
Size of attachment array.
Definition: attach.h:69
short idxlen
Number of attachmentes.
Definition: attach.h:68
short * v2r
Mapping from virtual to real attachment.
Definition: attach.h:71
An email to which things will be attached.
Definition: attach.h:35
struct Body * body
Attachment.
Definition: attach.h:36
bool collapsed
Group is collapsed.
Definition: attach.h:44
int num
Attachment index number.
Definition: attach.h:41
int level
Nesting depth of attachment.
Definition: attach.h:40
FILE * fp
Used in the recvattach menu.
Definition: attach.h:37
bool unowned
Don't unlink on detach.
Definition: attach.h:42
bool decrypted
Not part of message as stored in the email->body.
Definition: attach.h:43
int parent_type
Type of parent attachment, e.g. TYPE_MULTIPART.
Definition: attach.h:38
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:60
struct Expando * cmd_open
open-hook command
Definition: lib.h:63
struct Expando * cmd_append
append-hook command
Definition: lib.h:61
struct Expando * cmd_close
close-hook command
Definition: lib.h:62
A set of inherited config items.
Definition: subset.h:46
const char * name
Scope name of Subset.
Definition: subset.h:47
struct ConfigSet * cs
Parent ConfigSet.
Definition: subset.h:50
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:44
union HashKey key
Key representing the data.
Definition: hash.h:46
int type
Type of data stored in Hash Table, e.g. DT_STRING.
Definition: hash.h:45
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:43
struct AccountList accounts
List of all Accounts.
Definition: neomutt.h:48
struct ConfigSubset * sub
Inherited config items.
Definition: neomutt.h:47
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:65
enum ExpandoPadType pad_type
Padding type.
Definition: node_padding.h:66
Attribute associated with a MIME part.
Definition: parameter.h:33
char * attribute
Parameter name.
Definition: parameter.h:34
char * value
Parameter value.
Definition: parameter.h:35
A simple (non-regex) pattern.
Definition: lib.h:77
bool group_match
Check a group of Addresses.
Definition: lib.h:82
union Pattern::@1 p
struct PatternList * child
Arguments to logical operation.
Definition: lib.h:90
long min
Minimum for range checks.
Definition: lib.h:88
bool string_match
Check a string for a match.
Definition: lib.h:81
regex_t * regex
Compiled regex, for non-pattern matching.
Definition: lib.h:92
char * str
String, if string_match is set.
Definition: lib.h:94
long max
Maximum for range checks.
Definition: lib.h:89
short op
Operation, e.g. MUTT_PAT_SCORE.
Definition: lib.h:78
bool is_multi
Multiple case (only for ~I pattern now)
Definition: lib.h:87
POP-specific Account data -.
Definition: adata.h:37
time_t check_time
Definition: adata.h:51
struct Connection * conn
Connection to POP server.
Definition: adata.h:38
A parsed URL proto://user:password@host:port/path?a=1&b=2
Definition: url.h:69
char * user
Username.
Definition: url.h:71
char * host
Host.
Definition: url.h:73
char * path
Path.
Definition: url.h:75
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:334
struct HashElemArray get_elem_list(struct ConfigSet *cs, enum GetElemListFlags flags)
Create a sorted list of all config items.
Definition: subset.c:80
@ GEL_ALL_CONFIG
All the normal config (no synonyms or deprecated)
Definition: subset.h:81
#define CONFIG_TYPE(t)
Definition: types.h:49
@ DT_STRING
a string
Definition: types.h:44
#define D_SENSITIVE
Contains sensitive value, e.g. password.
Definition: types.h:80
const char * strkey
String key.
Definition: hash.h:36
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