[PATCH v2 03/14] cli/reply: reuse show_reply_headers() in headers-only format
[notmuch-archives.git] / ae / cdc2acb34f354ba4b8aa781355140025d6d408
1 Return-Path: <amdragon@mit.edu>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 85F03431FC9\r
6         for <notmuch@notmuchmail.org>; Tue, 15 Jul 2014 07:14:28 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id rjfSKzjFYdC2 for <notmuch@notmuchmail.org>;\r
16         Tue, 15 Jul 2014 07:14:23 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-2.mit.edu (dmz-mailsec-scanner-2.mit.edu\r
18         [18.9.25.13])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id A94DA431FC7\r
22         for <notmuch@notmuchmail.org>; Tue, 15 Jul 2014 07:14:23 -0700 (PDT)\r
23 X-AuditID: 1209190d-f79c06d000002f07-d8-53c5373c88fa\r
24 Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
25         (using TLS with cipher AES256-SHA (256/256 bits))\r
26         (Client did not present a certificate)\r
27         by dmz-mailsec-scanner-2.mit.edu (Symantec Messaging Gateway) with SMTP\r
28         id 3A.24.12039.E3735C35; Tue, 15 Jul 2014 10:14:23 -0400 (EDT)\r
29 Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
30         by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id s6FEEAFY017884; \r
31         Tue, 15 Jul 2014 10:14:11 -0400\r
32 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
33         (authenticated bits=0)\r
34         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
35         by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s6FEE9cb011614\r
36         (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT);\r
37         Tue, 15 Jul 2014 10:14:10 -0400\r
38 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80)\r
39         (envelope-from <amdragon@mit.edu>)\r
40         id 1X73Ue-0000cK-7V; Tue, 15 Jul 2014 10:14:08 -0400\r
41 Date: Tue, 15 Jul 2014 10:14:07 -0400\r
42 From: Austin Clements <amdragon@MIT.EDU>\r
43 To: Sime Ramov <sramov@pobox.com>\r
44 Subject: Re: notmuch-reply date format\r
45 Message-ID: <20140715141407.GF4660@mit.edu>\r
46 References: <1722345767858996112.enqueue@ouroboros.ramov.inet>\r
47         <20140714130431.GB4660@mit.edu>\r
48         <702358554056882337.enqueue@ouroboros.ramov.inet>\r
49 MIME-Version: 1.0\r
50 Content-Type: text/plain; charset=us-ascii\r
51 Content-Disposition: inline\r
52 In-Reply-To: <702358554056882337.enqueue@ouroboros.ramov.inet>\r
53 User-Agent: Mutt/1.5.21 (2010-09-15)\r
54 X-Brightmail-Tracker:\r
55  H4sIAAAAAAAAA+NgFmpgleLIzCtJLcpLzFFi42IR4hRV1rU3Pxps0LKCyeL6zZnMFjd/bmV1\r
56         YPJ4tuoWs8fFS8oBTFFcNimpOZllqUX6dglcGYcbF7IWtApU/Fuf1MD4g6eLkZNDQsBE4ti2\r
57         10wQtpjEhXvr2boYuTiEBGYzSVzqOs4OkhAS2MgosaFNBSJxmkliwe6XrBDOEkaJlunHwKpY\r
58         BFQlZvx+wgJiswloSGzbv5yxi5GDQ0RAUeLmClWQMLOAtMS3381g24QF1CT2/bvDCGLzCmhL\r
59         nPl/lh1i5hRGiU99R1ghEoISJ2dCzGQW0JK48e8lE8hMkEHL/3GAmJwCdhIzd2eAVIgKqEhM\r
60         ObmNbQKj0CwkzbOQNM9CaF7AyLyKUTYlt0o3NzEzpzg1Wbc4OTEvL7VI10gvN7NELzWldBMj\r
61         OKAleXcwvjuodIhRgINRiYf3xKfDwUKsiWXFlbmHGCU5mJREeYvZjgYL8SXlp1RmJBZnxBeV\r
62         5qQWH2KU4GBWEuGVNAHK8aYkVlalFuXDpKQ5WJTEed9aWwULCaQnlqRmp6YWpBbBZGU4OJQk\r
63         eD3NgBoFi1LTUyvSMnNKENJMHJwgw3mAhqeB1PAWFyTmFmemQ+RPMSpKifMymwIlBEASGaV5\r
64         cL2whPOKURzoFWHeDJB2HmCygut+BTSYCWhwec1hkMEliQgpqQbGXmaL4z5Wzx/ufpe7zzrR\r
65         /d/7BQe1JM+8f/egrzT2/tSM9stb8jfKOxW3rZLvOV3K5p5SfYW59myv9ZT30VmdfTPvRghK\r
66         emTYpnLNq57MPdFwu6pNotHnDIv4LXF1X1mZzQzL1ipb3cz/clSxkLXTZ/Or43Edvhms7h47\r
67         7WbcLX0W7qxSF6rEUpyRaKjFXFScCADrAAt+EwMAAA==\r
68 Cc: notmuch@notmuchmail.org\r
69 X-BeenThere: notmuch@notmuchmail.org\r
70 X-Mailman-Version: 2.1.13\r
71 Precedence: list\r
72 List-Id: "Use and development of the notmuch mail system."\r
73         <notmuch.notmuchmail.org>\r
74 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
75         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
76 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
77 List-Post: <mailto:notmuch@notmuchmail.org>\r
78 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
79 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
80         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
81 X-List-Received-Date: Tue, 15 Jul 2014 14:14:28 -0000\r
82 \r
83 Quoth Sime Ramov on Jul 15 at  9:35 am:\r
84 > Hello,\r
85\r
86 > * Austin Clements <amdragon@MIT.EDU> [Mon, 14 Jul 2014 09:04:31 -0400]:\r
87 > > Assuming the CLI is the right place for you to change this, you\r
88 > > probably want to call notmuch_message_get_date, then localtime, then\r
89 > > strftime.\r
90\r
91 > Tried to get this working to no avail. Not a programmer obviously :) I\r
92 > cobbled this together from various online sources:\r
93\r
94 > diff --git a/notmuch-reply.c b/notmuch-reply.c\r
95 > index 7c1c809..16cf19c 100644\r
96 > --- a/notmuch-reply.c\r
97 > +++ b/notmuch-reply.c\r
98 > @@ -44,9 +44,15 @@ format_part_reply (mime_node_t *node)\r
99 >      int i;\r
100 >  \r
101 >      if (node->envelope_file) {\r
102 > -     printf ("On %s, %s wrote:\n",\r
103 > -             notmuch_message_get_header (node->envelope_file, "date"),\r
104 > -             notmuch_message_get_header (node->envelope_file, "from"));\r
105 > +     struct tm *info;\r
106 > +     char dbuf[30];\r
107 > +\r
108 > +     info = localtime(notmuch_message_get_date(node->envelope_file));\r
109 \r
110 Close.  For whatever reason, localtime takes a pointer to a time_t,\r
111 not a time_t (even though time_t is just a number).  You'll need\r
112 something like\r
113 \r
114 time_t date;\r
115 \r
116 date = notmuch_message_get_date(node->envelope_file);\r
117 info = localtime(&date);\r
118 \r
119 > +\r
120 > +     strftime(dbuf, sizeof(dbuf), "%F %R %z", info);\r
121 > +     printf ("* %s [%s]:\n",\r
122 > +             notmuch_message_get_header(node->envelope_file, "from"), dbuf);\r
123 > +\r
124 >      } else if (GMIME_IS_MESSAGE (node->part)) {\r
125 >       GMimeMessage *message = GMIME_MESSAGE (node->part);\r
126 >       InternetAddressList *recipients;\r
127\r
128 > When compiling I get this warning:\r
129\r
130 > notmuch-reply.c: In function 'format_part_reply':\r
131 > notmuch-reply.c:50: warning: passing argument 1 of 'localtime' makes pointer from integer without a cast\r
132 \r
133 Ah, C.  "I'm sure they meant for that number that looks nothing like a\r
134 pointer to actually be a pointer that could corrupt memory, disclose\r
135 private information, or crash the program.  I'll just convert it for\r
136 them real quick..."\r
137 \r
138 > And a core dump when notmuch reply is invoked on a message. Am I even\r
139 > close? :) Thanks\r