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
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
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
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
53 From: David Bremner <bremner@unb.ca>
\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
59 notmuch-client.h | 4 ++++
\r
60 notmuch-log.c | 18 ++++++++++++++++++
\r
61 2 files changed, 22 insertions(+), 0 deletions(-)
\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
69 notmuch_log_append (int file_desc, const char *buffer, size_t len);
\r
72 +notmuch_log_string_pair (void *ctx, int file_desc,
\r
73 + const char *str1, const char *str2);
\r
76 debugger_is_active (void);
\r
78 diff --git a/notmuch-log.c b/notmuch-log.c
\r
79 index c4ddcd3..b0aca95 100644
\r
83 #include <sys/stat.h>
\r
87 +#include <talloc.h>
\r
89 #include "notmuch-client.h"
\r
91 @@ -100,3 +102,19 @@ notmuch_log_append (int file_desc, const char *buffer, size_t len){
\r
93 return NOTMUCH_STATUS_SUCCESS;
\r
97 +notmuch_log_string_pair(void *ctx, int log_fd,
\r
98 + const char *string1, const char *string2){
\r
100 + char *quoted1, *quoted2, *buffer;
\r
102 + quoted1 = json_quote_str (ctx, string1);
\r
103 + quoted2 = json_quote_str (ctx, string2);
\r
105 + buffer = talloc_asprintf (ctx, "%ld %s %s\n",
\r
106 + (long)time(NULL),
\r
107 + quoted1, quoted2);
\r
109 + return notmuch_log_append (log_fd, buffer, strlen(buffer));
\r