Re: [PATCH v4 01/16] add util/search-path.{c, h} to test for executables in $PATH
[notmuch-archives.git] / 83 / 79ce90efc38af26f6cd5539cd521f304ff2dc3
1 Return-Path: <bremner@unb.ca>\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 9060C40D143\r
6         for <notmuch@notmuchmail.org>; Mon, 11 Oct 2010 06:27:41 -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: -2.6\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-2.6 tagged_above=-999 required=5\r
12         tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7] autolearn=ham\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 bVgLzn2PX9DU for <notmuch@notmuchmail.org>;\r
16         Mon, 11 Oct 2010 06:27:29 -0700 (PDT)\r
17 Received: from tempo.its.unb.ca (tempo.its.unb.ca [131.202.1.21])\r
18         by olra.theworths.org (Postfix) with ESMTP id 37F5C40BFDB\r
19         for <notmuch@notmuchmail.org>; Mon, 11 Oct 2010 06:27:19 -0700 (PDT)\r
20 Received: from rocinante.cs.unb.ca\r
21         (fctnnbsc30w-142167176217.pppoe-dynamic.High-Speed.nb.bellaliant.net\r
22         [142.167.176.217]) (authenticated bits=0)\r
23         by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id o9BDRIGS003867\r
24         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);\r
25         Mon, 11 Oct 2010 10:27:18 -0300\r
26 Received: from bremner by rocinante.cs.unb.ca with local (Exim 4.72)\r
27         (envelope-from <bremner@unb.ca>)\r
28         id 1P5IPO-0004cd-J5; Mon, 11 Oct 2010 10:27:18 -0300\r
29 From: david@tethera.net\r
30 To: notmuch@notmuchmail.org\r
31 Subject: [PATCH 2/3] notmuch-log.c: Add a function to log a pair of strings\r
32         with a timestamp.\r
33 Date: Mon, 11 Oct 2010 10:26:56 -0300\r
34 Message-Id: <1286803617-17328-3-git-send-email-david@tethera.net>\r
35 X-Mailer: git-send-email 1.7.1\r
36 In-Reply-To: <1286803617-17328-1-git-send-email-david@tethera.net>\r
37 References: <1286803617-17328-1-git-send-email-david@tethera.net>\r
38 Cc: David Bremner <bremner@unb.ca>\r
39 X-BeenThere: notmuch@notmuchmail.org\r
40 X-Mailman-Version: 2.1.13\r
41 Precedence: list\r
42 List-Id: "Use and development of the notmuch mail system."\r
43         <notmuch.notmuchmail.org>\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
45         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
47 List-Post: <mailto:notmuch@notmuchmail.org>\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
50         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
51 X-List-Received-Date: Mon, 11 Oct 2010 13:27:42 -0000\r
52 \r
53 From: David Bremner <bremner@unb.ca>\r
54 \r
55 Since the function is supposed to work for any pair of strings, this\r
56 means some form of quoting seems necessary. I decided to re-use the\r
57 json quoting routines for convenience.\r
58 ---\r
59  notmuch-client.h |    4 ++++\r
60  notmuch-log.c    |   18 ++++++++++++++++++\r
61  2 files changed, 22 insertions(+), 0 deletions(-)\r
62 \r
63 diff --git a/notmuch-client.h b/notmuch-client.h\r
64 index 0422b1c..a849e21 100644\r
65 --- a/notmuch-client.h\r
66 +++ b/notmuch-client.h\r
67 @@ -201,6 +201,10 @@ notmuch_log_open (const char *path);\r
68  notmuch_status_t\r
69  notmuch_log_append (int file_desc, const char *buffer, size_t len);\r
70  \r
71 +notmuch_status_t\r
72 +notmuch_log_string_pair (void *ctx, int file_desc,\r
73 +                        const char *str1, const char *str2);\r
74 +\r
75  notmuch_bool_t\r
76  debugger_is_active (void);\r
77  \r
78 diff --git a/notmuch-log.c b/notmuch-log.c\r
79 index c4ddcd3..b0aca95 100644\r
80 --- a/notmuch-log.c\r
81 +++ b/notmuch-log.c\r
82 @@ -23,6 +23,8 @@\r
83  #include <sys/stat.h>\r
84  #include <fcntl.h>\r
85  #include <unistd.h>\r
86 +#include <time.h>\r
87 +#include <talloc.h>\r
88  \r
89  #include "notmuch-client.h"\r
90  /*\r
91 @@ -100,3 +102,19 @@ notmuch_log_append (int file_desc, const char *buffer, size_t len){\r
92  \r
93      return NOTMUCH_STATUS_SUCCESS;\r
94  }\r
95 +\r
96 +notmuch_status_t\r
97 +notmuch_log_string_pair(void *ctx, int log_fd,\r
98 +                       const char *string1, const char *string2){\r
99 +\r
100 +    char *quoted1, *quoted2, *buffer;\r
101 +\r
102 +    quoted1 = json_quote_str (ctx, string1);\r
103 +    quoted2 = json_quote_str (ctx, string2);\r
104 +\r
105 +    buffer = talloc_asprintf (ctx, "%ld %s %s\n",\r
106 +                             (long)time(NULL),\r
107 +                             quoted1, quoted2);\r
108 +\r
109 +    return notmuch_log_append (log_fd, buffer, strlen(buffer));\r
110 +}\r
111 -- \r
112 1.7.1\r
113 \r